3 ms·
Bitcoin transactions aren't as simple as "send X BTC from address A to address B". What's actually happening is that each transaction contains a number of inpu
by nebulous1 9y ago
Bitcoin transactions aren't as simple as "send X BTC from address A to address B". What's actually happening is that each transaction contains a number of inputs and a number of outputs, all of which have unique hashes (used to uniquely identify them in the system). Each input must either be a previous output, or the special case of no input in the generation transaction that each block miner gets to create (this assigns the bitcoin generated in each block and any fees accumulated from the other transactions).
So, if I send you 2 BTC to a single address, the transaction will probably have a single output. If you then try to send somebody 1 BTC your transaction has to use the entire 2 BTC input (which was the output from my transaction to you), but will have two outputs, 1 BTC with an output for whoever you're sending it to and another 1 BTC to an address your wallet controls.
So your transaction in the above example has to refer to the 2 BTC from my transaction by unique hash, it's not simply saying "send any 1 BTC from this address". This is all dealt with by your wallet.
Due to this, if transaction #2 was being processed first it would be using an input that didn't exist on the blockchain and would therefore be invalid.
- xg15 9y agoThanks for the explanation. This clears up a lot!