mirror of
https://github.com/boldsuck/haveno.git
synced 2024-12-23 04:29:22 +00:00
remove account id from revolut
This commit is contained in:
parent
c46d210822
commit
e6853d2e76
4 changed files with 5 additions and 63 deletions
|
@ -90,18 +90,10 @@ public final class RevolutAccount extends PaymentAccount {
|
||||||
return (revolutAccountPayload()).getUserName();
|
return (revolutAccountPayload()).getUserName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAccountId() {
|
|
||||||
return (revolutAccountPayload()).getAccountId();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean userNameNotSet() {
|
public boolean userNameNotSet() {
|
||||||
return (revolutAccountPayload()).userNameNotSet();
|
return (revolutAccountPayload()).userNameNotSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasOldAccountId() {
|
|
||||||
return (revolutAccountPayload()).hasOldAccountId();
|
|
||||||
}
|
|
||||||
|
|
||||||
private RevolutAccountPayload revolutAccountPayload() {
|
private RevolutAccountPayload revolutAccountPayload() {
|
||||||
return (RevolutAccountPayload) paymentAccountPayload;
|
return (RevolutAccountPayload) paymentAccountPayload;
|
||||||
}
|
}
|
||||||
|
@ -109,9 +101,6 @@ public final class RevolutAccount extends PaymentAccount {
|
||||||
@Override
|
@Override
|
||||||
public void onAddToUser() {
|
public void onAddToUser() {
|
||||||
super.onAddToUser();
|
super.onAddToUser();
|
||||||
|
|
||||||
// At save we apply the userName to accountId in case it is empty for backward compatibility
|
|
||||||
revolutAccountPayload().maybeApplyUserNameToAccountId();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -37,10 +37,6 @@ import static com.google.common.base.Preconditions.checkArgument;
|
||||||
@ToString
|
@ToString
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public final class RevolutAccountPayload extends PaymentAccountPayload {
|
public final class RevolutAccountPayload extends PaymentAccountPayload {
|
||||||
// Only used as internal Id to not break existing account witness objects
|
|
||||||
// We still show it in case it is different to the userName for additional security
|
|
||||||
@Getter
|
|
||||||
private String accountId = "";
|
|
||||||
|
|
||||||
// Was added in 1.3.8
|
// Was added in 1.3.8
|
||||||
// To not break signed accounts we keep accountId as internal id used for signing.
|
// To not break signed accounts we keep accountId as internal id used for signing.
|
||||||
|
@ -66,7 +62,6 @@ public final class RevolutAccountPayload extends PaymentAccountPayload {
|
||||||
|
|
||||||
private RevolutAccountPayload(String paymentMethod,
|
private RevolutAccountPayload(String paymentMethod,
|
||||||
String id,
|
String id,
|
||||||
String accountId,
|
|
||||||
@Nullable String userName,
|
@Nullable String userName,
|
||||||
long maxTradePeriod,
|
long maxTradePeriod,
|
||||||
Map<String, String> excludeFromJsonDataMap) {
|
Map<String, String> excludeFromJsonDataMap) {
|
||||||
|
@ -75,14 +70,12 @@ public final class RevolutAccountPayload extends PaymentAccountPayload {
|
||||||
maxTradePeriod,
|
maxTradePeriod,
|
||||||
excludeFromJsonDataMap);
|
excludeFromJsonDataMap);
|
||||||
|
|
||||||
this.accountId = accountId;
|
|
||||||
this.userName = userName;
|
this.userName = userName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Message toProtoMessage() {
|
public Message toProtoMessage() {
|
||||||
protobuf.RevolutAccountPayload.Builder revolutBuilder = protobuf.RevolutAccountPayload.newBuilder()
|
protobuf.RevolutAccountPayload.Builder revolutBuilder = protobuf.RevolutAccountPayload.newBuilder()
|
||||||
.setAccountId(accountId)
|
|
||||||
.setUserName(userName);
|
.setUserName(userName);
|
||||||
return getPaymentAccountPayloadBuilder().setRevolutAccountPayload(revolutBuilder).build();
|
return getPaymentAccountPayloadBuilder().setRevolutAccountPayload(revolutBuilder).build();
|
||||||
}
|
}
|
||||||
|
@ -92,7 +85,6 @@ public final class RevolutAccountPayload extends PaymentAccountPayload {
|
||||||
protobuf.RevolutAccountPayload revolutAccountPayload = proto.getRevolutAccountPayload();
|
protobuf.RevolutAccountPayload revolutAccountPayload = proto.getRevolutAccountPayload();
|
||||||
return new RevolutAccountPayload(proto.getPaymentMethodId(),
|
return new RevolutAccountPayload(proto.getPaymentMethodId(),
|
||||||
proto.getId(),
|
proto.getId(),
|
||||||
revolutAccountPayload.getAccountId(),
|
|
||||||
revolutAccountPayload.getUserName(),
|
revolutAccountPayload.getUserName(),
|
||||||
proto.getMaxTradePeriod(),
|
proto.getMaxTradePeriod(),
|
||||||
new HashMap<>(proto.getExcludeFromJsonDataMap()));
|
new HashMap<>(proto.getExcludeFromJsonDataMap()));
|
||||||
|
@ -112,20 +104,9 @@ public final class RevolutAccountPayload extends PaymentAccountPayload {
|
||||||
private Tuple2<String, String> getLabelValueTuple() {
|
private Tuple2<String, String> getLabelValueTuple() {
|
||||||
String label;
|
String label;
|
||||||
String value;
|
String value;
|
||||||
checkArgument(!userName.isEmpty() || hasOldAccountId(),
|
checkArgument(!userName.isEmpty(), "Username must be set");
|
||||||
"Either username must be set or we have an old account with accountId");
|
label = Res.get("payment.account.userName");
|
||||||
if (!userName.isEmpty()) {
|
value = userName;
|
||||||
label = Res.get("payment.account.userName");
|
|
||||||
value = userName;
|
|
||||||
|
|
||||||
if (hasOldAccountId()) {
|
|
||||||
label += "/" + Res.get("payment.account.phoneNr");
|
|
||||||
value += "/" + accountId;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
label = Res.get("payment.account.phoneNr");
|
|
||||||
value = accountId;
|
|
||||||
}
|
|
||||||
return new Tuple2<>(label, value);
|
return new Tuple2<>(label, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,35 +123,14 @@ public final class RevolutAccountPayload extends PaymentAccountPayload {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] getAgeWitnessInputData() {
|
public byte[] getAgeWitnessInputData() {
|
||||||
// getAgeWitnessInputData is called at new account creation when accountId is empty string.
|
return super.getAgeWitnessInputData(userName.getBytes(StandardCharsets.UTF_8));
|
||||||
if (hasOldAccountId()) {
|
|
||||||
// If the accountId was already in place (updated user who had used accountId for account age) we keep the
|
|
||||||
// old accountId to not invalidate the existing account age witness.
|
|
||||||
return super.getAgeWitnessInputData(accountId.getBytes(StandardCharsets.UTF_8));
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// If a new account was registered from version 1.3.8 or later we use the userName.
|
|
||||||
return super.getAgeWitnessInputData(userName.getBytes(StandardCharsets.UTF_8));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean userNameNotSet() {
|
public boolean userNameNotSet() {
|
||||||
return userName.isEmpty();
|
return userName.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasOldAccountId() {
|
|
||||||
return !accountId.equals(userName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUserName(String userName) {
|
public void setUserName(String userName) {
|
||||||
this.userName = userName;
|
this.userName = userName;
|
||||||
}
|
}
|
||||||
|
|
||||||
// In case it is a new account we need to fill the accountId field to support not-updated traders who are not
|
|
||||||
// aware of the new userName field
|
|
||||||
public void maybeApplyUserNameToAccountId() {
|
|
||||||
if (accountId.isEmpty()) {
|
|
||||||
accountId = userName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,12 +105,6 @@ public class RevolutForm extends PaymentMethodForm {
|
||||||
TextField userNameTf = addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.account.userName"), userName).second;
|
TextField userNameTf = addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.account.userName"), userName).second;
|
||||||
userNameTf.setMouseTransparent(false);
|
userNameTf.setMouseTransparent(false);
|
||||||
|
|
||||||
if (account.hasOldAccountId()) {
|
|
||||||
String accountId = account.getAccountId();
|
|
||||||
TextField accountIdTf = addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.account.phoneNr"), accountId).second;
|
|
||||||
accountIdTf.setMouseTransparent(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
addLimitations(true);
|
addLimitations(true);
|
||||||
addCurrenciesGrid(false);
|
addCurrenciesGrid(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1052,8 +1052,7 @@ message PopmoneyAccountPayload {
|
||||||
}
|
}
|
||||||
|
|
||||||
message RevolutAccountPayload {
|
message RevolutAccountPayload {
|
||||||
string account_id = 1;
|
string user_name = 1;
|
||||||
string user_name = 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message PerfectMoneyAccountPayload {
|
message PerfectMoneyAccountPayload {
|
||||||
|
|
Loading…
Reference in a new issue