Author

Topic: Things I still don't understand about the blockchain (Read 470 times)

HCP
legendary
Activity: 2086
Merit: 4361
Isn't this a very similar number of bytes for each transaction? I mean, it's simply adding or removing numbers for public addresses - isn't it?
Not necessarily. When you send bitcoins to an address... it creates an "Unspent Transaction Output"... also know as an UTXO. When you want to create a transaction, you need to start adding UTXOs together until you get enough to add up to the total you're trying to spend (+ miners fee).

So... if you have a "big" UTXO, like 1.0 BTC... and you want to send 0.1 BTC someone... that's easy... 1 UTXO in -> 2 UTXOs out (0.1 to the person, 0.8999 back to you as change, + 0.0001 miners fee). A transaction like that (1 in, 2 out) will generally be around 226bytes.

However, if you have a whole bunch on little UTXOs in your wallet... like you have 15x 0.01 BTC payments... and now you want to send 0.1 BTC to someone... you're going to need 11 UTXOs as input (remember, you have to cover the miners fee!) So... 11 UTXO in -> 2 UTXO out (0.1 to person, 0.009 to you as change + 0.001 miners fee).

The "general" formula for transaction size is:

(#Inputs * 148) + (#outputs * 34) + 10 bytes

So, the first one:
(1 * 148) + (2 * 34) + 10 = 226 bytes Cheesy

and the 2nd one:
(11 * 148) + (2 * 34) + 10 = 1706 bytes! Shocked

This is the reason why you should try as hard as possible to avoid collecting lots of small amounts in your wallet... sooner or later you'll end up needing to use a whole bunch of UTXOs to create a transaction and you'll get slammed on fees Undecided

Quote
Another question in that path: Once I send something bitcoins, where does my transaction goes to for all the miners to grab it from?
I understand that all the past data is in the blockchain, but where is the data that is still not in the blockchain?
There is a network of "nodes" who hold and relay unconfirmed transactions... they have what is referred to as a "mempool" or memory pool... your transaction sits in the mempool of various nodes until a miner includes it in a block.

If it sits for too long (used to be around 72 hours, but seems to be getting longer these days) nodes will start to drop it from their mempool. Once all nodes drop it, it is like the transaction never existed and your coins should be respendable by your wallet.
newbie
Activity: 12
Merit: 1
Thanks again Foxpup,

You said about the fee amount:
Quote
It is proportional to the number of bytes of data the transaction requires, since that's the limiting factor in including transactions in a block.
Isn't this a very similar number of bytes for each transaction? I mean, it's simply adding or removing numbers for public addresses - isn't it?


Another question in that path: Once I send something bitcoins, where does my transaction goes to for all the miners to grab it from?
I understand that all the past data is in the blockchain, but where is the data that is still not in the blockchain?

Thanks again!
legendary
Activity: 4542
Merit: 3393
Vile Vixen and Miss Bitcointalk 2021-2023
1. How are those set and where? Is the fee set on each transaction? Can I choose to pay as much as I want?
The sender of the transaction sets the fee for that transaction, and it can be as much or as little as they choose. Note that competently designed wallet software will automatically choose an appropriate fee based on current conditions; it is not normally necessary to choose a fee manually.

2. Is it percentage or fixed?
It is proportional to the number of bytes of data the transaction requires, since that's the limiting factor in including transactions in a block.

3. The miner of the latest block gets all the fees for the transaction in that block? Or is it more complicated?
Yes, it's that simple.
newbie
Activity: 12
Merit: 1
Thanks Foxpup, I really appreciate your help!

I have more questions now.. Tongue

Fees:
1. How are those set and where? Is the fee set on each transaction? Can I choose to pay as much as I want?
2. Is it percentage or fixed?
3. The miner of the latest block gets all the fees for the transaction in that block? Or is it more complicated?

Thanks again
legendary
Activity: 4542
Merit: 3393
Vile Vixen and Miss Bitcointalk 2021-2023
1. Bitcoin block size is limited to 1 MB - right?
Right.

So what will happen if the amount of transactions in last 10 minutes will not be able to fit in the block?
Normally, the transactions paying the highest fees get in first, and all others will have to wait for the next block. (Miners don't have to prioritise transactions by fee, but they have a financial incentive to do so.)

Or for example if someone malicious will run a loop script that opens millions / billions of addresses and send them 0.0000001 BTC to clog the system...?
Without fees (making the attack incredibly expensive), such transactions will not be confirmed.



2. As I understand - The blockchain's ledger doesn't have my wallets total amount - it's only documenting the transactions.
So to know how much BTC my wallet has - We have to calculate everything from the beginning of the blockchain, or at least from the first block of my wallet's address - right?
Right.

If this is true, how come it's not super slow once the blockchain in very big?
Because wallet software stores the result, so it only has to calculate it from scratch once, which doesn't take too long in any case as computers are fast.
newbie
Activity: 12
Merit: 1
Hi,

I'm into bitcoin and crypto for a few years. And getting more and more into this space.

However, there are things that I still don't understand about bitcoin and blockchain in general and I think others will also appreciate learning about.
I hope someone can help me understand the following:

1. Bitcoin block size is limited to 1 MB - right?
So what will happen if the amount of transactions in last 10 minutes will not be able to fit in the block?
Or for example if someone malicious will run a loop script that opens millions / billions of addresses and send them 0.0000001 BTC to clog the system...?

2. As I understand - The blockchain's ledger doesn't have my wallets total amount - it's only documenting the transactions.
So to know how much BTC my wallet has - We have to calculate everything from the beginning of the blockchain, or at least from the first block of my wallet's address - right?
If this is true, how come it's not super slow once the blockchain in very big?


Thanks!

 
Jump to: