0

I am attempting to calculate the mining fee of a transaction, given it's unsigned transaction hex by taking difference between the sum of the inputs and outputs.

I also have access to an array of Txout and Txin blobs.

Taking the sum of the the Txout array is easy, as first eight bytes is the value of the output, but I do not know how to get the value of an input for a Txin.

The format of the Txin blobs is that which is described on the bitcoin.it wiki --

Previous Transaction hash   ||  32 bytes
Previous Txout-index        || 4 bytes
Txin-script                 || 1-9 bytes
Txin-script                 || arbitrary number of bytes
sequence_no                 ||  4 bytes

How can I get the value of each input?

1 Answer 1

2

You have to look up the previous unspent transaction output using the hash and txout-index, and this output contains the amount in satoshis which is provided in entirety as input for the transaction.

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.