Bitcoin Forum

Alternate cryptocurrencies => Altcoin Discussion => Topic started by: cryptapus on June 18, 2014, 12:56:46 AM



Title: Getting public address from scriptSig (for an altcoin varient)
Post by: cryptapus on June 18, 2014, 12:56:46 AM
Code:
I'm posting this in the Bitcoin Tech. Support as I'm not sure where to go with this, moderators please feel free to move this if it is more appropriate elsewhere. I understand this is for an altcoin that most bitcoin brains will not look at the source, nor care, and I fully expect not to receive a response. I am interested in this more to be educated than anything else...

308cb8732951cabed1f9596f96cf093daff7733cfd42d3cb9dacee180220652f1c73cf27fe01429b1262e86fc406f52ef73d8ad283b991b82ce12cb49b2801"
            },
            "sequence" : 429496729
        }

The "asm" line is quite short and has no break in it. Also, the "hex" line seems to show just the signature. My guess is that this particular altcoin clone is attempting to hide the sender by only supplying the signed input(?)

Any ideas?


Title: Re: Getting public address from scriptSig (for an altcoin varient)
Post by: amaclin on June 18, 2014, 03:56:07 AM
There is no address-info in scriptSig
You have to take the previous transaction and look at its outputs

this is spending PAY_TO_PUBKEY output
Code:
"txid" : "d12adf1ae575830b4e8d9e1178ccbaf4f22db106b2f268705445d21d17ac815f"
"asm" : "304402205242f797308cb8732951cabed1f9596f96cf093daff7733cfd42d3cb9dacee180220652f1c73cf27fe01429b1262e86fc406f52ef73d8ad283b991b82ce12cb49b2801"

30 - magic der prefix
44 - length of der data
0220 5242f797308cb8732951cabed1f9596f96cf093daff7733cfd42d3cb9dacee18 - R
0220 652f1c73cf27fe01429b1262e86fc406f52ef73d8ad283b991b82ce12cb49b28 -S
01 - hashtype (all)

you can not get pubkey (and address) from this data.
you should take d12adf1ae575830b4e8d9e1178ccbaf4f22db106b2f268705445d21d17ac815f and look at its output #1


Title: Re: Getting public address from scriptSig (for an altcoin varient)
Post by: coinsolidation on June 19, 2014, 12:10:07 PM
that is strange http://coinia.net/zimstake/blockexplorer.php?q=d12adf1ae575830b4e8d9e1178ccbaf4f22db106b2f268705445d21d17ac815f outputs total more than inputs.

edit: ahh it's not strange, it's a PoS block generation http://coinia.net/zimstake/blockexplorer.php?q=31684


Title: Re: Getting public address from scriptSig (for an altcoin varient)
Post by: cryptapus on June 24, 2014, 06:35:43 PM
There is no address-info in scriptSig
You have to take the previous transaction and look at its outputs

this is spending PAY_TO_PUBKEY output
Code:
"txid" : "d12adf1ae575830b4e8d9e1178ccbaf4f22db106b2f268705445d21d17ac815f"
"asm" : "304402205242f797308cb8732951cabed1f9596f96cf093daff7733cfd42d3cb9dacee180220652f1c73cf27fe01429b1262e86fc406f52ef73d8ad283b991b82ce12cb49b2801"

30 - magic der prefix
44 - length of der data
0220 5242f797308cb8732951cabed1f9596f96cf093daff7733cfd42d3cb9dacee18 - R
0220 652f1c73cf27fe01429b1262e86fc406f52ef73d8ad283b991b82ce12cb49b28 -S
01 - hashtype (all)

you can not get pubkey (and address) from this data.
you should take d12adf1ae575830b4e8d9e1178ccbaf4f22db106b2f268705445d21d17ac815f and look at its output #1


I guess I'm not totally satisfied with that answer. I see what you are saying but then why does every bitcoin/altcoin transaction scriptSig "asm" have two parts? Under what circumstances does that not happen? My guess is that that's just the way the client is coded, and that a valid transaction need not include a two part scriptSig, but that's just a guess...

