Ok so after a little reading I think I've finally got this but I wanted to confirm with the experts.
If I have a compressed public key then my transaction size will be calculated:
148x(inputs) + 34x(outputs) + 10x(inputs)
But I also understand that there could be a 1 byte difference in the input sizes.
It can vary as much as 4 bytes per input IIRC.Also, you do not need to do
10x(inputs). There is not an extra 10 bytes per input, rather that is a fixed 10 or so bytes (maximum is actually 26 bytes; depends on the number of inputs and number of outputs).
If you're using an uncompressed public key then your transaction size would be calculated:
180x(inputs) + 34x(outputs) + 10x(inputs)
Same comment about the
10x(inputs) as above.
Will this give me a fairly accurate fee?
It will tell you the size of your transaction fairly accurately, within a couple of bytes, and that won't really matter when it comes to the transaction fee. It's close enough.
I'm also not sure how to tell if my public key is compressed but I guess I could just check bitaddress.org address info.
A compressed public key will be 32 bytes long, uncompressed is 65. Compressed keys begin with
02 or
03 whereas uncompressed begin with
04.