Allows direct use of the proof to get block header related info without additional parsing, and more directly mirrors gettxoutproof arguments.
[RPC] verifytxoutproof returns object including blockhash #11120
pull instagibbs wants to merge 2 commits into bitcoin:master from instagibbs:verifytxoutproof-blockhash changing 3 files +50 −19-
instagibbs commented at 3:50 PM on August 23, 2017: member
- instagibbs renamed this:
verifytxoutproof returns object including blockhash
[RPC] verifytxoutproof returns object including blockhash
on Aug 23, 2017 - laanwj added the label RPC/REST/ZMQ on Aug 23, 2017
-
in src/rpc/rawtransaction.cpp:265 in d77cded0b1 outdated
264 | + ", throwing an RPC error if the block is not in our best chain\n" 265 | "\nArguments:\n" 266 | "1. \"proof\" (string, required) The hex-encoded proof generated by gettxoutproof\n" 267 | - "\nResult:\n" 268 | - "[\"txid\"] (array, strings) The txid(s) which the proof commits to, or empty array if the proof is invalid\n" 269 | + "\nResult: (or empty if proof is invalid)\n"
kallewoof commented at 8:21 AM on August 24, 2017:Remove
ormaybe? I.e.Result: (empty if proof is invalid)\nkallewoof commented at 8:22 AM on August 24, 2017: memberutACK d77cded0b1d026f030ee424b89a01cfd6b7b9000
instagibbs force-pushed on Aug 24, 2017instagibbs commented at 1:34 PM on August 24, 2017: memberupdated with nit fix
in src/rpc/rawtransaction.cpp:262 in e7f9824f49 outdated
257 | @@ -258,19 +258,23 @@ UniValue verifytxoutproof(const JSONRPCRequest& request) 258 | if (request.fHelp || request.params.size() != 1) 259 | throw std::runtime_error( 260 | "verifytxoutproof \"proof\"\n" 261 | - "\nVerifies that a proof points to a transaction in a block, returning the transaction it commits to\n" 262 | - "and throwing an RPC error if the block is not in our best chain\n" 263 | + "\nVerifies that a proof points to a transaction in a block, returning the blockhash and transactions it commits to\n" 264 | + ", throwing an RPC error if the block is not in our best chain\n"
promag commented at 1:50 PM on August 25, 2017:Nit,
,in the above line?
kallewoof commented at 2:04 PM on August 25, 2017:I was gonna mention that but chose not to. Agree though, I think that would look better.
in src/rpc/rawtransaction.cpp:261 in e7f9824f49 outdated
257 | @@ -258,19 +258,23 @@ UniValue verifytxoutproof(const JSONRPCRequest& request) 258 | if (request.fHelp || request.params.size() != 1) 259 | throw std::runtime_error( 260 | "verifytxoutproof \"proof\"\n" 261 | - "\nVerifies that a proof points to a transaction in a block, returning the transaction it commits to\n" 262 | - "and throwing an RPC error if the block is not in our best chain\n" 263 | + "\nVerifies that a proof points to a transaction in a block, returning the blockhash and transactions it commits to\n"
promag commented at 1:51 PM on August 25, 2017:... the block hash and ...in src/rpc/rawtransaction.cpp:289 in e7f9824f49 outdated
286 | @@ -283,7 +287,10 @@ UniValue verifytxoutproof(const JSONRPCRequest& request) 287 | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found in chain"); 288 | 289 | for (const uint256& hash : vMatch)
promag commented at 1:56 PM on August 25, 2017:Nit, add curly braces.
promag commented at 1:57 PM on August 25, 2017: memberConcept ACK.
instagibbs force-pushed on Aug 25, 2017instagibbs commented at 2:07 PM on August 25, 2017: memberfixed @promag nits, curly-bracketed the surrounding statements since I'm touching it already
in src/rpc/rawtransaction.cpp:295 in 57d35fff53 outdated
300 | + } 301 | 302 | - for (const uint256& hash : vMatch) 303 | - res.push_back(hash.GetHex()); 304 | + res.push_back(Pair("txids", txids)); 305 | + res.push_back(Pair("blockhash", merkleBlock.header.GetHash().GetHex()));
promag commented at 2:26 PM on August 25, 2017:Push
blockhashfirst.
kallewoof commented at 10:47 PM on August 25, 2017:I'm curious about the reason for this request. Alphabetical ordering?
promag commented at 11:35 PM on August 25, 2017:Also matches the documentation above.
instagibbs force-pushed on Aug 25, 2017instagibbs force-pushed on Mar 6, 2018instagibbs commented at 6:04 PM on March 6, 2018: memberrebased, re-added legacy behavior under deprecation
instagibbs commented at 6:08 PM on March 6, 2018: memberping @kallewoof
fanquake added the label Needs release notes on Mar 6, 2018in src/rpc/rawtransaction.cpp:297 in a3716960de outdated
293 | @@ -294,6 +294,8 @@ UniValue verifytxoutproof(const JSONRPCRequest& request) 294 | " \"blockhash\" (string) The blockhash the included proof commits to\n" 295 | " [\"txid\"] (array, strings) The txid(s) which the proof commits to\n" 296 | "}\n" 297 | + "\nResult: (DEPRECATED. To see this result in v0.17 instead, please start bitcoind with -deprecatedrpc=verifytxoutproof. Empty if proof is invalid)\n"
kallewoof commented at 6:16 PM on March 6, 2018:I'm not sure about the
in v0.17 insteadwording -- what about when bitcoin hits v0.18?
promag commented at 6:19 PM on March 6, 2018:I thought the same, but there are other occurrences in the code. I would remove the version though.
instagibbs commented at 6:25 PM on March 6, 2018: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?
instagibbs commented at 6:27 PM on March 6, 2018:Pushed a new wording, hopefully clearer and more pertinent to the user.
kallewoof commented at 6:17 PM on March 6, 2018: memberre-utACK a3716960de5555572408efdab4eba75484c8c1e3
promag commented at 6:19 PM on March 6, 2018: member@instagibbs See https://github.com/bitcoin/bitcoin/pull/11872/files#diff-ef76fd6674f07db88c3422fdbf0bcf9fR65 for release note example.
instagibbs force-pushed on Mar 6, 2018instagibbs commented at 6:36 PM on March 6, 2018: memberfixed up deprecation message, added release notes
promag commented at 6:37 PM on March 6, 2018: memberCould add a test for the empty response
{}, at least I don't see it?in doc/release-notes.md:65 in 423c9d6e08 outdated
61 | @@ -62,6 +62,7 @@ RPC changes 62 | ### Low-level changes 63 | 64 | - The `fundrawtransaction` rpc will reject the previously deprecated `reserveChangeKey` option. 65 | +- The `verifytxoutproof` rpc will output an object instead of an array unless `-deprecatedrpc=verifytxoutproof` is set
promag commented at 6:39 PM on March 6, 2018:Nit, missing period, sorry.
instagibbs force-pushed on Mar 6, 2018instagibbs commented at 6:46 PM on March 6, 2018: memberfixed up release note nit. I think the only way to return
{}is to have a non-matching hash header... too lazy to construct one in paste it in.promag commented at 7:16 PM on March 6, 2018: member@instagibbs here is one
verifytxoutproof 0000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 { }Maybe it should throw an error in this case?
kallewoof approvedkallewoof commented at 4:35 AM on March 7, 2018: memberutACK - looks good
instagibbs commented at 5:53 PM on March 7, 2018: member@promag yeah I'll catch the deprecated case of
[]and throw an error for new behaviorinstagibbs force-pushed on Mar 7, 2018instagibbs force-pushed on Mar 7, 2018in src/rpc/rawtransaction.cpp:314 in ce6ae10e5c outdated
315 | - return res; 316 | + if (merkleBlock.txn.ExtractMatches(vMatch, vIndex) != merkleBlock.header.hashMerkleRoot) { 317 | + if (IsDeprecatedRPCEnabled("verifytxoutproof")) { 318 | + return txids; 319 | + } else { 320 | + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No valid transaction commitments are found in the proof");
promag commented at 6:17 PM on March 7, 2018: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')instagibbs force-pushed on Mar 7, 2018instagibbs commented at 6:21 PM on March 7, 2018: memberdone
MarcoFalke commented at 3:21 PM on March 8, 2018: memberNeeds rebase to fix travis (sorry)
instagibbs force-pushed on Mar 8, 2018instagibbs commented at 3:24 PM on March 8, 2018: memberrebased
kallewoof approvedkallewoof commented at 7:05 PM on March 8, 2018: memberutACK ec1695eedc545545e5273e19f1e1b80aaebecf28
promag commented at 11:18 PM on March 11, 2018: memberutACK ec1695e.
MarcoFalke commented at 6:31 PM on March 13, 2018: memberNeeds rebase (after merge of
LookupBlockIndex)instagibbs force-pushed on Mar 13, 2018instagibbs commented at 6:39 PM on March 13, 2018: memberrebased
kallewoof commented at 11:21 PM on March 13, 2018: member@instagibbs Travis is timing out. I tried restarting the two jobs that timed out but it still fails. Not sure what's up.
kallewoof commented at 11:29 PM on March 13, 2018: member@promag I think that's unrelated (and I don't think @instagibbs merged the commit that triggered the error that was fixed).
in src/rpc/rawtransaction.cpp:314 in d43e00a902 outdated
315 | - return res; 316 | + if (merkleBlock.txn.ExtractMatches(vMatch, vIndex) != merkleBlock.header.hashMerkleRoot) { 317 | + if (IsDeprecatedRPCEnabled("verifytxoutproof")) { 318 | + return txids; 319 | + } else { 320 | + throw JSONRPCError(RPC_INVALID_PARAMETER, "No valid transaction commitments are found in the proof");
sipa commented at 12:25 AM on March 14, 2018:Is the RPC user at fault when this happens? If not, I don't think this should be an RPC error.
instagibbs commented at 1:51 PM on March 14, 2018: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.
sipa commented at 12:50 AM on March 15, 2018:Ok, fair. Let's keep it this way then.
kallewoof commented at 12:49 AM on March 15, 2018: memberre-utACK d43e00a
instagibbs force-pushed on Mar 23, 2018instagibbs commented at 12:53 PM on March 23, 2018: memberrebased due to release notes conflict
instagibbs force-pushed on Mar 26, 2018instagibbs commented at 3:16 PM on March 26, 2018: memberrebased again...
verifytxoutproof returns object including blockhash 453c28751badd release notes for verifytxoutproof api break 674b877fadinstagibbs force-pushed on Apr 16, 2018instagibbs commented at 4:59 PM on April 16, 2018: memberrebased again for yet another release notes conflict
MarcoFalke added the label Needs rebase on Jun 6, 2018in src/rpc/rawtransaction.cpp:295 in 674b877fad
293 | "1. \"proof\" (string, required) The hex-encoded proof generated by gettxoutproof\n" 294 | "\nResult:\n" 295 | - "[\"txid\"] (array, strings) The txid(s) which the proof commits to, or empty array if the proof is invalid\n" 296 | + "{\n" 297 | + " \"blockhash\" (string) The blockhash the included proof commits to\n" 298 | + " [\"txid\"] (array, strings) The txid(s) which the proof commits to\n"
promag commented at 12:26 AM on June 14, 2018:Should mention response key:
\"txids\".instagibbs closed this on Jul 10, 2018fanquake removed the label Needs release note on Mar 20, 2019laanwj removed the label Needs rebase on Oct 24, 2019DrahtBot locked this on Dec 16, 2021ContributorsLabels
github-metadata-mirror
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-03 21:15 UTC
This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me