Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Fuzzy on June 12, 2012, 06:13:21 AM



Title: Possible to send a transaction without sending ALL coins from your adress?
Post by: Fuzzy on June 12, 2012, 06:13:21 AM
Does the bitcoin protocol support the ability to send a portion of your balance from address A to someone else's address X without sending ALL the coins from address A?

As I understand, the default transaction method in the standard client would take all the coins from A, send whatever amount you specified to address X, and send the remainder to address B, which is just another address in your wallet address pool.





Title: Re: Possible to send a transaction without sending ALL coins from your adress?
Post by: DeathAndTaxes on June 12, 2012, 06:17:16 AM
No.

The reason why is Bitcoin doesn't know/care about address balances.  You spend (use as inputs) prior tx ouputs.  We call these outputs "unspent" outputs.  Due to the way that Bitcoin tx are constructed any Output can only be spent once.  So all outputs can be classified as either spent or unspent.  The spent ones can be pruned away and the sum of all the unspent outputs for which you have private keys is the "value" of your wallet.

As a technicallity you can "send" less than the value of an output but the output is still totally spent.  If you create tx with 50 BTC input and 1 BTC output then you just created a tx w/ a 49 BTC tx fee.  Lucky miner to be the one who mines that block.


Title: Re: Possible to send a transaction without sending ALL coins from your adress?
Post by: Revalin on June 12, 2012, 06:19:00 AM
Close.  It will take all the coins from certain prior outputs in address A -  but not necessarily the whole balance since there may be other transactions - and send them all to X and B.  It already does this routinely.

It is not possible to spend only part of a transaction.  You have to generate change unless you're spending the exact amount of one of the prior outputs.


Title: Re: Possible to send a transaction without sending ALL coins from your adress?
Post by: Fuzzy on June 12, 2012, 06:47:08 AM
Interesting. Could you then Just have a wallet with two addresses, A and B, and bounce the change from one to the other when sending to X?

ie, your wallet has address A and B only, and A holds 50 BTC. X,Y,Z are various addresses you want to send coins to.

A sends 10 to X, remaining 40 to B

B now has 40 BTC.


B sends 10 to Y, remaining 30 to A

A now has 30 BTC


A sends 10 to Z, remaining 20 to B

B now has 20 BTC.

etc etc...


I'm looking at the possibility of hard-coding the private keys for A and B into an executable, in case anyone is wondering why I'm asking.


Title: Re: Possible to send a transaction without sending ALL coins from your adress?
Post by: bitcats on June 12, 2012, 06:53:45 AM
Does the bitcoin protocol support the ability to send a portion of your balance from address A to someone else's address X without sending ALL the coins from address A?

As I understand, the default transaction method in the standard client would take all the coins from A, send whatever amount you specified to address X, and send the remainder to address B, which is just another address in your wallet address pool.
You can use Electrum if you automatically want to get the change back to the sending address.


Title: Re: Possible to send a transaction without sending ALL coins from your adress?
Post by: Maged on June 12, 2012, 06:54:17 AM
Oh, in that case, let me add an important detail: the change address can be any Bitcoin address, including an address that signed an input.

So, A sends 10 to X, remaining 40 to A.


Title: Re: Possible to send a transaction without sending ALL coins from your adress?
Post by: Fuzzy on June 12, 2012, 07:06:50 AM
Oh, in that case, let me add an important detail: the change address can be any Bitcoin address, including an address that signed an input.

So, A sends 10 to X, remaining 40 to A.

Bingo! Talk about a technicality o.O

Just to be sure, can anyone confirm this will work without some other technical catch?


Title: Re: Possible to send a transaction without sending ALL coins from your adress?
Post by: DeathAndTaxes on June 12, 2012, 07:12:49 AM
Yes it will work.  Blockchain.info wallet works this way


Title: Re: Possible to send a transaction without sending ALL coins from your adress?
Post by: Revalin on June 12, 2012, 07:18:34 AM
It's no technicality.  It works just fine.

Again, this will fully use all of JUST the inputs (not the whole balance of A).


Title: Re: Possible to send a transaction without sending ALL coins from your adress?
Post by: Foxpup on June 12, 2012, 07:39:53 AM
Oh, in that case, let me add an important detail: the change address can be any Bitcoin address, including an address that signed an input.

So, A sends 10 to X, remaining 40 to A.

Bingo! Talk about a technicality o.O

Just to be sure, can anyone confirm this will work without some other technical catch?

There's no technical catch, just a privacy catch: by using a different address for change, there is no way to know with absolute certainty (though you can make an educated guess) which address is the recipient and which is the change; sending change to the original address removes the guesswork involved in determining who the recipient is.


Title: Re: Possible to send a transaction without sending ALL coins from your adress?
Post by: da2ce7 on June 12, 2012, 12:19:43 PM
Sending change to a new address becomes a non-issue when the client finally supports deterministic wallets.  ;D