Changeset View
Changeset View
Standalone View
Standalone View
test/functional/wallet_importmulti.py
Show First 20 Lines • Show All 508 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
success=True) | success=True) | ||||
self.log.info( | self.log.info( | ||||
"Should not treat individual keys from the imported bare multisig as watchonly") | "Should not treat individual keys from the imported bare multisig as watchonly") | ||||
test_address(self.nodes[1], | test_address(self.nodes[1], | ||||
key1.p2pkh_addr, | key1.p2pkh_addr, | ||||
ismine=False, | ismine=False, | ||||
iswatchonly=False) | 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': "pkh([" + 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': "pkh([" + 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__': | if __name__ == '__main__': | ||||
ImportMultiTest().main() | ImportMultiTest().main() |