diff options
author | Andrew Chow <github@achow101.com> | 2023-05-08 13:13:30 -0400 |
---|---|---|
committer | Andrew Chow <github@achow101.com> | 2023-05-08 13:31:28 -0400 |
commit | fa53611cf1b2ab2f49470ba75ee29a94a7b89105 (patch) | |
tree | 0e150cbe3f756c78159377266d73cbb7af5b79c4 /src/wallet/scriptpubkeyman.cpp | |
parent | 26cb32c02d76d6635c67942a5eeb70a6199df69d (diff) | |
parent | fe49f06c0e91b96feb8d8f1bd478c3173f14782c (diff) | |
download | bitcoin-fa53611cf1b2ab2f49470ba75ee29a94a7b89105.tar.xz |
Merge bitcoin/bitcoin#26076: Switch hardened derivation marker to h
fe49f06c0e91b96feb8d8f1bd478c3173f14782c doc: clarify PR 26076 release note (Sjors Provoost)
bd13dc2f46ea10302a928fcf0f53b7aed77ad260 Switch hardened derivation marker to h in descriptors (Sjors Provoost)
Pull request description:
This makes it easier to handle descriptor strings manually, especially when importing from another Bitcoin Core wallet.
For example the `importdescriptors` RPC call is easiest to use `h` as the marker: `'["desc": ".../0h/..."]'`, avoiding the need for escape characters. With this change `listdescriptors` will use `h`, so you can copy-paste the result, without having to add escape characters or switch `'` to 'h' manually.
Both markers can still be parsed.
The `hdkeypath` field in `getaddressinfo` is also impacted by this change, except for legacy wallets. The latter is to prevent accidentally breaking ancient software that uses our legacy wallet.
See discussion in #15740
ACKs for top commit:
achow101:
ACK fe49f06c0e91b96feb8d8f1bd478c3173f14782c
darosior:
re-ACK fe49f06c0e91b96feb8d8f1bd478c3173f14782c
Tree-SHA512: f78bc873b24a6f7a2bf38f5dd58f2b723e35e6b10e4d65c36ec300e2d362d475eeca6e5afa04b3037ab4bee0bf8ebc93ea5fc18102a2111d3d88fc873c08dc89
Diffstat (limited to 'src/wallet/scriptpubkeyman.cpp')
-rw-r--r-- | src/wallet/scriptpubkeyman.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp index 62bd0c06cd..953fdb63b6 100644 --- a/src/wallet/scriptpubkeyman.cpp +++ b/src/wallet/scriptpubkeyman.cpp @@ -1555,7 +1555,7 @@ bool LegacyScriptPubKeyMan::AddKeyOriginWithDB(WalletBatch& batch, const CPubKey std::copy(info.fingerprint, info.fingerprint + 4, mapKeyMetadata[pubkey.GetID()].key_origin.fingerprint); mapKeyMetadata[pubkey.GetID()].key_origin.path = info.path; mapKeyMetadata[pubkey.GetID()].has_key_origin = true; - mapKeyMetadata[pubkey.GetID()].hdKeypath = WriteHDKeypath(info.path); + mapKeyMetadata[pubkey.GetID()].hdKeypath = WriteHDKeypath(info.path, /*apostrophe=*/true); return batch.WriteKeyMetadata(mapKeyMetadata[pubkey.GetID()], pubkey, true); } @@ -1821,7 +1821,7 @@ std::optional<MigrationData> LegacyScriptPubKeyMan::MigrateToDescriptor() // Make the combo descriptor std::string xpub = EncodeExtPubKey(master_key.Neuter()); - std::string desc_str = "combo(" + xpub + "/0'/" + ToString(i) + "'/*')"; + std::string desc_str = "combo(" + xpub + "/0h/" + ToString(i) + "h/*h)"; FlatSigningProvider keys; std::string error; std::unique_ptr<Descriptor> desc = Parse(desc_str, keys, error, false); @@ -2264,20 +2264,20 @@ bool DescriptorScriptPubKeyMan::SetupDescriptorGeneration(const CExtKey& master_ std::string desc_suffix = "/*)"; switch (addr_type) { case OutputType::LEGACY: { - desc_prefix = "pkh(" + xpub + "/44'"; + desc_prefix = "pkh(" + xpub + "/44h"; break; } case OutputType::P2SH_SEGWIT: { - desc_prefix = "sh(wpkh(" + xpub + "/49'"; + desc_prefix = "sh(wpkh(" + xpub + "/49h"; desc_suffix += ")"; break; } case OutputType::BECH32: { - desc_prefix = "wpkh(" + xpub + "/84'"; + desc_prefix = "wpkh(" + xpub + "/84h"; break; } case OutputType::BECH32M: { - desc_prefix = "tr(" + xpub + "/86'"; + desc_prefix = "tr(" + xpub + "/86h"; break; } case OutputType::UNKNOWN: { @@ -2290,13 +2290,13 @@ bool DescriptorScriptPubKeyMan::SetupDescriptorGeneration(const CExtKey& master_ // Mainnet derives at 0', testnet and regtest derive at 1' if (Params().IsTestChain()) { - desc_prefix += "/1'"; + desc_prefix += "/1h"; } else { - desc_prefix += "/0'"; + desc_prefix += "/0h"; } std::string internal_path = internal ? "/1" : "/0"; - std::string desc_str = desc_prefix + "/0'" + internal_path + desc_suffix; + std::string desc_str = desc_prefix + "/0h" + internal_path + desc_suffix; // Make the descriptor FlatSigningProvider keys; |