-
Notifications
You must be signed in to change notification settings - Fork 37.7k
[rpc] Verbose flags for chaining and scripting #10877
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
Code wise, this is more of a refactor (much more lines are touch for refactoring then the intended feature). Wouldn't' the non verbose mode (== directly return hex) include some risks because one my miss important errors (sent back through the "error" json array/object)? |
@jonasschnelli For |
@kallewoof your right about I think its probably acceptable to suppress those errors, but maybe we should mention that in the help description. |
I'm actually confused why the sign code doesn't throw an error in the case you mentioned. Why would it continue when the tx appears to be broken? Hm.. |
Does this sounds more like a bash mode for cli than verbose option? Edit: Do we want this option in the RPC interface? |
Another suggestion to ease chaining and eventually reduce the transmitted data is to specify a json path to filter the output. For instance:
Compared to jq, it has the advantage of server side filtering. But I guess it is too much for core. |
I chose verbose because if you look at e.g. |
IMO verbose is unclear and usually means more detailed logs which is unrelated. Also, I think we should discourage chaining these calls because the middle results/errors are important and should be acknowledge/logged/handled/whatever. As you said, it's still doable using other tools. Not sure about others, but for me it's a NACK. |
Verbose is not restricted to logs, in my world. The word itself simply means "using or expressed in more words than are needed" which I think fits very nicely with the use case here (you don't need the complete flag for signing, for instance; it's just a helpful thing to have). Yes, it's doable using other tools, but this dependency is rather superfluous considering the relatively small addition (style fixes outweighs the code itself) means less work for the node (a string rather than a JSON object). It's ultimately ~2-3 lines per RPC call to remove a potential dependency on external tools. I think that's worth something personally. |
Concept ACK. I think chaining commands together without intermediate error checking like this is definitely dangerous and poor practice, but there are probably legitimate use-cases for testing, etc. Thinking out loud: verbosity is a very common option for RPCs. Perhaps we should consider making it a query string in the URL rather than adding parameters to every RPC that requires it. Maybe that's not practical, but worth considering. |
9f2228c
to
a2c1bb3
Compare
a2c1bb3
to
ee5e3ef
Compare
ab02248
to
6ec50f8
Compare
6ec50f8
to
acbe256
Compare
acbe256
to
317f1d2
Compare
Rebased, and dropped |
One NACK, one concept ACK. I think it's not worth keeping this around. |
[Reviewer hint: use ?w=1 to avoid seeing a bunch of indentation changes.]
Right now, some RPC commands return JSON data along with transaction hex strings, which means scripting and/or chaining needs to do JSON processing before being able to use the resulting transaction data. For use cases where you don't need the extra info, this PR adds a verbose=false mode (default true) which returns only the transaction hex string.
This means you can now do things like this:
This is also useful in scripts, where you perform some operation on a transaction and store the tx itself in a variable. Before you would need e.g.
jq
or some other tool to do this.Edit:
signrawtransaction
has been deprecated; I chose to add verbose to the new commandswithkey
/withwallet
but not tosignrawtransaction
.