-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Allow simple multiwallet rpc calls #18734
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
Allow simple multiwallet rpc calls #18734
Conversation
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 still don't get what are the use cases beside the obvious getbalances
. Not sure about mutation calls, like send.
Does it make sense to have one unified view in qt instead? That view could show all loaded wallets + their balances, flags etc.
@@ -355,6 +411,10 @@ static CTransactionRef SendMoney(interfaces::Chain::Lock& locked_chain, CWallet | |||
|
|||
static UniValue sendtoaddress(const JSONRPCRequest& request) | |||
{ | |||
if (IsMultiwalletJSONRPCRequest(request)) { | |||
return ExecForeachWalletJSONRPCRequest(request, &sendtoaddress); |
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.
Do we want to incur in double payments?
I think @promag has a good point. Apart from |
Fair point. I think this is why I would favour this approach which can be implemented per call. I guess there are some edge cases for other calls like |
Instead of the not-quite-regex-but-still-a-pattern I'd prefer the caller to explicitly list the wallets. I think requiring that the user calls Also, the returned array could be a json dict with keys being the wallet name. That is easier to parse at the client. |
Probably meh to not support a pure "
Good point. A downside could be the identifiability of an error (you already don't get the http response code). |
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. |
listing transactions, coins. This what I currently do in scripts like btc-coins, but the round-trips are a bit slow with many wallets
good point, that seems like a footgun. seems like this is more useful for not-mutating calls
I think that would be useful, but runs into similar issues when creating transactions where you probably want to know what wallet you're creating from. So maybe it would make sense to limit it to balances and maybe transactions in a unified qt view? The logic for this could be tricky.
👍
👍 |
if (IsMultiwalletJSONRPCRequest(request)) { | ||
return ExecForeachWalletJSONRPCRequest(request, &importprivkey); | ||
} |
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.
Can we avoid adding this to every wallet function?
if (IsMultiwalletJSONRPCRequest(request)) { | ||
return ExecForeachWalletJSONRPCRequest(request, &dumpprivkey); | ||
} |
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.
Something like dumpprivkey
should probably just return the first result it gets (and ignore all the failures)?
Any reason not to return {
"walletname": result,
...
}
```? |
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.
Tested Concept ACK 57b449d rebased on current master
-
I really like the
rpcwallet=*
wildcard feature; it would be my default use as a human user. -
The ability to specify multiple wallets with
rpcwallet=
would be good also, especially for RPC clients/scripts, as a logical follow-up. -
Agree with the idea of initially adding this only for get*, list*, and maybe
keypoolrefill
calls. -
Agree with the suggestions to try returning this as a JSON dict of objects with wallet names as keys.
UniValue ExecForeachWalletJSONRPCRequest(JSONRPCRequest mutable_request, const rpcfn_type& func) { | ||
std::string search_string = URL_DECODE(mutable_request.URI.substr(WALLET_ENDPOINT_BASE.size())); | ||
const size_t pos = search_string.find('*'); | ||
assert(pos != std::string::npos); // we must have checked earlier for an asterisk |
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.
Needed to appease test/lint/lint-assertions.sh
- assert(pos != std::string::npos); // we must have checked earlier for an asterisk
+ CHECK_NONFATAL(pos != std::string::npos); // we must have checked earlier for an asterisk
Going to close this as "Up for Grabs" for now. |
Would fix #18715.
See discussion in #18453.
Currently, batching RPC requests across wallets does not work due to the fact that each wallet has its own endpoint.
This PR allows using a simple wildcard approach for the wallet endpoint (
/wallet/*/
).Using
bitcoin-cli
-rpcwallet="*"
or-rpcwallet="pattern*
works with this PR.This PR is a simple approach that allows detailed control on a per call basis. Some calls probably need special logic (
rescanblockchain
). Some calls make not much sense across wallets (dumpwallet
orbackupwallet
as example).The output (or error/s) will be bundles as json array with a dictionary for each wallet:
Alternatives:
Todo: