Skip to content

Commit

Permalink
Add further validation checks for delayed payout tx
Browse files Browse the repository at this point in the history
Do some extra sanity checks like tx.outputSum < tx.inputSum, to rule out
any edge cases where an invalid delayed payout tx might still arise.
  • Loading branch information
stejbac committed Nov 19, 2020
1 parent 3574204 commit 345426f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@

public class TradeWalletService {
private static final Logger log = LoggerFactory.getLogger(TradeWalletService.class);
private static final Coin MIN_DELAYED_PAYOUT_TX_FEE = Coin.valueOf(1000);

private final WalletsSetup walletsSetup;
private final Preferences preferences;
Expand Down Expand Up @@ -766,6 +767,9 @@ public Transaction finalizeUnconnectedDelayedPayoutTx(Transaction delayedPayoutT
WalletService.printTx("finalizeDelayedPayoutTx", delayedPayoutTx);
WalletService.verifyTransaction(delayedPayoutTx);

if (checkNotNull(inputValue).isLessThan(delayedPayoutTx.getOutputSum().add(MIN_DELAYED_PAYOUT_TX_FEE))) {
throw new TransactionVerificationException("Delayed payout tx is paying less than the minimum allowed tx fee");
}
Script scriptPubKey = get2of2MultiSigOutputScript(buyerPubKey, sellerPubKey, false);
input.getScriptSig().correctlySpends(delayedPayoutTx, 0, witness, inputValue, scriptPubKey, Script.ALL_VERIFY_FLAGS);
return delayedPayoutTx;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import bisq.core.btc.wallet.TradeWalletService;
import bisq.core.dao.governance.param.Param;
import bisq.core.trade.Trade;
import bisq.core.trade.TradeDataValidation;
import bisq.core.trade.protocol.tasks.TradeTask;

import bisq.common.taskrunner.TaskRunner;
Expand Down Expand Up @@ -53,6 +54,10 @@ protected void run() {
donationAddressString,
minerFee,
lockTime);
TradeDataValidation.validateDelayedPayoutTx(trade,
preparedDelayedPayoutTx,
processModel.getDaoFacade(),
processModel.getBtcWalletService());

processModel.setPreparedDelayedPayoutTx(preparedDelayedPayoutTx);

Expand Down

0 comments on commit 345426f

Please sign in to comment.