Skip to content
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

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

Merged
merged 1 commit into from Jul 18, 2017

Conversation

TheBlueMatt
Copy link
Contributor

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.

@TheBlueMatt
Copy link
Contributor Author

TheBlueMatt commented Jul 10, 2017

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.

@TheBlueMatt TheBlueMatt force-pushed the 2017-07-keep-change branch 2 times, most recently from 8596787 to 6715e78 Compare July 10, 2017 18:36
@jonasschnelli
Copy link
Contributor

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 6715e782c3049ec43c0c94268f9ad924988e5ddf.
PR should have a short release-notes description.

@meshcollider
Copy link
Contributor

Concept ACK, seems extremely sensible

@TheBlueMatt
Copy link
Contributor Author

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 laanwj added this to the 0.15.0 milestone Jul 11, 2017
assert(changeaddress != "")
nextaddr = self.nodes[3].getnewaddress()
# Now the change address key should be removed from the keypool
assert(changeaddress != nextaddr)
Copy link
Member

Choose a reason for hiding this comment

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

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

@morcos
Copy link
Member

morcos commented Jul 12, 2017

Alex was here

@sipa
Copy link
Member

sipa commented Jul 13, 2017

Pieter was here.

@jonasschnelli
Copy link
Contributor

Jonas was here (though wants rebase).

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.
@TheBlueMatt
Copy link
Contributor Author

Rebased.

@TheBlueMatt TheBlueMatt mentioned this pull request Jul 18, 2017
12 tasks
@laanwj laanwj merged commit cf82a9e into bitcoin:master Jul 18, 2017
laanwj added a commit that referenced this pull request Jul 18, 2017
…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
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request May 3, 2019
Summary:
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.

Backport of Core PR 10784
bitcoin/bitcoin#10784

Completes T609

Test Plan:
make check
test_runner.py

Reviewers: deadalnix, Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc

Reviewed By: Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc

Differential Revision: https://reviews.bitcoinabc.org/D2846
jonspock pushed a commit to devaultcrypto/devault that referenced this pull request Jun 5, 2019
Summary:
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.

Backport of Core PR 10784
bitcoin/bitcoin#10784

Completes T609

Test Plan:
make check
test_runner.py

Reviewers: deadalnix, Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc

Reviewed By: Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc

Differential Revision: https://reviews.bitcoinabc.org/D2846
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Sep 8, 2019
…out reserving 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 bitcoin#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
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Sep 8, 2019
…out reserving 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 bitcoin#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
barrystyle pushed a commit to PACGlobalOfficial/PAC that referenced this pull request Jan 22, 2020
…out reserving 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 bitcoin#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
random-zebra added a commit to random-zebra/PIVX that referenced this pull request Mar 11, 2021
>>> Inspired by bitcoin#11864 (+bitcoin#10784)

Since CreateTransaction still needs cs_main we need to obtain both locks
in FundTransaction, to preserve locking order.

