mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-02 09:46:52 -05:00
Take non-importing keys into account for spendability warning in descriptor import
This commit is contained in:
parent
6e597001a4
commit
b5d3987724
2 changed files with 5 additions and 1 deletions
|
@ -1197,6 +1197,9 @@ static UniValue ProcessImportDescriptor(ImportData& import_data, std::map<CKeyID
|
||||||
bool spendable = std::all_of(pubkey_map.begin(), pubkey_map.end(),
|
bool spendable = std::all_of(pubkey_map.begin(), pubkey_map.end(),
|
||||||
[&](const std::pair<CKeyID, CPubKey>& used_key) {
|
[&](const std::pair<CKeyID, CPubKey>& used_key) {
|
||||||
return privkey_map.count(used_key.first) > 0;
|
return privkey_map.count(used_key.first) > 0;
|
||||||
|
}) && std::all_of(import_data.key_origins.begin(), import_data.key_origins.end(),
|
||||||
|
[&](const std::pair<CKeyID, std::pair<CPubKey, KeyOriginInfo>>& entry) {
|
||||||
|
return privkey_map.count(entry.first) > 0;
|
||||||
});
|
});
|
||||||
if (!watch_only && !spendable) {
|
if (!watch_only && !spendable) {
|
||||||
warnings.push_back("Some private keys are missing, outputs will be considered watchonly. If this is intentional, specify the watchonly flag.");
|
warnings.push_back("Some private keys are missing, outputs will be considered watchonly. If this is intentional, specify the watchonly flag.");
|
||||||
|
|
|
@ -629,7 +629,8 @@ class ImportMultiTest(BitcoinTestFramework):
|
||||||
self.log.info("Should import a 1-of-2 bare multisig from descriptor")
|
self.log.info("Should import a 1-of-2 bare multisig from descriptor")
|
||||||
self.test_importmulti({"desc": descsum_create("multi(1," + key1.pubkey + "," + key2.pubkey + ")"),
|
self.test_importmulti({"desc": descsum_create("multi(1," + key1.pubkey + "," + key2.pubkey + ")"),
|
||||||
"timestamp": "now"},
|
"timestamp": "now"},
|
||||||
success=True)
|
success=True,
|
||||||
|
warnings=["Some private keys are missing, outputs will be considered watchonly. If this is intentional, specify the watchonly flag."])
|
||||||
self.log.info("Should not treat individual keys from the imported bare multisig as watchonly")
|
self.log.info("Should not treat individual keys from the imported bare multisig as watchonly")
|
||||||
test_address(self.nodes[1],
|
test_address(self.nodes[1],
|
||||||
key1.p2pkh_addr,
|
key1.p2pkh_addr,
|
||||||
|
|
Loading…
Add table
Reference in a new issue