WalletTool: eliminate reassignment of coinSelector

This commit is contained in:
Sean Gilligan 2023-09-06 10:57:30 -07:00 committed by Andreas Schildbach
parent e186ef9c84
commit 983febfad0

View File

@ -433,7 +433,7 @@ public class WalletTool implements Callable<Integer> {
System.err.println("--select-addr and --select-output cannot be used together.");
return 1;
}
CoinSelector coinSelector = null;
CoinSelector coinSelector;
if (selectAddrStr != null) {
Address selectAddr;
try {
@ -450,14 +450,15 @@ public class WalletTool implements Callable<Integer> {
return false;
}
});
}
if (selectOutputStr != null) {
} else if (selectOutputStr != null) {
String[] parts = selectOutputStr.split(":", 2);
Sha256Hash selectTransactionHash = Sha256Hash.wrap(parts[0]);
int selectIndex = Integer.parseInt(parts[1]);
coinSelector = CoinSelector.fromPredicate(candidate ->
candidate.getIndex() == selectIndex && candidate.getParentTransactionHash().equals(selectTransactionHash)
);
} else {
coinSelector = null;
}
send(coinSelector, outputsStr, feePerVkb, lockTimeStr, allowUnconfirmed);
} else if (paymentRequestLocationStr != null) {