-
Notifications
You must be signed in to change notification settings - Fork 38.7k
rpcwallet: 'ischange' field for 'getaddressinfo' RPC #14410
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
5175317 to
c2f4b33
Compare
|
Not sure about this.. What is the rationale? Also, could test the new field. |
|
concept ACK, needs test. @promag Why not? It's useful to probe the state of the wallet, especially when using things like |
promag
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.
@instagibbs because it can be misleading? Especially if you fundrawtransaction with explicit changeAddress
especially when using things like importmulti where this can be set.
I'm not following, can you explain?
src/wallet/rpcwallet.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.
Reading this looks like the address can be reused. Suggestion If the address was used for change output?
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.
Thanks for the suggestion. Fixed that.
|
c2f4b33 to
ee014ae
Compare
src/wallet/wallet.h
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.
Please make the parameter naming between those two consistent:
bool CWallet::IsChange(const CScript& script) const { … }
bool IsChange(const CScript& dest) const;
Make both script or both dest :-)
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.
Done.
ee014ae to
70e9899
Compare
|
I'm not sure it needs a dedicated test, so I added testing of |
promag
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.
Agree that there's no need for a dedicated test.
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.
nit,
for address in output_addresses
assert_equal(self.nodes[node_sender].getaddressinfo(address)['ischange'], address not in destinations)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.
Done, with some changes though:)
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.
Maybe this does not belong here — test_change_output_type? Maybe somewhere in wallet_basic.py?
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.
Moved it to wallet_basic.py with some additional code to ensure transaction with change.
1aa8b91 to
9298081
Compare
|
utACK 9298081df8a9b538cf5b572fd99f7063a67dae76 No reason why this can't be exposed. |
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.
Could test that setting a label for a change address sets ischange to false. This is the test change:
@@ -497,7 +497,12 @@ class WalletTest(BitcoinTestFramework):
output_addresses = [vout['scriptPubKey']['addresses'][0] for vout in tx["vout"]]
assert len(output_addresses) > 1
for address in output_addresses:
- assert_equal(self.nodes[0].getaddressinfo(address)['ischange'], address != destination)
+ ischange = self.nodes[0].getaddressinfo(address)['ischange']
+ assert_equal(ischange, address != destination)
+ if ischange: change = address
+ self.nodes[0].setlabel(change, 'foobar')
+ assert_equal(self.nodes[0].getaddressinfo(change)['ischange'], False)
if __name__ == '__main__':
WalletTest().main()Also could add a small release note? Maybe in doc/release-notes-14282.md?
Tested ACK 9298081.
9298081 to
9a7ccca
Compare
|
@promag done and done (amended release node into first commit and test fix into second one). Let me know if release note is ok. |
9a7ccca to
14a0652
Compare
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsNo conflicts as of last run. |
|
utACK 14a0652. |
|
utACK 14a0652 |
14a0652 tests: add test for 'getaddressinfo' RPC result 'ischange' field (whythat) 93d1aa9 rpcwallet: add 'ischange' field to 'getaddressinfo' response (whythat) Pull request description: Implementation of proposal in #14396. This introduces `CWallet::IsChange(CScript&)` method and replaces original `CWallet::IsChange(CTxOut&)` method with overloaded version that delegates to the new method with *txout*'s `scriptPubKey`. In this way `TODO` note from the original method can still be addressed in a single place. Tree-SHA512: ef5dbc82d76b4b9b2fa6a70abc3385a677c55021f79e187ee2f392ee32bc6b406191f4129acae5c17b0206e72b6712e7e0cad574a4bbd966871c2e656c45e041
Implementation of proposal in #14396.
This introduces
CWallet::IsChange(CScript&)method and replaces originalCWallet::IsChange(CTxOut&)method with overloaded version that delegates to the new method with txout'sscriptPubKey. In this wayTODOnote from the original method can still be addressed in a single place.