Skip to content

Commit

Permalink
Merge pull request #7294 from alvasw/sendBsq_Throw_InsufficientMoneyE…
Browse files Browse the repository at this point in the history
…xception_when_BSQ_balance_too_low

sendBsq: Throw InsufficientMoneyException when BSQ balance too low
  • Loading branch information
alejandrogarcia83 authored Nov 20, 2024
2 parents 7a6ef6b + a7ff534 commit 10a3a04
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions core/src/main/java/bisq/core/btc/wallet/BsqWalletV2.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public TransactionBroadcast sendBsq(Address receiverAddress,
bsqTx.addOutput(receiverAmount, receiverAddress);

CoinSelection selection = bsqCoinSelector.select(receiverAmount, bsqWallet.calculateAllSpendCandidates());
if (selection.valueGathered.isLessThan(receiverAmount)) {
throw new InsufficientMoneyException(receiverAmount, "Wallet doesn't have " + receiverAmount + " BSQ.");
}
selection.gathered.forEach(bsqTx::addInput);

Coin change = bsqCoinSelector.getChange(receiverAmount, selection);
Expand Down

0 comments on commit 10a3a04

Please sign in to comment.