mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-22 22:45:21 +01:00
Use checkNotNull and checkArgument for checking pre conditions
in signBsqSwapTransaction. Remove unused code
This commit is contained in:
parent
20e83b6afe
commit
91276c9bde
1 changed files with 4 additions and 36 deletions
|
@ -759,45 +759,13 @@ public class BsqWalletService extends WalletService implements DaoStateListener
|
|||
throws TransactionVerificationException {
|
||||
for (TransactionInput input : myInputs) {
|
||||
TransactionOutput connectedOutput = input.getConnectedOutput();
|
||||
if (connectedOutput != null && connectedOutput.isMine(wallet)) {
|
||||
signTransactionInput(wallet, aesKey, transaction, input, input.getIndex());
|
||||
checkScriptSig(transaction, input, input.getIndex());
|
||||
} else {
|
||||
if (connectedOutput == null) {
|
||||
log.error("connectedOutput is null");
|
||||
return;
|
||||
}
|
||||
if (!connectedOutput.isMine(wallet)) {
|
||||
log.error("connectedOutput is not mine");
|
||||
}
|
||||
}
|
||||
checkNotNull(connectedOutput, "connectedOutput must not be null");
|
||||
checkArgument(connectedOutput.isMine(wallet), "connectedOutput is not mine");
|
||||
signTransactionInput(wallet, aesKey, transaction, input, input.getIndex());
|
||||
checkScriptSig(transaction, input, input.getIndex());
|
||||
}
|
||||
}
|
||||
|
||||
// Only use confirmed BSQ inputs as the counterparty cannot verify unconfirmed BSQ inputs
|
||||
public Tuple2<Transaction, Coin> prepareBsqInputsForBsqSwap(Coin requiredInput) throws InsufficientBsqException {
|
||||
daoKillSwitch.assertDaoIsNotDisabled();
|
||||
bsqCoinSelector.setAllowSpendMyOwnUnconfirmedTxOutputs(false);
|
||||
|
||||
var dummyTx = new Transaction(params);
|
||||
var coinSelection = bsqCoinSelector.select(requiredInput, wallet.calculateAllSpendCandidates());
|
||||
coinSelection.gathered.forEach(dummyTx::addInput);
|
||||
|
||||
var change = Coin.ZERO;
|
||||
try {
|
||||
change = bsqCoinSelector.getChange(requiredInput, coinSelection);
|
||||
} catch (InsufficientMoneyException e) {
|
||||
log.error("Missing funds in takerPreparesAtomicBsqInputs");
|
||||
throw new InsufficientBsqException(e.missing);
|
||||
} finally {
|
||||
bsqCoinSelector.setAllowSpendMyOwnUnconfirmedTxOutputs(true);
|
||||
}
|
||||
checkArgument(change.isZero() || Restrictions.isAboveDust(change));
|
||||
|
||||
// printTx("takerPreparesAtomicBsqInputs", dummyTx);
|
||||
return new Tuple2<>(dummyTx, change);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Blind vote tx
|
||||
|
|
Loading…
Add table
Reference in a new issue