Add friendly output to dumpwallet #9564.
- Add help message.
- Show created dumpfile path.
- Add rpc test.
575@@ -572,7 +576,9 @@ UniValue dumpwallet(const JSONRPCRequest& request)
576 EnsureWalletIsUnlocked();
577
578 ofstream file;
579- file.open(request.params[0].get_str().c_str());
580+ boost::filesystem::path filepath = request.params[0].get_str();
581+ filepath = absolute(filepath);
Also is there a “namespaced” name for this function? E.g., boost::filesystem::absolute? It’d be good to use the fully qualified name, otherwise it’s difficult to hunt down such dependencies/lookup documentation.
I don’t have a firm opinion to add to the above conversation though, except that I would add a way to get dumpwallet to serialize results across network (although dangerous if unencrypted/authenticated link) in case the user wants the wallet dump locally (RPC may even be called on a different machine let alone different directory as @aideca points out).
Maybe an absolute path or if not, relative to the data-dir? If possible?
Good idea. It’s our (effective) convention for command line arguments as well. I think it would be good to chdir
the daemon to the data directory at start. This also avoids issues with the daemon holding on to resources (e.g. the starting directory could be deleted later) discussed in #8278.
RPC may even be called on a different machine
A way to dump the wallet over the network could be useful. The practical problem is that there is currently no way to do streaming writes to the network from RPC code, so the entire wallet would have to be dumped in memory, which would result in huge memory and parsing/generating overhead. I looked at streaming to the HTTP in a different context here: #7759.
Also yes there’s a bit of a security concern though it’s no different from dumpprivkey and friends…
utACK 48abaea.
I also want to explicitly approve of the returning of a JSON rather than a plain string, it may be useful (in future work?) to augment this call’s return value with other data as well (e.g., which user owns the dump file, how many keys were dumped, etc).
560@@ -561,7 +561,11 @@ UniValue dumpwallet(const JSONRPCRequest& request)
561 "dumpwallet \"filename\"\n"
562 "\nDumps all wallet keys in a human-readable format.\n"
563 "\nArguments:\n"
564- "1. \"filename\" (string, required) The filename\n"
565+ "1. \"filename\" (string, required) The filename (if not full path, relative to bitcoind path)\n"
566+ "\nResult:\n"
567+ "{ (json object)\n"
568+ " \"dumpfilepath\" : { (string) The filename\n"
560@@ -561,7 +561,11 @@ UniValue dumpwallet(const JSONRPCRequest& request)
561 "dumpwallet \"filename\"\n"
562 "\nDumps all wallet keys in a human-readable format.\n"
563 "\nArguments:\n"
564- "1. \"filename\" (string, required) The filename\n"
565+ "1. \"filename\" (string, required) The filename (if not full path, relative to bitcoind path)\n"
Definite concept ACK. A couple of nitty comments about language.
I agree that it’d be better to change the default location to be the bitcoin datadir if possible, but that might be out of scope of this small PR.
Thank you for your comments and sorry for my late reply.
I just updated help text and qualified function name. “chdir daemon to the data-dir” and “dump the wallet over the network” are quite interesting. But it’s out of scope of this PR as jnewbery said.
aideca
laanwj
jonasschnelli
JeremyRubin
MarcoFalke
jnewbery
achow101
paveljanik
Labels
RPC/REST/ZMQ
Milestone
0.15.0