Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Farghaly on October 26, 2014, 12:17:45 PM



Title: Calculating transaction fees programmatically ?
Post by: Farghaly on October 26, 2014, 12:17:45 PM
Hello,

Regarding transaction fees https://en.bitcoin.it/wiki/Transaction_fee i have several unanswered questions:
  • How to calcaulate tx size ? http://bitcoin.stackexchange.com/questions/1195/how-to-calculate-transaction-size-before-sending is a good pattern but didn't mention P2SH
  • What's actually measured ? inputs, outputs, signatures ?
  • Is it possible to calculate tx size from its hex ?
  • What's the average multi-sig input size ?
  • Is there any reference implementation on calculating tx fee from size ?

Thank you


Title: Re: Calculating transaction fees programmatically ?
Post by: Foxpup on October 26, 2014, 12:35:24 PM
  • How to calcaulate tx size ? http://bitcoin.stackexchange.com/questions/1195/how-to-calculate-transaction-size-before-sending is a good pattern but didn't mention P2SH
  • What's actually measured ? inputs, outputs, signatures ?
Bytes.

  • Is it possible to calculate tx size from its hex ?
Yes. There are two hex digits to a byte. Count the number of hex digits, divide by two, and that's the size in bytes. Note if you have a program that is processing transactions, it already has the raw data, and hence already knows how many bytes there are.

  • Is there any reference implementation on calculating tx fee from size ?
Bitcoin Core.


Title: Re: Calculating transaction fees programmatically ?
Post by: bitok.com on October 28, 2014, 01:11:15 PM
Bitcoind Json RPC api allows you to create raw transaction, so you can add any fee you like. For now we are using bitcoind sendtoaddress api call, which calculates fee automatically, but are considering raw transaction generation.