Bitcoin-com / rest.bitcoin.com

Bitcoin.com's Cloud's REST API
https://rest.bitcoin.com
MIT License
19 stars 26 forks source link

GET /transaction/details/{txid} returning value in wrong unit! #397

Open alwaysAn0n opened 5 years ago

alwaysAn0n commented 5 years ago

The vin.value field is being expressed in satoshis but the vout.value is being expressed in whole BCH units ( and also with the wrong data type ) . I expect them to use the same unit if they are using the same name. This could cause some serious trouble for service providers if they are relying on those numbers and didn't notice the difference.

Below is an excerpt from https://rest.bitcoin.com/v2/transaction/details/ab722718c1a1b3efc32b0d22814ea3d73eac96f7981541dbaa9c8c7c804e86db

{
  "txid": "ab722718c1a1b3efc32b0d22814ea3d73eac96f7981541dbaa9c8c7c804e86db",
  "version": 1,
  "locktime": 0,
  "vin": [
    {
      "txid": "525cdd4f8535f81df77c623becc548391a63558deb7a2ceb81a9b8e366ac9cbb",
      "vout": 2,
      "sequence": 4294967294,
      "n": 0,
      "scriptSig": {
        "hex": "473044022024f28144a6d0ce79392e7b0dcbe299a312e993491070b77e8fef5d4e7d04a8f30220704d80ee52b37c3b519f6bf15aecd34f9fc29b5be716e30b22465605fa816a0241210227a4f74bb91099deb228160396bbfb1b9b87c1ae38be49c9ce5139bf6874ac38",
        "asm": "3044022024f28144a6d0ce79392e7b0dcbe299a312e993491070b77e8fef5d4e7d04a8f30220704d80ee52b37c3b519f6bf15aecd34f9fc29b5be716e30b22465605fa816a02[ALL|FORKID] 0227a4f74bb91099deb228160396bbfb1b9b87c1ae38be49c9ce5139bf6874ac38"
      },
      "value": 1501076,
      "legacyAddress": "143JrBsyoCDuhNDfF49vr6bAwbd26D57nA",
      "cashAddress": "bitcoincash:qqs4sxat33wsqvl6p83m4xwd3vy2vwzg8c7aentecx"
    }

    ...

  ],
  "vout": [
    {
      "value": "0.01500806",
      "n": 0,
      "scriptPubKey": {
        "hex": "76a914ce4f6bb6b464263750905206eb6e4ce4f9ee93e588ac",
        "asm": "OP_DUP OP_HASH160 ce4f6bb6b464263750905206eb6e4ce4f9ee93e5 OP_EQUALVERIFY OP_CHECKSIG",
        "addresses": [
          "1KosLmYUSoyPTnRSH8Et2avFvhH6ZyJJdG"
        ],
        "type": "pubkeyhash",
        "cashAddrs": [
          "bitcoincash:qr8y76akk3jzvd6sjpfqd6mwfnj0nm5nu5d8w4x6e5"
        ]
      },
      "spentTxId": null,
      "spentIndex": null,
      "spentHeight": null
    }

    ...

  ],
  "blockhash": "0000000000000000000d94a05528a14f10e32c71b028ad338bc5723e3d6b65a3",
  "blockheight": 579445,
  "confirmations": 370,
  "time": 1555976912,
  "blocktime": 1555976912,
  "valueOut": 0.07800639,
  "size": 621,
  "valueIn": 0.07801449,
  "fees": 0.0000081
}
alwaysAn0n commented 5 years ago

Uh oh. I just realized this issue is probably a duplicate of https://github.com/Bitcoin-com/rest.bitcoin.com/issues/395

I'm going to leave mine open though since it includes more information.