By the way, I think you have to be careful with looking at a previous output to get a sending address. If there are multiple outputs in the previous output you will need to verify which one is the correct one...


Title: Re: Getting public address from scriptSig (for an altcoin varient)
Post by: amaclin on June 24, 2014, 07:33:51 PM
Quote
I guess I'm not totally satisfied with that answer. I see what you are saying but then why does every bitcoin/altcoin transaction scriptSig "asm" have two parts?
Valid scriptSig must correspond the previous output.
If output is PAY_TO_PUBKEY_HASH (the most popular one) I should provide signature and my public key.
So there are two pushes in scriptSig.

For output type PAY_TO_PUBKEY you already provide my public key in your output. So, I should put only the signature in scriptSig

There are other script types.

Quote
By the way, I think you have to be careful with looking at a previous output to get a sending address. If there are multiple outputs in the previous output you will need to verify which one is the correct one...
No-no-no! Stop here and read manuals again

The transaction may have more than one output.
Each output is a pair of value and script.

When I receive transaction from the network i do the following:
1) Is it correct? If yes - continue.
2) Are the output scripts known by my client? If yes - continue
3) Can I redeem(resend,forward) this outputs later? If yes - wow! Somebody sent me money!

Read carefuly https://en.bitcoin.it/wiki/Script#Scripts please


Title: Re: Getting public address from scriptSig (for an altcoin varient)
Post by: cryptapus on June 24, 2014, 10:43:48 PM
Quote
I guess I'm not totally satisfied with that answer. I see what you are saying but then why does every bitcoin/altcoin transaction scriptSig "asm" have two parts?
Valid scriptSig must correspond the previous output.
If output is PAY_TO_PUBKEY_HASH (the most popular one) I should provide signature and my public key.
So there are two pushes in scriptSig.

For output type PAY_TO_PUBKEY you already provide my public key in your output. So, I should put only the signature in scriptSig

There are other script types.


Ah.. This is what I was looking for. Thanks for this.

Quote

Quote
By the way, I think you have to be careful with looking at a previous output to get a sending address. If there are multiple outputs in the previous output you will need to verify which one is the correct one...
No-no-no! Stop here and read manuals again

The transaction may have more than one output.
Each output is a pair of value and script.

When I receive transaction from the network i do the following:
1) Is it correct? If yes - continue.
2) Are the output scripts known by my client? If yes - continue
3) Can I redeem(resend,forward) this outputs later? If yes - wow! Somebody sent me money!

Read carefuly https://en.bitcoin.it/wiki/Script#Scripts please

My point was that I'm not sure you can assume that "output #1" was the pair that you were interested in, it might be the 2nd, etc.

Thanks for the insight!


Title: Re: Getting public address from scriptSig (for an altcoin varient)
Post by: DeathAndTaxes on June 24, 2014, 11:51:57 PM
My point was that I'm not sure you can assume that "output #1" was the pair that you were interested in, it might be the 2nd, etc.

What?

You don't assume anything.   Every input refers to a specific exact output.
Quote
"txid" : "d12adf1ae575830b4e8d9e1178ccbaf4f22db106b2f268705445d21d17ac815f",
            "vout" : 1,

Note the bolded portion.   vout refers the to output index and it is a zero based index so "1" = 2nd output.  If it was "0" it would be the 1st output and if it was "128" it would be the 129th output of that tx.  There is no assumptions involved.


Title: Re: Getting public address from scriptSig (for an altcoin varient)
Post by: cryptapus on June 25, 2014, 01:00:23 PM
My point was that I'm not sure you can assume that "output #1" was the pair that you were interested in, it might be the 2nd, etc.

What?

You don't assume anything.   Every input refers to a specific exact output.
Quote
"txid" : "d12adf1ae575830b4e8d9e1178ccbaf4f22db106b2f268705445d21d17ac815f",
            "vout" : 1,

Note the bolded portion.   vout refers the to output index and it is a zero based index so "1" = 2nd output.  If it was "0" it would be the 1st output and if it was "128" it would be the 129th output of that tx.  There is no assumptions involved.


OK, thanks for the clarification.

Thank you all for your insight.