Skip to content

Conversation

@dooglus
Copy link
Contributor

@dooglus dooglus commented Aug 28, 2017

... so it recogizes SegWit change addresses.

Fixes #11137.

Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

Move { to this line.

Copy link
Contributor

Choose a reason for hiding this comment

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

const CTxDestination& dest.

Copy link
Contributor Author

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)?

Copy link
Member

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)

Copy link
Contributor

Choose a reason for hiding this comment

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

Sort include.

Copy link
Contributor

Choose a reason for hiding this comment

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

const CTxDestination& dest.

Copy link
Contributor

@promag promag Aug 28, 2017

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

Copy link
Contributor Author

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.

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.

utACK 89daeb84915d7fd21230771ed266dde1f7d7afda

Copy link
Member

Choose a reason for hiding this comment

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

function names are PascalCase.

Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor Author

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.

Copy link
Member

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.

@promag
Copy link
Contributor

promag commented Aug 29, 2017

BTW, squash and reword, commit message is too long.

@dooglus dooglus force-pushed the change_ismine_0.15 branch 2 times, most recently from 434c2cf to b49064c Compare August 29, 2017 00:17
@dooglus
Copy link
Contributor Author

dooglus commented Aug 29, 2017

Addressed @MarcoFalke's nit re. masking out ISMINE_SPENDABLE.

Squashed.

Reworded commit message.

@promag
Copy link
Contributor

promag commented Aug 29, 2017

Thanks @dooglus but could you remove period. Suggestion Use IsMine to validate custom change address. Update PR title accordingly.

Copy link
Member

Choose a reason for hiding this comment

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

The bool(..) is unnecessary.

@dooglus dooglus force-pushed the change_ismine_0.15 branch from b49064c to cc827dd Compare August 29, 2017 00:37
@dooglus
Copy link
Contributor Author

dooglus commented Aug 29, 2017

Removed period from commit message

Removed bool

Squashed again

@dooglus dooglus force-pushed the change_ismine_0.15 branch from cc827dd to bddab7f Compare August 29, 2017 00:39
@dooglus
Copy link
Contributor Author

dooglus commented Aug 29, 2017

Replaced commit message with @promag's suggested one

@dooglus dooglus force-pushed the change_ismine_0.15 branch from bddab7f to 1143d1e Compare August 29, 2017 00:42
@dooglus
Copy link
Contributor Author

dooglus commented Aug 29, 2017

It appears that calling the function IsMine instead of isMine caused an error:

  CXX      qt/qt_libbitcoinqt_a-walletmodeltransaction.o
qt/walletmodel.cpp:566:12: error: too many arguments to function call, expected 1, have 2; did you mean '::IsMine'?
    return IsMine(*wallet, dest);
           ^~~~~~
           ::IsMine
./script/ismine.h:39:12: note: '::IsMine' declared here
isminetype IsMine(const CKeyStore& keystore, const CTxDestination& dest, SigVersion = SIGVERSION_BASE);
           ^

I'll call it 'IsSpendable()` instead.

@maflcko
Copy link
Member

maflcko commented Aug 29, 2017

utACK 848ef973d7ecb054e0d6d6952fd69a0816f3b7cd

@promag
Copy link
Contributor

promag commented Aug 29, 2017

@dooglus i believe you only had to call like ::IsMine(). Either way please update PR title too, and elaborate more about the motivation in the description. Ty.

@meshcollider
Copy link
Contributor

@promag title is still correct I believe, because it still uses IsMine() to check

@promag
Copy link
Contributor

promag commented Aug 29, 2017

@meshcollider it's too long 🙄.

@dooglus dooglus changed the title Use IsMine() to check whether we own the custom change address... Use IsMine to validate custom change address Aug 29, 2017
@dooglus
Copy link
Contributor Author

dooglus commented Aug 29, 2017

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.

@sipa
Copy link
Member

sipa commented Aug 29, 2017

Should change to a watch-only address be permitted?

@dooglus
Copy link
Contributor Author

dooglus commented Aug 29, 2017

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.

@promag
Copy link
Contributor

promag commented Aug 29, 2017

should change to a watch-only address be permitted?

@sipa follow up discussion? For now ISMINE_SPENDABLE is clear and does prevents possible problems that ISMINE_WATCH_ONLY could have.

Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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.

@jonasschnelli
Copy link
Contributor

utACK 848ef973d7ecb054e0d6d6952fd69a0816f3b7cd

@dooglus dooglus force-pushed the change_ismine_0.15 branch from 848ef97 to c41224d Compare August 30, 2017 07:43
@meshcollider
Copy link
Contributor

utACK c41224d

@promag
Copy link
Contributor

promag commented Sep 4, 2017

utACK c41224d.

@practicalswift
Copy link
Contributor

practicalswift commented Sep 4, 2017

Concept ACK! Solves also the issue discussed in my PR #10972 which I've now closed.

@laanwj laanwj added this to the 0.15.1 milestone Sep 5, 2017
@laanwj laanwj merged commit c41224d into bitcoin:0.15 Sep 5, 2017
@maflcko maflcko removed this from the 0.15.1 milestone Sep 5, 2017
@laanwj
Copy link
Member

laanwj commented Sep 5, 2017

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.
We need a new PR for master.

maflcko pushed a commit that referenced this pull request Sep 5, 2017
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
codablock pushed a commit to codablock/dash that referenced this pull request Sep 25, 2019
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
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants