-
Notifications
You must be signed in to change notification settings - Fork 38.8k
rpc: alias helper #19957
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
rpc: alias helper #19957
Conversation
e01eaff to
97e383e
Compare
|
Concept ACK |
Sjors
left a comment
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.
Looks good. No strong opinion on handwaving away the constness in 97e383ef829523130f192aebf67c71cc7e10d975
6828ba5 to
06dca23
Compare
06dca23 to
9056b07
Compare
|
Concept ACK, not sure about the approach. I think that we could improve consistency if internally all keys are transformed like |
|
@promag That sounds like a good idea but people pointed out that it could be potentially riskful (use the |
|
I am wondering if the aliases can be passed in via RPCArg and the merging be done by RPCHelpMan before dispatching the request to the method. |
|
@MarcoFalke That sounds like a good idea. I can think of a number of ways to do that:
I'm leaning towards number 2 on that list but may change my mind if it turns out to be ugly. |
|
One issue with doing it in RPCArg is that it requires duplication e.g. for callers of bitcoin/src/wallet/rpcwallet.cpp Lines 2956 to 2962 in 9056b07
|
|
Oh it looks like RPCArg already has
The PRCArg vector or initializer list is a C++ struct, so it can be easily deduplicated and re-used. Even parts of it, which can be concatenated with our |
|
@MarcoFalke The way I understood it was that you'd provide the arguments before the RPCHelper cleaned up. In the FundTransaction case, the RPCHelper has already cleaned once, so you'd have to do it twice. Which sounds kind of similar to what I'm doing here already. |
The suggestion is to just transform args and json keys, not command names or arg values. |
|
@promag Ah, right. |
Introduce a new "check alias" helper for RPC commands, which checks and moves the values into the "primary" key.
The first commit simply
pushKV's the value from the alias, if set, whereas the second commit const-casts the keys vector in UniValue and modifies that directly, i.e. "rename". Some people (cough sipa cough) might object to the approach, so I'm splitting into two commits.This is partially also a cleanup of #16378.