Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: derrend on May 19, 2014, 04:18:06 AM



Title: possible to decode bitcoin address from 'scriptSig' in a raw transaction?
Post by: derrend on May 19, 2014, 04:18:06 AM
Code:
7.  "in":[
8.    {"prev_out":
9.      {"hash":"2007ae...",
10.      "n":0},
11.    "scriptSig":"304502... 042b2d..."}],

Quote
Line 11 contains the signature of the person sending the money,
304502..., followed by a space, and then the corresponding public key, 04b2d.... Again, these are both in hexadecimal.

Can I convert the public key in scriptSig back into it's corresponding bitcoin address or is this not possible?
Thanks :)


Title: Re: possible to decode bitcoin address from 'scriptSig' in a raw transaction?
Post by: DannyHamilton on May 19, 2014, 04:43:01 AM
Code:
7.  "in":[
8.    {"prev_out":
9.      {"hash":"2007ae...",
10.      "n":0},
11.    "scriptSig":"304502... 042b2d..."}],

Quote
Line 11 contains the signature of the person sending the money,
304502..., followed by a space, and then the corresponding public key, 04b2d.... Again, these are both in hexadecimal.

Can I convert the public key in scriptSig back into it's corresponding bitcoin address or is this not possible?
Thanks :)

http://lmgtfy.com/?q=technical+background+of+bitcoin+address&l=1


Title: Re: possible to decode bitcoin address from 'scriptSig' in a raw transaction?
Post by: cp1 on May 19, 2014, 04:55:55 AM
Yes, there are many utilities to do that, or you can write your own.  For example:

Code:
$ echo 0406b7bb1663fc7b6a8a5630038a393581fe24c4fa6da64d94fd76de758885809f40ba54c40b95040294defc84d255079b4a13d1f784c1cf271dbc0d4e864a1696 | sx addr
$ 1F1kaJLcYMFGK8Fzx5HD1gBjciGJ6U3a1e


Title: Re: possible to decode bitcoin address from 'scriptSig' in a raw transaction?
Post by: derrend on May 19, 2014, 05:22:30 AM
I did it with gferrin's bitcoin-code (https://github.com/gferrin/bitcoin-code/blob/master/keyUtils.py),
My confusion stemmed from the
Code:
base58.public_key_to_bc_address()
function in gavinandresen's bitcointools (https://github.com/gavinandresen/bitcointools) giving me the wrong result. (most likely I am running the wrong version or something)

Thank you for the pointers fellas :)