Author

Topic: Bitcoinbook P2SH(P2WPKH/P2WSH) example?? (Read 1235 times)

newbie
Activity: 15
Merit: 5
January 20, 2017, 02:19:45 PM
#5
Double check that you are hashing everything correctly and that all of the hashes match up to what they say they should be.

You should also take a look in the actual BIP where this is specified: https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#P2WPKH_nested_in_BIP16_P2SH

Yes, I'm not even getting the right hash160 of the segwit program (according to the book example) but it seems that I'm following the right process (the lib author hadn't seen anything wrong with my code).

The process I'm following:

1) Create segwit program with the pubkeyhash and the version number provided in the book:
Code:
OP_0 0x14 0xab68025513c3dbd2f7b92a94e0581f5d50f654e7

2) Getting the hash160 of 1) (not matching from here below):
Code:
3e0547268b3b19288b3adef9719ec8659f4b2b0b 

3) Embedding 2) in a p2sh script:
Code:
OP_HASH160 0x14 0x3e0547268b3b19288b3adef9719ec8659f4b2b0b OP_EQUAL

4) Obtaining the address from 3):
Code:
37Lx99uaGn5avKBxiW26HjedQE3LrDCZru

Using bcoin lib.
Yes. This is correct. It looks like there is an error in book.

Ok, issue updated, just in case...
staff
Activity: 3458
Merit: 6793
Just writing some code
January 20, 2017, 12:57:53 PM
#4
Double check that you are hashing everything correctly and that all of the hashes match up to what they say they should be.

You should also take a look in the actual BIP where this is specified: https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#P2WPKH_nested_in_BIP16_P2SH

Yes, I'm not even getting the right hash160 of the segwit program (according to the book example) but it seems that I'm following the right process (the lib author hadn't seen anything wrong with my code).

The process I'm following:

1) Create segwit program with the pubkeyhash and the version number provided in the book:
Code:
OP_0 0x14 0xab68025513c3dbd2f7b92a94e0581f5d50f654e7

2) Getting the hash160 of 1) (not matching from here below):
Code:
3e0547268b3b19288b3adef9719ec8659f4b2b0b 

3) Embedding 2) in a p2sh script:
Code:
OP_HASH160 0x14 0x3e0547268b3b19288b3adef9719ec8659f4b2b0b OP_EQUAL

4) Obtaining the address from 3):
Code:
37Lx99uaGn5avKBxiW26HjedQE3LrDCZru

Using bcoin lib.
Yes. This is correct. It looks like there is an error in book.
newbie
Activity: 15
Merit: 5
January 20, 2017, 11:25:40 AM
#3
Double check that you are hashing everything correctly and that all of the hashes match up to what they say they should be.

You should also take a look in the actual BIP where this is specified: https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#P2WPKH_nested_in_BIP16_P2SH

Yes, I'm not even getting the right hash160 of the segwit program (according to the book example) but it seems that I'm following the right process (the lib author hadn't seen anything wrong with my code).

The process I'm following:

1) Create segwit program with the pubkeyhash and the version number provided in the book:
Code:
OP_0 0x14 0xab68025513c3dbd2f7b92a94e0581f5d50f654e7

2) Getting the hash160 of 1) (not matching from here below):
Code:
3e0547268b3b19288b3adef9719ec8659f4b2b0b 

3) Embedding 2) in a p2sh script:
Code:
OP_HASH160 0x14 0x3e0547268b3b19288b3adef9719ec8659f4b2b0b OP_EQUAL

4) Obtaining the address from 3):
Code:
37Lx99uaGn5avKBxiW26HjedQE3LrDCZru

Using bcoin lib.
staff
Activity: 3458
Merit: 6793
Just writing some code
January 20, 2017, 11:13:46 AM
#2
Double check that you are hashing everything correctly and that all of the hashes match up to what they say they should be.

You should also take a look in the actual BIP where this is specified: https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#P2WPKH_nested_in_BIP16_P2SH
newbie
Activity: 15
Merit: 5
January 20, 2017, 07:42:23 AM
#1
I'm trying to replicate the example on Andreas bitcoinbook dev branch, about upgrading to segwit addresses but without success. Someone can please confirm that the example at least is correct?

https://github.com/bitcoinbook/bitcoinbook/blob/develop/segwit.asciidoc#pay-to-witness-public-key-hash-inside-pay-to-script-hash

For example, in the P2WPKH case, the final P2SH(P2WPKH) the book says the resulting address is 3AzZFY4WJJZbVr2A6qBTbdkYRpMLbdg6gD but I'm getting 37Lx99uaGn5avKBxiW26HjedQE3LrDCZru . I checked that address  and the hash coincides with the base58 encoding, so can someone make a full example confirmation? I think I'm getting the p2wpkh program hash wrong. you can watch my code on the issue i linked below.

I opened an issue but the last commit is from 3 months ago: https://github.com/bitcoinbook/bitcoinbook/issues/228


Jump to: