mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-13 03:30:42 +02:00
Merge 11803 via bugfix_dumpwallet_hdkeypath
This commit is contained in:
commit
5f71b8ff12
@ -882,7 +882,13 @@ RPCHelpMan dumpwallet()
|
|||||||
} else {
|
} else {
|
||||||
file << "change=1";
|
file << "change=1";
|
||||||
}
|
}
|
||||||
file << strprintf(" # addr=%s%s\n", strAddr, (metadata.has_key_origin ? " hdkeypath="+WriteHDKeypath(metadata.key_origin.path, /*apostrophe=*/true) : ""));
|
if (metadata.has_key_origin) {
|
||||||
|
file << " hdkeypath=" + WriteHDKeypath(metadata.key_origin.path, /*apostrophe=*/true);
|
||||||
|
if (!(metadata.hd_seed_id.IsNull() || (metadata.hdKeypath == "s" && metadata.hd_seed_id == keyid))) {
|
||||||
|
file << " hdseedid=" + metadata.hd_seed_id.GetHex();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file << strprintf(" # addr=%s\n", strAddr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file << "\n";
|
file << "\n";
|
||||||
|
@ -37,10 +37,10 @@ def read_dump(file_name, addrs, script_addrs, hd_master_addr_old):
|
|||||||
else:
|
else:
|
||||||
# split out some data
|
# split out some data
|
||||||
key_date_label, comment = line.split("#")
|
key_date_label, comment = line.split("#")
|
||||||
key_date_label = key_date_label.split(" ")
|
key_date_label = key_date_label.rstrip().split(" ")
|
||||||
# key = key_date_label[0]
|
# key = key_date_label[0]
|
||||||
date = key_date_label[1]
|
date = key_date_label[1]
|
||||||
keytype = key_date_label[2]
|
key_params = dict(map(lambda x: x.split('=', 1), key_date_label[2:]))
|
||||||
|
|
||||||
imported_key = date == '1970-01-01T00:00:01Z'
|
imported_key = date == '1970-01-01T00:00:01Z'
|
||||||
if imported_key:
|
if imported_key:
|
||||||
@ -48,25 +48,25 @@ def read_dump(file_name, addrs, script_addrs, hd_master_addr_old):
|
|||||||
# Skip them
|
# Skip them
|
||||||
continue
|
continue
|
||||||
|
|
||||||
addr_keypath = comment.split(" addr=")[1]
|
comment_params = dict(map(lambda x: x.split('=', 1), comment.strip().split(" ")))
|
||||||
addr = addr_keypath.split(" ")[0]
|
addr = comment_params['addr']
|
||||||
keypath = None
|
keypath = None
|
||||||
if keytype == "inactivehdseed=1":
|
if key_params.get('inactivehdseed'):
|
||||||
# ensure the old master is still available
|
# ensure the old master is still available
|
||||||
assert hd_master_addr_old == addr
|
assert hd_master_addr_old == addr
|
||||||
elif keytype == "hdseed=1":
|
elif key_params.get('hdseed'):
|
||||||
# ensure we have generated a new hd master key
|
# ensure we have generated a new hd master key
|
||||||
assert hd_master_addr_old != addr
|
assert hd_master_addr_old != addr
|
||||||
hd_master_addr_ret = addr
|
hd_master_addr_ret = addr
|
||||||
elif keytype == "script=1":
|
elif key_params.get('script'):
|
||||||
# scripts don't have keypaths
|
# scripts don't have keypaths
|
||||||
keypath = None
|
keypath = None
|
||||||
else:
|
else:
|
||||||
keypath = addr_keypath.rstrip().split("hdkeypath=")[1]
|
keypath = key_params['hdkeypath']
|
||||||
|
|
||||||
# count key types
|
# count key types
|
||||||
for addrObj in addrs:
|
for addrObj in addrs:
|
||||||
if addrObj['address'] == addr.split(",")[0] and addrObj['hdkeypath'] == keypath and keytype == "label=":
|
if addrObj['address'] == addr.split(",")[0] and addrObj['hdkeypath'] == keypath and key_params.get('label') == "":
|
||||||
if addr.startswith('m') or addr.startswith('n'):
|
if addr.startswith('m') or addr.startswith('n'):
|
||||||
# P2PKH address
|
# P2PKH address
|
||||||
found_legacy_addr += 1
|
found_legacy_addr += 1
|
||||||
@ -76,16 +76,16 @@ def read_dump(file_name, addrs, script_addrs, hd_master_addr_old):
|
|||||||
elif addr.startswith('bcrt1'):
|
elif addr.startswith('bcrt1'):
|
||||||
found_bech32_addr += 1
|
found_bech32_addr += 1
|
||||||
break
|
break
|
||||||
elif keytype == "change=1":
|
elif key_params.get('change'):
|
||||||
found_addr_chg += 1
|
found_addr_chg += 1
|
||||||
break
|
break
|
||||||
elif keytype == "reserve=1":
|
elif key_params.get('reserve'):
|
||||||
found_addr_rsv += 1
|
found_addr_rsv += 1
|
||||||
break
|
break
|
||||||
|
|
||||||
# count scripts
|
# count scripts
|
||||||
for script_addr in script_addrs:
|
for script_addr in script_addrs:
|
||||||
if script_addr == addr.rstrip() and keytype == "script=1":
|
if script_addr == addr.rstrip() and key_params.get('script'):
|
||||||
found_script_addr += 1
|
found_script_addr += 1
|
||||||
break
|
break
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user