-
Notifications
You must be signed in to change notification settings - Fork 37.7k
rpc: add ability to export/import descriptor files in listdescriptors
and importdescriptors
#25747
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
author: Luke Dashjr <luke-jr+git@utopios.org>
This changes `listdescriptors` to accept `options` parameter but retains compatibility with the previous `private` parameter.
What's the point? Why can't you just redirect |
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. |
@kristapsk with #25757, perhaps the purpose of this PR has become clearer. From the #25757 description:
Without these PRs, the user can manually create a file from the And this also opens the way to add the functionality of importing descriptors from files in the GUI, |
Concept ACK considering #25757 exists. I think you should add the other PR's commits to this one. |
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 was able to save the descriptor file with
./src/bitcoin-cli -regtest -rpcwallet=test listdescriptors '{"save_to_file": "my_desc"}'
But I feel like the syntax is a bit much, is there a way to simplify it?
In this case, it would be simplier to just do ./src/bitcoin-cli -regtest -rpcwallet=test listdescriptors > my_desc
desc_file = os.path.join(node.datadir, 'desc.json') | ||
assert_equal({ | ||
'wallet_name': 'w2', | ||
'descriptor_file': desc_file | ||
}, wallet.listdescriptors({'save_to_file': desc_file})) | ||
|
||
with open(desc_file, encoding="utf8") as json_file: | ||
assert_equal(expected['descriptors'], json.load(json_file)) | ||
|
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 add a case when the file already exists?
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 dd96b3d.
This changes `importdescriptors` to accept `options` parameter but maintains compatibility with the previous `requests` parameter.
save_to_file
to listdescriptors
RPClistdescriptors
and importdescriptors
@aureleoules As suggested, I merged the other PR's commit to this one. Note that The |
Concept NACK. Using shell redirection is enough for CLI. Probably this change is better fitting with the GUI. |
Concept NACK. I think we're trying to eliminate file-based RPC methods? At the very least, we shouldn't make RPC methods that do both file-based and non-file-based access... |
This PR assumes that using descriptor files is a less error-prone and less manual way of creating watch-only wallets than the current way. If it is not the case, what is the current workflow to create a watch-only wallet ? |
For that use case, I would suggest a RPC method that makes a watch-only copy of a loaded wallet. |
🐙 This pull request conflicts with the target branch and needs rebase. Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a "draft". |
This PR does not seem to have conceptual support. Please leave a comment if you would like this to be reopened. |
This PR adds a new parameter
save_to_file
tolistdescriptors
RPC, allowing the user to save the descriptors directly to a file and also adds a new parameterdesriptor_file
toimportdescriptors
RPC, allowing the user to import the descriptors directly from a file.The first and second commits add the
options
parameter in a way that maintains compatibility with the previousprivate
parameter.With this PR, exporting / importing descriptors and creating watch-only wallet is as simple as:
Without this PR, the user can manually create a file from the
listdescriptors
output or usejq
to extract thedescriptor
field fromlistdescriptors
but the idea here is to make things more automated and standardized.And this also opens the way to add the functionality of importing descriptors from files in the GUI,