Bitcoin Forum
November 01, 2024, 03:46:28 PM *
News: Bitcoin Pumpkin Carving Contest
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Question about transaction outputs.  (Read 843 times)
piuk (OP)
Hero Member
*****
expert
Offline Offline

Activity: 910
Merit: 1005



View Profile WWW
August 17, 2011, 03:39:20 PM
 #1

When a bitcoin user sends an amount smaller than the size of their balance it is my understanding that two transactions are created and the remainder is sent back to the user. In a transaction such as this:

Quote
{
            "hash" : "6d124d67f4ebfd7a2b4e05852a86980b665f3e46903dd3177c12b3ebeb6ffbb6",
            "version" : 1,
            "lock_time" : 0,
            "size" : 259,
            "in" : [
                {
                    "prev_out" : {
                        "hash" : "5add561ad3d8e0e554809623509681101c85a666c5e48a5c3887c7c922e7841a",
                        "n" : 0
                    },
                    "scriptSig" : "3046022100b05a8751279e78c5096c536af528532f37e16c92ca9a4ac0f91e279f5f65990302210 0be87185a99bc6ace21209f13b148d44eaef2a2d7df6fda67bef84ab2e927b71701 04e6a2a199649366be01cabb1d9019ab755de0add011bfc2ea34c4c0243f1f80a708a2c2d53a91b f44bba215df1a4b1c8ebbe13480da35db73f080b425e05532ad"
                }
            ],
            "out" : [
                {
                    "value" : 18.44000000,
                    "scriptPubKey" : "OP_DUP OP_HASH160 1106a35156e021ac69bfb0fc0922a633447214e0 OP_EQUALVERIFY OP_CHECKSIG"
                },
                {
                    "value" : 0.01000000,
                    "scriptPubKey" : "OP_DUP OP_HASH160 b644b4754ea9a24ff7932b6d63e0878be63bd155 OP_EQUALVERIFY OP_CHECKSIG"
                }
            ]
 }

Is there anyway to determine which output was "real" and which one was returned to the original owner?

piuk (OP)
Hero Member
*****
expert
Offline Offline

Activity: 910
Merit: 1005



View Profile WWW
August 17, 2011, 08:27:03 PM
 #2

I guess it is not possible then? i.e. there is no relationship between prev_out hash and any of the out hashes?

jackjack
Legendary
*
Offline Offline

Activity: 1176
Merit: 1280


May Bitcoin be touched by his Noodly Appendage


View Profile
August 17, 2011, 08:40:36 PM
 #3

Nope, impossible to know because the output address is a pool key which never was used before

Own address: 19QkqAza7BHFTuoz9N8UQkryP4E9jHo4N3 - Pywallet support: 1AQDfx22pKGgXnUZFL1e4UKos3QqvRzNh5 - Bitcointalk++ script support: 1Pxeccscj1ygseTdSV1qUqQCanp2B2NMM2
Pywallet: instructions. Encrypted wallet support, export/import keys/addresses, backup wallets, export/import CSV data from/into wallet, merge wallets, delete/import addresses and transactions, recover altcoins sent to bitcoin addresses, sign/verify messages and files with Bitcoin addresses, recover deleted wallets, etc.
samr7
Full Member
***
Offline Offline

Activity: 140
Merit: 430

Firstbits: 1samr7


View Profile
August 17, 2011, 08:41:14 PM
 #4

I guess it is not possible then? i.e. there is no relationship between prev_out hash and any of the out hashes?

Somebody who knows the source better than I can correct, but it looks like the output for "change" is inserted at a random position in the transaction.  See CWallet::CreateTransaction(), wallet.c:969.  So, there shouldn't be any deterministic clues.
piuk (OP)
Hero Member
*****
expert
Offline Offline

Activity: 910
Merit: 1005



View Profile WWW
August 17, 2011, 08:52:57 PM
 #5

Ok thanks.

Forp
Full Member
***
Offline Offline

Activity: 195
Merit: 100


View Profile
August 17, 2011, 09:06:40 PM
 #6

Somebody who knows the source better than I can correct, but it looks like the output for "change" is inserted at a random position in the transaction.  See CWallet::CreateTransaction(), wallet.c:969.  So, there shouldn't be any deterministic clues.

From my point of view it is a correct reading of the source but an incorrectly drawn conclusion.

Example: Assume a transaction hat the outputs X and Y. Then usually ONE is the recipient of the payment and the OTHER is the original owner of the coins. Now assume that X is a well known bitcoin address (for example a donation address mentioned here in the forum). In this case you can safely conclude that Y belongs to the original owner of the coins.





kjj
Legendary
*
Offline Offline

Activity: 1302
Merit: 1026



View Profile
August 18, 2011, 12:00:13 PM
 #7

You can guess based on the amounts and have a very good chance of getting it right.  The code looks for the smallest single transaction larger than the spend amount to redeem, if possible, and then the smallest group of transactions.

For better privacy, the client could attempt to make the spend and the change roughly equal in size, but that will churn the wallet and make you pay higher fees in the long run.

17Np17BSrpnHCZ2pgtiMNnhjnsWJ2TMqq8
I routinely ignore posters with paid advertising in their sigs.  You should too.
piuk (OP)
Hero Member
*****
expert
Offline Offline

Activity: 910
Merit: 1005



View Profile WWW
August 18, 2011, 05:04:20 PM
 #8

thanks for your help kjj and forp, I think i can come up with a pretty accurate guess using both those methods.

Another thing i'm confused about. How to I determine the address the block reward was sent to? e.g. is their some way to extract the address out of "scriptSig"?

jackjack
Legendary
*
Offline Offline

Activity: 1176
Merit: 1280


May Bitcoin be touched by his Noodly Appendage


View Profile
August 18, 2011, 05:14:30 PM
 #9

thanks for your help kjj and forp, I think i can come up with a pretty accurate guess using both those methods.

Another thing i'm confused about. How to I determine the address the block reward was sent to? e.g. is their some way to extract the address out of "scriptSig"?
Take the 65 bytes starting with 04, it's the public key
Then, do that: http://dl.dropbox.com/u/1139081/BitcoinImg/PubKeyToAddr.png

Own address: 19QkqAza7BHFTuoz9N8UQkryP4E9jHo4N3 - Pywallet support: 1AQDfx22pKGgXnUZFL1e4UKos3QqvRzNh5 - Bitcointalk++ script support: 1Pxeccscj1ygseTdSV1qUqQCanp2B2NMM2
Pywallet: instructions. Encrypted wallet support, export/import keys/addresses, backup wallets, export/import CSV data from/into wallet, merge wallets, delete/import addresses and transactions, recover altcoins sent to bitcoin addresses, sign/verify messages and files with Bitcoin addresses, recover deleted wallets, etc.
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!