Skip to content

Conversation

andrewtoth
Copy link
Contributor

@andrewtoth andrewtoth commented Nov 12, 2018

The current *receivedby* RPCs filter out coinbase transactions. This doesn't seem correct since an output to your address in a coinbase transaction is receiving those coins.

This PR corrects this behaviour. Also, a new option include_immature_coinbase is added (default=false) that includes immature coinbase transactions when set to true.

However, since this is potentially a breaking change this PR introduces a hidden configuration option -deprecatedrpc=exclude_coinbase. This can be set to revert to previous behaviour. If no reports of broken workflow are received, then this option can be removed in a future release.

Fixes #14654.

@sipa
Copy link
Member

sipa commented Nov 12, 2018

Concept ACK, but you can't break compatibility by reordering another argument to listreceivedbyaddress. It's also unnecessary I think; you can specify "null" to get the default.

@andrewtoth
Copy link
Contributor Author

@sipa Not sure how to pass "null" as address_filter parameter without breaking #14417.

Copy link
Contributor

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

Concept ACK

@sipa Not sure how to pass "null" as address_filter parameter without breaking #14417.

You can use named arguments instead.

Could have release note of the changed RPC's and the new argument.

@gmaxwell
Copy link
Contributor

gmaxwell commented Nov 12, 2018

Do we know a usecase where anyone would want this behaviour? It seems transparently broken to me.

If not, I think I would prefer we fix it and have a LOUD release note about the change, and if we're feeling especially conservative have a hidden config option to restore the old behaviour which we can drop after a couple releases if no one reports needing it.

Having an option presents a perpetual usage complexity increase, and defaulting the option to the old behaviour risks users being messed up by continuing to miss these payments.

One thing to consider, however, is that coinbase payments have different deconfirmation risks then general transactions... and cannot be spent for 100 blocks. E.g. you don't want service that accept a 1 conf deposit and withdraw being exploited as a orphan risk eliminator. Nor do we want to undermine parties cashflow handling by causing them to think they can spend more now than they can. There is justification for treating coinbase payments differently (e.g. only showing them once they're spendable), just not for hiding them completely. Having a "include coinbase payments yes/no" doesn't solve these concerns. Having a "delay them by 100 blocks, yes/no" probably would.

So maybe I would suggest having an argument to hide them until maturity, defaulting on, a hidden option to get the old behaviour, defaulting off, to be removed once it's confirmed no one needs it, and a loud release note explaining the change.

@promag
Copy link
Contributor

promag commented Nov 12, 2018

@gmaxwell it is however useful to know if a payment was made regardless if it takes 100 blocks to be spendable?

@gmaxwell
Copy link
Contributor

