Bitcoin Forum
May 05, 2024, 06:41:02 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: BTC protocol question - why do I get money back?  (Read 1694 times)
BrightAnarchist (OP)
Donator
Legendary
*
Offline Offline

Activity: 853
Merit: 1000



View Profile
January 28, 2012, 12:44:22 AM
 #1

I think I'm just not understanding something about the BTC protocol. Can someone explain why Bitcoin splits my transaction into seemingly random-sized smaller transactions, and why it automatically creates a new second address during a transaction ( that is, it sends some coins back to me at a new address)?

I thought you could just cleanly sign over a specific number of coins to a new address.

Thanks!
1714934462
Hero Member
*
Offline Offline

Posts: 1714934462

View Profile Personal Message (Offline)

Ignore
1714934462
Reply with quote  #2

1714934462
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714934462
Hero Member
*
Offline Offline

Posts: 1714934462

View Profile Personal Message (Offline)

Ignore
1714934462
Reply with quote  #2

1714934462
Report to moderator
1714934462
Hero Member
*
Offline Offline

Posts: 1714934462

View Profile Personal Message (Offline)

Ignore
1714934462
Reply with quote  #2

1714934462
Report to moderator
Revalin
Hero Member
*****
Offline Offline

Activity: 728
Merit: 500


165YUuQUWhBz3d27iXKxRiazQnjEtJNG9g


View Profile
January 28, 2012, 12:48:14 AM
 #2

It can't just use the balance of an address.  It has to name specific inputs.  So if you received .01 BTC 50 times, and you want to spend .25 BTC, it will have to specifically call out 25 of those transactions as inputs, then one or two outputs (depending if change is required).

      War is God's way of teaching Americans geography.  --Ambrose Bierce
Bitcoin is the Devil's way of teaching geeks economics.  --Revalin 165YUuQUWhBz3d27iXKxRiazQnjEtJNG9g
Red Emerald
Hero Member
*****
Offline Offline

Activity: 742
Merit: 500



View Profile WWW
January 28, 2012, 12:49:00 AM
 #3

I think I'm just not understanding something about the BTC protocol. Can someone explain why Bitcoin splits my transaction into seemingly random-sized smaller transactions, and why it automatically creates a new second address during a transaction ( that is, it sends some coins back to me at a new address)?

I thought you could just cleanly sign over a specific number of coins to a new address.

Thanks!


When the output of a transaction is used as the input of another transaction, it must be spent in its entirety. Sometimes the coin value of the output is higher than what the user wishes to pay. In this case, the client generates a new Bitcoin address, and sends the difference back to this address. This is known as change.
The wallet file contains the private keys for change addresses, and they can receive and send coins normally. However, the GUI in the default client does not display them in the address book.

BrightAnarchist (OP)
Donator
Legendary
*
Offline Offline

Activity: 853
Merit: 1000



View Profile
January 28, 2012, 12:49:09 AM
 #4

Ahhhhh, right.

Okay, I feel stupid now Smiley

Thanks though!
Ente
Legendary
*
Offline Offline

Activity: 2126
Merit: 1001



View Profile
January 28, 2012, 12:24:01 PM
 #5

I am still undecided if I like that "send change somewhere else" (because its more anonymous) or hate it (because eventually someone will lose Bitcoins)..

Ente
BrightAnarchist (OP)
Donator
Legendary
*
Offline Offline

Activity: 853
Merit: 1000



View Profile
January 28, 2012, 06:30:41 PM
 #6

I am still undecided if I like that "send change somewhere else" (because its more anonymous) or hate it (because eventually someone will lose Bitcoins)..

Ente

True, this why you have to be so careful when spending bitcoin! Because it is not immediately obvious in the default client what is going on. The coderr patch makes it much more transparent.
BookLover
Hero Member
*****
Offline Offline

Activity: 533
Merit: 500


^Bitcoin Library of Congress.


View Profile
January 29, 2012, 02:41:13 PM
 #7

I am still undecided if I like that "send change somewhere else" (because its more anonymous) or hate it (because eventually someone will lose Bitcoins)..

Ente
People have already lost coins, but since the implementation of the key-pool I haven't heard of any unsolved problems.

chrisrico
Hero Member
*****
Offline Offline

Activity: 496
Merit: 500


View Profile
January 29, 2012, 03:30:27 PM
 #8

People have already lost coins, but since the implementation of the key-pool I haven't heard of any unsolved problems.

I lost some partially due to my own stupidity, partially due to not realizing that this change occurred.

Quote
Technical note: the encrypted wallet’s ‘keypool’ will be regenerated the first time you request a new bitcoin address;

I keep multiple wallets, encrypted with GPG. I have a script that lets me choose a wallet, unpacks it to the ~/.bitcoin directory, waits for Bitcoin to close, and then encrypts and securely deletes the wallet. For this reason, if something goes wrong, I feel comfortable deleting the wallet.dat file since I have a very recent (encrypted) backup.

So, I updated to the new version, it futzed around with my wallet, I sent some coins to myself (change going to an address from the (fresh) key pool). Then I closed Bitcoin and something went wrong with my script, so I deleted wallet.dat, along with the private key used for the change. I lost 77 BTC that day and it has made me much more cautious.
jake262144
Full Member
***
Offline Offline

Activity: 210
Merit: 100


View Profile
January 29, 2012, 08:07:31 PM
 #9

I lost 77 BTC that day and it has made me much more cautious.
It would seem your (obviously lacking in error control) backup script made you develop a cavalier attitude toward the wallet file.
Ever heard of doing off-site backups?

Also, what the hell? Unless you changed it, there should be a pool of 100 unused keys in your wallet.
How were you able to run out of key-pool with so many "recent backups"?
Something just doesn't add up here.
chrisrico
Hero Member
*****
Offline Offline

Activity: 496
Merit: 500


View Profile
January 29, 2012, 08:51:18 PM
 #10

It would seem your (obviously lacking in error control) backup script made you develop a cavalier attitude toward the wallet file.
Ever heard of doing off-site backups?

It's not a backup script.

Also, what the hell? Unless you changed it, there should be a pool of 100 unused keys in your wallet.
How were you able to run out of key-pool with so many "recent backups"?
Something just doesn't add up here.

As I mentioned, this occurred after the release of 0.5.0. The first time that version runs it rewrites your wallet, which entails creating a new key pool. If I had realized this at the time, I would not have deleted wallet.dat and would not have had this problem. Since I didn't, though, I deleted it and lost the completely new pool, from which the ~77 BTC change address pulled.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!