Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: BradZimdack on November 15, 2012, 01:31:46 AM



Title: Estimating Transaction Size (in bytes)
Post by: BradZimdack on November 15, 2012, 01:31:46 AM
According to the transaction fee rules, the size of the transaction is used to calculate fees (https://en.bitcoin.it/wiki/Transaction_fees).  From what I've read elsewhere, the size of the tx will be: 180 bytes per input + 34 bytes per output + 10 bytes.

However, while I've found that calculation to hold up most of the time, it doesn't seem to be accurate all of the time.  Is there a more reliable way to know how large a transaction will be so that appropriate fees can be assigned when creating a raw transaction?


Title: Re: Estimating Transaction Size (in bytes)
Post by: lile on November 15, 2012, 07:04:08 AM
According to the transaction fee rules, the size of the transaction is used to calculate fees (https://en.bitcoin.it/wiki/Transaction_fees).  From what I've read elsewhere, the size of the tx will be: 180 bytes per input + 34 bytes per output + 10 bytes.

However, while I've found that calculation to hold up most of the time, it doesn't seem to be accurate all of the time.  Is there a more reliable way to know how large a transaction will be so that appropriate fees can be assigned when creating a raw transaction?
There is no way of knowing in advance how big the signatures are going to be. You can try making several transactions and based on the size of those figure out how large the fee must be.

You could also use a conservative estimate for the size and have users in some cases pay a little bit more.


Title: Re: Estimating Transaction Size (in bytes)
Post by: someone42 on November 15, 2012, 01:31:03 PM
According to the transaction fee rules, the size of the transaction is used to calculate fees (https://en.bitcoin.it/wiki/Transaction_fees).  From what I've read elsewhere, the size of the tx will be: 180 bytes per input + 34 bytes per output + 10 bytes.

However, while I've found that calculation to hold up most of the time, it doesn't seem to be accurate all of the time.  Is there a more reliable way to know how large a transaction will be so that appropriate fees can be assigned when creating a raw transaction?
As lile has pointed out, the size of signatures can vary.

In particular, for uncompressed public keys, there is:
  • a 25% chance each input is 179 bytes or smaller,
  • a 50% chance each input is 180 bytes,
  • a 25% chance each input is 181 bytes.
However, what makes a bigger difference is that if compressed public keys are used, each input is 32 bytes smaller.

If you want to set a conservative limit, 181 bytes per input + 34 bytes per output + 10 bytes seems like a good bet. This limit only applies to reasonably-sized (< 253 inputs and outputs) and standard (one signature required) transactions.


Title: Transaction Fee Calculation
Post by: jainsanket662 on September 09, 2014, 10:15:31 AM
Hi,

please tell me how to calculate transaction fee exactly??

suppose i have 5 BTC , Which i had received from different different addresses and now i want to send 2 BTC to another address,
then how to get transaction fee before sending it ?

please tell me the calculation of transaction fee and how do i calculate every time before sending amount.

Thanxs in advanced .  :-[


Title: Re: Transaction Fee Calculation
Post by: DannyHamilton on September 09, 2014, 12:48:01 PM
Hi,

please tell me how to calculate transaction fee exactly??

suppose i have 5 BTC , Which i had received from different different addresses and now i want to send 2 BTC to another address,
then how to get transaction fee before sending it ?

please tell me the calculation of transaction fee and how do i calculate every time before sending amount.

Thanxs in advanced .  :-[

What wallet program are you using?


Title: Re: Transaction Fee Calculation
Post by: deepceleron on September 10, 2014, 02:23:17 AM
Hi,

please tell me how to calculate transaction fee exactly??

suppose i have 5 BTC , Which i had received from different different addresses and now i want to send 2 BTC to another address,
then how to get transaction fee before sending it ?

please tell me the calculation of transaction fee and how do i calculate every time before sending amount.

Thanxs in advanced .  :-[

Your wallet program will choose previous payments seeming at random to make up your new payment, and it is the number of these payments that make up the data size of the transaction you will send and therefore the fee. Your wallet may choose to spend from one large previous payment, or it may take 50 dust payments and spend them all to make the transaction. Bitcoin Core will alert you to the specific fee that will be included when sending. Unless you have a relatively unused wallet, there is no way to predict what the size will be (Bitcoin attempts to minimize the change, not minimize the fee).

You can manually compose a payment if you want to get into the inner workings of Bitcoin transactions, but this is beyond the needs of most people.


Title: Re: Transaction Fee Calculation
Post by: jainsanket662 on September 10, 2014, 06:27:45 AM
Hi,

please tell me how to calculate transaction fee exactly??

suppose i have 5 BTC , Which i had received from different different addresses and now i want to send 2 BTC to another address,
then how to get transaction fee before sending it ?

please tell me the calculation of transaction fee and how do i calculate every time before sending amount.

Thanxs in advanced .  :-[

What wallet program are you using?

We are using Bitcoin-qt (Bitcoin Core version V0 9.1.0.1)