3

I am writing a webapp in PHP that needs to generate Bitcoin addresses from their mpk.

I have successfully done it for P2SH addresses (starting with a 1, with a xpub mpk) using the BitWasp php library, roughly using the method outlined here.

I wanted to do the same for P2SH-P2WSH addresses (starting with a 3, with a ypub mpk) to make use of SegWit, but I always get the same error, using the same method (using the 49' derivation path instead of 44'):

HD key magic bytes do not match network magic bytes.

I have checked and this library can generate P2SH-P2WSH addresses, but so far, I have only been able to generate them from the raw public key (following Bitwasp's examples).

So I was wondering, could I be pointed towards a method to generate the P2SH-P2WSH addresses from their ypub using PHP only?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.