Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix revolut accountID bug #4506

Merged
merged 1 commit into from
Sep 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions core/src/main/java/bisq/core/payment/PaymentAccount.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,9 @@ public String getSaltAsHex() {
public String getOwnerId() {
return paymentAccountPayload.getOwnerId();
}

public void onAddToUser() {
// We are in the process to get added to the user. This is called just before saving the account and the
// last moment we could apply some special handling if needed (e.g. as it happens for Revolut)
}
}
22 changes: 17 additions & 5 deletions core/src/main/java/bisq/core/payment/RevolutAccount.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,34 @@ protected PaymentAccountPayload createPayload() {
}

public void setUserName(String userName) {
((RevolutAccountPayload) paymentAccountPayload).setUserName(userName);
revolutAccountPayload().setUserName(userName);
}

public String getUserName() {
return ((RevolutAccountPayload) paymentAccountPayload).getUserName();
return (revolutAccountPayload()).getUserName();
}

public String getAccountId() {
return ((RevolutAccountPayload) paymentAccountPayload).getAccountId();
return (revolutAccountPayload()).getAccountId();
}

public boolean userNameNotSet() {
return ((RevolutAccountPayload) paymentAccountPayload).userNameNotSet();
return (revolutAccountPayload()).userNameNotSet();
}

public boolean hasOldAccountId() {
return ((RevolutAccountPayload) paymentAccountPayload).hasOldAccountId();
return (revolutAccountPayload()).hasOldAccountId();
}

private RevolutAccountPayload revolutAccountPayload() {
return (RevolutAccountPayload) paymentAccountPayload;
}

@Override
public void onAddToUser() {
super.onAddToUser();

// At save we apply the userName to accountId in case it is empty for backward compatibility
revolutAccountPayload().maybeApplyUserNameToAccountId();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private RevolutAccountPayload(String paymentMethod,
excludeFromJsonDataMap);

this.accountId = accountId;
setUserName(userName);
this.userName = userName;
}

@Override
Expand Down Expand Up @@ -169,7 +169,11 @@ public boolean hasOldAccountId() {

public void setUserName(String userName) {
this.userName = userName;
// We need to set accountId as pre v1.3.8 clients expect the accountId field
}

// 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;
}
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/java/bisq/core/user/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ public boolean hasPaymentAccountForCurrency(TradeCurrency tradeCurrency) {
///////////////////////////////////////////////////////////////////////////////////////////

public void addPaymentAccount(PaymentAccount paymentAccount) {
paymentAccount.onAddToUser();

boolean changed = paymentAccountsAsObservable.add(paymentAccount);
setCurrentPaymentAccount(paymentAccount);
if (changed)
Expand Down