It can be, but listreceivedbyaddress doesn't normally show unconfirmed payments and the output IIRC doesn't even tell you if its an immature coinbase payment (and if it did, many people who didn't even realize coinbase payments were possible would not know to check for it)

@promag
Copy link
Contributor

promag commented Nov 12, 2018

@gmaxwell what if we consider minconf the depth added to the minimum spendable depth? Then minconf=1 for coinbase transactions would be 101?

@andrewtoth
Copy link
Contributor Author

@gmaxwell I agree. I think it is an error that should be corrected. I'm not sure why anyone would want coinbase txs excluded. I haven't seen a good explanation for why they are filtered out, or a usecase.

@DrahtBot
Copy link
Contributor

DrahtBot commented Nov 13, 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:

  • #20892 (tests: Run both descriptor and legacy tests within a single test invocation by achow101)

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.

@andrewtoth
Copy link
Contributor Author

andrewtoth commented Nov 15, 2018

Commits and PR description have been updated.

@andrewtoth
Copy link
Contributor Author

andrewtoth commented Nov 16, 2018

I refactored the getreceivedby calls to use a common function GetReceived. This mirrors the listreceivedby calls and doesn't repeat as much code.

@andrewtoth andrewtoth changed the title [RPC] Add include_coinbase option to receiveby RPCs [RPC] Include coinbase transactions in receiveby RPCs Nov 17, 2018
@andrewtoth andrewtoth changed the title [RPC] Include coinbase transactions in receiveby RPCs [RPC] Include coinbase transactions in receivedby RPCs Nov 17, 2018
@andrewtoth andrewtoth force-pushed the receivedby-coinbase branch 3 times, most recently from 3a1cc7c to 97602b5 Compare November 20, 2018 02:40
@andrewtoth
Copy link
Contributor Author

@gmaxwell Updated this PR with your suggestions.

@andrewtoth andrewtoth force-pushed the receivedby-coinbase branch 2 times, most recently from b49685a to 0fa9b60 Compare November 24, 2018 15:01
@maflcko
Copy link
Member

maflcko commented Dec 6, 2021

Yeah, needs rebase again.

                                   TypeError: generatetoaddress() missing 1 required keyword-only argument: 'invalid_call'

@andrewtoth
Copy link
Contributor Author

Rebased.

@maflcko
Copy link
Member

maflcko commented Dec 7, 2021

Looks like there are test failures with descriptor wallets?

@andrewtoth
Copy link
Contributor Author

@MarcoFalke fixed.

@jnewbery
Copy link
Contributor

jnewbery commented Dec 7, 2021

reACK 1dcba99

Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

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

Sorry for the incremental review

This release changes this behaviour and returns results accounting for received coins from coinbase outputs.

A new option, `include_immature_coinbase` (default=`false`), determines whether to account for immature coinbase transactions.
Immature coinbase transactions are coinbase transactions that have 100 or fewer confirmations, and are not spendable.
Copy link
Member

Choose a reason for hiding this comment

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

Is this still up-to-date? The default seems to be true. Also, instead of using the release notes to explain what immature txs are, what about moving this to the rpc help? Either this is relevant for future releases as well, or not at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The option is defined here and here, made clear to be false when no option is specified by your suggestion here.

I can move the immature txs explanation to the rpc help if I have to rebase again. Do you think it's a blocker? The release notes will have to be manually updated anyways, right?

Copy link
Member

Choose a reason for hiding this comment

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

No, not a blocker.

Sorry for the brain fart. I keep messing up true and false for boolean values lately.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe for clarity (in the future) the second section can be switched with the third section, so that the behavior changing stuff is bundled together and the new rpc arg option is in a separate bundle?

Copy link
Member

Choose a reason for hiding this comment

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

If someone decides to address the nits, the notes snippet can also be moved to the main release notes file in the same pull request, to avoid having to touch it again.

@maflcko maflcko merged commit 63c63b5 into bitcoin:master Dec 7, 2021
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Dec 7, 2021
RandyMcMillan pushed a commit to RandyMcMillan/mempool-tab that referenced this pull request Dec 23, 2021
…eceivedby RPCs

9a6ee0c Coinbase receivedby rpcs release notes (Andrew Toth)
c774578 Test including coinbase transactions in receivedby wallet rpcs (Andrew Toth)
4347045 Include coinbase transactions in receivedby wallet rpcs (Andrew Toth)

Pull request description:

  The current `*receivedby*` RPCs filter out coinbase transactions. This doesn't seem correct since an output to your address in a coinbase transaction *is* receiving those coins.

  This PR corrects this behaviour. Also, a new option `include_immature_coinbase` is added (default=`false`) that includes immature coinbase transactions when set to true.

  However, since this is potentially a breaking change this PR introduces a hidden configuration option `-deprecatedrpc=exclude_coinbase`. This can be set to revert to previous behaviour. If no reports of broken workflow are received, then this option can be removed in a future release.

  Fixes bitcoin/bitcoin#14654.

ACKs for top commit:
  jnewbery:
    reACK 9a6ee0c

Tree-SHA512: bfc43b81279fea5b6770a4620b196f6bc7c818d221b228623e9f535ec75a2406bc440e3df911608a3680f11ab64c5a4103917162114f5ff7c4ca8ab07bb9d3df
maflcko pushed a commit that referenced this pull request May 20, 2022
…ogic

a4703ce doc: add release notes about removal of the `deprecatedrpc=exclude_coinbase` (Sebastian Falbesoner)
ef0aa74 rpc: wallet: remove `-deprecatedrpc=exclude_coinbase` logic (Sebastian Falbesoner)

Pull request description:

  Including coinbase transactions in `receivedby` RPCs and adding the `-deprecatedrpc=exclude_coinbase` was done in PR #14707 (released in v23.0). For the next release v24.0, this configuration option can be removed.

ACKs for top commit:
  fanquake:
    ACK a4703ce

Tree-SHA512: 97cd4e78501e64f678c78d2ebb5be5376688c023e34fced71dd24e432d27aa31a74b5483545f49ba0bdf48656d8b8b7bee74e3db26cf6daf112613f1caa4dfa4
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request May 28, 2022
…base` logic

a4703ce doc: add release notes about removal of the `deprecatedrpc=exclude_coinbase` (Sebastian Falbesoner)
ef0aa74 rpc: wallet: remove `-deprecatedrpc=exclude_coinbase` logic (Sebastian Falbesoner)

Pull request description:

  Including coinbase transactions in `receivedby` RPCs and adding the `-deprecatedrpc=exclude_coinbase` was done in PR bitcoin#14707 (released in v23.0). For the next release v24.0, this configuration option can be removed.

ACKs for top commit:
  fanquake:
    ACK a4703ce

Tree-SHA512: 97cd4e78501e64f678c78d2ebb5be5376688c023e34fced71dd24e432d27aa31a74b5483545f49ba0bdf48656d8b8b7bee74e3db26cf6daf112613f1caa4dfa4
@andrewtoth andrewtoth deleted the receivedby-coinbase branch November 16, 2022 01:05
jamesdorfman added a commit to jamesdorfman/elements that referenced this pull request Jun 3, 2023
I'm not certain my merge conflict resolution in src/wallet/rpcwallet.cpp
was correct, please double check that thoroughly.
delta1 added a commit to delta1/elements that referenced this pull request Jun 5, 2023
knst pushed a commit to knst/dash that referenced this pull request Aug 17, 2023
…eived function

a1d5b12 Merge getreceivedby tally into GetReceived function (Andrew Toth)

Pull request description:

  This PR merges the tally code of `getreceivedbyaddress` and `getreceivedbylabel` into a single function `GetReceived`. This reduces repeated code and makes it similar to `listreceivedbyaddress` and `listreceivedbylabel`, which use the function `ListReceived`. It will also make the change in bitcoin#14707 simpler and easier to review.

ACKs for top commit:
  theStack:
    re-ACK bitcoin@a1d5b12
  meshcollider:
    utACK a1d5b12

Tree-SHA512: 43d9cd92f7c2c6a8b9c7509aa85a9b9233a6cfec1c43a9062e3bdfb83515413d1feafa8938c828351278ba22bd31c47e62ab5341e4bddc2493103b094d73b047
knst pushed a commit to knst/dash that referenced this pull request Aug 18, 2023
…eived function

a1d5b12 Merge getreceivedby tally into GetReceived function (Andrew Toth)

Pull request description:

  This PR merges the tally code of `getreceivedbyaddress` and `getreceivedbylabel` into a single function `GetReceived`. This reduces repeated code and makes it similar to `listreceivedbyaddress` and `listreceivedbylabel`, which use the function `ListReceived`. It will also make the change in bitcoin#14707 simpler and easier to review.

ACKs for top commit:
  theStack:
    re-ACK bitcoin@a1d5b12
  meshcollider:
    utACK a1d5b12

Tree-SHA512: 43d9cd92f7c2c6a8b9c7509aa85a9b9233a6cfec1c43a9062e3bdfb83515413d1feafa8938c828351278ba22bd31c47e62ab5341e4bddc2493103b094d73b047
knst pushed a commit to knst/dash that referenced this pull request Aug 18, 2023
…eived function

a1d5b12 Merge getreceivedby tally into GetReceived function (Andrew Toth)

Pull request description:

  This PR merges the tally code of `getreceivedbyaddress` and `getreceivedbylabel` into a single function `GetReceived`. This reduces repeated code and makes it similar to `listreceivedbyaddress` and `listreceivedbylabel`, which use the function `ListReceived`. It will also make the change in bitcoin#14707 simpler and easier to review.

ACKs for top commit:
  theStack:
    re-ACK bitcoin@a1d5b12
  meshcollider:
    utACK a1d5b12

Tree-SHA512: 43d9cd92f7c2c6a8b9c7509aa85a9b9233a6cfec1c43a9062e3bdfb83515413d1feafa8938c828351278ba22bd31c47e62ab5341e4bddc2493103b094d73b047
knst pushed a commit to knst/dash that referenced this pull request Aug 18, 2023
…eived function

a1d5b12 Merge getreceivedby tally into GetReceived function (Andrew Toth)

Pull request description:

  This PR merges the tally code of `getreceivedbyaddress` and `getreceivedbylabel` into a single function `GetReceived`. This reduces repeated code and makes it similar to `listreceivedbyaddress` and `listreceivedbylabel`, which use the function `ListReceived`. It will also make the change in bitcoin#14707 simpler and easier to review.

ACKs for top commit:
  theStack:
    re-ACK bitcoin@a1d5b12
  meshcollider:
    utACK a1d5b12

Tree-SHA512: 43d9cd92f7c2c6a8b9c7509aa85a9b9233a6cfec1c43a9062e3bdfb83515413d1feafa8938c828351278ba22bd31c47e62ab5341e4bddc2493103b094d73b047
knst pushed a commit to knst/dash that referenced this pull request Aug 20, 2023
…eived function

a1d5b12 Merge getreceivedby tally into GetReceived function (Andrew Toth)

Pull request description:

  This PR merges the tally code of `getreceivedbyaddress` and `getreceivedbylabel` into a single function `GetReceived`. This reduces repeated code and makes it similar to `listreceivedbyaddress` and `listreceivedbylabel`, which use the function `ListReceived`. It will also make the change in bitcoin#14707 simpler and easier to review.

ACKs for top commit:
  theStack:
    re-ACK bitcoin@a1d5b12
  meshcollider:
    utACK a1d5b12

Tree-SHA512: 43d9cd92f7c2c6a8b9c7509aa85a9b9233a6cfec1c43a9062e3bdfb83515413d1feafa8938c828351278ba22bd31c47e62ab5341e4bddc2493103b094d73b047
knst pushed a commit to knst/dash that referenced this pull request Aug 24, 2023
…eived function

a1d5b12 Merge getreceivedby tally into GetReceived function (Andrew Toth)

Pull request description:

  This PR merges the tally code of `getreceivedbyaddress` and `getreceivedbylabel` into a single function `GetReceived`. This reduces repeated code and makes it similar to `listreceivedbyaddress` and `listreceivedbylabel`, which use the function `ListReceived`. It will also make the change in bitcoin#14707 simpler and easier to review.

ACKs for top commit:
  theStack:
    re-ACK bitcoin@a1d5b12
  meshcollider:
    utACK a1d5b12

Tree-SHA512: 43d9cd92f7c2c6a8b9c7509aa85a9b9233a6cfec1c43a9062e3bdfb83515413d1feafa8938c828351278ba22bd31c47e62ab5341e4bddc2493103b094d73b047
PastaPastaPasta pushed a commit to knst/dash that referenced this pull request Aug 30, 2023
…eived function

a1d5b12 Merge getreceivedby tally into GetReceived function (Andrew Toth)

Pull request description:

  This PR merges the tally code of `getreceivedbyaddress` and `getreceivedbylabel` into a single function `GetReceived`. This reduces repeated code and makes it similar to `listreceivedbyaddress` and `listreceivedbylabel`, which use the function `ListReceived`. It will also make the change in bitcoin#14707 simpler and easier to review.

ACKs for top commit:
  theStack:
    re-ACK bitcoin@a1d5b12
  meshcollider:
    utACK a1d5b12

Tree-SHA512: 43d9cd92f7c2c6a8b9c7509aa85a9b9233a6cfec1c43a9062e3bdfb83515413d1feafa8938c828351278ba22bd31c47e62ab5341e4bddc2493103b094d73b047
@bitcoin bitcoin locked and limited conversation to collaborators Nov 16, 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.

received wallet rpc calls do not include coinbase outputs