-
Notifications
You must be signed in to change notification settings - Fork 37.8k
[RPC] verifytxoutproof returns object including blockhash #11120
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
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.
utACK d77cded0b1d026f030ee424b89a01cfd6b7b9000
src/rpc/rawtransaction.cpp
Outdated
"\nArguments:\n" | ||
"1. \"proof\" (string, required) The hex-encoded proof generated by gettxoutproof\n" | ||
"\nResult:\n" | ||
"[\"txid\"] (array, strings) The txid(s) which the proof commits to, or empty array if the proof is invalid\n" | ||
"\nResult: (or empty if proof is invalid)\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.
Remove or
maybe? I.e. Result: (empty if proof is invalid)\n
d77cded
to
e7f9824
Compare
updated with nit fix |
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.
Concept ACK.
src/rpc/rawtransaction.cpp
Outdated
"\nVerifies that a proof points to a transaction in a block, returning the transaction it commits to\n" | ||
"and throwing an RPC error if the block is not in our best chain\n" | ||
"\nVerifies that a proof points to a transaction in a block, returning the blockhash and transactions it commits to\n" | ||
", throwing an RPC error if the block is not in our best chain\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.
Nit, ,
in the above line?
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 gonna mention that but chose not to. Agree though, I think that would look better.
src/rpc/rawtransaction.cpp
Outdated
@@ -258,19 +258,23 @@ UniValue verifytxoutproof(const JSONRPCRequest& request) | |||
if (request.fHelp || request.params.size() != 1) | |||
throw std::runtime_error( | |||
"verifytxoutproof \"proof\"\n" | |||
"\nVerifies that a proof points to a transaction in a block, returning the transaction it commits to\n" | |||
"and throwing an RPC error if the block is not in our best chain\n" | |||
"\nVerifies that a proof points to a transaction in a block, returning the blockhash and transactions it commits to\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.
... the block hash and ...
src/rpc/rawtransaction.cpp
Outdated
@@ -283,7 +287,10 @@ UniValue verifytxoutproof(const JSONRPCRequest& request) | |||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found in chain"); | |||
|
|||
for (const uint256& hash : vMatch) |
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.
Nit, add curly braces.
e7f9824
to
57d35ff
Compare
fixed @promag nits, curly-bracketed the surrounding statements since I'm touching it already |
src/rpc/rawtransaction.cpp
Outdated
for (const uint256& hash : vMatch) | ||
res.push_back(hash.GetHex()); | ||
res.push_back(Pair("txids", txids)); | ||
res.push_back(Pair("blockhash", merkleBlock.header.GetHash().GetHex())); |
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.
Push blockhash
first.
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'm curious about the reason for this request. Alphabetical ordering?
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.
Also matches the documentation above.
57d35ff
to
9efd4fe
Compare
9efd4fe
to
a371696
Compare
rebased, re-added legacy behavior under deprecation |
ping @kallewoof |
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.
re-utACK a3716960de5555572408efdab4eba75484c8c1e3
src/rpc/rawtransaction.cpp
Outdated
@@ -294,6 +294,8 @@ UniValue verifytxoutproof(const JSONRPCRequest& request) | |||
" \"blockhash\" (string) The blockhash the included proof commits to\n" | |||
" [\"txid\"] (array, strings) The txid(s) which the proof commits to\n" | |||
"}\n" | |||
"\nResult: (DEPRECATED. To see this result in v0.17 instead, please start bitcoind with -deprecatedrpc=verifytxoutproof. Empty if proof is invalid)\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'm not sure about the in v0.17 instead
wording -- what about when bitcoin hits v0.18?
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 thought the same, but there are other occurrences in the code. I would remove the version though.
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'm a bit confused, if this is merged now, it definitely would be the way to see the old text for 0.17. Now, perhaps the note should also say when it will be removed?
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.
Pushed a new wording, hopefully clearer and more pertinent to the user.
@instagibbs See https://github.com/bitcoin/bitcoin/pull/11872/files#diff-ef76fd6674f07db88c3422fdbf0bcf9fR65 for release note example. |
a371696
to
c1c3631
Compare
fixed up deprecation message, added release notes |
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.
Could add a test for the empty response {}
, at least I don't see it?
doc/release-notes.md
Outdated
@@ -62,6 +62,7 @@ RPC changes | |||
### Low-level changes | |||
|
|||
- The `fundrawtransaction` rpc will reject the previously deprecated `reserveChangeKey` option. | |||
- The `verifytxoutproof` rpc will output an object instead of an array unless `-deprecatedrpc=verifytxoutproof` is set |
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.
Nit, missing period, sorry.
423c9d6
to
954ec5b
Compare
fixed up release note nit. I think the only way to return |
@instagibbs here is one
Maybe it should throw an error in this case? |
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.
utACK - looks good
@promag yeah I'll catch the deprecated case of |
0d9330b
to
ce6ae10
Compare
src/rpc/rawtransaction.cpp
Outdated
if (IsDeprecatedRPCEnabled("verifytxoutproof")) { | ||
return txids; | ||
} else { | ||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No valid transaction commitments are found in the proof"); |
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.
s/RPC_INVALID_ADDRESS_OR_KEY/RPC_INVALID_PARAMETER?
Add a test for the error, like:
assert_raises_rpc_error(-8, 'No valid transaction commitments are found in the proof', self.nodes[2].gettxoutproof,
'0000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000')
ce6ae10
to
7045e31
Compare
done |
Needs rebase to fix travis (sorry) |
7045e31
to
ec1695e
Compare
rebased |
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.
utACK ec1695eedc545545e5273e19f1e1b80aaebecf28
utACK ec1695e. |
Needs rebase (after merge of |
ec1695e
to
d43e00a
Compare
rebased |
@instagibbs Travis is timing out. I tried restarting the two jobs that timed out but it still fails. Not sure what's up. |
master should be fixed after #12681. |
@promag I think that's unrelated (and I don't think @instagibbs merged the commit that triggered the error that was fixed). |
if (IsDeprecatedRPCEnabled("verifytxoutproof")) { | ||
return txids; | ||
} else { | ||
throw JSONRPCError(RPC_INVALID_PARAMETER, "No valid transaction commitments are found in the proof"); |
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.
Is the RPC user at fault when this happens? If not, I don't think this should be an RPC error.
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.
We already error out when the block is not found in the chain, which is just as much the users' fault.
I'll leave this up to others to chime in.
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.
Ok, fair. Let's keep it this way then.
re-utACK d43e00a |
d43e00a
to
b761342
Compare
rebased due to release notes conflict |
b761342
to
5f63fa9
Compare
rebased again... |
5f63fa9
to
674b877
Compare
rebased again for yet another release notes conflict |
"[\"txid\"] (array, strings) The txid(s) which the proof commits to, or empty array if the proof is invalid\n" | ||
"{\n" | ||
" \"blockhash\" (string) The blockhash the included proof commits to\n" | ||
" [\"txid\"] (array, strings) The txid(s) which the proof commits to\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.
Should mention response key: \"txids\"
.
Allows direct use of the proof to get block header related info without additional parsing, and more directly mirrors
gettxoutproof
arguments.