From 235550d01992555a316c9c4639f5bec6255a244f Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Sat, 6 Apr 2019 08:23:19 -0700 Subject: [PATCH] Take non-importing keys into account for spendability warning in descriptor import Github-Pull: #15749 Rebased-From: b5d39877242504160a7f2c24c60c07a845d7a064 --- src/wallet/rpcdump.cpp | 3 +++ test/functional/wallet_importmulti.py | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp index a809a5e782d..ed9742e6c24 100644 --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -1193,6 +1193,9 @@ static UniValue ProcessImportDescriptor(ImportData& import_data, std::map& used_key) { return privkey_map.count(used_key.first) > 0; + }) && std::all_of(import_data.key_origins.begin(), import_data.key_origins.end(), + [&](const std::pair>& entry) { + return privkey_map.count(entry.first) > 0; }); 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."); diff --git a/test/functional/wallet_importmulti.py b/test/functional/wallet_importmulti.py index c6d0425f223..bfee2fe4c9c 100755 --- a/test/functional/wallet_importmulti.py +++ b/test/functional/wallet_importmulti.py @@ -630,7 +630,8 @@ class ImportMultiTest(BitcoinTestFramework): 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 + ")"), "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") test_address(self.nodes[1], key1.p2pkh_addr,