Merge fa53611cf1 into merged_master (Bitcoin PR bitcoin/bitcoin#26076)

This commit is contained in:
Byron Hambly 2025-05-16 11:10:32 +02:00
commit 5b856b6f5f
20 changed files with 162 additions and 142 deletions

View file

@ -1560,7 +1560,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);
}
@ -1826,7 +1826,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);
@ -2269,20 +2269,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: {
@ -2295,13 +2295,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;