-
Notifications
You must be signed in to change notification settings - Fork 86
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
GetTransaction
does not correctly propagate the output of getrawtransaction
calls.
#493
Comments
I looked into this using the debugger, and what happens is, the Go library function
and since the "height" member is missing in the |
That's correct, in terms of the deserialization from the zcashd output. With respect to the protobuf part of this, the protobuf height field should really have been defined as Even though protobuf defines optional fields, it is not possible to test whether a value for the field was set or not, you can only test against the default value (which could be a valid value in the domain.) The only reason we're okay here is that we assume that wallets will never be querying for the genesis block's coinbase transaction, for which a height 0 is a valid value in the domain. |
It turns out that the
GetTransaction
method added tolightwalletd
is horribly broken, because it does not correctly propagate the output of thegetrawtransaction
JSON-RPC method.It says here "optionally includes the block height" (which runs into the gRPC problem that this gets aliased with the genesis block height 0 making the transactions look mined), but below says "block height if mined, or -1" (implying to users of the RPC that -1 means "unmined").
Meanwhile,
getrawtransaction
actually returns:-1
for transactions mined in blocks that are not in the main chain (i.e. conflicted).This is further muddied by the fact that the Go parser is parsing the height field as an
int
, which is machine-dependent (and thus could differ fromzcashd
), and also I don't know how it handles omitted values (because it isn't to my knowledge a nullable type). So the unmined transactions might be getting their height fields coerced to some default in Go (0?) rather than being set as optional in the returned Protobuf (aka 0) - this needs further investigation.RawTransaction
was then further misused by the addition of theGetMempoolStream
RPC. Transactions in the mempool should never be associated with the latest block height; if any height is associated with them, it should be the "mempool height" which islatest_height + 1
(which is the height at which the consensus rules are applied to the mempool transactions). So that RPC is broken as well.This is going to be Not Fun™️ to fix.
Originally posted by @str4d in zcash/librustzcash#1473 (comment)
The text was updated successfully, but these errors were encountered: