# Can two or more transactions sent from the same address be mined in the same block in Bitcoin's blockchain?

Imagine a person Bob has 10 bitcoins in his wallet. He wants to send 5 bitcoins to Alice and another 5 bitcoins to Uncle Tom simultaneously (in separate transactions). Will both Bob's transactions be confirmed in the same block?

If yes, than consider the case when Bob sends all 10 bitcoins to Alice in one transaction and simultaneously issues another transaction to send Uncle Tom the same 10 bitcoins. How is the double spending problem prevented in this case (I would like a technical answer for this one)?

For more technical details:

The thing to understand is that 'bitcoins' actually exist as 'unspent transaction ouputs' (UTXO)s. Here is some info comparing the UTXO model, to the 'accounts model'.

In your first example, Bob would create a transaction that 'consumes' some UTXOs in his wallet that sum to a total ≥5 BTC, and send it to Alice. If the total was more than exactly 5, then Bob's transaction would include a change address that pays the extra back to himself. Bob creates and broadcasts this transaction.

Now, assuming he had exactly 10 BTC in his wallet (and ignoring tx fees), in order for Bob to send Uncle Tom 5 BTC immediately, he will need to make a transaction that includes the change UTXO created in the transaction sent to Alice. He does this, and broadcasts it to the network.

Both of these transactions can be mined in the same block, or they can be mined in separate blocks, but the important thing is: Alice's transaction must come first, since it creates a UTXO that is spent in Uncle Tom's transaction. Even within a block, the order of transactions matters in this way. First Alice's, then Uncle Tom's. The other way around would create an invalid block that the network would reject.

In the second example, Bob would sum up all the UTXOs in his wallet, and create a 10 BTC transaction to send to Alice, but he would also use the same UTXOs to create a transaction to send to Uncle Tom.

Lets say that Bob strategically broadcast these two transactions to the network, so that about half the network heard about Alice's transaction first, and the other half heard about Uncle Tom's transaction first.

In this case, only one transaction will eventually be 'confirmed' by being included in a block, because all of Bob's UTXOs can only be consumed once! A second attempt would be rejected by the network as invalid. So whichever transaction is included in a block first will be the winner, though you may want to wait a few confirmations to be completely sure. Any nodes that heard about the other transaction first will simply discard it once they hear about the winning transaction being included in a block.

Will both Bob's transactions be confirmed in the same block?

This cannot be guaranteed. They might or might not.

consider the case when Bob sends all 10 bitcoins to Alice in one transaction and simultaneously issues another transaction to send Uncle Tom the same 10 bitcoins.

Bob's wallet will not allow him to double-spend. If Bob circumvents this, one of the transactions will be rejected by the network. In the worst case there may be a short period where it is unclear which transaction will win.

Each node in the network, whether a miner or a wallet will verify incoming transactions and mined blocks and will reject any that attempt to spend TXOs that are not UTXOs - i.e. which that node knows are already spent.

It can be that one miner selects the payment to Alice for inclusion in a block and another miner selects the payment to Tom. Other nodes will reject the second of such blocks that they receive, eventually the blocks with the most proof of work will be the only ones accepted, including by both miners.

Related questions:

and

• From a technical point of view, how will one of the transactions be rejected by the network? – anonuser1 Dec 4 '18 at 10:39
• @anonuser1: See links at end of answer for more details – RedGrittyBrick Dec 4 '18 at 10:59
• Once a transaction A is added to a block to be mined, will the node that is doing the mining for that block keep track of the output of that transaction A, so that if a new transaction B comes from the same address of transaction A, than it would know the eventual output of both the transactions and decide whether to accept both or reject one of these transactions? – anonuser1 Dec 4 '18 at 11:01
• @anonuser: No single node will ever simultaneously accept two transactions, for different recipients, which use the same UTXOs as inputs. It isn't just a matter of the address, there can be many UTXOs associated with an address. – RedGrittyBrick Dec 4 '18 at 11:23