mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-05 02:33:07 +02:00
Merge #15024: Allow specific private keys to be derived from descriptor
53b7de629dAdd test for dumping the private key imported from descriptor (MeshCollider)2857bc4a64Extend importmulti descriptor tests (MeshCollider)81a884bbd0Import private keys from descriptor with importmulti if provided (MeshCollider)a4d1bd1a29Add private key derivation functions to descriptors (MeshCollider) Pull request description: ~This is based on #14491, review the last 3 commits only.~ Currently, descriptors have an Expand() function which returns public keys and scripts for a specific index of a ranged descriptor. But the private key for a specific index is not given. This allows private keys for specific indices to be derived. This also allows those keys to be imported through the `importmulti` RPC rather than having to provide them separately. ACKs for commit 53b7de: achow101: ACK53b7de629dTree-SHA512: c060bc01358a1adc76d3d470fefc2bdd39c837027f452e9bc4bd2e726097e1ece4af9d5627efd942a5f8819271e15ba54f010b169b50a9435a1f0f40fd1cebf3
This commit is contained in:
@@ -1165,8 +1165,7 @@ static UniValue ProcessImportDescriptor(ImportData& import_data, std::map<CKeyID
|
||||
|
||||
const UniValue& priv_keys = data.exists("keys") ? data["keys"].get_array() : UniValue();
|
||||
|
||||
// Expand all descriptors to get public keys and scripts.
|
||||
// TODO: get private keys from descriptors too
|
||||
// Expand all descriptors to get public keys and scripts, and private keys if available.
|
||||
for (int i = range_start; i <= range_end; ++i) {
|
||||
FlatSigningProvider out_keys;
|
||||
std::vector<CScript> scripts_temp;
|
||||
@@ -1180,7 +1179,10 @@ static UniValue ProcessImportDescriptor(ImportData& import_data, std::map<CKeyID
|
||||
import_data.import_scripts.emplace(x.second);
|
||||
}
|
||||
|
||||
parsed_desc->ExpandPrivate(i, keys, out_keys);
|
||||
|
||||
std::copy(out_keys.pubkeys.begin(), out_keys.pubkeys.end(), std::inserter(pubkey_map, pubkey_map.end()));
|
||||
std::copy(out_keys.keys.begin(), out_keys.keys.end(), std::inserter(privkey_map, privkey_map.end()));
|
||||
import_data.key_origins.insert(out_keys.origins.begin(), out_keys.origins.end());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user