diff --git a/src/wallet/rpc/backup.cpp b/src/wallet/rpc/backup.cpp index 8cddb8b0990485..8287eb0e7278e6 100644 --- a/src/wallet/rpc/backup.cpp +++ b/src/wallet/rpc/backup.cpp @@ -1483,7 +1483,7 @@ static UniValue ProcessDescriptorImport(CWallet& wallet, const UniValue& data, c } // Active descriptors must be ranged - if (active && !parsed_desc->IsRange()) { + if (active && !parsed_desc->IsRange() && parsed_desc->GetOutputType() != OutputType::SILENT_PAYMENT) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Active descriptors must be ranged"); } diff --git a/test/functional/wallet_miniscript.py b/test/functional/wallet_miniscript.py index 67e128390200ca..428571475862ad 100755 --- a/test/functional/wallet_miniscript.py +++ b/test/functional/wallet_miniscript.py @@ -55,6 +55,7 @@ f"tr(4d54bb9928a0683b7e383de72943b214b0716f58aa54c7ba6bcea2328bc9c768,{{{{{P2WSH_MINISCRIPTS[0]},{P2WSH_MINISCRIPTS[1]}}},{P2WSH_MINISCRIPTS[2].replace('multi', 'multi_a')}}})", # A Taproot with all above scripts in its tree. f"tr(4d54bb9928a0683b7e383de72943b214b0716f58aa54c7ba6bcea2328bc9c768,{{{{{P2WSH_MINISCRIPTS[0]},{P2WSH_MINISCRIPTS[1]}}},{{{P2WSH_MINISCRIPTS[2].replace('multi', 'multi_a')},{P2WSH_MINISCRIPTS[3]}}}}})", + f"sp({TPRVS[0]},{TPUBS[0]})", ] DESCS_PRIV = [ @@ -217,36 +218,48 @@ def skip_test_if_missing_module(self): def watchonly_test(self, desc): self.log.info(f"Importing descriptor '{desc}'") desc = descsum_create(f"{desc}") - assert self.ms_wo_wallet.importdescriptors( - [ - { - "desc": desc, - "active": True, - "range": 2, - "next_index": 0, - "timestamp": "now", - } - ] - )[0]["success"] + range = None if desc.startswith("sp(") else 2 + wallet = self.ms_sp_wallet if desc.startswith("sp(") else self.ms_wo_wallet + + import_desc_data = { + "desc": desc, + "active": True, + "next_index": 0, + "timestamp": "now", + } + if range is not None: + import_desc_data["range"] = range + assert wallet.importdescriptors([import_desc_data])[0]["success"] self.log.info("Testing we derive new addresses for it") - addr_type = "bech32m" if desc.startswith("tr(") else "bech32" - assert_equal( - self.ms_wo_wallet.getnewaddress(address_type=addr_type), - self.funder.deriveaddresses(desc, 0)[0], - ) - assert_equal( - self.ms_wo_wallet.getnewaddress(address_type=addr_type), - self.funder.deriveaddresses(desc, 1)[1], - ) + addr_type = "bech32" + if desc.startswith("tr("): + addr_type = "bech32m" + elif desc.startswith("sp("): + addr_type = "silent-payment" + + if range is not None: + assert_equal( + wallet.getnewaddress(address_type=addr_type), + self.funder.deriveaddresses(desc, 0)[0], + ) + assert_equal( + wallet.getnewaddress(address_type=addr_type), + self.funder.deriveaddresses(desc, 1)[1], + ) + else: + assert_equal( + wallet.getnewaddress(address_type=addr_type), + self.funder.deriveaddresses(desc)[0], + ) self.log.info("Testing we detect funds sent to one of them") - addr = self.ms_wo_wallet.getnewaddress() + addr = wallet.getnewaddress() txid = self.funder.sendtoaddress(addr, 0.01) self.wait_until( - lambda: len(self.ms_wo_wallet.listunspent(minconf=0, addresses=[addr])) == 1 + lambda: len(wallet.listunspent(minconf=0, addresses=[addr])) == 1 ) - utxo = self.ms_wo_wallet.listunspent(minconf=0, addresses=[addr])[0] + utxo = wallet.listunspent(minconf=0, addresses=[addr])[0] assert utxo["txid"] == txid and utxo["solvable"] def signing_test( @@ -329,7 +342,11 @@ def run_test(self): wallet_name="ms_wo", descriptors=True, disable_private_keys=True ) self.ms_wo_wallet = self.nodes[0].get_wallet_rpc("ms_wo") - self.nodes[0].createwallet(wallet_name="ms_sig", descriptors=True) + self.nodes[0].createwallet( + wallet_name="ms_sp_wallet", descriptors=True, silent_payment=True + ) + self.ms_sp_wallet = self.nodes[0].get_wallet_rpc("ms_sp_wallet") + self.nodes[0].createwallet(wallet_name="ms_sig", descriptors=True, silent_payment=True) self.ms_sig_wallet = self.nodes[0].get_wallet_rpc("ms_sig") # Sanity check we wouldn't let an insane Miniscript descriptor in