mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-25 06:55:32 +01:00
Merge bitcoin/bitcoin#29523: Wallet: Add max_tx_weight to transaction funding options (take 2)
734076c6de[wallet, rpc]: add `max_tx_weight` to tx funding options (ismaelsadeeq)b6fc5043c1[wallet]: update the data type of `change_output_size`, `change_spend_size` and `tx_noinputs_size` to `int` (ismaelsadeeq)baab0d2d43[doc]: update reason for deducting change output weight (ismaelsadeeq)7f61d31a5c[refactor]: update coin selection algorithms input parameter `max_weight` name (ismaelsadeeq) Pull request description: This PR taken over from #29264 The PR added an option `max_tx_weight` to transaction funding RPC's that ensures the resulting transaction weight does not exceed the specified `max_tx_weight` limit. If `max_tx_weight` is not given `MAX_STANDARD_TX_WEIGHT` is used as the max threshold. This PR addressed outstanding review comments in #29264 For more context and rationale behind this PR see https://delvingbitcoin.org/t/lightning-transactions-with-v3-and-ephemeral-anchors/418/11?u=instagibbs ACKs for top commit: achow101: ACK734076c6defurszy: utACK734076c6derkrux: reACK [734076c](734076c6de) Tree-SHA512: 013501aa443d239ee2ac01bccfc5296490c27b4edebe5cfca6b96c842375e895e5cfeb5424e82e359be581460f8be92095855763a62779a18ccd5bdfdd7ddce7
This commit is contained in:
@@ -542,6 +542,7 @@ CreatedTransactionResult FundTransaction(CWallet& wallet, const CMutableTransact
|
||||
{"minconf", UniValueType(UniValue::VNUM)},
|
||||
{"maxconf", UniValueType(UniValue::VNUM)},
|
||||
{"input_weights", UniValueType(UniValue::VARR)},
|
||||
{"max_tx_weight", UniValueType(UniValue::VNUM)},
|
||||
},
|
||||
true, true);
|
||||
|
||||
@@ -701,6 +702,10 @@ CreatedTransactionResult FundTransaction(CWallet& wallet, const CMutableTransact
|
||||
}
|
||||
}
|
||||
|
||||
if (options.exists("max_tx_weight")) {
|
||||
coinControl.m_max_tx_weight = options["max_tx_weight"].getInt<int>();
|
||||
}
|
||||
|
||||
if (recipients.empty())
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "TX must have at least one output");
|
||||
|
||||
@@ -786,6 +791,8 @@ RPCHelpMan fundrawtransaction()
|
||||
},
|
||||
},
|
||||
},
|
||||
{"max_tx_weight", RPCArg::Type::NUM, RPCArg::Default{MAX_STANDARD_TX_WEIGHT}, "The maximum acceptable transaction weight.\n"
|
||||
"Transaction building will fail if this can not be satisfied."},
|
||||
},
|
||||
FundTxDoc()),
|
||||
RPCArgOptions{
|
||||
@@ -1240,6 +1247,8 @@ RPCHelpMan send()
|
||||
{"vout_index", RPCArg::Type::NUM, RPCArg::Optional::OMITTED, "The zero-based output index, before a change output is added."},
|
||||
},
|
||||
},
|
||||
{"max_tx_weight", RPCArg::Type::NUM, RPCArg::Default{MAX_STANDARD_TX_WEIGHT}, "The maximum acceptable transaction weight.\n"
|
||||
"Transaction building will fail if this can not be satisfied."},
|
||||
},
|
||||
FundTxDoc()),
|
||||
RPCArgOptions{.oneline_description="options"}},
|
||||
@@ -1287,6 +1296,9 @@ RPCHelpMan send()
|
||||
// Automatically select coins, unless at least one is manually selected. Can
|
||||
// be overridden by options.add_inputs.
|
||||
coin_control.m_allow_other_inputs = rawTx.vin.size() == 0;
|
||||
if (options.exists("max_tx_weight")) {
|
||||
coin_control.m_max_tx_weight = options["max_tx_weight"].getInt<int>();
|
||||
}
|
||||
SetOptionsInputWeights(options["inputs"], options);
|
||||
// Clear tx.vout since it is not meant to be used now that we are passing outputs directly.
|
||||
// This sets us up for a future PR to completely remove tx from the function signature in favor of passing inputs directly
|
||||
@@ -1697,6 +1709,8 @@ RPCHelpMan walletcreatefundedpsbt()
|
||||
{"vout_index", RPCArg::Type::NUM, RPCArg::Optional::OMITTED, "The zero-based output index, before a change output is added."},
|
||||
},
|
||||
},
|
||||
{"max_tx_weight", RPCArg::Type::NUM, RPCArg::Default{MAX_STANDARD_TX_WEIGHT}, "The maximum acceptable transaction weight.\n"
|
||||
"Transaction building will fail if this can not be satisfied."},
|
||||
},
|
||||
FundTxDoc()),
|
||||
RPCArgOptions{.oneline_description="options"}},
|
||||
|
||||
Reference in New Issue
Block a user