Do not allow users to get keys from keypool without reserving them #10784

Merged
merged 1 commit into from Jul 18, 2017

Conversation

Projects
None yet
6 participants
Contributor

TheBlueMatt commented Jul 10, 2017

fundrawtransaction allows users to add a change output and then
not have it removed from keypool. While it would be nice to have
users follow the normal CreateTransaction/CommitTransaction process
we use internally, there isnt much benefit in exposing this option,
especially with HD wallets, while there is ample room for users to
misunderstand or misuse this option.

This partially reverts #9377. Would be nice to get this for 15 since its kinda crazy we have this option to begin with IMO, will need release notes as an RPC option is now ignored.

Contributor

TheBlueMatt commented Jul 10, 2017 edited

This could be particularly nasty in some use-cases (especially pre-HD-split) - eg a user might fundrawtransaction, then call getnewaddress, hand out the address for someone to pay them, then sendrawtransaction. This may result in the user thinking they have been paid by their counterparty, even though it was really just their change!

This could obviously also result in needless keyreuse.

Member

jonasschnelli commented Jul 11, 2017

History of fundrawtransaction regarding change-output:
Before 0.14, the change-output keys was never reserved from the key pool (flaw-ish).
Since 0.14, by default, the key will be reserved but there is an option to not reserve it (keep the old behaviour) done via #9377. The option was added because the assumption was that API consumers relay on this old, flaw-ish, behaviour.

This PR would basically remove the option to not reserve the key.

I think in general we should do that, though I'm not sure if there are any API consumers who expect that one can avoid reserving the CO-key. But indeed, that should stop.

Concept ACK 6715e78.
PR should have a short release-notes description.

Concept ACK, seems extremely sensible

Contributor

TheBlueMatt commented Jul 11, 2017

Would be nice to get an 0.15 tag on this - I think its quite a serious API flaw (which I commented positively on on #9377 :(. Indeed, will need release notes, but I'll leave that for #9889.

laanwj added this to the 0.15.0 milestone Jul 11, 2017

test/functional/fundrawtransaction.py
- assert(changeaddress != "")
- nextaddr = self.nodes[3].getnewaddress()
- # Now the change address key should be removed from the keypool
- assert(changeaddress != nextaddr)
@morcos

morcos Jul 12, 2017

Contributor

You should keep the bottom half of this test to show we're not getting address reuse

Contributor

morcos commented Jul 12, 2017

Alex was here

fanquake deleted a comment from MIGUELWAXX Jul 12, 2017

Owner

sipa commented Jul 13, 2017

Pieter was here.

Member

jonasschnelli commented Jul 18, 2017

Jonas was here (though wants rebase).

@TheBlueMatt TheBlueMatt Do not allow users to get keys from keypool without reserving them
fundrawtransaction allows users to add a change output and then
not have it removed from keypool. While it would be nice to have
users follow the normal CreateTransaction/CommitTransaction process
we use internally, there isnt much benefit in exposing this option,
especially with HD wallets, while there is ample room for users to
misunderstand or misuse this option.

This could be particularly nasty in some use-cases (especially
pre-HD-split) - eg a user might fundrawtransaction, then call
getnewaddress, hand out the address for someone to pay them, then
sendrawtransaction. This may result in the user thinking they have
received payment, even though it was really just their own change!

This could obviously result in needless key-reuse.
cf82a9e
Contributor

TheBlueMatt commented Jul 18, 2017

Rebased.

TheBlueMatt referenced this pull request Jul 18, 2017

Open

TODO for release notes 0.15.0 #9889

0 of 10 tasks complete

@laanwj laanwj merged commit cf82a9e into bitcoin:master Jul 18, 2017

1 check was pending

continuous-integration/travis-ci/pr The Travis CI build is in progress
Details

@laanwj laanwj added a commit that referenced this pull request Jul 18, 2017

@laanwj laanwj Merge #10784: Do not allow users to get keys from keypool without res…
…erving them


cf82a9e Do not allow users to get keys from keypool without reserving them (Matt Corallo)

Pull request description:

  fundrawtransaction allows users to add a change output and then
  not have it removed from keypool. While it would be nice to have
  users follow the normal CreateTransaction/CommitTransaction process
  we use internally, there isnt much benefit in exposing this option,
  especially with HD wallets, while there is ample room for users to
  misunderstand or misuse this option.

  This partially reverts #9377. Would be nice to get this for 15 since its kinda crazy we have this option to begin with IMO, will need release notes as an RPC option is now ignored.

Tree-SHA512: 72b5ee9c4a229b84d799dfb00c56fe80d8bba914ce81a433c3f5ab325bf9bf2b839ee658c261734f0ee183ab19435039481014d09c41dbe155e6323e63beb01d
9e8d6a3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment