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

Import key origin data through descriptors in importmulti #14021

Merged
merged 9 commits into from Feb 14, 2019

Conversation

@achow101
Copy link
Member

@achow101 achow101 commented Aug 22, 2018

This PR allows for key origin data as defined by the descriptors document to be imported to the wallet when importing a descriptor using importmulti. This allows the walletprocesspsbt to include the BIP 32 derivation paths for keys that it is watching that are from a different HD wallet.

In order to make this easier to use, a new field hdmasterkeyfingerprint has been added to getaddressinfo. Additionally I have removed hdmasterkeyid as was planned. I think that this API change is fine since it was going to be removed in 0.18 anyways. CKeyMetadata has also been extended to store key origin info to facilitate this.

@instagibbs
Copy link
Member

@instagibbs instagibbs commented Aug 22, 2018

Nice! strong concept ACK

@achow101
Copy link
Member Author

@achow101 achow101 commented Aug 25, 2018

Fixed a bug where the keymetadata wasn't being written to the wallet file. Also added a test for that case.

@achow101
Copy link
Member Author

@achow101 achow101 commented Aug 28, 2018

Rebased and also changed the keymeta stuff to add the hd master key id at key generation and when the wallet is first loaded.

@@ -560,6 +560,14 @@ bool ParseHDKeypath(const std::string& keypath_str, std::vector<uint32_t>& keypa
// Finds whether it is hardened
uint32_t path = 0;
size_t pos = item.find("'");
if (pos == std::string::npos) {
// Look for h
Copy link
Member

@luke-jr luke-jr Aug 29, 2018

Why?

Copy link
Member

@instagibbs instagibbs Aug 29, 2018

why not? This is quite standard.

Copy link
Member Author

@achow101 achow101 Aug 29, 2018

It's fairly standard to use h or H as the indicator, not just '. In fact, the BIP uses H, but as a subscript. ' is not actually used as the indicator for hardened in the BIP even though that is what everyone uses.

The main reason for allowing this is so that you don't have to do any annoying escaping stuff for the ' when entering the keypaths on the command line.

@achow101
Copy link
Member Author

@achow101 achow101 commented Sep 4, 2018

Rebased

@laanwj
Copy link
Member

@laanwj laanwj commented Sep 13, 2018

Concept ACK, thanks for working on this

achow101 added 5 commits Feb 14, 2019
Store the master key fingerprint and derivation path in the
key metadata. hdKeypath is kept to indicate the seed and for
backwards compatibility, but all key derivation path output
uses the key origin info instead of hdKeypath.
@achow101 achow101 force-pushed the import-multi-hd branch from 1b1c6aa to cb3511b Feb 14, 2019
@meshcollider
Copy link
Member

@meshcollider meshcollider commented Feb 14, 2019

Changes since @sipa's are just nit-fixes, a new test, and a missing brace bugfix 👍

@meshcollider meshcollider merged commit cb3511b into bitcoin:master Feb 14, 2019
0 of 2 checks passed
meshcollider added a commit that referenced this issue Feb 14, 2019
cb3511b Add release notes for importing key origin info change (Andrew Chow)
4c75a69 Test importing descriptors with key origin information (Andrew Chow)
02d6586 Import KeyOriginData when importing descriptors (Andrew Chow)
3d235df Implement a function to add KeyOriginInfo to a wallet (Andrew Chow)
eab63bc Store key origin info in key metadata (Andrew Chow)
345bff6 Remove hdmasterkeyid (Andrew Chow)
bac8c67 Add a method to CWallet to write just CKeyMetadata (Andrew Chow)
e7652d3 Add WriteHDKeypath function and move *HDKeypath to util/bip32.{h,cpp} (Andrew Chow)
c45415f Refactor keymetadata writing to a separate method (Andrew Chow)

Pull request description:

  This PR allows for key origin data as defined by the descriptors document to be imported to the wallet when importing a descriptor using `importmulti`. This allows the `walletprocesspsbt` to include the BIP 32 derivation paths for keys that it is watching that are from a different HD wallet.

  In order to make this easier to use, a new field `hdmasterkeyfingerprint` has been added to `getaddressinfo`. Additionally I have removed `hdmasterkeyid` as was planned. I think that this API change is fine since it was going to be removed in 0.18 anyways. `CKeyMetadata` has also been extended to store key origin info to facilitate this.

Tree-SHA512: 9c7794f3c793da57e23c5abbdc3d58779ee9dea3d53168bb86c0643a4ad5a11a446264961e2f772f35eea645048cb60954ed58050002caee4e43cd9f51215097
@meshcollider meshcollider removed this from Blockers in High-priority for review Feb 14, 2019
meshcollider added a commit to meshcollider/bitcoin that referenced this issue Feb 18, 2019
0bedcba Use a single wallet batch for UpgradeKeyMetadata (Jonas Schnelli)

Pull request description:

  Opening wallets (the first time) after bitcoin#14021 took on my end around 30 seconds due to the keymetadata migration (tested on regtest).

  Using a single wallet batch reduces the required time for the migration down to <1s on my system for a default 2k keypool wallet.

Tree-SHA512: f68739e452d382f5294186f47511b94884a1a0868688dd3179034a7e091a67f93bc9dd45cdfc9fa6b1fe90362772b719278012f2f56b752b803c87db8597a7b0
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this issue May 22, 2020
Summary:
Partial backport of Core [[bitcoin/bitcoin#14021 | PR14021]]
bitcoin/bitcoin@c45415f

Test Plan:
  ninja
  ninja check
  ninja check-functional

Reviewers: O1 Bitcoin ABC, #bitcoin_abc, Fabien

Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D6004
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this issue May 22, 2020
Summary:
Creates new files util/bip32.h and util/bip32.cpp for containing
BIP 32 stuff.
Moves FormatKeyPath from descriptor.cpp to util/bip32.
Adds a wrapper around it to prepent the 'm' for when just the
BIP 32 style keypath is needed.

Partial backport of Core [[bitcoin/bitcoin#14021 | PR14021]]
bitcoin/bitcoin@e7652d3

Depends on D6004

Test Plan:
  ../configure --enable-deprecated-build-system
  make check

  ninja
  ninja check
  test_runner.py

Reviewers: O1 Bitcoin ABC, #bitcoin_abc, Fabien

Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D6204
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this issue May 22, 2020
Summary:
Deprecated return results that were scheduled to be removed in v0.21

Partial backport of Core [[bitcoin/bitcoin#14021 | PR14021]]
bitcoin/bitcoin@345bff6

Test Plan:
  ninja
  ninja check-functional

Reviewers: O1 Bitcoin ABC, #bitcoin_abc, deadalnix

Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, deadalnix

Subscribers: deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D5933
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this issue May 22, 2020
Summary:
Partial backport of Core [[bitcoin/bitcoin#14021 | PR14021]]
bitcoin/bitcoin@bac8c67

Depends on D6204

Test Plan:
  ninja

Reviewers: O1 Bitcoin ABC, #bitcoin_abc, deadalnix

Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D6227
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this issue May 22, 2020
Summary:
Store the master key fingerprint and derivation path in the
key metadata. hdKeypath is kept to indicate the seed and for
backwards compatibility, but all key derivation path output
uses the key origin info instead of hdKeypath.

Partial backport of Core [[bitcoin/bitcoin#14021 | PR14021]]
bitcoin/bitcoin@eab63bc

Depends on D6227

Test Plan:
  ninja
  ninja check

Reviewers: O1 Bitcoin ABC, #bitcoin_abc, deadalnix

Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D6228
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this issue May 22, 2020
Summary:
Partial backport of Core [[bitcoin/bitcoin#14021 | PR14021]]
bitcoin/bitcoin@3d235df

Depends on D6228

Test Plan:
  ninja

Reviewers: O1 Bitcoin ABC, #bitcoin_abc, deadalnix

Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D6229
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this issue May 22, 2020
Summary:
Partial backport of Core [[bitcoin/bitcoin#14021 | PR14021]]
bitcoin/bitcoin@02d6586

Depends on D6229

Test Plan:
  ninja
  ninja check

Reviewers: O1 Bitcoin ABC, #bitcoin_abc, deadalnix

Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D6230
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this issue May 22, 2020
…e notes

Summary:
Test is separated from the rest of the changes to make review easier.

Partial backport of Core [[bitcoin/bitcoin#14021 | PR14021]]
bitcoin/bitcoin@4c75a69
bitcoin/bitcoin@cb3511b

Depends on D6230

Test Plan:
  ninja
  ninja check
  ninja check-functional

Reviewers: O1 Bitcoin ABC, #bitcoin_abc, deadalnix

Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D6215
ftrader added a commit to bitcoin-cash-node/bitcoin-cash-node that referenced this issue Aug 17, 2020
Summary:
Partial backport of Core [[bitcoin/bitcoin#14021 | PR14021]]
bitcoin/bitcoin@c45415f

Test Plan:
  ninja
  ninja check
  ninja check-functional

Reviewers: O1 Bitcoin ABC, #bitcoin_abc, Fabien

Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D6004
vijaydasmp added a commit to vijaydasmp/dash that referenced this issue Sep 28, 2021
…portmulti

cb3511b Add release notes for importing key origin info change (Andrew Chow)
4c75a69 Test importing descriptors with key origin information (Andrew Chow)
02d6586 Import KeyOriginData when importing descriptors (Andrew Chow)
3d235df Implement a function to add KeyOriginInfo to a wallet (Andrew Chow)
eab63bc Store key origin info in key metadata (Andrew Chow)
345bff6 Remove hdmasterkeyid (Andrew Chow)
bac8c67 Add a method to CWallet to write just CKeyMetadata (Andrew Chow)
e7652d3 Add WriteHDKeypath function and move *HDKeypath to util/bip32.{h,cpp} (Andrew Chow)
c45415f Refactor keymetadata writing to a separate method (Andrew Chow)

Pull request description:

  This PR allows for key origin data as defined by the descriptors document to be imported to the wallet when importing a descriptor using `importmulti`. This allows the `walletprocesspsbt` to include the BIP 32 derivation paths for keys that it is watching that are from a different HD wallet.

  In order to make this easier to use, a new field `hdmasterkeyfingerprint` has been added to `getaddressinfo`. Additionally I have removed `hdmasterkeyid` as was planned. I think that this API change is fine since it was going to be removed in 0.18 anyways. `CKeyMetadata` has also been extended to store key origin info to facilitate this.

Tree-SHA512: 9c7794f3c793da57e23c5abbdc3d58779ee9dea3d53168bb86c0643a4ad5a11a446264961e2f772f35eea645048cb60954ed58050002caee4e43cd9f51215097
vijaydasmp added a commit to vijaydasmp/dash that referenced this issue Sep 28, 2021
…portmulti

cb3511b Add release notes for importing key origin info change (Andrew Chow)
4c75a69 Test importing descriptors with key origin information (Andrew Chow)
02d6586 Import KeyOriginData when importing descriptors (Andrew Chow)
3d235df Implement a function to add KeyOriginInfo to a wallet (Andrew Chow)
eab63bc Store key origin info in key metadata (Andrew Chow)
345bff6 Remove hdmasterkeyid (Andrew Chow)
bac8c67 Add a method to CWallet to write just CKeyMetadata (Andrew Chow)
e7652d3 Add WriteHDKeypath function and move *HDKeypath to util/bip32.{h,cpp} (Andrew Chow)
c45415f Refactor keymetadata writing to a separate method (Andrew Chow)

Pull request description:

  This PR allows for key origin data as defined by the descriptors document to be imported to the wallet when importing a descriptor using `importmulti`. This allows the `walletprocesspsbt` to include the BIP 32 derivation paths for keys that it is watching that are from a different HD wallet.

  In order to make this easier to use, a new field `hdmasterkeyfingerprint` has been added to `getaddressinfo`. Additionally I have removed `hdmasterkeyid` as was planned. I think that this API change is fine since it was going to be removed in 0.18 anyways. `CKeyMetadata` has also been extended to store key origin info to facilitate this.

Tree-SHA512: 9c7794f3c793da57e23c5abbdc3d58779ee9dea3d53168bb86c0643a4ad5a11a446264961e2f772f35eea645048cb60954ed58050002caee4e43cd9f51215097
vijaydasmp added a commit to vijaydasmp/dash that referenced this issue Sep 28, 2021
vijaydasmp added a commit to vijaydasmp/dash that referenced this issue Sep 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet