vulpemventures / go-elements

Go support for Liquid/Elements transactions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FromScript should set both Script and WitnessScript

tiero opened this issue · comments

At the moment the Script field is nil. This factory method should follow the same behavior of FromPublicKey and set both fields, so the user could generate both types of addresses (legacy or segwit)

@tiero can you advise which test case is failing to create expected address?

@tiero can you advise which test case is failing to create expected address?

We do not have a proper test. At the moment we use fromScript to just get the corresponding hash or withnessHash.

Given whatever script (eg of a P2WPKH) and get out the legacy script, useful for signing.

Given whatever script (eg of a P2WPKH) and get out the legacy script, useful for signing.

Aren't we doing that already here? In case of P2PKH we set both information we are able to, public key hash and script.

Yes, we do for p2pkh, but we should do it also for witness one.

when we sign a tx that spends a p2wpkh we still need the legacy script to produce the correct signature hash.

example on how to do it having the legacy hash
legacyScript := append(append([]byte{0x76, 0xa9, 0x14}, Hash...), []byte{0x88, 0xac}...)