This PR adds min_conf option to fundrawtransaction
and walletcreatefundedpsbt
RPC.
Fixes #14542.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
listunspent
options.
https://github.com/bitcoin/bitcoin/blob/742ee213499194f97e59dae4971f1474ae7d57ad/src/wallet/rpcwallet.cpp#L2592-L2598
max_conf
usefulness ist doubtable,… but maybe acceptable to be consistent with listunspent
(and it’s a argument based option-object even in non-argument based RPC calls).
Concept ACK
Maybe you can add some test cases to the rpc_fundrawtransaction.py as well to make sure coin selection fails if conditions are not met?
Nevermind, I see the note about tests.
I believe the max exists for listunspent so that with the other flags you can see only unconfirmed outputs, which wouldn’t apply here, I think.
The maximum argument turns out to be a severe nuisance on listunspent because 99.99999% of the time you want it set to maximum and ‘maximum’ is some arbitrary big number but too big and the rpc is rejected (and that threshold even changed once, breaking all my spending automation). … but there it’s not an optional argument, so I think the same nuisance wouldn’t apply here.
Still, we’re left with functionality being added where no one can articulate a reason. I don’t think that is acceptable, esp where if it ever became useful it could be added without breaking compatibility.
max_conf
is probably not the most useful
max_conf
option. Please concept ACK to add release note and tests.
2940@@ -2936,6 +2941,7 @@ static UniValue fundrawtransaction(const JSONRPCRequest& request)
2941 " \"replaceable\" (boolean, optional) Marks this transaction as BIP125 replaceable.\n"
2942 " Allows this transaction to be replaced by a transaction with higher fees\n"
2943 " \"conf_target\" (numeric, optional) Confirmation target (in blocks)\n"
2944+ " \"min_conf\" (numeric, optional, default=1) The minimum confirmations to filter\n"
0 " \"min_conf\" (numeric, optional, default=0) The minimum confirmations to filter\n"
3950@@ -3945,6 +3951,7 @@ UniValue walletcreatefundedpsbt(const JSONRPCRequest& request)
3951 " \"replaceable\" (boolean, optional) Marks this transaction as BIP125 replaceable.\n"
3952 " Allows this transaction to be replaced by a transaction with higher fees\n"
3953 " \"conf_target\" (numeric, optional) Confirmation target (in blocks)\n"
3954+ " \"min_conf\" (numeric, optional, default=1) The minimum confirmations to filter\n"
0 " \"min_conf\" (numeric, optional, default=0) The minimum confirmations to filter\n"
3021@@ -3017,6 +3022,7 @@ static UniValue fundrawtransaction(const JSONRPCRequest& request)
3022 {"replaceable", RPCArg::Type::BOOL, /* opt */ true, /* default_val */ "", "Marks this transaction as BIP125 replaceable.\n"
3023 " Allows this transaction to be replaced by a transaction with higher fees"},
3024 {"conf_target", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "", "Confirmation target (in blocks)"},
3025+ {"min_conf", RPCArg::Type::NUM, /* opt */ true, /* default_val */ 0, "The minimum confirmations to filter"},
3020@@ -3016,6 +3021,7 @@ static UniValue fundrawtransaction(const JSONRPCRequest& request)
3021 {"replaceable", RPCArg::Type::BOOL, /* opt */ true, /* default_val */ "fallback to wallet's default", "Marks this transaction as BIP125 replaceable.\n"
3022 " Allows this transaction to be replaced by a transaction with higher fees"},
3023 {"conf_target", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "fallback to wallet's default", "Confirmation target (in blocks)"},
3024+ {"min_conf", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "0", "The minimum confirmations to filter"},
0 {"min_conf", RPCArg::Type::NUM, /* default */ "0", "The minimum confirmations to filter"},
sendmany::minconf was 1
(by default and in many scripts), so it couldn’t be used in the same fashion as min_conf
in this pull request. Otherwise it would break existing behaviour to spend own mempool-change #15595 (comment).
I wouldn’t object adding min_conf
with default=0 to other wallet calls as well.
3028@@ -3024,7 +3029,7 @@ void FundTransaction(CWallet* const pwallet, CMutableTransaction& tx, CAmount& f
3029
3030 std::string strFailReason;
3031
3032- if (!pwallet->FundTransaction(tx, fee_out, change_position, strFailReason, lockUnspents, setSubtractFeeFromOutputs, coinControl)) {
3033+ if (!pwallet->FundTransaction(tx, fee_out, change_position, strFailReason, lockUnspents, setSubtractFeeFromOutputs, coinControl, min_depth)) {
Could pass down via coin control to avoid having to adjust all function signatures?
See e.g. https://github.com/bitcoin/bitcoin/pull/15595/files#diff-5694bdba4c3d58805c185a3fbced2868R36
60@@ -61,6 +61,7 @@ src/qt/bitcoin-qt.includes
61 *.orig
62 *.pyc
63 *.o
64+*.o.*
I’m glad you ask 😄try running make -j10
and in parallel run git status
. Some editors will refresh showing these temporary files (mostly *.o.tmp
).
Edit 2: at least on macos. Edit: happy to submit this in a separate PR.
listunspent
and handles all utxo the same, regardless if change or not.
🐙 This pull request conflicts with the target branch and needs rebase.
While looking for this functionability I found this PR, and I also had the same concerns as @gmaxwell regarding the trusted/untrusted. However could we use instead m_min_depth_mine
& m_min_depth_theirs
similar to
and implement it at either AvailableCoins
or construct the CoinEligibilityFilter
with the passed arguments at
?. This way we can set 0 || 1
for own transactions, and 3+
for untrusted txs (since node already marks eligible with 1 confirmation, but that’s not enough for a third party tx)
I’m interested in submitting a PR in case the proposed resolution is correct.