Skip to content

Conversation

@achow101
Copy link
Member

@achow101 achow101 commented Jun 18, 2019

The wallet should give out destinations instead of keys. It should be the one that handles the conversion from key to destination and the setting of the label, not the caller. In order to do this, two new member functions are introduced GetNewDestination() and GetNewChangeDestination(). Additionally, CReserveKey is changed to be ReserveDestination and represents destinations whose keys can be returned to the keypool.

@DrahtBot
Copy link
Contributor

DrahtBot commented Jun 18, 2019

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #16361 (Remove redundant pre-TopUpKeypool checks by instagibbs)
  • #16341 (WIP: Introduce ScriptPubKeyMan interface and use it for key and script management (aka wallet boxes) by achow101)
  • #16208 (wallet: Consume CReserveKey on successful CreateTransaction by instagibbs)
  • #14582 (wallet: try -avoidpartialspends mode and use its result if fees do not change by kallewoof)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

Copy link
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

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

Concept ACK

You have a typo in commit 7d014e492cdcca847cc0e46f0457b1bc89831f90 message.

Copy link
Contributor

Choose a reason for hiding this comment

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

2010b1a13e6b7eaa681cc62ae58079ccbec72816

This should be atomic or add EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) annotation?

Also, could make GetKeyFromPool private?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done. Also fixed typo

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

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

Concept ACK. Will review more closely, but this seems like a nice, straightforward change.

@achow101 achow101 force-pushed the cwallet-getnewaddr branch from 7d014e4 to 835ae12 Compare June 20, 2019 16:14
Copy link
Member

Choose a reason for hiding this comment

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

interfaces/wallet.cpp:146:16: error: calling function 'GetNewAddress' requires holding mutex 'm_wallet->cs_wallet' exclusively [-Werror,-Wthread-safety-analysis]

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

@achow101 achow101 force-pushed the cwallet-getnewaddr branch from 835ae12 to 89df834 Compare June 20, 2019 17:22
Copy link
Member

Choose a reason for hiding this comment

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

nit: the message is translated here, but not in the new occurences. As this looks like a message that will be returned over the RPC interface (referring to a RPC command, at least). Maybe better to not translate it here either?

Copy link
Member Author

Choose a reason for hiding this comment

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

I've made it untranslated.

@laanwj
Copy link
Member

laanwj commented Jun 27, 2019

