Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcdump.cpp
Show First 20 Lines • Show All 886 Lines • ▼ Show 20 Lines | UniValue dumpwallet(const Config &config, const JSONRPCRequest &request) { | ||||
file << strprintf("# * Best block at time of backup was %i (%s),\n", | file << strprintf("# * Best block at time of backup was %i (%s),\n", | ||||
chainActive.Height(), | chainActive.Height(), | ||||
chainActive.Tip()->GetBlockHash().ToString()); | chainActive.Tip()->GetBlockHash().ToString()); | ||||
file << strprintf("# mined on %s\n", | file << strprintf("# mined on %s\n", | ||||
FormatISO8601DateTime(chainActive.Tip()->GetBlockTime())); | FormatISO8601DateTime(chainActive.Tip()->GetBlockTime())); | ||||
file << "\n"; | file << "\n"; | ||||
// add the base58check encoded extended master if the wallet uses HD | // add the base58check encoded extended master if the wallet uses HD | ||||
CKeyID masterKeyID = pwallet->GetHDChain().masterKeyID; | CKeyID seed_id = pwallet->GetHDChain().seed_id; | ||||
if (!masterKeyID.IsNull()) { | if (!seed_id.IsNull()) { | ||||
CKey key; | CKey key; | ||||
if (pwallet->GetKey(masterKeyID, key)) { | if (pwallet->GetKey(seed_id, key)) { | ||||
CExtKey masterKey; | CExtKey masterKey; | ||||
masterKey.SetMaster(key.begin(), key.size()); | masterKey.SetSeed(key.begin(), key.size()); | ||||
file << "# extended private masterkey: " << EncodeExtKey(masterKey) | file << "# extended private masterkey: " << EncodeExtKey(masterKey) | ||||
<< "\n\n"; | << "\n\n"; | ||||
} | } | ||||
} | } | ||||
for (std::vector<std::pair<int64_t, CKeyID>>::const_iterator it = | for (std::vector<std::pair<int64_t, CKeyID>>::const_iterator it = | ||||
vKeyBirth.begin(); | vKeyBirth.begin(); | ||||
it != vKeyBirth.end(); it++) { | it != vKeyBirth.end(); it++) { | ||||
const CKeyID &keyid = it->second; | const CKeyID &keyid = it->second; | ||||
std::string strTime = FormatISO8601DateTime(it->first); | std::string strTime = FormatISO8601DateTime(it->first); | ||||
std::string strAddr; | std::string strAddr; | ||||
std::string strLabel; | std::string strLabel; | ||||
CKey key; | CKey key; | ||||
if (pwallet->GetKey(keyid, key)) { | if (pwallet->GetKey(keyid, key)) { | ||||
file << strprintf("%s %s ", EncodeSecret(key), strTime); | file << strprintf("%s %s ", EncodeSecret(key), strTime); | ||||
if (GetWalletAddressesForKey(config, pwallet, keyid, strAddr, | if (GetWalletAddressesForKey(config, pwallet, keyid, strAddr, | ||||
strLabel)) { | strLabel)) { | ||||
file << strprintf("label=%s", strLabel); | file << strprintf("label=%s", strLabel); | ||||
} else if (keyid == masterKeyID) { | } else if (keyid == seed_id) { | ||||
file << "hdmaster=1"; | file << "hdmaster=1"; | ||||
} else if (mapKeyPool.count(keyid)) { | } else if (mapKeyPool.count(keyid)) { | ||||
file << "reserve=1"; | file << "reserve=1"; | ||||
} else if (pwallet->mapKeyMetadata[keyid].hdKeypath == "m") { | } else if (pwallet->mapKeyMetadata[keyid].hdKeypath == "m") { | ||||
file << "inactivehdmaster=1"; | file << "inactivehdmaster=1"; | ||||
} else { | } else { | ||||
file << "change=1"; | file << "change=1"; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 597 Lines • Show Last 20 Lines |