[rpc] Fix issue: "Negative version of transaction using json-rpc" #12430

pull l2a5b1 wants to merge 1 commits into bitcoin:master from l2a5b1:patch/11561/fix-negative-json-rpc-version changing 1 files +1 −1
  1. l2a5b1 commented at 12:43 AM on February 14, 2018: contributor

    In case that it is a valid issue, this PR fixes #11561 ("Negative version of transaction using json-rpc").

    The verbose output of the getrawtransaction RPC gives a response with a negative transaction version number if the MSB of the transaction version number is set.

    This behavior can easily be reproduced by requesting the verbose transaction data of Mainnet transaction c659729a7fea5071361c2c1a68551ca2bf77679b27086cc415adeeb03852e369, via the getrawtransaction RPC, which gives a response with a negative transaction version number:

    {
      ...
      "version": -1703168784,
      ...
    }
    

    To fix the issue, commit 42df694 casts the transaction version number to an uint64_t and masks off its most significant 32 bits to pass a positive transaction version number to UniValue::pushKV(const std::string&, uint64_t):bool.

    In the case of the example above it gives a response with a positive transaction version number:

    {
      ...
      "version": 2591798512,
      ...
    }
    

    This transaction version number is equal to the transaction version number created by block explorers that show a positive transaction version number. See for example:

    Transaction c659729a7fea5071361c2c1a68551ca2bf77679b27086cc415adeeb03852e369 on Blockcypher.com

  2. Passes a positive transaction version number to UniValue::pushKV(const std::string&, uint64_t):bool by casting the transaction version number of type int32_t to an uint64_t and masking off its most significant 32 bits. 42df694a79
  3. gmaxwell commented at 1:58 AM on February 14, 2018: contributor

    Negative transaction versions are negative, the distinction is not just cosmetic. There is protocol behavior e.g. interpretation of sequence numbers for CSV that depends on the version being over a threshold.

  4. fanquake added the label RPC/REST/ZMQ on Feb 14, 2018
  5. l2a5b1 commented at 11:58 AM on February 14, 2018: contributor

    Thanks @gmaxwell!

    I should not have followed up to #11561 by submitting a PR that breaks the RPC output. The eagerness to contribute clouded my better judgement. Apologies for that.

  6. l2a5b1 closed this on Feb 14, 2018

  7. laanwj referenced this in commit 6e67754e48 on Apr 24, 2018
  8. PastaPastaPasta referenced this in commit d771f38538 on Nov 10, 2020
  9. PastaPastaPasta referenced this in commit 4fef156283 on Dec 11, 2020
  10. PastaPastaPasta referenced this in commit 28c66ee89b on Dec 12, 2020
  11. PastaPastaPasta referenced this in commit e80c73ae16 on Dec 15, 2020
  12. PastaPastaPasta referenced this in commit 6f37eab266 on Dec 15, 2020
  13. PastaPastaPasta referenced this in commit a6e332134a on Dec 18, 2020
  14. MarcoFalke locked this on Sep 8, 2021

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-04-13 15:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me