This PR adds min_conf option to fundrawtransaction and walletcreatefundedpsbt RPC.
Fixes #14542.
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--174a7506f384e20aa4161008e828411d-->
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.
Will add release notes and tests after some concept ACK.
What is the max_conf for?
@gmaxwell just followed listunspent options.
https://github.com/bitcoin/bitcoin/blob/742ee213499194f97e59dae4971f1474ae7d57ad/src/wallet/rpcwallet.cpp#L2592-L2598
Concept ACK.
The 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).
Is it reasonable to add these options to coin control?
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.
@promag I think in such a specific case they can manually pick the inputs to fund the transaction with, I agree with the comments above and think max_conf is probably not the most useful
Rebased and removed 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"
" \"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"
" \"min_conf\" (numeric, optional, default=0) The minimum confirmations to filter\n"
Current default for min_conf is 0.
Concept ACK
Concept ACK
Added tests and release notes. Is this useful for 0.17 branch (after 0.17.1)?
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"},
Whoopsie, default_value should be string. Should fix this by disallowing something else.
Rebased.
:( I hate to say it, but I think this runs into the problems resolving #14602. In short, you almost never want to spend coins that come from third parties without confirmation (as they could be doublespent, causing you to double spend someone) but you almost always do want to be willing to use your own change unconfirmed if its required to get enough funds-- otherwise you'll have seemingly inexplicable failures due to coins being tied up by other unconfirmed transactions.
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"},
{"min_conf", RPCArg::Type::NUM, /* default */ "0", "The minimum confirmations to filter"},
Done.
Rebased.
In light of removal of minconf from sendmany, are we still moving forward on this?
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.*
Why?
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.
This is similar to listunspent and handles all utxo the same, regardless if change or not.
@promag here's a rebase you can use https://github.com/bitcoin/bitcoin/compare/master...luke-jr:fundraw_minconf
<!--cf906140f33d8803c4a75a2196329ecb-->
🐙 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.
<!--13523179cfe9479db18ec6c5d236f789-->There hasn't been much activity lately and the patch still needs rebase. What is the status here?
<!--13523179cfe9479db18ec6c5d236f789-->There hasn't been much activity lately and the patch still needs rebase. What is the status here?
Marked "up for grabs"