From 74da9ee89d5b5d1f6357f6f711f977d14d4a1b9c Mon Sep 17 00:00:00 2001 From: Novo Date: Sat, 3 Aug 2024 21:28:52 +0100 Subject: [PATCH] test: wallet import rescan for silent payments --- .../wallet_silentpayments_receiving.py | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/functional/wallet_silentpayments_receiving.py b/test/functional/wallet_silentpayments_receiving.py index d8c59add9ec67..6df7cced086b8 100755 --- a/test/functional/wallet_silentpayments_receiving.py +++ b/test/functional/wallet_silentpayments_receiving.py @@ -110,6 +110,31 @@ def test_basic(self): assert_equal(wallet.getbalance(), 0) + def test_import_rescan(self): + self.log.info("Check import rescan works for silent payments") + + self.nodes[0].createwallet(wallet_name="alice", silent_payment=True) + self.nodes[0].createwallet(wallet_name="alice_wo", disable_private_keys=True, silent_payment=True) + alice = self.nodes[0].get_wallet_rpc("alice") + alice_wo = self.nodes[0].get_wallet_rpc("alice_wo") + + address = alice.getnewaddress(address_type="silent-payment") + self.def_wallet.sendtoaddress(address, 10) + blockhash = self.generate(self.nodes[0], 1)[0] + timestamp = self.nodes[0].getblockheader(blockhash)["time"] + assert_approx(alice.getbalance(), 10, 0.0001) + assert_equal(alice_wo.getbalance(), 0) + + alice_sp_desc = [d["desc"] for d in alice.listdescriptors()["descriptors"] if d["desc"].startswith("sp(")][0] + alice_wo.importdescriptors([{ + "desc": alice_sp_desc, + "active": True, + "next_index": 0, + "timestamp": timestamp + }]) + + assert_approx(alice_wo.getbalance(), 10, 0.0001) + def run_test(self): self.def_wallet = self.nodes[0].get_wallet_rpc(self.default_wallet_name) self.generate(self.nodes[0], 101) @@ -118,6 +143,7 @@ def run_test(self): self.test_encrypt_and_decrypt() self.test_encrypting_unencrypted() self.test_basic() + self.test_import_rescan() if __name__ == '__main__':