Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpc: Add min_conf option to fund transaction calls #14641

Closed
wants to merge 2 commits into from

Conversation

promag
Copy link
Member

@promag promag commented Nov 2, 2018

This PR adds min_conf option to fundrawtransaction and walletcreatefundedpsbt RPC.

Fixes #14542.

@DrahtBot
Copy link
Contributor

DrahtBot commented Nov 2, 2018

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

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.

@promag
Copy link
Member Author

promag commented Nov 2, 2018

Will add release notes and tests after some concept ACK.

@gmaxwell
Copy link
Contributor

gmaxwell commented Nov 3, 2018

What is the max_conf for?

@promag
Copy link
Member Author

promag commented Nov 3, 2018

@gmaxwell just followed listunspent options.

"listunspent ( minconf maxconf [\"addresses\",...] [include_unsafe] [query_options])\n"
"\nReturns array of unspent transaction outputs\n"
"with between minconf and maxconf (inclusive) confirmations.\n"
"Optionally filter to only include txouts paid to specified addresses.\n"
"\nArguments:\n"
"1. minconf (numeric, optional, default=1) The minimum confirmations to filter\n"
"2. maxconf (numeric, optional, default=9999999) The maximum confirmations to filter\n"

@jonasschnelli
Copy link
Contributor

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).

@promag
Copy link
Member Author

promag commented Nov 4, 2018

Is it reasonable to add these options to coin control?

Copy link
Contributor

@conscott conscott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@gmaxwell
Copy link
Contributor

gmaxwell commented Nov 6, 2018

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
Copy link
Member Author

promag commented Nov 7, 2018

@gmaxwell I'm happy to remove max_conf here, as it isn't required for #14542. However it can be acceptable to create a transaction with fresh inputs, especially with 0 confirmations?

@meshcollider
Copy link
Contributor

@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

@promag promag changed the title RPC: Add min/max confirmation options to fund transaction calls rpc: Add min_conf option to fund transaction calls Nov 12, 2018
@promag
Copy link
Member Author

promag commented Nov 12, 2018

Rebased and removed max_conf option. Please concept ACK to add release note and tests.

Copy link
Member Author

@promag promag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current default for min_conf is 0.

src/wallet/rpcwallet.cpp Outdated Show resolved Hide resolved
src/wallet/rpcwallet.cpp Outdated Show resolved Hide resolved
@meshcollider
Copy link
Contributor

Concept ACK

1 similar comment
@laanwj
Copy link
Member

laanwj commented Nov 23, 2018

Concept ACK

@promag promag force-pushed the 2018-11-fundrawtransaction branch 2 times, most recently from 0c328a4 to 2b11f02 Compare December 4, 2018 23:21
@promag
Copy link
Member Author

promag commented Dec 4, 2018

Added tests and release notes. Is this useful for 0.17 branch (after 0.17.1)?

src/wallet/rpcwallet.cpp Outdated Show resolved Hide resolved
.gitignore Outdated
@@ -61,6 +61,7 @@ src/qt/bitcoin-qt.includes
*.orig
*.pyc
*.o
*.o.*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Member Author

@promag promag Apr 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@maflcko
Copy link
Member

maflcko commented Jul 2, 2019

On pull request is removing min conf, the other is adding it. Would be nice if there was a uniform general direction.

@promag
Copy link
Member Author

promag commented Jul 2, 2019

This is similar to listunspent and handles all utxo the same, regardless if change or not.

@luke-jr
Copy link
Member

luke-jr commented Apr 1, 2020

@promag here's a rebase you can use master...luke-jr:fundraw_minconf

@promag
Copy link
Member Author

promag commented Apr 1, 2020

Thanks @luke-jr!

@DrahtBot
Copy link
Contributor

🐙 This pull request conflicts with the target branch and needs rebase.

@ejose19
Copy link

ejose19 commented Nov 27, 2020

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

bool OutputGroup::EligibleForSpending(const CoinEligibilityFilter& eligibility_filter) const
{
return m_depth >= (m_from_me ? eligibility_filter.conf_mine : eligibility_filter.conf_theirs)
&& m_ancestors <= eligibility_filter.max_ancestors
&& m_descendants <= eligibility_filter.max_descendants;
}

and implement it at either AvailableCoins or construct the CoinEligibilityFilter with the passed arguments at