After introducing the chain interface (bitcoin#14437) we can change the
LOCK2(cs_main, cs_wallet) to just LOCK(cs_wallet)
random-zebra added a commit to random-zebra/PIVX that referenced this pull request Mar 12, 2021
>>> Inspired by bitcoin#11864 (+bitcoin#10784)

Since CreateTransaction still needs cs_main we need to obtain both locks
in FundTransaction, to preserve locking order.

After introducing the chain interface (bitcoin#14437) we can change the
LOCK2(cs_main, cs_wallet) to just LOCK(cs_wallet)
random-zebra added a commit to random-zebra/PIVX that referenced this pull request Mar 18, 2021
>>> Inspired by bitcoin#11864 (+bitcoin#10784)

Since CreateTransaction still needs cs_main we need to obtain both locks
in FundTransaction, to preserve locking order.

After introducing the chain interface (bitcoin#14437) we can change the
LOCK2(cs_main, cs_wallet) to just LOCK(cs_wallet)
random-zebra added a commit to random-zebra/PIVX that referenced this pull request Mar 22, 2021
>>> Inspired by bitcoin#11864 (+bitcoin#10784)

Since CreateTransaction still needs cs_main we need to obtain both locks
in FundTransaction, to preserve locking order.

After introducing the chain interface (bitcoin#14437) we can change the
LOCK2(cs_main, cs_wallet) to just LOCK(cs_wallet)
random-zebra added a commit to random-zebra/PIVX that referenced this pull request Mar 25, 2021
>>> Inspired by bitcoin#11864 (+bitcoin#10784)

Since CreateTransaction still needs cs_main we need to obtain both locks
in FundTransaction, to preserve locking order.

After introducing the chain interface (bitcoin#14437) we can change the
LOCK2(cs_main, cs_wallet) to just LOCK(cs_wallet)
random-zebra added a commit to random-zebra/PIVX that referenced this pull request Mar 25, 2021
>>> Inspired by bitcoin#11864 (+bitcoin#10784)

Since CreateTransaction still needs cs_main we need to obtain both locks
in FundTransaction, to preserve locking order.

After introducing the chain interface (bitcoin#14437) we can change the
LOCK2(cs_main, cs_wallet) to just LOCK(cs_wallet)
random-zebra added a commit to random-zebra/PIVX that referenced this pull request Mar 25, 2021
>>> Inspired by bitcoin#11864 (+bitcoin#10784)

Since CreateTransaction still needs cs_main we need to obtain both locks
in FundTransaction, to preserve locking order.

After introducing the chain interface (bitcoin#14437) we can change the
LOCK2(cs_main, cs_wallet) to just LOCK(cs_wallet)
random-zebra added a commit to random-zebra/PIVX that referenced this pull request Mar 25, 2021
>>> Inspired by bitcoin#11864 (+bitcoin#10784)

Since CreateTransaction still needs cs_main we need to obtain both locks
in FundTransaction, to preserve locking order.

After introducing the chain interface (bitcoin#14437) we can change the
LOCK2(cs_main, cs_wallet) to just LOCK(cs_wallet)
random-zebra added a commit to random-zebra/PIVX that referenced this pull request Mar 25, 2021
>>> Inspired by bitcoin#11864 (+bitcoin#10784)

Since CreateTransaction still needs cs_main we need to obtain both locks
in FundTransaction, to preserve locking order.

After introducing the chain interface (bitcoin#14437) we can change the
LOCK2(cs_main, cs_wallet) to just LOCK(cs_wallet)
random-zebra added a commit to random-zebra/PIVX that referenced this pull request Mar 26, 2021
>>> Inspired by bitcoin#11864 (+bitcoin#10784)

Since CreateTransaction still needs cs_main we need to obtain both locks
in FundTransaction, to preserve locking order.

After introducing the chain interface (bitcoin#14437) we can change the
LOCK2(cs_main, cs_wallet) to just LOCK(cs_wallet)
random-zebra added a commit to random-zebra/PIVX that referenced this pull request Mar 26, 2021
>>> Inspired by bitcoin#11864 (+bitcoin#10784)

Since CreateTransaction still needs cs_main we need to obtain both locks
in FundTransaction, to preserve locking order.

After introducing the chain interface (bitcoin#14437) we can change the
LOCK2(cs_main, cs_wallet) to just LOCK(cs_wallet)
random-zebra added a commit to random-zebra/PIVX that referenced this pull request Mar 31, 2021
>>> Inspired by bitcoin#11864 (+bitcoin#10784)

Since CreateTransaction still needs cs_main we need to obtain both locks
in FundTransaction, to preserve locking order.

After introducing the chain interface (bitcoin#14437) we can change the
LOCK2(cs_main, cs_wallet) to just LOCK(cs_wallet)
random-zebra added a commit to random-zebra/PIVX that referenced this pull request Mar 31, 2021
>>> Inspired by bitcoin#11864 (+bitcoin#10784)

Since CreateTransaction still needs cs_main we need to obtain both locks
in FundTransaction, to preserve locking order.

After introducing the chain interface (bitcoin#14437) we can change the
LOCK2(cs_main, cs_wallet) to just LOCK(cs_wallet)
random-zebra added a commit to random-zebra/PIVX that referenced this pull request Apr 5, 2021
>>> Inspired by bitcoin#11864 (+bitcoin#10784)

Since CreateTransaction still needs cs_main we need to obtain both locks
in FundTransaction, to preserve locking order.

After introducing the chain interface (bitcoin#14437) we can change the
LOCK2(cs_main, cs_wallet) to just LOCK(cs_wallet)
random-zebra added a commit to random-zebra/PIVX that referenced this pull request Apr 6, 2021
>>> Inspired by bitcoin#11864 (+bitcoin#10784)

Since CreateTransaction still needs cs_main we need to obtain both locks
in FundTransaction, to preserve locking order.

After introducing the chain interface (bitcoin#14437) we can change the
LOCK2(cs_main, cs_wallet) to just LOCK(cs_wallet)
random-zebra added a commit to random-zebra/PIVX that referenced this pull request Apr 7, 2021
>>> Inspired by bitcoin#11864 (+bitcoin#10784)

Since CreateTransaction still needs cs_main we need to obtain both locks
in FundTransaction, to preserve locking order.

After introducing the chain interface (bitcoin#14437) we can change the
LOCK2(cs_main, cs_wallet) to just LOCK(cs_wallet)
@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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants