Bitcoin Forum
April 20, 2024, 03:16:52 AM *
News: Latest Bitcoin Core release: 26.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1] 2 »  All
  Print  
Author Topic: How to calculate bitcoin transaction size and fees  (Read 515 times)
RapTarX (OP)
Hero Member
*****
Offline Offline

Activity: 1358
Merit: 850



View Profile
May 06, 2019, 02:52:11 PM
Last edit: May 06, 2019, 06:03:13 PM by RapTarX
Merited by BitcoinGirl.Club (4)
 #1

Bitcoin fees depend on the size of the transaction. For a bigger size of transaction, you must have to pay higher transaction fee. Here bigger size don't refer to the amount of the bitcoin to be transacted.

How to calculate transaction size
Source

Input*180 + output*34 + 10 plus or minus input
Say, input is 2 and output is to 3 address. The size is-
2*180 + 3*34 + 10 + or - 2 = 474/470bytes.

Input= number of times received bitcoin on an address.
Output= number of addresses where you will send.

When input and output increase, the total size will also be increased which will cause you higher fee.

How to calculate fees
Now that the transaction size is calculated, check bitcoinfees and find out the current amount of satoshi per byte.
According to this site-
Quote
The fastest and cheapest transaction fee is currently 62 satoshis/byte
If someones pay 62 satoshi per byte, the transaction will likely to be listed in the next block, however, it's possible to pay less fee which will cause slow confirmation. If more fee is paid, the transaction process will be more faster.

1713583012
Hero Member
*
Offline Offline

Posts: 1713583012

View Profile Personal Message (Offline)

Ignore
1713583012
Reply with quote  #2

1713583012
Report to moderator
1713583012
Hero Member
*
Offline Offline

Posts: 1713583012

View Profile Personal Message (Offline)

Ignore
1713583012
Reply with quote  #2

1713583012
Report to moderator
Every time a block is mined, a certain amount of BTC (called the subsidy) is created out of thin air and given to the miner. The subsidy halves every four years and will reach 0 in about 130 years.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
Bitcoin_Arena
Copper Member
Legendary
*
Offline Offline

Activity: 2016
Merit: 1771


฿itcoin for all, All for ฿itcoin.


View Profile
May 06, 2019, 03:03:14 PM
 #2

I am a little confused on the output part.
Question is how do you come up with the output even before the transaction has been made since we are still trying to calculate the transaction fee?

.BEST..CHANGE.███████████████
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
███████████████
..BUY/ SELL CRYPTO..
RapTarX (OP)
Hero Member
*****
Offline Offline

Activity: 1358
Merit: 850



View Profile
May 06, 2019, 03:07:04 PM
Merited by Bitcoin_Arena (1)
 #3

I am a little confused on the output part.
Question is how do you come up with the output even before the transaction has been made since we are still trying to calculate the transaction fee?
Output means on how much addresses you are going to send. Generally, it should be 2 because if you send in one address, the change will be sent to another address of yourself. You may send 4 people at once (or more), the output will be 4+1=5 (if you send all the amount you have, no change will be made and total output will be 4 in that case). May be I'm wrong because I'm newbie in this space and trying to learn.
Edit-
Quote
The transaction output is the bitcoin address to which the money was sent.
Source- https://www.thebalance.com/how-does-a-bitcoin-transaction-work-391213

Therefore, it's known to us before transactions been made.

bitmover
Legendary
*
Offline Offline

Activity: 2282
Merit: 5878


bitcoindata.science


View Profile WWW
May 06, 2019, 03:22:06 PM
Merited by LoyceV (1), BitcoinGirl.Club (1), DdmrDdmr (1), Bitcoin_Arena (1), RapTarX (1)
 #4

There is one important thing you forgot to mention.

What matters for fees is not how many addresses you have, but how many inputs you have.

Let´s suppose you engaged in many sig campaigns and you received 0,0005 every week for 20 weeks. You earned 0,01BTC, however you will have more than 20 inputs on the same address.

Every transaction made from your address will now have cost based on every input, individually, when you want to move them.

That´s why it´s important to consolidate your small inputs when fees are low.

If you consolidate your 20 0,0005 BTC with 2 sat/byte, it will be much cheaper than making a transaction now for 20 inputs with 60 sat/byte.

Take a look at LoyceV guide about it:
Fees are low, use this opportunity to Consolidate your small inputs!

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
RapTarX (OP)
Hero Member
*****
Offline Offline

Activity: 1358
Merit: 850



View Profile
May 06, 2019, 03:32:04 PM
 #5

I had once seen this article but never tried to understand it. Thank you for breaking it down. Until now, I had misunderstanding about this. I guess now why it's important to consolidate all the input into one when fee is lower.
Corrected the OP.

Bitcoin_Arena
Copper Member
Legendary
*
Offline Offline

Activity: 2016
Merit: 1771


฿itcoin for all, All for ฿itcoin.


View Profile
May 06, 2019, 04:35:40 PM
 #6

There is one important thing you forgot to mention.

What matters for fees is not how many addresses you have, but how many inputs you have.
Thanks for the additional information.
I really had no idea that inputs can actually affect one's transaction fee.



Now back you your calculation @RapTarX
Code:
2*180 + 3*34 + 10 + or - 2 = 470/456 bytes.
we do see a +2 or -2 resulting into 470/456 bytes.

So which bytes do we consider? 470 or 456?
Or this is just a range where you can pick any value between 456 and 470 bytes and multiply with given rate which is currently 62sats/byte to get the total fees you have to pay?



Sorry for so many questions, I have been so reluctant in learning how to calculate these fees and this is an opportunity for me to know something  Wink

.BEST..CHANGE.███████████████
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
███████████████
..BUY/ SELL CRYPTO..
RapTarX (OP)
Hero Member
*****
Offline Offline

Activity: 1358
Merit: 850



View Profile
May 06, 2019, 04:43:56 PM
 #7

So which bytes do we consider? 470 or 456?
Or this is just a range where you can pick any value between 456 and 470 bytes and multiply with given rate which is currently 62sats/byte to get the total fees you have to pay?
I guess it's a range. The size can be anywhere between those two however I'm not certain about this till now. Probably a senior member can confirm it.

Quote
Sorry for so many questions, I have been so reluctant in learning how to calculate these fees and this is an opportunity for me to know something  Wink
A simple suggestion-
Do query on here or google. Read article, share here whatever you have learnt. Community will correct you. This thread can be an example of that.

LoyceV
Legendary
*
Offline Offline

Activity: 3290
Merit: 16498


Thick-Skinned Gang Leader and Golden Feather 2021


View Profile WWW
May 06, 2019, 06:00:40 PM
Merited by BitcoinGirl.Club (1)
 #8

Input*180 + output*34 + 10 plus or minus input
Say, input is 2 and output is to 3 address. The size is-
2*180 + 3*34 + 10 + or - 2 = 470/456 bytes.
There's a much easier solution: use https://coinb.in/#fees, and in a few clicks you get the size including a recommended fee for a fast transaction. Note that most transactions don't need to be fast.

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
RapTarX (OP)
Hero Member
*****
Offline Offline

Activity: 1358
Merit: 850



View Profile
May 06, 2019, 06:04:23 PM
 #9

Input*180 + output*34 + 10 plus or minus input
Say, input is 2 and output is to 3 address. The size is-
2*180 + 3*34 + 10 + or - 2 = 470/456 bytes.
There's a much easier solution: use https://coinb.in/#fees, and in a few clicks you get the size including a recommended fee for a fast transaction. Note that most transactions don't need to be fast.
Thank you but it was an initiative of learning the process how it actually get done.

we do see a +2 or -2 resulting into 470/456 bytes.
It should be 474/470 bytes. My initial calculation was wrong. I guess you got it now.

john2231
Hero Member
*****
Offline Offline

Activity: 924
Merit: 1001



View Profile
May 06, 2019, 07:05:12 PM
 #10

Check this formula below I just got it from google when searching images.

BitcoinGirl.Club
Legendary
*
Offline Offline

Activity: 2744
Merit: 2711


Farewell LEO: o_e_l_e_o


View Profile WWW
May 06, 2019, 07:50:21 PM
 #11


There's a much easier solution: use https://coinb.in/#fees, and in a few clicks you get the size including a recommended fee for a fast transaction. Note that most transactions don't need to be fast.
Yes this site made me people lazy LOL (especially me). Until today I did not have this mind how byte size calculation works. All those days I only played with the sat/B field.

Thanks OP. It was useful more me 🙂 I left you some reward. Enjoy your 50 merit mark.

▄▄███████▄▄
▄██████████████▄
▄██████████████████▄
▄████▀▀▀▀███▀▀▀▀█████▄
▄█████████████▄█▀████▄
███████████▄███████████
██████████▄█▀███████████
██████████▀████████████
▀█████▄█▀█████████████▀
▀████▄▄▄▄███▄▄▄▄████▀
▀██████████████████▀
▀███████████████▀
▀▀███████▀▀
.
 MΞTAWIN  THE FIRST WEB3 CASINO   
.
.. PLAY NOW ..
Quickseller
Copper Member
Legendary
*
Offline Offline

Activity: 2870
Merit: 2298


View Profile
May 06, 2019, 08:14:01 PM
Merited by bob123 (1)
 #12

Your formula is only accurate for non-segwit (and non-multisig) inputs.

A SegWit input will take up 91 bites and a bech32 input (a different type of SW address that starts with “BC1”) will take up 68 bites of block space after accounting for the witness (signature) discount.
RapTarX (OP)
Hero Member
*****
Offline Offline

Activity: 1358
Merit: 850



View Profile
May 06, 2019, 09:47:05 PM
 #13

Check this formula below I just got it from google when searching images.
I guess I too use this one as source in the OP, you probably have missed that part.

Thanks OP. It was useful more me 🙂 I left you some reward. Enjoy your 50 merit mark.
My pleasure. Thank you anyway.

Your formula is only accurate for non-segwit (and non-multisig) inputs.

A SegWit input will take up 91 bites and a bech32 input (a different type of SW address that starts with “BC1”) will take up 68 bites of block space after accounting for the witness (signature) discount.
Please link me toward the calculation of Segwit and bech32 segwit transaction size calculation. Interested to learn it.

Thirdspace
Hero Member
*****
Offline Offline

Activity: 1232
Merit: 738


Mixing reinvented for your privacy | chipmixer.com


View Profile
May 06, 2019, 10:50:54 PM
 #14

Your formula is only accurate for non-segwit (and non-multisig) inputs.

A SegWit input will take up 91 bites and a bech32 input (a different type of SW address that starts with “BC1”) will take up 68 bites of block space after accounting for the witness (signature) discount.
Please link me toward the calculation of Segwit and bech32 segwit transaction size calculation. Interested to learn it.

yes, your calculation works only for non-segwit inputs specifically utxo from uncompressed legacy addresses
for non-segwit compressed legacy you simply replace 180 with 148
checkout coinb.in's fee calculator that was mentioned by LoyceV in the post above
it should give you estimate size on almost all different possible inputs, except bech32 Tongue

pooya87
Legendary
*
Offline Offline

Activity: 3430
Merit: 10492



View Profile
May 07, 2019, 03:10:37 AM
Merited by LoyceV (2), bitmover (1)
 #15

please don't create incomplete guides like this one here with a misleading formula. what you have found on the internet belongs to many years ago where bitcoin only had 1 type of transactions with 2 type of public keys (compressed and uncompressed) nowadays there are more variations and that formula is so complicated that you better leave it to your wallet to automatically calculate it for you.
of if you want to post a guide then do it completely by including all the possible cases with different types of input/output. and keep in mind that fees are no longer measured in satoshi/byte but instead in satoshi/virtualByte

also please don't suggest bitcoinfees.earn.com (https://bitcointalk.org/index.php?topic=2848987.msg30657510#msg30657510)

Now back you your calculation @RapTarX
Code:
2*180 + 3*34 + 10 + or - 2 = 470/456 bytes.
we do see a +2 or -2 resulting into 470/456 bytes.

it is because the day Satoshi created bitcoin he decided to use a third party library for signature stuff. this library is the OpenSSL library. there the encoding used for signatures is a wasteful and in one word stupid encoding for something like bitcoin.
to keep it simple here is how it works:
when you create an ECDSA signature you basically have 2 n-bits integers (256 bit for bitcoin's curve) in this particular encoding, on top of other wasted bytes you sometimes have to add an additional byte (=0) to the start of these integers to tell everyone reading the encoding that the numbers are positive. so sometimes you end up with
(some other bytes) + 1 + 32 + 1 + 32 or
(some other bytes) + 0 + 32 + 0 + 32 or
(some other bytes) + 1 + 32 + 0 + 32 or
(some other bytes) + 0 + 32 + 1 + 32
hence the +-2

which again brings us back to the first line of this comment! nowadays the second number is changed for some reasons (outside of the scope of this topic) so it will always be smaller than 32 byte. and there is a much newer change which also changes the first number so that it is 32 bytes (in some implementations such as bitcoin-core) so you will always end up with the same 32 byte size hence a fixed signature size.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
RapTarX (OP)
Hero Member
*****
Offline Offline

Activity: 1358
Merit: 850



View Profile
May 07, 2019, 04:37:49 AM
 #16

please don't create incomplete guides like this one here with a misleading formula. what you have found on the internet belongs to many years ago where bitcoin only had 1 type of transactions with 2 type of public keys (compressed and uncompressed)
My bad, I am fairly new in this space and had no idea that fee can vary for legacy and segwit address. Had no idea for more input, I have to pay more fee. I got another thread about future fee of bitcoin transaction and this question peek at my mind that how fee is actually calculated. I was redirected to an article, was probably an old one which had referred to this method only.
Anyway, this is help and beginners board, beginners can do some mistakes. I guess members like you will always help beginners to understand the system, this is why a forum is the best place to learn.
I will update the topic with more information.
Thank you.

pooya87
Legendary
*
Offline Offline

Activity: 3430
Merit: 10492



View Profile
May 07, 2019, 05:10:58 AM
Merited by RapTarX (1)
 #17

please don't create incomplete guides like this one here with a misleading formula. what you have found on the internet belongs to many years ago where bitcoin only had 1 type of transactions with 2 type of public keys (compressed and uncompressed)
My bad, I am fairly new in this space and had no idea that fee can vary for legacy and segwit address. Had no idea for more input, I have to pay more fee. I got another thread about future fee of bitcoin transaction and this question peek at my mind that how fee is actually calculated. I was redirected to an article, was probably an old one which had referred to this method only.
Anyway, this is help and beginners board, beginners can do some mistakes. I guess members like you will always help beginners to understand the system, this is why a forum is the best place to learn.
I will update the topic with more information.
Thank you.

it is not just legacy and SegWit, it is also compressed and uncompressed public keys and also multi signatures both in SegWit outputs (2 types) and in legacy outputs (1 type). which depending on their number of signers the size can be very different. before the year ends we may even see new signatures (Schnorr) and end up with a new transaction size based on them!

it is good to learn but it is best to try and post things as a question.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
bitmover
Legendary
*
Offline Offline

Activity: 2282
Merit: 5878


bitcoindata.science


View Profile WWW
May 07, 2019, 10:11:33 AM
 #18


I will update the topic with more information.
Thank you.

I think this will be great.
Research more about the subject and expand your OP.

I did that with https://bitcointalk.org/index.php?topic=3317586.0

I read a lot about it and wrote. Then many users explained a lot of things to me that I wasn't aware and I updated it. Later on I read more about it and made new additions. You can do it here.


so far bitcoinfees.earn.com is inaccurate and leads to higher fees. coinb.in is better but i haven't checked it in long term to see how it performs under different circumstances.
I experienced this as well.

I usually search about 3-4 websites before making a transaction.  usually I use a lower value than suggested.

I noticed that Electrum suggests a fee as well when you are about to make a transaction (and they were lower than those websites).. Few months ago I made transactions with 1 sat/byte that wwere confirmed in less than 1hour, and most of those websites were suggesting more han 10sat/byte.


.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
codehtcmail
Sr. Member
****
Offline Offline

Activity: 1188
Merit: 260

Tryig to survive in this harsh world


View Profile
May 07, 2019, 12:27:45 PM
 #19

I use Electrum and rarely use their suggested fees unless I am in a hurry.
I am sending bitcoins to myself from a non segwit to a segwit address and I paid only 5 sat/byte as I don't really care when it will get confirmed.
TryNinja
Legendary
*
Offline Offline

Activity: 2814
Merit: 6962



View Profile WWW
May 07, 2019, 12:36:15 PM
 #20

I use Electrum and rarely use their suggested fees unless I am in a hurry.
I am sending bitcoins to myself from a non segwit to a segwit address and I paid only 5 sat/byte as I don't really care when it will get confirmed.
It will get confirmed pretty soon. The mempool is pretty much empty and 1-3 blocks would clean it up to 2-3 sat/byte transactions.

I think this is the best website to visualize the state of the mempool and see that: https://jochen-hoenicke.de/queue/#1,2h

.
.HUGE.
▄██████████▄▄
▄█████████████████▄
▄█████████████████████▄
▄███████████████████████▄
▄█████████████████████████▄
███████▌██▌▐██▐██▐████▄███
████▐██▐████▌██▌██▌██▌██
█████▀███▀███▀▐██▐██▐█████

▀█████████████████████████▀

▀███████████████████████▀

▀█████████████████████▀

▀█████████████████▀

▀██████████▀▀
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
CASINSPORTSBOOK
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
Pages: [1] 2 »  All
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!