3

Is there an address associated with P2WSH scripts?
for testnet txid =6717c8971dccbf826790efc16fb357f1e225fed3448247b8556c9f13a6c0ce42, i get: "vout": [ { "value": 0.05994165, "n": 0, "scriptPubKey": { "asm": "0 43aac20a116e09ea4f7914be1c55e4c17aa600b7", "hex": "001443aac20a116e09ea4f7914be1c55e4c17aa600b7", "type": "witness_v0_keyhash" } } ] Is there no address associated with this?

5

It's a Segwit output and hence does not have the address associated with it. The locking script for a Segwit transaction includes the witness version (0 in this case) and the redeem script (which is 43aac20a116e09ea4f7914be1c55e4c17aa600b7). Given that the length of the redeem script is 20-byte, this locking address is pay-to-witness public key hash (P2WPKH). Hence the redeem script is hash160 of the compressed public key.

Since Segwit was implemented with a soft fork, there are clients that have not fully updated their software. For those clients, the locking script will look in a way that anyone can spend the output. But for Segwit aware clients, they would realize that it is a Segwit transaction with 0 as the witness version.

You could create a pay-to-script-hash of the P2WPKH. By that I mean that you could embed the witness as a script and generate an address. What you need to do is take hash160 of (0x001443aac20a116e09ea4f7914be1c55e4c17aa600b7). The first byte 00 is the witness version, second byte (14) represents the bytes to push to the stack (20-bytes) and the rest is your witness. Then you can base58check encode it using a prefix of '0x05'

In the future it is expected that most clients will upgrade to Segwit. At that time, it is proposed that the address to be locked will be a base32encode of the script (0 43aac20a116e09ea4f7914be1c55e4c17aa600b7). The address will start with bc for mainnet, separated by 1 and then the encoded version including the checksum. This addresses are called Bech-32 address.

This is how the address will look. Refer BIP-173 for more details.

Mainnet P2WPKH: bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4

Testnet P2WPKH: tb1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx

Mainnet P2WSH: bc1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3qccfmv3

Testnet P2WSH: tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sl5k7

2

Native segwit outputs (P2WSH and P2WPKH) do not currently have an address type, so there are no addresses for these outputs.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.