diff options
author | Andrew Chow <achow101-github@achow101.com> | 2018-11-06 09:23:51 -0500 |
---|---|---|
committer | Andrew Chow <achow101-github@achow101.com> | 2019-02-14 17:58:25 -0500 |
commit | 4c75a69f36a7630342e68b12999115e6b6b1e1e0 (patch) | |
tree | 9c962e7c35ae025d6534368ad8df5e527c348db6 /test/functional/wallet_importmulti.py | |
parent | 02d6586d7a0f1a0886010e733760ce59cf0935c3 (diff) |
Test importing descriptors with key origin information
Diffstat (limited to 'test/functional/wallet_importmulti.py')
-rwxr-xr-x | test/functional/wallet_importmulti.py | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/test/functional/wallet_importmulti.py b/test/functional/wallet_importmulti.py index 7cce72b39f..ee59ef0966 100755 --- a/test/functional/wallet_importmulti.py +++ b/test/functional/wallet_importmulti.py @@ -626,5 +626,70 @@ class ImportMultiTest(BitcoinTestFramework): iswatchonly=False) + # Import pubkeys with key origin info + self.log.info("Addresses should have hd keypath and master key id after import with key origin") + pub_addr = self.nodes[1].getnewaddress() + pub_addr = self.nodes[1].getnewaddress() + info = self.nodes[1].getaddressinfo(pub_addr) + pub = info['pubkey'] + pub_keypath = info['hdkeypath'] + pub_fpr = info['hdmasterfingerprint'] + result = self.nodes[0].importmulti( + [{ + 'desc' : "wpkh([" + pub_fpr + pub_keypath[1:] +"]" + pub + ")", + "timestamp": "now", + }] + ) + assert result[0]['success'] + pub_import_info = self.nodes[0].getaddressinfo(pub_addr) + assert_equal(pub_import_info['hdmasterfingerprint'], pub_fpr) + assert_equal(pub_import_info['pubkey'], pub) + assert_equal(pub_import_info['hdkeypath'], pub_keypath) + + # Import privkeys with key origin info + priv_addr = self.nodes[1].getnewaddress() + info = self.nodes[1].getaddressinfo(priv_addr) + priv = self.nodes[1].dumpprivkey(priv_addr) + priv_keypath = info['hdkeypath'] + priv_fpr = info['hdmasterfingerprint'] + result = self.nodes[0].importmulti( + [{ + 'desc' : "wpkh([" + priv_fpr + priv_keypath[1:] + "]" + priv + ")", + "timestamp": "now", + }] + ) + assert result[0]['success'] + priv_import_info = self.nodes[0].getaddressinfo(priv_addr) + assert_equal(priv_import_info['hdmasterfingerprint'], priv_fpr) + assert_equal(priv_import_info['hdkeypath'], priv_keypath) + + # Make sure the key origin info are still there after a restart + self.stop_nodes() + self.start_nodes() + import_info = self.nodes[0].getaddressinfo(pub_addr) + assert_equal(import_info['hdmasterfingerprint'], pub_fpr) + assert_equal(import_info['hdkeypath'], pub_keypath) + import_info = self.nodes[0].getaddressinfo(priv_addr) + assert_equal(import_info['hdmasterfingerprint'], priv_fpr) + assert_equal(import_info['hdkeypath'], priv_keypath) + + # Check legacy import does not import key origin info + self.log.info("Legacy imports don't have key origin info") + pub_addr = self.nodes[1].getnewaddress() + info = self.nodes[1].getaddressinfo(pub_addr) + pub = info['pubkey'] + result = self.nodes[0].importmulti( + [{ + 'scriptPubKey': {'address': pub_addr}, + 'pubkeys': [pub], + "timestamp": "now", + }] + ) + assert result[0]['success'] + pub_import_info = self.nodes[0].getaddressinfo(pub_addr) + assert_equal(pub_import_info['pubkey'], pub) + assert 'hdmasterfingerprint' not in pub_import_info + assert 'hdkeypath' not in pub_import_info + if __name__ == '__main__': ImportMultiTest().main() |