|
16 | 16 | and test the values returned."""
|
17 | 17 |
|
18 | 18 | import concurrent.futures
|
| 19 | +import time |
19 | 20 |
|
20 | 21 | from test_framework.authproxy import JSONRPCException
|
21 | 22 | from test_framework.blocktools import COINBASE_MATURITY
|
@@ -708,5 +709,56 @@ def run_test(self):
|
708 | 709 |
|
709 | 710 | assert_equal(temp_wallet.getbalance(), encrypted_wallet.getbalance())
|
710 | 711 |
|
| 712 | + self.log.info("Multipath descriptors") |
| 713 | + self.nodes[1].createwallet(wallet_name="multipath", descriptors=True, blank=True) |
| 714 | + w_multipath = self.nodes[1].get_wallet_rpc("multipath") |
| 715 | + self.nodes[1].createwallet(wallet_name="multipath_split", descriptors=True, blank=True) |
| 716 | + w_multisplit = self.nodes[1].get_wallet_rpc("multipath_split") |
| 717 | + timestamp = int(time.time()) |
| 718 | + |
| 719 | + self.test_importdesc({"desc": descsum_create(f"wpkh({xpriv}/<10;20>/0/*)"), |
| 720 | + "active": True, |
| 721 | + "range": 10, |
| 722 | + "timestamp": "now", |
| 723 | + "label": "some label"}, |
| 724 | + success=False, |
| 725 | + error_code=-8, |
| 726 | + error_message="Multipath descriptors should not have a label", |
| 727 | + wallet=w_multipath) |
| 728 | + self.test_importdesc({"desc": descsum_create(f"wpkh({xpriv}/<10;20>/0/*)"), |
| 729 | + "active": True, |
| 730 | + "range": 10, |
| 731 | + "timestamp": timestamp, |
| 732 | + "internal": True}, |
| 733 | + success=False, |
| 734 | + error_code=-5, |
| 735 | + error_message="Cannot have multipath descriptor while also specifying \'internal\'", |
| 736 | + wallet=w_multipath) |
| 737 | + |
| 738 | + self.test_importdesc({"desc": descsum_create(f"wpkh({xpriv}/<10;20>/0/*)"), |
| 739 | + "active": True, |
| 740 | + "range": 10, |
| 741 | + "timestamp": timestamp}, |
| 742 | + success=True, |
| 743 | + wallet=w_multipath) |
| 744 | + |
| 745 | + self.test_importdesc({"desc": descsum_create(f"wpkh({xpriv}/10/0/*)"), |
| 746 | + "active": True, |
| 747 | + "range": 10, |
| 748 | + "timestamp": timestamp}, |
| 749 | + success=True, |
| 750 | + wallet=w_multisplit) |
| 751 | + self.test_importdesc({"desc": descsum_create(f"wpkh({xpriv}/20/0/*)"), |
| 752 | + "active": True, |
| 753 | + "range": 10, |
| 754 | + "internal": True, |
| 755 | + "timestamp": timestamp}, |
| 756 | + success=True, |
| 757 | + wallet=w_multisplit) |
| 758 | + for _ in range(0, 10): |
| 759 | + assert_equal(w_multipath.getnewaddress(address_type="bech32"), w_multisplit.getnewaddress(address_type="bech32")) |
| 760 | + assert_equal(w_multipath.getrawchangeaddress(address_type="bech32"), w_multisplit.getrawchangeaddress(address_type="bech32")) |
| 761 | + assert_equal(sorted(w_multipath.listdescriptors()["descriptors"], key=lambda x: x["desc"]), sorted(w_multisplit.listdescriptors()["descriptors"], key=lambda x: x["desc"])) |
| 762 | + |
711 | 763 | if __name__ == '__main__':
|
712 | 764 | ImportDescriptorsTest().main()
|
0 commit comments