What is a Bitcoin transaction like?
Bitcoin transactions are understood as bitcoin shipments. All of them are nothing more than records saved in the blockchain.
A transaction is divided into three parts:
- Input/s. Sections of an issuer address containing bitcoins.
- Amount. The amount of Bitcoins that the issuer sends to the receiver.
- Output(s). The receiver's purse.
This structure maintains the security of Bitcoin, as it is signed with cryptographic keys that certify its validity.
This operation internally is represented under Bitcoin scripting ,and the vast majority of Bitcoin transactions currently respond to that scheme.
If the issuer has control of an address with 1 bitcoin but only wants to transfer 0.3 bitcoins and there was no concept of "inputs" there would be no way that the system could know that part of that 1 is the 0.3 sent being forwarded. Therefore there is the concept of entries, to which bitcoins that arrive at an address are associated.
This takes enough entries to reach the desired amount, and if to reach 0.3 you have had to select 3 entries of 0.12 each, the result being 0.36, the other remaining 0.06 are sent to your own address indicating it as output next to the address to which you wanted to send 0.3.
That is, we have a scenario of inputs and outputs.
The own address where the remaining 0.06 BTC is sent can be the same address as any associated with the entries or a new one. This is called the direction of change.
It is also important to understand that in the same transaction there can be as many entries from the same address or multiple entries as desired. The same goes for exits. This allows you to make multiple shipments to different people in the same transaction with a single commission payment to miners. This functionality is exploited by some wallets to save costs.
The internal way of rewarding miners comes from funds that are not allocated to any address. All remaining bitcoins in a transaction that are not assigned to any address are left by the miner who mines the block with your transaction inside and are impossible to recover.