Author

Topic: Getting public address from scriptSig (for an altcoin varient) (Read 1284 times)

hero member
Activity: 626
Merit: 504
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.
donator
Activity: 1218
Merit: 1079
Gerald Davis
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.
hero member
Activity: 626
Merit: 504
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!
legendary
Activity: 1260
Merit: 1019
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
hero member
Activity: 626
Merit: 504
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...
sr. member
Activity: 294
Merit: 250
Bitmark Developer
legendary
Activity: 1260
Merit: 1019
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
hero member
Activity: 626
Merit: 504
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?
Jump to: