-
Notifications
You must be signed in to change notification settings - Fork 37.7k
rpc: fix data optionality for RPC calls. #27829
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
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsNo conflicts as of last run. |
I get that this is confusing, but this change isn't correct. The Maybe it's worth elaborating in the prose text above? |
Understood you're saying the change isn't correct. How would someone properly indicate the "data" is optional if not specifying it as optional? The parent output is required and some of it's children elements are optional. From my perspective what I would expect to see is a required "outputs" and within outputs there being required and optional fields. For instance: Full text of for outputs as reference:
|
The |
Let me rephrase my question: Does there need to be a new idea of specifying whether the (json object) itself is optional? Edit: Is this what "prose text" means? |
9235d06
to
30acffa
Compare
@sipa, edited the commit. Something like this look good? |
ACK 30acffa |
src/rpc/rawtransaction.cpp
Outdated
@@ -149,6 +149,7 @@ static std::vector<RPCArg> CreateTxDoc() | |||
}, | |||
{"outputs", RPCArg::Type::ARR, RPCArg::Optional::NO, "The outputs (key-value pairs), where none of the keys are duplicated.\n" | |||
"That is, each address can only appear once and there can only be one 'data' object.\n" | |||
"Either {\"data\"} or {\"address\"}, are required, but specifying both is optional.\n" |
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 find this wording confusing. Do you mean to say that the user can combine data and address entries? Or that you can provide data or an address directly without putting "data" or "address" in front of it? (but then how it does it know the difference?)
Examples can be helpful. Maybe say "see send RPC for examples" and then expand the send
RPC docs with said examples.
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 you mean to say that the user can combine data and address entries?
The outputs array, outputs []
, must contain at minimum either an obj containing {"address" ".."}
or an obj containing {"data": ".."}
. You can also specify both, but you must have at least one.
I'm reading over this block of help text again.
(json array, required) The outputs (key-value pairs), where none of the keys are duplicated.
That is, each address can only appear once and there can only be one 'data' object.
For compatibility reasons, a dictionary, which holds the key-value pairs directly, is also
accepted as second parameter.
just using separate objs
[
{
"bc1address1":"0.01",
},
{
"bc1address2":"0.02",
},
{
"data":"ff00ff00ff"
}
]
or...
Also note:
a dictionary, which holds the key-value pairs directly, is also accepted as second parameter.
I believe this is saying you can also do something like:
[
{
"bc1address1":"0.01",
"bc1address2":"0.02",
"data":"ff00ff00ff"
}
]
I think this style is for compatibility reasons per docs, so I'm guessing it's preferred/future proof to break everything out into individual objects. Please correct me if I'm wrong!
Current:
"Either {\"data\"} or {\"address\"}, are required, but specifying both is optional.\n"
Something like this be better?:
"At least one object containing the key \"data\" or \"address\" is required.\n"
@Sjors Not sure if you saw my response above, let me know what you think, we can close this out if there's no appetite for this small change. |
I think you have correctly identified that this text could be improved and we should move forward with the PR. |
@miketwenty1 Needs rebase. Are you still working on this? |
79dc796
to
aaddf50
Compare
@jonatack thanks for the bump. Open for feedback. I took @murchandamus suggestions where it seemed appropriate. |
aaddf50
to
27b168b
Compare
I think the CI failure is unrelated to your change (see #28027). |
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.
tACK 27b168b
I didn't think about it very deeply, but the new text is an improvement in clarity.
I think the CI failure is unrelated to your change (see #28027, cc @achow101).
ACK 27b168b |
27b168b Update help text for spend and rawtransaction rpcs (Michael Tidwell) Pull request description: The "data" field without outputs was marked as "required" in the help docs when using bitcoin-cli. This field when left off worked as an intended optional OP_RETURN. closes bitcoin#27828. Motivation: It is hard to understand that "data" is actually optional for commands like `createpsbt` and `walletcreatefundedpsbt`. ACKs for top commit: achow101: ACK 27b168b Sjors: tACK 27b168b Tree-SHA512: 235e7ed4af69880880c04015b3f7de72c8f31ae035485c4c64c483e282948f3ea3f1eef16f15e260a1aaf21114150713516ba6a99967ccad9ecd91ff67cb0450
The "data" field without outputs was marked as "required" in the help docs when using bitcoin-cli. This field when left off worked as an intended optional OP_RETURN. closes #27828.
Motivation: It is hard to understand that "data" is actually optional for commands like
createpsbt
andwalletcreatefundedpsbt
.