wallet: Add seedfp to transparent keys in dumpwallet / z_exportwallet
Also refactors Sapling key export logic to match. Sapling key exports already have hdkeypath and seedfp (in a different spot in the line). Sprout key exports are unmodified, because we have removed the ability to generate new Sprout keys, so there will never be HD Sprout keys.
This commit is contained in:
parent
eaf8eb40f4
commit
78fea33cde
|
@ -649,6 +649,7 @@ UniValue dumpwallet_impl(const UniValue& params, bool fDumpZKeys)
|
||||||
std::string strAddr = keyIO.EncodeDestination(keyid);
|
std::string strAddr = keyIO.EncodeDestination(keyid);
|
||||||
CKey key;
|
CKey key;
|
||||||
if (pwalletMain->GetKey(keyid, key)) {
|
if (pwalletMain->GetKey(keyid, key)) {
|
||||||
|
CKeyMetadata keyMeta = pwalletMain->mapKeyMetadata[keyid];
|
||||||
file << strprintf("%s %s ", keyIO.EncodeSecret(key), strTime);
|
file << strprintf("%s %s ", keyIO.EncodeSecret(key), strTime);
|
||||||
if (pwalletMain->mapAddressBook.count(keyid)) {
|
if (pwalletMain->mapAddressBook.count(keyid)) {
|
||||||
file << strprintf("label=%s", EncodeDumpString(pwalletMain->mapAddressBook[keyid].name));
|
file << strprintf("label=%s", EncodeDumpString(pwalletMain->mapAddressBook[keyid].name));
|
||||||
|
@ -657,7 +658,11 @@ UniValue dumpwallet_impl(const UniValue& params, bool fDumpZKeys)
|
||||||
} else {
|
} else {
|
||||||
file << "change=1";
|
file << "change=1";
|
||||||
}
|
}
|
||||||
file << strprintf(" # addr=%s%s\n", strAddr, (pwalletMain->mapKeyMetadata[keyid].hdKeypath.size() > 0 ? " hdkeypath="+pwalletMain->mapKeyMetadata[keyid].hdKeypath : ""));
|
file << strprintf(" # addr=%s", strAddr);
|
||||||
|
if (!(keyMeta.hdKeypath.empty() || keyMeta.seedFp.IsNull())) {
|
||||||
|
file << strprintf(" hdkeypath=%s seedfp=%s", keyMeta.hdKeypath, keyMeta.seedFp.GetHex());
|
||||||
|
}
|
||||||
|
file << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file << "\n";
|
file << "\n";
|
||||||
|
@ -686,12 +691,12 @@ UniValue dumpwallet_impl(const UniValue& params, bool fDumpZKeys)
|
||||||
auto ivk = extsk.expsk.full_viewing_key().in_viewing_key();
|
auto ivk = extsk.expsk.full_viewing_key().in_viewing_key();
|
||||||
CKeyMetadata keyMeta = pwalletMain->mapSaplingZKeyMetadata[ivk];
|
CKeyMetadata keyMeta = pwalletMain->mapSaplingZKeyMetadata[ivk];
|
||||||
std::string strTime = EncodeDumpTime(keyMeta.nCreateTime);
|
std::string strTime = EncodeDumpTime(keyMeta.nCreateTime);
|
||||||
|
file << strprintf("%s %s", keyIO.EncodeSpendingKey(extsk), strTime);
|
||||||
// Keys imported with z_importkey do not have zip32 metadata
|
// Keys imported with z_importkey do not have zip32 metadata
|
||||||
if (keyMeta.hdKeypath.empty() || keyMeta.seedFp.IsNull()) {
|
if (!(keyMeta.hdKeypath.empty() || keyMeta.seedFp.IsNull())) {
|
||||||
file << strprintf("%s %s # zaddr=%s\n", keyIO.EncodeSpendingKey(extsk), strTime, keyIO.EncodePaymentAddress(addr));
|
file << strprintf(" %s %s", keyMeta.hdKeypath, keyMeta.seedFp.GetHex());
|
||||||
} else {
|
|
||||||
file << strprintf("%s %s %s %s # zaddr=%s\n", keyIO.EncodeSpendingKey(extsk), strTime, keyMeta.hdKeypath, keyMeta.seedFp.GetHex(), keyIO.EncodePaymentAddress(addr));
|
|
||||||
}
|
}
|
||||||
|
file << strprintf(" # zaddr=%s\n", keyIO.EncodePaymentAddress(addr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file << "\n";
|
file << "\n";
|
||||||
|
|
Loading…
Reference in New Issue