Bitcoin Forum

Other => Beginners & Help => Topic started by: AliceWonder on July 06, 2013, 07:00:10 AM



Title: Let me clarify one more thing with transactions
Post by: AliceWonder on July 06, 2013, 07:00:10 AM
Assume bitcoin-qt client but I don't think it matters. And assume no miner fees. And assume everyone starts with 0 BTC.

Bob has seven people each send him 1 BTC. Let's say they went to seven different addresses in his wallet.

Bob sends 7 BTC to Mary. The transaction will involve all seven of Bob's keys (signed by private and include public) to prove he has right to spend those 7 BTC.
But the transaction will be a single transaction even though it comes from 7 different addresses.

Mary sends 4 BTC to Freddie.

What will happen is two outgoing transactions, both signed by Mary's public key.
One worth 4 BTC that goes to Freddie and one worth 3 BTC that goes to a fresh address in Mary's wallet.

So Mary will still have 3 BTC in her wallet but the address she received the 7 at will show 0 BTC.

Is this correct?


Title: Re: Let me clarify one more thing with transactions
Post by: DeathAndTaxes on July 06, 2013, 07:15:04 AM
No.  This portion is incorrect.

Quote
Mary sends 4 BTC to Freddie.

What will happen is two outgoing transactions, both signed by Mary's public key.
One worth 4 BTC that goes to Freddie and one worth 3 BTC that goes to a fresh address in Mary's wallet.

The transaction from Mary will be a single transaction

Input0: 7 BTC sent from Bob.
Output0: 4 BTC to Freddie
Output1: 3 BTC "change" back to Mary.

It is best to always think about transactions as simply inputs and outputs.  In Bob's case if he received 7x 1 BTC inputs it doesn't matter if they were sent to 7 addresses or all 7 to one address regardless they are 7 discrete inputs.  So Bob's tx would look like this

Input0: 1 BTC
Input1: 1 BTC
Input2: 1 BTC
Input3: 1 BTC
Input4: 1 BTC
Input5: 1 BTC
Input6: 1 BTC
Output: 7 BTC (to mary)

A couple of general rules
1) Transactions consists of one or more inputs and outputs.
2) The sum of the inputs of a tx must be equal to or greater than the sum of the outputs
3) If the sum of inputs is greater than the sum of the outputs the difference is the fee paid to miners.
4) All tx (except coinbase txs) have as their inputs, the unspent outputs of prior transactions.
5) Outputs can only be unspent or spent.  You can't spend part of an output.









Title: Re: Let me clarify one more thing with transactions
Post by: DannyHamilton on July 06, 2013, 01:26:38 PM
Assume bitcoin-qt client but I don't think it matters.

It does matter.  Each wallet has its own way of handling the "change" in the transaction.  Bitcoin-Qt uses a new completely random address for the change.  blockchain.info sends the change back to the main address displayd for your wallet when you log in.  I can't remember which one, but I think either MultiBit or Electrum send the change to the second address in your address list (if you have more than one address, otherwise it sends to the only address in the list).
 3 BTC that goes to a fresh address in Mary's wallet.

So Mary will still have 3 BTC in her wallet but the address she received the 7 at will show 0 BTC.

Is this correct?

This is where the wallet matters. DeathAndTaxes already took care of correcting the rest of your confusion, but you may want to be aware that the protocol says nothing about where you have to send the "change", only that any value from the sum of the inputs that is greater than the sum of the outputs becomes fees to the miner.  If you don't want that excess value to be paid to the miner, then you have to send it "somewhere". The protocol doesn't really care where you send it.  As such, each wallet designer has chosen their own way of deciding where to send that excess value.


Title: Re: Let me clarify one more thing with transactions
Post by: AliceWonder on July 06, 2013, 05:34:40 PM
OK thank you, I think I got it now.