Skip to content

Commit b702ae8

Browse files
committed
Add CScripts to dumpwallet RPC
1 parent cdc260a commit b702ae8

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/wallet/rpcdump.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,8 @@ UniValue dumpwallet(const JSONRPCRequest& request)
640640
const std::map<CKeyID, int64_t>& mapKeyPool = pwallet->GetAllReserveKeys();
641641
pwallet->GetKeyBirthTimes(mapKeyBirth);
642642

643+
std::set<CScriptID> scripts = pwallet->GetCScripts();
644+
643645
// sort time/key pairs
644646
std::vector<std::pair<int64_t, CKeyID> > vKeyBirth;
645647
for (const auto& entry : mapKeyBirth) {
@@ -694,6 +696,15 @@ UniValue dumpwallet(const JSONRPCRequest& request)
694696
}
695697
}
696698
file << "\n";
699+
for (const CScriptID &scriptid : scripts) {
700+
CScript script;
701+
std::string address = EncodeDestination(scriptid);
702+
if(pwallet->GetCScript(scriptid, script)) {
703+
file << strprintf("%s 0 script=1", HexStr(script.begin(), script.end()));
704+
file << strprintf(" # addr=%s\n", address);
705+
}
706+
}
707+
file << "\n";
697708
file << "# End of dump\n";
698709
file.close();
699710

0 commit comments

Comments
 (0)