File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 14
14
#include < boost/date_time/posix_time/posix_time.hpp>
15
15
#include < boost/variant/get.hpp>
16
16
#include < boost/algorithm/string.hpp>
17
+ #include < boost/filesystem.hpp>
17
18
18
19
using namespace std ;
19
20
@@ -305,12 +306,20 @@ UniValue dumpwallet(const UniValue& params, bool fHelp)
305
306
" \n "
306
307
" <filename> -> filename to dump wallet to\n "
307
308
" \n "
308
- " Dumps all wallet keys in a human-readable format\n " );
309
+ " Dumps all wallet keys in a human-readable format into the specified file.\n "
310
+ " If a path is not specified in the filename, the data directory is used." );
309
311
310
312
EnsureWalletIsUnlocked ();
311
313
314
+ boost::filesystem::path PathForDump = boost::filesystem::path (params[0 ].get_str ());
315
+ boost::filesystem::path DefaultPathDataDir = GetDataDir ();
316
+
317
+ // If provided filename does not have a path, then append parent path, otherwise leave alone.
318
+ if (PathForDump.parent_path ().empty ())
319
+ PathForDump = DefaultPathDataDir / PathForDump;
320
+
312
321
ofstream file;
313
- file.open (params[ 0 ]. get_str ().c_str ());
322
+ file.open (PathForDump. string ().c_str ());
314
323
if (!file.is_open ())
315
324
throw JSONRPCError (RPC_INVALID_PARAMETER, " Cannot open wallet dump file" );
316
325
You can’t perform that action at this time.
0 commit comments