Post
Topic
Board Beginners & Help
Merits 3 from 2 users
Re: Why does transaction works this way??
by
pooya87
on 15/06/2024, 04:36:19 UTC
⭐ Merited by hosseinimr93 (2) ,khaled0111 (1)
I've been curious about why transaction had to deal with spending of all inputs on a particular address.
Although I'm not new to the fact that all transaction  have to be spent in a single output  buy why does it have to work that way??
There are two ways I can think of in the payment systems. (1) Account based balance (2) output/coin based balance.

Bitcoin chose the second method an it is similar to physical cash.
Explaining it through cash helps you understand how things work better. When you receive cash, your "pocket" doesn't have a counter telling you a number that is your balance. Your balance is the sum of each of those individual "coins" or "bank notes". And when you want to spend your cash you have to pay a combination of those "coins" or "notes". For example if you have twelve 1 dollar bills and two 20 dollar bills and one to pay 22 dollars, you can either pay them using two 20 dollar bills and receive a 18 dollar "change" or you can use a single 20 dollar bill plus two 1 dollar bills without receiving any change. You can also give them all your cash ($52) and receive $30 (a single 30 dollar bill assuming that exists) change back!

That is how Bitcoin works as well. When you receive bitcoin, you are receiving individual outputs called "coins" and when you want to spend them you have to select these outputs to spend just like what we did with cash.

Quote
So the change I'm  receiving  can I call it an output  or a new input ??
It is an output when you receive it and it is an input when you spend it.

Quote
If it's not on a new address but on the same address(the received  UTXO), will it be counted as part of inputs along with other input when I want to send again  to a new address.
It doesn't matter in which address you receive those coins, they are all outputs that can be spent with each other in the same transaction.