-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Use IsMine to validate custom change address #11184
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
src/qt/sendcoinsdialog.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.
IMO remove the comment, the code is more expressive.
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.
Move { to this line.
src/qt/walletmodel.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.
const CTxDestination& 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.
Where can I find guidelines about where to put the whitespace? I went with the existing layout. See how the line I replaced had (const CKeyID &address)?
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.
This is mentioned in the developer notes. Though, you could always just run clang format (also mentioned in the developer notes)
src/qt/walletmodel.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.
Sort include.
src/qt/walletmodel.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.
const CTxDestination& 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.
For the record, another option, that doesn't require to include in this header script/ismine.h, is bool isSpendable(const CKeyID& address).
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.
I don't see bool isSpendable(const CKeyID& address) anywhere. And the point is that we want to be able to check the spendability of general addresses, not only CKeyIDs.
maflcko
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.
utACK 89daeb84915d7fd21230771ed266dde1f7d7afda
src/qt/walletmodel.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.
function names are PascalCase.
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.
Check src/qt/walletmodel.h - they're all lowerThenUpper
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.
Yes but it's 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.
So what's the plan? Shouldn't we go through the code fixing all the outdated style at once rather than fixing one at a time?
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.
I mean, I can change just the one I touched if that's preferable.
src/qt/sendcoinsdialog.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.
if you feel like it, you might add a const CTxDestination dest = addr.Get(); before that line and then use if (!bool(model->IsMine(dest) & ISMINE_SPENDABLE)).
Though, it shouldn't make a difference.
|
BTW, squash and reword, commit message is too long. |
434c2cf to
b49064c
Compare
|
Addressed @MarcoFalke's nit re. masking out ISMINE_SPENDABLE. Squashed. Reworded commit message. |
|
Thanks @dooglus but could you remove period. Suggestion |
src/qt/sendcoinsdialog.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.
The bool(..) is unnecessary.
b49064c to
cc827dd
Compare
|
Removed period from commit message Removed Squashed again |
cc827dd to
bddab7f
Compare
|
Replaced commit message with @promag's suggested one |
bddab7f to
1143d1e
Compare
|
It appears that calling the function I'll call it 'IsSpendable()` instead. |
1143d1e to
848ef97
Compare
|
utACK 848ef973d7ecb054e0d6d6952fd69a0816f3b7cd |
|
@dooglus i believe you only had to call like |
|
@promag title is still correct I believe, because it still uses IsMine() to check |
|
@meshcollider it's too long 🙄. |
|
I finally understood what you meant about IsSpendable(), so did it that way. IsSpendable() calls IsMine(), so the commit log is correct. I've used the same string for the PR title. |
|
Should change to a watch-only address be permitted? |
|
Change to any address is permitted. The warning is for if you do not have control of the address. I'd like to see a warning if I accidentally try to send change to a watchonly address. Because maybe I accidentally copied the wrong address and am about to lose my coins. |
@sipa follow up discussion? For now |
src/qt/sendcoinsdialog.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.
Wouldn't if (!model->IsSpendable(addr.Get())) { be simpler?
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.
Yes it would, and that's how I had it until @MarcoFalke made this comment.
Is there a style guide that tells me how such things should be? Lots of people seem to have ideas about what's right, but I'd like to see something in writing, as it were.
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.
dest can be used in a few places below, but as I mentioned above this is just personal preference for one style over another. Just use what you feel makes more sense, no need to discuss.
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.
Good point. I use it in the few places below now too.
|
utACK 848ef973d7ecb054e0d6d6952fd69a0816f3b7cd |
848ef97 to
c41224d
Compare
|
utACK c41224d |
|
utACK c41224d. |
|
Concept ACK! Solves also the issue discussed in my PR #10972 which I've now closed. |
|
Ouch, did no one notice that this was filed against 0.15? Had to revert it, because otherwise it would mess up the release process for 0.15.0. |
a1ea1cf qt: Use IsMine to validate custom change address (Chris Moore) Pull request description: Fixes #11137 Closes #11184 (which was accidentally opened against 0.15 branch) Tree-SHA512: a20a59b4f36c1471a9c84bcc7c69048576d1f413104c299a7ed9ba221f28eddf93d727fca2926420ea5d0dd9aba582924f26a5acd44d995039b7202c73eb53bc
a1ea1cf qt: Use IsMine to validate custom change address (Chris Moore) Pull request description: Fixes bitcoin#11137 Closes bitcoin#11184 (which was accidentally opened against 0.15 branch) Tree-SHA512: a20a59b4f36c1471a9c84bcc7c69048576d1f413104c299a7ed9ba221f28eddf93d727fca2926420ea5d0dd9aba582924f26a5acd44d995039b7202c73eb53bc
... so it recogizes SegWit change addresses.
Fixes #11137.