File tree 2 files changed +17
-4
lines changed
2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -603,7 +603,11 @@ UniValue dumpwallet(const JSONRPCRequest& request)
603
603
" dumpwallet \" filename\"\n "
604
604
" \n Dumps all wallet keys in a human-readable format.\n "
605
605
" \n Arguments:\n "
606
- " 1. \" filename\" (string, required) The filename\n "
606
+ " 1. \" filename\" (string, required) The filename with path (either absolute or relative to bitcoind)\n "
607
+ " \n Result:\n "
608
+ " { (json object)\n "
609
+ " \" filename\" : { (string) The filename with full absolute path\n "
610
+ " }\n "
607
611
" \n Examples:\n "
608
612
+ HelpExampleCli (" dumpwallet" , " \" test\" " )
609
613
+ HelpExampleRpc (" dumpwallet" , " \" test\" " )
@@ -614,7 +618,9 @@ UniValue dumpwallet(const JSONRPCRequest& request)
614
618
EnsureWalletIsUnlocked (pwallet);
615
619
616
620
std::ofstream file;
617
- file.open (request.params [0 ].get_str ().c_str ());
621
+ boost::filesystem::path filepath = request.params [0 ].get_str ();
622
+ filepath = boost::filesystem::absolute (filepath);
623
+ file.open (filepath.string ().c_str ());
618
624
if (!file.is_open ())
619
625
throw JSONRPCError (RPC_INVALID_PARAMETER, " Cannot open wallet dump file" );
620
626
@@ -679,7 +685,11 @@ UniValue dumpwallet(const JSONRPCRequest& request)
679
685
file << " \n " ;
680
686
file << " # End of dump\n " ;
681
687
file.close ();
682
- return NullUniValue;
688
+
689
+ UniValue reply (UniValue::VOBJ);
690
+ reply.push_back (Pair (" filename" , filepath.string ()));
691
+
692
+ return reply;
683
693
}
684
694
685
695
Original file line number Diff line number Diff line change 4
4
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
5
"""Test the dumpwallet RPC."""
6
6
7
+ import os
8
+
7
9
from test_framework .test_framework import BitcoinTestFramework
8
10
from test_framework .util import (assert_equal , bitcoind_processes )
9
11
@@ -82,7 +84,8 @@ def run_test (self):
82
84
self .nodes [0 ].keypoolrefill ()
83
85
84
86
# dump unencrypted wallet
85
- self .nodes [0 ].dumpwallet (tmpdir + "/node0/wallet.unencrypted.dump" )
87
+ result = self .nodes [0 ].dumpwallet (tmpdir + "/node0/wallet.unencrypted.dump" )
88
+ assert_equal (result ['filename' ], os .path .abspath (tmpdir + "/node0/wallet.unencrypted.dump" ))
86
89
87
90
found_addr , found_addr_chg , found_addr_rsv , hd_master_addr_unenc = \
88
91
read_dump (tmpdir + "/node0/wallet.unencrypted.dump" , addrs , None )
You can’t perform that action at this time.
0 commit comments