Refactor: rename methods, move return statement

This commit is contained in:
sqrrm 2020-12-15 19:35:49 +01:00
parent e0f4dc22e7
commit 26024bd6ec
No known key found for this signature in database
GPG key ID: 45235F9EF87089EC
3 changed files with 7 additions and 8 deletions

View file

@ -882,13 +882,13 @@ public class AccountAgeWitnessService {
tradeAmountIsSufficient(trade.getTradeAmount());
}
public String signInfoFromAccount(PaymentAccount paymentAccount) {
public String getSignInfoFromAccount(PaymentAccount paymentAccount) {
var pubKey = keyRing.getSignatureKeyPair().getPublic();
var witness = getMyWitness(paymentAccount.getPaymentAccountPayload());
return Utilities.bytesAsHexString(witness.getHash()) + "," + Utilities.bytesAsHexString(pubKey.getEncoded());
}
public Tuple2<AccountAgeWitness, byte[]> signInfoFromString(String signInfo) {
public Tuple2<AccountAgeWitness, byte[]> getSignInfoFromString(String signInfo) {
var parts = signInfo.split(",");
if (parts.length != 2) {
return null;
@ -899,12 +899,11 @@ public class AccountAgeWitnessService {
var accountAgeWitnessHash = Utilities.decodeFromHex(parts[0]);
pubKeyHash = Utilities.decodeFromHex(parts[1]);
accountAgeWitness = getWitnessByHash(accountAgeWitnessHash);
return accountAgeWitness
.map(ageWitness -> new Tuple2<>(ageWitness, pubKeyHash))
.orElse(null);
} catch (Exception e) {
return null;
}
return accountAgeWitness
.map(ageWitness -> new Tuple2<>(ageWitness, pubKeyHash))
.orElse(null);
}
}

View file

@ -547,7 +547,7 @@ public class FiatAccountsView extends PaymentAccountsView<GridPane, FiatAccounts
if (selectedAccount == null) {
return;
}
Utilities.copyToClipboard(accountAgeWitnessService.signInfoFromAccount(selectedAccount));
Utilities.copyToClipboard(accountAgeWitnessService.getSignInfoFromAccount(selectedAccount));
}
}

View file

@ -94,7 +94,7 @@ public class SignSpecificWitnessWindow extends Overlay<SignSpecificWitnessWindow
if (newValue == null || newValue.isEmpty()) {
return;
}
signInfo = accountAgeWitnessService.signInfoFromString(newValue);
signInfo = accountAgeWitnessService.getSignInfoFromString(newValue);
if (signInfo == null) {
actionButton.setDisable(true);
return;