-
Notifications
You must be signed in to change notification settings - Fork 38.6k
RPC/Wallet: Add "use_txids" to output of getaddressinfo #22693
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
Conversation
|
Concept ACK |
bcec6dc to
160d61c
Compare
160d61c to
9fe7926
Compare
|
Concept ACK |
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code CoverageFor detailed information about the code coverage, see the test coverage report. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsReviewers, 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. |
rajarshimaitra
left a comment
There was a problem hiding this 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.
f954a0d to
c6e5a3b
Compare
|
Rebased |
|
Concept ACK |
ghost
left a comment
There was a problem hiding this 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"
]
}
c6e5a3b to
8719b08
Compare
|
Rebased again |
03e8a66 to
cd4e5dd
Compare
cd4e5dd to
03e8a66
Compare
03e8a66 to
a00bc6f
Compare
|
Rebased again |
ryanofsky
left a comment
There was a problem hiding this 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}; |
There was a problem hiding this comment.
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.
| // 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); |
There was a problem hiding this comment.
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:
Line 3171 in 1ac627c
| 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.
src/wallet/wallet.cpp
Outdated
There was a problem hiding this comment.
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).
…(memory only) Github-Pull: bitcoin#22693 Rebased-From: fc7954a
…known to be used Github-Pull: bitcoin#22693 Rebased-From: 022887d
Github-Pull: bitcoin#22693 Rebased-From: a00bc6f
|
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. |
|
Approach NACK The review I left last year outlines my concerns with this approach, and they have not been addressed in any way. |
|
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. |
(Non-GUI part of bitcoin-core/gui#562, but without the bloom stuff)