Concept ACK
(my remark was going to be that the wallet should return Destinations, not addresses, but that's exactly that this does)

@Sjors
Copy link
Member

Sjors commented Jul 9, 2019

Concept ACK.

In line with @laanwj's comment, maybe rename GetNew(Change)Address to GetNew(Change)Destination, and ReserveAddress to ReserveDestination.

GetReservedAddress is still used in two places; maybe kill it in this PR?

Travis seems unhappy about a locking issue. On macOS I also get some warnings:
Schermafbeelding 2019-07-09 om 16 19 25

@achow101 achow101 force-pushed the cwallet-getnewaddr branch 2 times, most recently from 47a7c3f to 5b771f3 Compare July 9, 2019 18:42
@achow101
Copy link
Member Author

achow101 commented Jul 9, 2019

In line with @laanwj's comment, maybe rename GetNew(Change)Address to GetNew(Change)Destination, and ReserveAddress to ReserveDestination.

I've renamed it.

GetReservedAddress is still used in two places; maybe kill it in this PR?

It is?

Travis seems unhappy about a locking issue. On macOS I also get some warnings:

Should be fixed now.

@achow101 achow101 force-pushed the cwallet-getnewaddr branch from 5b771f3 to 3a58f6d Compare July 9, 2019 18:46
Copy link
Member

@instagibbs instagibbs left a comment

Choose a reason for hiding this comment

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

concept ACK

@achow101 achow101 force-pushed the cwallet-getnewaddr branch from 3a58f6d to c84cbd5 Compare July 9, 2019 20:34
@achow101 achow101 changed the title Have the wallet give out addresses instead of keys Have the wallet give out destinations instead of keys Jul 9, 2019
@instagibbs
Copy link
Member

utACK c84cbd5

achow101 added 3 commits July 9, 2019 16:43
Instead of having the same multiple lines of code everywhere
that new destinations are fetched, introduce GetNewDestination as
a member function of CWallet which does the key fetching, label
setting, script generation, and destination generation.
Instead of reserving keys, reserve destinations which are backed by keys
Adds a GetNewChangeDestination that has the same objective as GetNewDestination
@achow101 achow101 force-pushed the cwallet-getnewaddr branch from c84cbd5 to 8e7f930 Compare July 9, 2019 20:43
@instagibbs
Copy link
Member

re-utACK 8e7f930

only changes are clearing error messages at beginning of GetNew*

@sipa
Copy link
Member

sipa commented Jul 9, 2019

ACK 8e7f930. Concept ACK as this gives a much cleaner abstraction to work with, and light code review ACK.

It's bit confusing that constructing a (filled) ReserveDestination does not actually require a destination type, preventing the interface from being able to select where to draw change from based on the address type desired. Perhaps something for a follow-up?

@laanwj
Copy link
Member

laanwj commented Jul 10, 2019

ACK 8e7f930

@laanwj laanwj merged commit 8e7f930 into bitcoin:master Jul 10, 2019
laanwj added a commit that referenced this pull request Jul 10, 2019
8e7f930 Add GetNewChangeDestination for getting new change Destinations (Andrew Chow)
33d13ed Replace CReserveKey with ReserveDestinatoin (Andrew Chow)
172213b Add GetNewDestination to CWallet to fetch new destinations (Andrew Chow)

Pull request description:

  The wallet should give out destinations instead of keys. It should be the one that handles the conversion from key to destination and the setting of the label, not the caller. In order to do this, two new member functions are introduced `GetNewDestination()` and `GetNewChangeDestination()`. Additionally, `CReserveKey` is changed to be `ReserveDestination` and represents destinations whose keys can be returned to the keypool.

ACKs for top commit:
  instagibbs:
    re-utACK 8e7f930
  sipa:
    ACK 8e7f930. Concept ACK as this gives a much cleaner abstraction to work with, and light code review ACK.
  laanwj:
    ACK 8e7f930

Tree-SHA512: 5be7051409232b71e0ef2c1fd1a3e76964ed2f5b14d47d06edc2ad3b3687abd0be2803a1adc45c0433aa2c3bed172e14f8a7e9f4a23bff70f86260b5a0497500
@Sjors
Copy link
Member

Sjors commented Jul 10, 2019

The macOS warnings I saw before are indeed gone now.

sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Jul 10, 2019
… keys

8e7f930 Add GetNewChangeDestination for getting new change Destinations (Andrew Chow)
33d13ed Replace CReserveKey with ReserveDestinatoin (Andrew Chow)
172213b Add GetNewDestination to CWallet to fetch new destinations (Andrew Chow)

Pull request description:

  The wallet should give out destinations instead of keys. It should be the one that handles the conversion from key to destination and the setting of the label, not the caller. In order to do this, two new member functions are introduced `GetNewDestination()` and `GetNewChangeDestination()`. Additionally, `CReserveKey` is changed to be `ReserveDestination` and represents destinations whose keys can be returned to the keypool.

ACKs for top commit:
  instagibbs:
    re-utACK bitcoin@8e7f930
  sipa:
    ACK 8e7f930. Concept ACK as this gives a much cleaner abstraction to work with, and light code review ACK.
  laanwj:
    ACK 8e7f930

Tree-SHA512: 5be7051409232b71e0ef2c1fd1a3e76964ed2f5b14d47d06edc2ad3b3687abd0be2803a1adc45c0433aa2c3bed172e14f8a7e9f4a23bff70f86260b5a0497500
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Jul 1, 2020
…stinations

Summary:
Instead of having the same multiple lines of code everywhere
that new destinations are fetched, introduce GetNewDestination as
a member function of CWallet which does the key fetching, label
setting, script generation, and destination generation.

bitcoin/bitcoin@172213b

---

Depends on D6714

Partial backport of Core [[bitcoin/bitcoin#16237 | PR16237]]

Test Plan:
  ninja check-all

Reviewers: #bitcoin_abc, jasonbcox, deadalnix

Reviewed By: #bitcoin_abc, jasonbcox, deadalnix

Subscribers: deadalnix, jasonbcox

Differential Revision: https://reviews.bitcoinabc.org/D6716
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Jul 1, 2020
Summary:
Instead of reserving keys, reserve destinations which are backed by keys

bitcoin/bitcoin@33d13ed

---

Depends on D6716

Partial backport of Core [[bitcoin/bitcoin#16237 | PR16237]]

Test Plan:
  ninja check-all

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D6717
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Jul 1, 2020
…ge Destinations

Summary:
Adds a GetNewChangeDestination that has the same objective as GetNewDestination

bitcoin/bitcoin@8e7f930

---

Depends on D6717

Concludes backport of Core [[bitcoin/bitcoin#16237 | PR16237]]

Test Plan:
  ninja check-all

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D6721
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 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.

10 participants