Skip to content

Conversation

instagibbs
Copy link
Member

@instagibbs instagibbs commented Aug 23, 2017

Allows direct use of the proof to get block header related info without additional parsing, and more directly mirrors gettxoutproof arguments.

@instagibbs instagibbs changed the title verifytxoutproof returns object including blockhash [RPC] verifytxoutproof returns object including blockhash Aug 23, 2017
Copy link
Contributor

@kallewoof kallewoof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK d77cded0b1d026f030ee424b89a01cfd6b7b9000

"\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"
Copy link
Contributor

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

@instagibbs instagibbs force-pushed the verifytxoutproof-blockhash branch from d77cded to e7f9824 Compare August 24, 2017 13:34
@instagibbs
Copy link
Member Author

updated with nit fix

Copy link
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK.

"\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"
Copy link
Contributor

@promag promag Aug 25, 2017

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?

Copy link
Contributor

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.

@@ -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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... the block hash and ...

@@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, add curly braces.

@instagibbs instagibbs force-pushed the verifytxoutproof-blockhash branch from e7f9824 to 57d35ff Compare August 25, 2017 14:07
@instagibbs
Copy link
Member Author

fixed @promag nits, curly-bracketed the surrounding statements since I'm touching it already

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()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Push blockhash first.

Copy link
Contributor

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?

Copy link
Contributor

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.

@instagibbs instagibbs force-pushed the verifytxoutproof-blockhash branch from 57d35ff to 9efd4fe Compare August 25, 2017 14:28
@instagibbs instagibbs force-pushed the verifytxoutproof-blockhash branch from 9efd4fe to a371696 Compare March 6, 2018 18:03
@instagibbs
Copy link
Member Author

rebased, re-added legacy behavior under deprecation

@instagibbs
Copy link
Member Author

ping @kallewoof

Copy link
Contributor

@kallewoof kallewoof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re-utACK a3716960de5555572408efdab4eba75484c8c1e3

@@ -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"
Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Member Author

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?

Copy link
Member Author

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.

@promag
Copy link
Contributor

promag commented Mar 6, 2018

@instagibbs instagibbs force-pushed the verifytxoutproof-blockhash branch from a371696 to c1c3631 Compare March 6, 2018 18:27
@instagibbs
Copy link
Member Author

fixed up deprecation message, added release notes

Copy link
Contributor

@promag promag left a 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?

@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, missing period, sorry.

@instagibbs instagibbs force-pushed the verifytxoutproof-blockhash branch from 423c9d6 to 954ec5b Compare March 6, 2018 18:45
@instagibbs
Copy link
Member Author

fixed 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
Copy link
Contributor

promag commented Mar 6, 2018

@instagibbs here is one

verifytxoutproof 0000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
{
}

Maybe it should throw an error in this case?

Copy link
Contributor

@kallewoof kallewoof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK - looks good

@instagibbs
Copy link
Member Author

@promag yeah I'll catch the deprecated case of [] and throw an error for new behavior

@instagibbs instagibbs force-pushed the verifytxoutproof-blockhash branch 2 times, most recently from 0d9330b to ce6ae10 Compare March 7, 2018 18:00
if (IsDeprecatedRPCEnabled("verifytxoutproof")) {
return txids;
} else {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No valid transaction commitments are found in the proof");
Copy link
Contributor

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')

@instagibbs instagibbs force-pushed the verifytxoutproof-blockhash branch from ce6ae10 to 7045e31 Compare March 7, 2018 18:21
@instagibbs
Copy link
Member Author

done

@maflcko
Copy link
Member

maflcko commented Mar 8, 2018

Needs rebase to fix travis (sorry)

@instagibbs instagibbs force-pushed the verifytxoutproof-blockhash branch from 7045e31 to ec1695e Compare March 8, 2018 15:24
@instagibbs
Copy link
Member Author

rebased

Copy link
Contributor

@kallewoof kallewoof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK ec1695eedc545545e5273e19f1e1b80aaebecf28

@promag
Copy link
Contributor

promag commented Mar 11, 2018

utACK ec1695e.

@maflcko
Copy link
Member

maflcko commented Mar 13, 2018

Needs rebase (after merge of LookupBlockIndex)

@instagibbs instagibbs force-pushed the verifytxoutproof-blockhash branch from ec1695e to d43e00a Compare March 13, 2018 18:37
@instagibbs
Copy link
Member Author

rebased

@kallewoof
Copy link
Contributor

@instagibbs Travis is timing out. I tried restarting the two jobs that timed out but it still fails. Not sure what's up.

@promag
Copy link
Contributor

promag commented Mar 13, 2018

master should be fixed after #12681.

@kallewoof
Copy link
Contributor

@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");
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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.

@kallewoof
Copy link
Contributor

kallewoof commented Mar 15, 2018

re-utACK d43e00a

@instagibbs instagibbs force-pushed the verifytxoutproof-blockhash branch from d43e00a to b761342 Compare March 23, 2018 12:53
@instagibbs
Copy link
Member Author

rebased due to release notes conflict

@instagibbs instagibbs force-pushed the verifytxoutproof-blockhash branch from b761342 to 5f63fa9 Compare March 26, 2018 15:15
@instagibbs
Copy link
Member Author

rebased again...

@instagibbs instagibbs force-pushed the verifytxoutproof-blockhash branch from 5f63fa9 to 674b877 Compare April 16, 2018 16:58
@instagibbs
Copy link
Member Author

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"
Copy link
Contributor

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\".

@instagibbs instagibbs closed this Jul 10, 2018
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants