-
Notifications
You must be signed in to change notification settings - Fork 37.7k
util, rpc: Add parameter to deriveaddresses
to display address information
#25366
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
Conversation
That seems dangerous as descriptor wallets (by default) use unhardened derivation, so leaking one derived private key is sufficient for an attacker to compute every private key. The choice to only allow exporting the xprv was deliberate, as with that, it'd be more obvious to users that what was being revealed was their entire wallet. Also: what does this do if multiple keys are involved? |
@sipa Yes, it's a good point. I initially considered that this might be as risky as running I changed the code to support multiple keys (and added functional tests for this case). Example:
|
I think the option for private keys should be separate from the option for other details. I am also hesitant about outputting private keys because of the unhardened derivation problem. |
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
I removed the private keys from RPC result as it is raising concerns about unhardened derivation problem. I think that separating private key option from the
|
(Arguably derivation means these "private keys" are really just a mid-state of the signature algorithm, and the entire wallet uses a single private key) |
src/rpc/output_script.cpp
Outdated
@@ -237,12 +237,30 @@ static RPCHelpMan deriveaddresses() | |||
{ | |||
{"descriptor", RPCArg::Type::STR, RPCArg::Optional::NO, "The descriptor."}, | |||
{"range", RPCArg::Type::RANGE, RPCArg::Optional::OMITTED_NAMED_ARG, "If a ranged descriptor is used, this specifies the end or the range (in [begin,end] notation) to derive."}, | |||
{"details", RPCArg::Type::BOOL, RPCArg::Default{false}, "If true, the keys of each address will be shown. Private keys will be shown only if the descriptor contains xpriv."}, |
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.
Booleans should typically not be positional arguments, but instead members of an "options" Object.
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.
Done in 544c2cc. Thanks for review.
This PR does not seem to have conceptual support. Please leave a comment if you would like this to be reopened. |
This PR adds the
details
parameter toderiveaddresses
RPC.With this option enabled, this RPC will return the private and public key and the output script for each address, as seen below.
Motivation: I needed to retrieve the private key from an address generated by a descriptor wallet, but
dumpprivkey
is not available for new wallets.This change allows extracting this type of information from an address generated by a descriptor.
If the descriptor contains
xpub
instead ofxpriv
, theprivate_key
field will be omitted.If the descriptor is non-ranged, the
index
field will be omitted.This PR does not change the current behavior if the new parameter is not used.
Example: