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: listunspent, add "include immature coinbase" flag #25730

Merged

Conversation

furszy
Copy link
Member

@furszy furszy commented Jul 28, 2022

Simple PR; adds a "include_immature_coinbase" flag to listunspent to include the immature coinbase UTXOs on the response. Requested by #25728.

@furszy furszy force-pushed the 2022_RPC_listunspent_include_immature_coinbase branch 3 times, most recently from 77b92ea to 8621fbf Compare July 28, 2022 15:39
Copy link
Contributor

@w0xlt w0xlt left a comment

Choose a reason for hiding this comment

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

Tested ACK 8621fbf

@DrahtBot
Copy link
Contributor

DrahtBot commented Jul 30, 2022

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #25789 (test: clean and extend availablecoins_tests coverage by furszy)

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.

Copy link
Member

@jarolrod jarolrod left a comment

Choose a reason for hiding this comment

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

tACK 8621fbf

Generated some blocks on regtest and checked the output of listunspent {args} ... include_immature_coinbase=true, to check that various immature coinbases were infact displayed

test/functional/wallet_balance.py Outdated Show resolved Hide resolved
test/functional/wallet_balance.py Outdated Show resolved Hide resolved
@furszy furszy force-pushed the 2022_RPC_listunspent_include_immature_coinbase branch from 8621fbf to 785f78b Compare August 3, 2022 13:15
@furszy
Copy link
Member Author

furszy commented Aug 3, 2022

thanks for the feedback.
Tackled @jarolrod nits and add release-notes.

@furszy furszy force-pushed the 2022_RPC_listunspent_include_immature_coinbase branch from 785f78b to ee50c00 Compare August 3, 2022 13:26
Copy link
Member

@jarolrod jarolrod left a comment

Choose a reason for hiding this comment

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

ACK ee50c00

Only change is small comment change and addition of release notes since my last review.

doc/release-notes.md Outdated Show resolved Hide resolved
@furszy furszy force-pushed the 2022_RPC_listunspent_include_immature_coinbase branch from ee50c00 to 36c2676 Compare August 3, 2022 20:44
src/wallet/rpc/coins.cpp Outdated Show resolved Hide resolved
@furszy furszy force-pushed the 2022_RPC_listunspent_include_immature_coinbase branch from 36c2676 to c070ea2 Compare August 12, 2022 16:50
Copy link
Contributor

@kouloumos kouloumos 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,

Although this flag is already part of the *receivedby* RPCs since #14707, the logic there is different. Therefore this PR changes AvailableCoins (mainly used by CreateTransactionInternal to get the available coins prior to coin selection) in order to allow immature coinbase txns to make it to the available coins list. To accomplish that, it introduces the include_immature_coinbase option as part of coin control.

Is the inclusion of immature coinbase txns in scope for Coin Control features? Is there a create-tx scenario that we will want to choose those txns?

@achow101
Copy link
Member

Reopened by request

@furszy furszy force-pushed the 2022_RPC_listunspent_include_immature_coinbase branch from c070ea2 to cdb4365 Compare October 12, 2022 21:01
@furszy furszy force-pushed the 2022_RPC_listunspent_include_immature_coinbase branch from cdb4365 to 47be4ac Compare October 13, 2022 00:10
@furszy
Copy link
Member Author

furszy commented Oct 13, 2022

Is the inclusion of immature coinbase txns in scope for Coin Control features? Is there a create-tx scenario that we will want to choose those txns?

Good point @kouloumos (sorry for the delay). It shouldn't be there. Just moved it to be another AvailableCoins argument.

Plus, to make AvailableCoins more "friendly" to use with so many arguments, have grouped all the filtering parameters inside a struct 9f57166.

Copy link

@vladimirfomene vladimirfomene left a comment

Choose a reason for hiding this comment

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

Review ACK. Just Nits

src/wallet/rpc/coins.cpp Outdated Show resolved Hide resolved
@furszy furszy force-pushed the 2022_RPC_listunspent_include_immature_coinbase branch from 9f57166 to 427548d Compare October 13, 2022 14:28
Copy link
Member

@aureleoules aureleoules left a comment

Choose a reason for hiding this comment

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

ACK 1406f1d - LGTM

427548d: I verified that the calls with hard-coded values match the defaults of AvailableCoinsParams.

src/wallet/spend.cpp Outdated Show resolved Hide resolved
@furszy furszy force-pushed the 2022_RPC_listunspent_include_immature_coinbase branch from 1022c18 to 1424246 Compare October 13, 2022 20:54
Copy link
Contributor

@rajarshimaitra rajarshimaitra left a comment

Choose a reason for hiding this comment

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

ReACK 1424246

Copy link
Member

@aureleoules aureleoules left a comment

Choose a reason for hiding this comment

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

reACK 1424246

Copy link
Contributor

@kouloumos kouloumos left a comment

Choose a reason for hiding this comment

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

ACK 1424246, with a small nit about naming.

src/wallet/rpc/spend.cpp Outdated Show resolved Hide resolved
@furszy furszy force-pushed the 2022_RPC_listunspent_include_immature_coinbase branch from 1424246 to 3319eb9 Compare October 14, 2022 14:53
@furszy
Copy link
Member Author

furszy commented Oct 14, 2022

Updated per @kouloumos feedback.

tiny diff, only renamed AvailableCoinsParams to CoinFilterParams.

@kouloumos
Copy link
Contributor

reACK 3319eb9

Copy link
Member

@aureleoules aureleoules left a comment

Choose a reason for hiding this comment

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

reACK 3319eb9

Copy link
Contributor

@danielabrozzoni danielabrozzoni 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, I have a couple of questions (beginner here, sorry :)) and I still haven't tested the code, but overalls it looks good to me!

src/wallet/spend.cpp Show resolved Hide resolved
test/functional/wallet_balance.py Show resolved Hide resolved
src/wallet/spend.h Show resolved Hide resolved
Copy link
Contributor

@danielabrozzoni danielabrozzoni left a comment

Choose a reason for hiding this comment

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

tACK 3319eb9 - the code looks good to me (but my C++ experience is limited), I tested locally and it works as expected. As I pointed out in #25728, this makes it way easier to track immature coins - at the moment in BDK we have to use listunspent combined with listtransactions to make sure to track correctly immature utxos.

Thanks for taking care of this! :)

@theStack
Copy link
Contributor

Concept ACK

so we can return the immature coinbase UTXOs as well.
Plus clean callers that use the params default values
-BEGIN VERIFY SCRIPT-

sed -i 's/nMinimumAmount/min_amount/g' $(git grep -l nMinimumAmount)
sed -i 's/nMaximumAmount/max_amount/g' $(git grep -l nMaximumAmount)
sed -i 's/nMinimumSumAmount/min_sum_amount/g' $(git grep -l nMinimumSumAmount)
sed -i 's/nMaximumCount/max_count/g' $(git grep -l nMaximumCount)

-END VERIFY SCRIPT-
@furszy furszy force-pushed the 2022_RPC_listunspent_include_immature_coinbase branch from 3319eb9 to fa84df1 Compare October 29, 2022 11:54
@furszy
Copy link
Member Author

furszy commented Oct 29, 2022

Rebased, conflicts solved.
Ready to go.

Copy link
Member

@aureleoules aureleoules left a comment

Choose a reason for hiding this comment

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

reACK fa84df1

Copy link
Contributor

@kouloumos kouloumos left a comment

Choose a reason for hiding this comment

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

reACK fa84df1

@danielabrozzoni
Copy link
Contributor

reACK fa84df1

Copy link
Contributor

@theStack theStack left a comment

Choose a reason for hiding this comment

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

Code-review ACK fa84df1

@achow101
Copy link
Member

ACK fa84df1

@achow101 achow101 merged commit f0c646f into bitcoin:master Nov 16, 2022
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Nov 16, 2022
…" flag

fa84df1 scripted-diff: wallet: rename AvailableCoinsParams members to snake_case (furszy)
61c2265 wallet: group AvailableCoins filtering parameters in a single struct (furszy)
f0f6a35 RPC: listunspent, add "include immature coinbase" flag (furszy)

Pull request description:

  Simple PR; adds a "include_immature_coinbase" flag to `listunspent` to include the immature coinbase UTXOs on the response.  Requested by bitcoin#25728.

ACKs for top commit:
  danielabrozzoni:
    reACK fa84df1
  achow101:
    ACK fa84df1
  aureleoules:
    reACK fa84df1
  kouloumos:
    reACK fa84df1
  theStack:
    Code-review ACK fa84df1

Tree-SHA512: 0f3544cb8cfd0378a5c74594480f78e9e919c6cfb73a83e0f3112f8a0132a9147cf846f999eab522cea9ef5bd3ffd60690ea2ca367dde457b0554d7f38aec792
@furszy furszy deleted the 2022_RPC_listunspent_include_immature_coinbase branch May 27, 2023 01:48
@bitcoin bitcoin locked and limited conversation to collaborators May 26, 2024
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.