New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add friendly output to dumpwallet #9740
Conversation
src/wallet/rpcdump.cpp
Outdated
@@ -572,7 +576,9 @@ UniValue dumpwallet(const JSONRPCRequest& request) | |||
EnsureWalletIsUnlocked(); | |||
|
|||
ofstream file; | |||
file.open(request.params[0].get_str().c_str()); | |||
boost::filesystem::path filepath = request.params[0].get_str(); | |||
filepath = absolute(filepath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. Shouldn't it be only accepting absolute paths in the first place?
Otherwise it will depend on the directory that bitcoind happens to have been started in, that'd be pretty crappy API design.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanx.
IMO, it is better to inform users that path argument is from the viewpoint of bitcoind either absolute nor relative.
The problem is that users expects path argument is the viewpoint of RPC-caller, but actually the one of bitcoind. The former is not same as the latter even if absolute path if they executed on different docker.
So i added doc and output at this time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe an absolute path or if not, relative to the data-dir? If possible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
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). |
This seems ready to be merged once 0.14 is branched off. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
src/wallet/rpcdump.cpp
Outdated
"1. \"filename\" (string, required) The filename (if not full path, relative to bitcoind path)\n" | ||
"\nResult:\n" | ||
"{ (json object)\n" | ||
" \"dumpfilepath\" : { (string) The filename\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to use the name "filename" (since this isn't just the path). You could change the help text to say "The filename with full absolute path"
src/wallet/rpcdump.cpp
Outdated
@@ -561,7 +561,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 (if not full path, relative to bitcoind path)\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The text is a bit clunky here. Perhaps "The filename with path (either absolute or relative to bitcoind)" is better?
Thank you for your comments and sorry for my late reply. I just updated help text and qualified function name. |
Needs rebase. |
Thanx! rebased & fixuped. |
ACK 164019d |
164019d Add dumpwallet output test (aideca) 9f82134 Add friendly output to dumpwallet refs bitcoin#9564 (aideca) Tree-SHA512: 913fcf18d42eebe34173f1f2519973494b1ad2d86d125ff4bf566d6c64aa501c02f8831e6f44812cd87a46916f61c6f510146af406865b31856d8336c173569f
164019d Add dumpwallet output test (aideca) 9f82134 Add friendly output to dumpwallet refs bitcoin#9564 (aideca) Tree-SHA512: 913fcf18d42eebe34173f1f2519973494b1ad2d86d125ff4bf566d6c64aa501c02f8831e6f44812cd87a46916f61c6f510146af406865b31856d8336c173569f
164019d Add dumpwallet output test (aideca) 9f82134 Add friendly output to dumpwallet refs bitcoin#9564 (aideca) Tree-SHA512: 913fcf18d42eebe34173f1f2519973494b1ad2d86d125ff4bf566d6c64aa501c02f8831e6f44812cd87a46916f61c6f510146af406865b31856d8336c173569f
164019d Add dumpwallet output test (aideca) 9f82134 Add friendly output to dumpwallet refs bitcoin#9564 (aideca) Tree-SHA512: 913fcf18d42eebe34173f1f2519973494b1ad2d86d125ff4bf566d6c64aa501c02f8831e6f44812cd87a46916f61c6f510146af406865b31856d8336c173569f
Add friendly output to dumpwallet #9564.