Skip to content

Conversation

@luke-jr
Copy link
Member

@luke-jr luke-jr commented Aug 13, 2021

(Non-GUI part of bitcoin-core/gui#562, but without the bloom stuff)

@ghost
Copy link

ghost commented Aug 13, 2021

Concept ACK

@luke-jr luke-jr force-pushed the getaddressinfo_txids branch from bcec6dc to 160d61c Compare August 13, 2021 02:46
@luke-jr luke-jr changed the title RPC/Wallet: Add "txids" Array to getaddressinfo result for used addresses RPC/Wallet: Add "use_txids" to output of getaddressinfo Aug 13, 2021
@luke-jr luke-jr force-pushed the getaddressinfo_txids branch from 160d61c to 9fe7926 Compare August 13, 2021 02:49
@kristapsk
Copy link
Contributor

Concept ACK

@DrahtBot
Copy link
Contributor

DrahtBot commented Sep 9, 2021

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

Code Coverage

For detailed information about the code coverage, see the test coverage report.

Reviews

See the guideline for information on the review process.

Type Reviewers
Concept ACK ghost, theStack, pk-b2, jonatack, fjahr, ajtowns, brunoerg
Approach ACK ryanofsky
Approach NACK S3RK, achow101
Stale ACK rajarshimaitra, aureleoules, kristapsk

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #27865 (wallet: Track no-longer-spendable TXOs separately by achow101)
  • #19461 (multiprocess: Add bitcoin-gui -ipcconnect option by ryanofsky)
  • #19460 (multiprocess: Add bitcoin-wallet -ipcconnect option by ryanofsky)

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

Strong concept + tACK 9fe7926

This is very useful for downstream wallets trying to sync using bitcoin core rpc (mostly in home servers). This makes transaction history lookup of addresses easy.

Thank you for working on this.

Hope this gets in soon.

@luke-jr
Copy link
Member Author

luke-jr commented Dec 18, 2021

Rebased

@theStack
Copy link
Contributor

Concept ACK

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

tACK bfb162d

This can be helpful information for privacy. Since it returns two transactions if RBF is used to replace earlier transaction, this adds another interesting information in the results. It is documented in the comments, would be better if present in RPC help as well.

Steps that I performed to test use_txids in getaddressinfo:

Create new address in Core:

bitcoin-cli -rpcwallet="" getnewaddress
tb1qs4ajsepmawzgse0v8d83sletcca2kn4nzr9hln

Check result for getaddressinfo:

bitcoin-cli -rpcwallet="" getaddressinfo tb1qs4ajsepmawzgse0v8d83sletcca2kn4nzr9hln
{
  "address": "tb1qs4ajsepmawzgse0v8d83sletcca2kn4nzr9hln",
  "scriptPubKey": "0014857b28643beb848865ec3b4f187f2bc63aab4eb3",
  "ismine": true,
  "solvable": true,
  "desc": "wpkh([6ba7ec01/0'/0'/40']02f1b431e7cacb981fb24cb28365c6f45b8b7a4f891d3b4dfc1981dd7705b95249)#jypvcx7u",
  "iswatchonly": false,
  "isscript": false,
  "iswitness": true,
  "witness_version": 0,
  "witness_program": "857b28643beb848865ec3b4f187f2bc63aab4eb3",
  "pubkey": "02f1b431e7cacb981fb24cb28365c6f45b8b7a4f891d3b4dfc1981dd7705b95249",
  "ischange": false,
  "timestamp": 1639765317,
  "hdkeypath": "m/0'/0'/40'",
  "hdseedid": "37bb332a78fc64d32f269a40710ed0d34d0a0ba5",
  "hdmasterfingerprint": "6ba7ec01",
  "labels": [
    ""
  ],
  "use_txids": [
  ]
}

Send some bitcoin to this address and check result for getaddressinfo:

bitcoin-cli -rpcwallet="" getaddressinfo tb1qs4ajsepmawzgse0v8d83sletcca2kn4nzr9hln
{
  "address": "tb1qs4ajsepmawzgse0v8d83sletcca2kn4nzr9hln",
  "scriptPubKey": "0014857b28643beb848865ec3b4f187f2bc63aab4eb3",
  "ismine": true,
  "solvable": true,
  "desc": "wpkh([6ba7ec01/0'/0'/40']02f1b431e7cacb981fb24cb28365c6f45b8b7a4f891d3b4dfc1981dd7705b95249)#jypvcx7u",
  "iswatchonly": false,
  "isscript": false,
  "iswitness": true,
  "witness_version": 0,
  "witness_program": "857b28643beb848865ec3b4f187f2bc63aab4eb3",
  "pubkey": "02f1b431e7cacb981fb24cb28365c6f45b8b7a4f891d3b4dfc1981dd7705b95249",
  "ischange": false,
  "timestamp": 1639765317,
  "hdkeypath": "m/0'/0'/40'",
  "hdseedid": "37bb332a78fc64d32f269a40710ed0d34d0a0ba5",
  "hdmasterfingerprint": "6ba7ec01",
  "labels": [
    ""
  ],
  "use_txids": [
    "feaf134bc878824c5cfb7fc1d7b2a6c802f2482dd7becf8f5cc46a473e3bd4e0"
  ]
}

Replace the transaction using RBF and confirm if there are two transaction ids in result for getaddressinfo:

bitcoin-cli -rpcwallet="" getaddressinfo tb1qs4ajsepmawzgse0v8d83sletcca2kn4nzr9hln
{
  "address": "tb1qs4ajsepmawzgse0v8d83sletcca2kn4nzr9hln",
  "scriptPubKey": "0014857b28643beb848865ec3b4f187f2bc63aab4eb3",
  "ismine": true,
  "solvable": true,
  "desc": "wpkh([6ba7ec01/0'/0'/40']02f1b431e7cacb981fb24cb28365c6f45b8b7a4f891d3b4dfc1981dd7705b95249)#jypvcx7u",
  "iswatchonly": false,
  "isscript": false,
  "iswitness": true,
  "witness_version": 0,
  "witness_program": "857b28643beb848865ec3b4f187f2bc63aab4eb3",
  "pubkey": "02f1b431e7cacb981fb24cb28365c6f45b8b7a4f891d3b4dfc1981dd7705b95249",
  "ischange": false,
  "timestamp": 1639765317,
  "hdkeypath": "m/0'/0'/40'",
  "hdseedid": "37bb332a78fc64d32f269a40710ed0d34d0a0ba5",
  "hdmasterfingerprint": "6ba7ec01",
  "labels": [
    ""
  ],
  "use_txids": [
    "b8d96d7683b1ed482c53c2b0b191e91d5db671ee21009fac4d72546bb13fde47",
    "feaf134bc878824c5cfb7fc1d7b2a6c802f2482dd7becf8f5cc46a473e3bd4e0"
  ]
}

Create an address in Electrum, check result for getaddressinfo in Core:

bitcoin-cli -rpcwallet="" getaddressinfo tb1qsp9g4v04yakgulv7ylz9t8g7m6cj46qff6k023
{
  "address": "tb1qsp9g4v04yakgulv7ylz9t8g7m6cj46qff6k023",
  "scriptPubKey": "0014804a8ab1f5276c8e7d9e27c4559d1edeb12ae809",
  "ismine": false,
  "solvable": false,
  "iswatchonly": false,
  "isscript": false,
  "iswitness": true,
  "witness_version": 0,
  "witness_program": "804a8ab1f5276c8e7d9e27c4559d1edeb12ae809",
  "ischange": false,
  "labels": [
  ],
  "use_txids": [
  ]
}

Send some bitcoin to this address from Core:

bitcoin-cli -rpcwallet="" sendtoaddress "tb1qsp9g4v04yakgulv7ylz9t8g7m6cj46qff6k023" 0.001
f9d09be836ca90951a5ce734598a5eb1fc56d2ed36a7d0c0c47a11dbd4a1e624

Check result for getaddressinfo:

bitcoin-cli -rpcwallet="" getaddressinfo tb1qsp9g4v04yakgulv7ylz9t8g7m6cj46qff6k023
{
  "address": "tb1qsp9g4v04yakgulv7ylz9t8g7m6cj46qff6k023",
  "scriptPubKey": "0014804a8ab1f5276c8e7d9e27c4559d1edeb12ae809",
  "ismine": false,
  "solvable": false,
  "iswatchonly": false,
  "isscript": false,
  "iswitness": true,
  "witness_version": 0,
  "witness_program": "804a8ab1f5276c8e7d9e27c4559d1edeb12ae809",
  "ischange": false,
  "labels": [
  ],
  "use_txids": [
    "f9d09be836ca90951a5ce734598a5eb1fc56d2ed36a7d0c0c47a11dbd4a1e624"
  ]
}

@luke-jr
Copy link
Member Author

luke-jr commented Feb 9, 2022

Rebased again

@luke-jr luke-jr force-pushed the getaddressinfo_txids branch 2 times, most recently from 03e8a66 to cd4e5dd Compare December 18, 2023 15:19
@DrahtBot DrahtBot requested review from rajarshimaitra and removed request for pk-b2 and rajarshimaitra December 18, 2023 15:19
@luke-jr luke-jr force-pushed the getaddressinfo_txids branch from cd4e5dd to 03e8a66 Compare December 18, 2023 15:19
@DrahtBot DrahtBot requested a review from pk-b2 December 18, 2023 15:19
@luke-jr luke-jr force-pushed the getaddressinfo_txids branch from 03e8a66 to a00bc6f Compare February 21, 2024 15:38
@luke-jr
Copy link
Member Author

luke-jr commented Feb 21, 2024

Rebased again

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

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

Approach ACK a00bc6f. There are a few small things I think need to be cleaned up but this seems like a good approach and a nice feature.

* Unlike other fields in address data struct, the used value is determined
* at runtime and not serialized as part of address data.
*/
bool m_used{false};
Copy link
Contributor

@ryanofsky ryanofsky Feb 23, 2024

Choose a reason for hiding this comment

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

In commit "Wallet: Keep track of what addresses are used in wallet transactions (memory only)" (fc7954a)

Would suggest moving this next to the previously_spent member below and naming it previously_received instead of m_used. Calling it "used" is ambiguous and confusing because at the walletdb level, "used" indicates whether funds sent to the address have previously been spent, not whether funds were sent to the address.

Other names for "previously_received" / "previously_spent" could work too of course, but "used" seems too ambiguous.

Comment on lines +170 to +171
// NOTE: We need to skip initialisation of the m_used flag, or else the address book count might be wrong
const std::shared_ptr<CWallet> wallet_instance = MakeWallet(name, path, options, CWallet::do_init_used_flag::Skip);
Copy link
Contributor

Choose a reason for hiding this comment

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

In commit "Wallet: Keep track of what addresses are used in wallet transactions (memory only)" (fc7954a)

This workaround is not really sufficient because it fixes the address book count for the wallet tool without fixing it for the bitcoind wallet:

walletInstance->WalletLogPrintf("m_address_book.size() = %u\n", walletInstance->m_address_book.size());


Ideally no workaround might be necessary if we could avoid adding extra entries to m_address_book (see #22693 (comment)). But assuming a workaround is necessary, it could be implemented more simply in both places with a new CAddressBookData method:

bool InAddressBook() const { return label || purpose || !receive_requests.empty(); } 

used with std::count_if instead of m_address_book.size() to return number of address book entries.

Copy link
Contributor

@ryanofsky ryanofsky Feb 23, 2024

Choose a reason for hiding this comment

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

re: #22693 (comment)

Don't think it's worth it to change this now just to revert it later.

Sure, I can see how knowing the output index would be useful. But in that case replacing the std::variant with just:

std::function<void(const CWalletTx&, uint32_t)>

would simplify this function a lot and not complicate the rpc much at all (would just add an unused parameter).

Retropex pushed a commit to Retropex/bitcoin that referenced this pull request Mar 28, 2024
Retropex pushed a commit to Retropex/bitcoin that referenced this pull request Mar 28, 2024
Retropex pushed a commit to Retropex/bitcoin that referenced this pull request Mar 28, 2024
@S3RK
Copy link
Contributor

S3RK commented Apr 11, 2024

I'm still not convinced about the approach of storing programmatically generated data in the address book, which is supposed to store user entered data.

For that reason I'm leaning Approach NACK.

@achow101
Copy link
Member

Approach NACK

The review I left last year outlines my concerns with this approach, and they have not been addressed in any way.

@achow101
Copy link
Member

This PR does not seem to have attracted much attention from reviewers. As such, it does not seem important enough right now to keep it sitting idle in the list of open PRs.

Closing due to lack of interest.

@achow101 achow101 closed this Oct 15, 2024
@bitcoin bitcoin locked and limited conversation to collaborators Oct 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.