Skip to content
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

Merged
merged 2 commits into from Jun 5, 2017
Merged

Add friendly output to dumpwallet #9740

merged 2 commits into from Jun 5, 2017

Conversation

aideca
Copy link
Contributor

@aideca aideca commented Feb 11, 2017

Add friendly output to dumpwallet #9564.

  • Add help message.
  • Show created dumpfile path.
  • Add rpc test.

@@ -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);
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor

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).

Copy link
Member

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...

@maflcko
Copy link
Member

maflcko commented Feb 11, 2017

utACK 48abaea

@JeremyRubin
Copy link
Contributor

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).

@laanwj laanwj added this to the 0.15.0 milestone Feb 14, 2017
@laanwj
Copy link
Member

laanwj commented Feb 14, 2017

This seems ready to be merged once 0.14 is branched off.

Copy link
Contributor

@jnewbery jnewbery left a 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.

"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"
Copy link
Contributor

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"

@@ -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"
Copy link
Contributor

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?

@aideca
Copy link
Contributor Author

aideca commented Mar 12, 2017

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.

@achow101
Copy link
Member

Needs rebase.

@aideca
Copy link
Contributor Author

aideca commented Apr 13, 2017

Thanx! rebased & fixuped.

@paveljanik
Copy link
Contributor

ACK 164019d

@laanwj laanwj merged commit 164019d into bitcoin:master Jun 5, 2017
@laanwj laanwj mentioned this pull request Jun 5, 2017
12 tasks
laanwj added a commit that referenced this pull request Jun 5, 2017
164019d Add dumpwallet output test (aideca)
9f82134 Add friendly output to dumpwallet refs #9564 (aideca)

Tree-SHA512: 913fcf18d42eebe34173f1f2519973494b1ad2d86d125ff4bf566d6c64aa501c02f8831e6f44812cd87a46916f61c6f510146af406865b31856d8336c173569f
@cdecker cdecker mentioned this pull request Sep 3, 2017
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jun 13, 2020
164019d Add dumpwallet output test (aideca)
9f82134 Add friendly output to dumpwallet refs bitcoin#9564 (aideca)

Tree-SHA512: 913fcf18d42eebe34173f1f2519973494b1ad2d86d125ff4bf566d6c64aa501c02f8831e6f44812cd87a46916f61c6f510146af406865b31856d8336c173569f
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jun 13, 2020
164019d Add dumpwallet output test (aideca)
9f82134 Add friendly output to dumpwallet refs bitcoin#9564 (aideca)

Tree-SHA512: 913fcf18d42eebe34173f1f2519973494b1ad2d86d125ff4bf566d6c64aa501c02f8831e6f44812cd87a46916f61c6f510146af406865b31856d8336c173569f
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jun 17, 2020
164019d Add dumpwallet output test (aideca)
9f82134 Add friendly output to dumpwallet refs bitcoin#9564 (aideca)

Tree-SHA512: 913fcf18d42eebe34173f1f2519973494b1ad2d86d125ff4bf566d6c64aa501c02f8831e6f44812cd87a46916f61c6f510146af406865b31856d8336c173569f
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jun 18, 2020
164019d Add dumpwallet output test (aideca)
9f82134 Add friendly output to dumpwallet refs bitcoin#9564 (aideca)

Tree-SHA512: 913fcf18d42eebe34173f1f2519973494b1ad2d86d125ff4bf566d6c64aa501c02f8831e6f44812cd87a46916f61c6f510146af406865b31856d8336c173569f
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants