aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Chow <github@achow101.com>2023-03-22 12:47:18 -0400
committerAndrew Chow <github@achow101.com>2023-03-22 12:54:26 -0400
commitfc7c21f664fd24ac17f518d07f04e0a3d9f8681c (patch)
tree2f07f65b450357c5ab4a512bd1f7a8d2f0d26aae /src
parenta70911492fcd1f726782cca2f1ffac18c25e8fb4 (diff)
parentd7cc503843769b789dc5f031b4ddc75d555ba980 (diff)
Merge bitcoin/bitcoin#27271: RPC: Fix fund transaction crash when at 0-value, 0-fee
d7cc503843769b789dc5f031b4ddc75d555ba980 Fix fund transaction case at 0-value, 0-fee (Greg Sanders) Pull request description: and when no inputs are pre-selected. triggered via: walletcreatefundedpsbt '[]' '[{"data": "deadbeef"}]' 0 '{"fee_rate": "0"}' ACKs for top commit: achow101: ACK d7cc503843769b789dc5f031b4ddc75d555ba980 josibake: ACK https://github.com/bitcoin/bitcoin/pull/27271/commits/d7cc503843769b789dc5f031b4ddc75d555ba980 furszy: Crashes sucks code ACK d7cc5038 Tree-SHA512: 3f5e10875666aaf52c11d6a38b951aa75d0cbe684cc7f904e199f7a864923bf31d03a654687f8b746cae0eebb886a799bff2c6d200699438480d4c0ff8785f3a
Diffstat (limited to 'src')
-rw-r--r--src/wallet/spend.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/wallet/spend.cpp b/src/wallet/spend.cpp
index 409b43670a..e4d88bdc62 100644
--- a/src/wallet/spend.cpp
+++ b/src/wallet/spend.cpp
@@ -917,6 +917,12 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
const CAmount not_input_fees = coin_selection_params.m_effective_feerate.GetFee(coin_selection_params.m_subtract_fee_outputs ? 0 : coin_selection_params.tx_noinputs_size);
CAmount selection_target = recipients_sum + not_input_fees;
+ // This can only happen if feerate is 0, and requested destinations are value of 0 (e.g. OP_RETURN)
+ // and no pre-selected inputs. This will result in 0-input transaction, which is consensus-invalid anyways
+ if (selection_target == 0 && !coin_control.HasSelected()) {
+ return util::Error{_("Transaction requires one destination of non-0 value, a non-0 feerate, or a pre-selected input")};
+ }
+
// Fetch manually selected coins
PreSelectedInputs preset_inputs;
if (coin_control.HasSelected()) {