Skip to content

Commit

Permalink
sendBsq: Throw InsufficientMoneyException when BSQ balance too low
Browse files Browse the repository at this point in the history
We should throw an InsufficientMoneyException when the CoinSelection
gathered amount is lower than the amount the user wants to send.
  • Loading branch information
alvasw committed Nov 14, 2024
1 parent 569636c commit 5125ed9
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 5125ed9

Please sign in to comment.