0

Suppose I have following object

console.log(bitcoinjs.Transaction.fromHex(rawTx));

The output

Transaction {
  version: 2,
  locktime: 1655960,
  ins: [
    {
      hash: <Buffer dc 4d aa 10 db 80 36 52 24 49 7c c5 7c bc c5 bc df be e1 2d 58 61 70 e1 0c 7b 76 a7 35 cc 7c 3a>,
      index: 21,
      script: <Buffer 16 00 14 5f f3 9b e6 42 af a9 f3 59 25 34 e7 6a dd b2 ee e3 41 82 15>,
      sequence: 4294967294,
      witness: [Array]
    }
  ],
  outs: [
    {
      value: 1000000,
      script: <Buffer a9 14 14 ea 69 2e 87 76 ec c6 2e 6a aa a1 7d cc d2 8f f3 30 b7 46 87>
    },
    {
      value: 3299775,
      script: <Buffer a9 14 73 e2 99 78 43 31 1e cc 32 b5 ac 38 ef c9 9b b3 ae 54 bc 7c 87>
    }
  ]
}

How can I decode transfer amount (in BTC) from this object?

  • 2
    What do you mean by "transfer amount"? You have the output values there... – pinhead Jan 9 at 15:07
0

The transfer amount (BTC) is, (somewhat dependant on the library used), most commonly denominated as "value:" Read: the outs => value: *

 {
      value: 1000000,
      script: <Buffer a9 14 14 ea 69 2e 87 76 ec c6 2e 6a aa a1 7d cc d2 8f f3 30 b7 46 87>
    },
    {
      value: 3299775,
      script: <Buffer a9 14 73 e2 99 78 43 31 1e cc 32 b5 ac 38 ef c9 9b b3 ae 54 bc 7c 87>
    }

Where the value is most often denominated in satoshis (a single unit.). But, some block explorers (blockchair) or other libraries will denominate in single units of Bitcoin, as is done below. (10^8 satoshis - 1 BTC ( 100 mil))

1000000 = 0.01BTC 3299775 = 0.03299775 BTC

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.