bitcoin/src/wallet/wallet.cpp

Lines 2484 to 2491 in e2ff5e7

bool res = value_to_select <= 0 ||
SelectCoinsMinConf(value_to_select, CoinEligibilityFilter(1, 6, 0), groups, setCoinsRet, nValueRet, coin_selection_params, bnb_used) ||
SelectCoinsMinConf(value_to_select, CoinEligibilityFilter(1, 1, 0), groups, setCoinsRet, nValueRet, coin_selection_params, bnb_used) ||
(m_spend_zero_conf_change && SelectCoinsMinConf(value_to_select, CoinEligibilityFilter(0, 1, 2), groups, setCoinsRet, nValueRet, coin_selection_params, bnb_used)) ||
(m_spend_zero_conf_change && SelectCoinsMinConf(value_to_select, CoinEligibilityFilter(0, 1, std::min((size_t)4, max_ancestors/3), std::min((size_t)4, max_descendants/3)), groups, setCoinsRet, nValueRet, coin_selection_params, bnb_used)) ||
(m_spend_zero_conf_change && SelectCoinsMinConf(value_to_select, CoinEligibilityFilter(0, 1, max_ancestors/2, max_descendants/2), groups, setCoinsRet, nValueRet, coin_selection_params, bnb_used)) ||
(m_spend_zero_conf_change && SelectCoinsMinConf(value_to_select, CoinEligibilityFilter(0, 1, max_ancestors-1, max_descendants-1), groups, setCoinsRet, nValueRet, coin_selection_params, bnb_used)) ||
(m_spend_zero_conf_change && !fRejectLongChains && SelectCoinsMinConf(value_to_select, CoinEligibilityFilter(0, 1, std::numeric_limits<uint64_t>::max()), groups, setCoinsRet, nValueRet, coin_selection_params, bnb_used));

?. 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.

@DrahtBot
Copy link
Contributor

There hasn't been much activity lately and the patch still needs rebase. What is the status here?
  • Is it still relevant? ➡️ Please solve the conflicts to make it ready for review and to ensure the CI passes.
  • Is it no longer relevant? ➡️ Please close.
  • Did the author lose interest or time to work on this? ➡️ Please close it and mark it 'Up for grabs' with the label, so that it can be picked up in the future.

1 similar comment
@DrahtBot
Copy link
Contributor

There hasn't been much activity lately and the patch still needs rebase. What is the status here?
  • Is it still relevant? ➡️ Please solve the conflicts to make it ready for review and to ensure the CI passes.
  • Is it no longer relevant? ➡️ Please close.
  • Did the author lose interest or time to work on this? ➡️ Please close it and mark it 'Up for grabs' with the label, so that it can be picked up in the future.

@maflcko
Copy link
Member

maflcko commented Mar 21, 2022

Marked "up for grabs"

@fanquake fanquake closed this Apr 26, 2022
luke-jr pushed a commit to luke-jr/bitcoin that referenced this pull request May 21, 2022
…psbt [as deprecated]

Github-Pull: bitcoin#14641
Rebased-From: 965628a [partial]
luke-jr pushed a commit to luke-jr/bitcoin that referenced this pull request May 21, 2022
achow101 added a commit that referenced this pull request Jan 16, 2023
…ansaction calls

cfe5aeb rpc: add minconf and maxconf options to sendall (ishaanam)
a07a413 Wallet/RPC: Allow specifying min & max chain depth for inputs used by fund calls (Juan Pablo Civile)

Pull request description:

  This PR adds a "minconf" option to `fundrawtransaction`, `walletcreatefundedpsbt`,  and `sendall`.
  Alternative implementation of #14641
  Fixes #14542

  Edit: This PR now also adds this option to `send`

ACKs for top commit:
  achow101:
    ACK cfe5aeb
  Xekyo:
    ACK cfe5aeb
  furszy:
    diff ACK cfe5aeb, only a non-blocking nit.

Tree-SHA512: 836e610926eec3a62308fba88ddbd6a13d8f4dac37352d0309599f893cde9c1df5e9c298fda6e076493068e4d213e4afa7290a9e3bdb5a95a5d507da3f7b59e8
@bitcoin bitcoin locked and limited conversation to collaborators Jun 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fundrawtransaction - select input transaction with minimum confirmations