I'm using bitcoinjs-lib and its Transaction object. Transaction.ins is an array of objects, each which has a hash and script property. Both of these properties are Uint8Arrays.

I am trying to get the hex string version of the input.hash but Transaction.ins[i].hash.toString('hex') produces an incorrect result. Is there a way to get this value properly?

1 Answer 1


Apparently you need to reverse the array before toString. Transaction.ins[i].hash.reverse().toString('hex') produces the correct result. Make sure to call hash.reverse() afterward.

source: ScriptHash from bitcoin address with BitcoinJS

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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