mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-03-10 17:26:28 +01:00
WalletTool: simplify coinSelector lambdas
This commit is contained in:
parent
853aeebd81
commit
e186ef9c84
1 changed files with 4 additions and 7 deletions
|
@ -445,8 +445,7 @@ public class WalletTool implements Callable<Integer> {
|
||||||
final Address validSelectAddr = selectAddr;
|
final Address validSelectAddr = selectAddr;
|
||||||
coinSelector = CoinSelector.fromPredicate(candidate -> {
|
coinSelector = CoinSelector.fromPredicate(candidate -> {
|
||||||
try {
|
try {
|
||||||
Address candidateAddr = candidate.getScriptPubKey().getToAddress(net);
|
return candidate.getScriptPubKey().getToAddress(net).equals(validSelectAddr);
|
||||||
return validSelectAddr.equals(candidateAddr);
|
|
||||||
} catch (ScriptException x) {
|
} catch (ScriptException x) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -456,11 +455,9 @@ public class WalletTool implements Callable<Integer> {
|
||||||
String[] parts = selectOutputStr.split(":", 2);
|
String[] parts = selectOutputStr.split(":", 2);
|
||||||
Sha256Hash selectTransactionHash = Sha256Hash.wrap(parts[0]);
|
Sha256Hash selectTransactionHash = Sha256Hash.wrap(parts[0]);
|
||||||
int selectIndex = Integer.parseInt(parts[1]);
|
int selectIndex = Integer.parseInt(parts[1]);
|
||||||
coinSelector = CoinSelector.fromPredicate(candidate -> {
|
coinSelector = CoinSelector.fromPredicate(candidate ->
|
||||||
int candidateIndex = candidate.getIndex();
|
candidate.getIndex() == selectIndex && candidate.getParentTransactionHash().equals(selectTransactionHash)
|
||||||
Sha256Hash candidateTransactionHash = candidate.getParentTransactionHash();
|
);
|
||||||
return selectIndex == candidateIndex && selectTransactionHash.equals(candidateTransactionHash);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
send(coinSelector, outputsStr, feePerVkb, lockTimeStr, allowUnconfirmed);
|
send(coinSelector, outputsStr, feePerVkb, lockTimeStr, allowUnconfirmed);
|
||||||
} else if (paymentRequestLocationStr != null) {
|
} else if (paymentRequestLocationStr != null) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue