diff options
author | MeshCollider <dobsonsa68@gmail.com> | 2017-12-20 19:01:05 +1300 |
---|---|---|
committer | MeshCollider <dobsonsa68@gmail.com> | 2017-12-20 20:24:37 +1300 |
commit | 656fde53a3a0d88a1e3c1aef7ae99083e4b06a7d (patch) | |
tree | 3988a21e2b68bfa038328fcd4345d4419147f174 /src | |
parent | 1bab9b23af95986f9452d468257cc34d2c5017b2 (diff) |
Add script birthtime metadata to dump and import wallet
Diffstat (limited to 'src')
-rw-r--r-- | src/wallet/rpcdump.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp index 92c3bd080c..41179ebd4a 100644 --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -545,6 +545,11 @@ UniValue importwallet(const JSONRPCRequest& request) fGood = false; continue; } + int64_t birth_time = DecodeDumpTime(vstr[1]); + if (birth_time > 0) { + pwallet->m_script_metadata[CScriptID(script)].nCreateTime = birth_time; + nTimeBegin = std::min(nTimeBegin, birth_time); + } } } file.close(); @@ -653,6 +658,7 @@ UniValue dumpwallet(const JSONRPCRequest& request) pwallet->GetKeyBirthTimes(mapKeyBirth); std::set<CScriptID> scripts = pwallet->GetCScripts(); + // TODO: include scripts in GetKeyBirthTimes() output instead of separate // sort time/key pairs std::vector<std::pair<int64_t, CKeyID> > vKeyBirth; @@ -710,9 +716,15 @@ UniValue dumpwallet(const JSONRPCRequest& request) file << "\n"; for (const CScriptID &scriptid : scripts) { CScript script; + std::string create_time = "0"; std::string address = EncodeDestination(scriptid); + // get birth times for scripts with metadata + auto it = pwallet->m_script_metadata.find(scriptid); + if (it != pwallet->m_script_metadata.end()) { + create_time = EncodeDumpTime(it->second.nCreateTime); + } if(pwallet->GetCScript(scriptid, script)) { - file << strprintf("%s 0 script=1", HexStr(script.begin(), script.end())); + file << strprintf("%s %s script=1", HexStr(script.begin(), script.end()), create_time); file << strprintf(" # addr=%s\n", address); } } |