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.