Skip to content

Commit

Permalink
Refactor: rename methods, move return statement
Browse files Browse the repository at this point in the history
  • Loading branch information
sqrrm committed Dec 15, 2020
1 parent e0f4dc2 commit 26024bd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -882,13 +882,13 @@ public boolean isSignWitnessTrade(Trade trade) {
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;
Expand All @@ -899,12 +899,11 @@ public Tuple2<AccountAgeWitness, byte[]> signInfoFromString(String signInfo) {
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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ protected void copyAccount() {
if (selectedAccount == null) {
return;
}
Utilities.copyToClipboard(accountAgeWitnessService.signInfoFromAccount(selectedAccount));
Utilities.copyToClipboard(accountAgeWitnessService.getSignInfoFromAccount(selectedAccount));
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private void addSelectWitnessContent() {
if (newValue == null || newValue.isEmpty()) {
return;
}
signInfo = accountAgeWitnessService.signInfoFromString(newValue);
signInfo = accountAgeWitnessService.getSignInfoFromString(newValue);
if (signInfo == null) {
actionButton.setDisable(true);
return;
Expand Down

0 comments on commit 26024bd

Please sign in to comment.