From 9f821347793b6523fd0b609a198e0e83e76affbf Mon Sep 17 00:00:00 2001 From: aideca Date: Fri, 10 Feb 2017 12:47:53 +0000 Subject: [PATCH 1/2] Add friendly output to dumpwallet refs #9564 --- src/wallet/rpcdump.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp index 7ff9e7ae58..60666718e3 100644 --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -579,7 +579,11 @@ UniValue dumpwallet(const JSONRPCRequest& request) "dumpwallet \"filename\"\n" "\nDumps all wallet keys in a human-readable format.\n" "\nArguments:\n" - "1. \"filename\" (string, required) The filename\n" + "1. \"filename\" (string, required) The filename with path (either absolute or relative to bitcoind)\n" + "\nResult:\n" + "{ (json object)\n" + " \"filename\" : { (string) The filename with full absolute path\n" + "}\n" "\nExamples:\n" + HelpExampleCli("dumpwallet", "\"test\"") + HelpExampleRpc("dumpwallet", "\"test\"") @@ -590,7 +594,9 @@ UniValue dumpwallet(const JSONRPCRequest& request) EnsureWalletIsUnlocked(pwallet); std::ofstream file; - file.open(request.params[0].get_str().c_str()); + boost::filesystem::path filepath = request.params[0].get_str(); + filepath = boost::filesystem::absolute(filepath); + file.open(filepath.string().c_str()); if (!file.is_open()) throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot open wallet dump file"); @@ -655,7 +661,11 @@ UniValue dumpwallet(const JSONRPCRequest& request) file << "\n"; file << "# End of dump\n"; file.close(); - return NullUniValue; + + UniValue reply(UniValue::VOBJ); + reply.push_back(Pair("filename", filepath.string())); + + return reply; } From 164019d611e9d67fd3e66eb7f18033c9249764d4 Mon Sep 17 00:00:00 2001 From: aideca Date: Sat, 11 Feb 2017 05:43:28 +0000 Subject: [PATCH 2/2] Add dumpwallet output test --- test/functional/wallet-dump.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/functional/wallet-dump.py b/test/functional/wallet-dump.py index 8876f935a4..352add28fb 100755 --- a/test/functional/wallet-dump.py +++ b/test/functional/wallet-dump.py @@ -4,6 +4,8 @@ # file COPYING or http://www.opensource.org/licenses/mit-license.php. """Test the dumpwallet RPC.""" +import os + from test_framework.test_framework import BitcoinTestFramework from test_framework.util import (start_nodes, start_node, assert_equal, bitcoind_processes) @@ -82,7 +84,8 @@ class WalletDumpTest(BitcoinTestFramework): self.nodes[0].keypoolrefill() # dump unencrypted wallet - self.nodes[0].dumpwallet(tmpdir + "/node0/wallet.unencrypted.dump") + result = self.nodes[0].dumpwallet(tmpdir + "/node0/wallet.unencrypted.dump") + assert_equal(result['filename'], os.path.abspath(tmpdir + "/node0/wallet.unencrypted.dump")) found_addr, found_addr_chg, found_addr_rsv, hd_master_addr_unenc = \ read_dump(tmpdir + "/node0/wallet.unencrypted.dump", addrs, None)