A few days ago, I got a BITCOIN traffic which contains some tx message. some of tx messages contain witness data. I want to produce all output addresses from transaction output scripts. I extracted some of them, but in some cases, generated output address however seems to be valid, but I can't track them in some sites like


as an example, in tx output script which is showed below, how I can extract True address?


it seems a script which has op_code = 0x00 and push data length = 0x14.

1 Answer 1


It's a native segwit output. 0x00 signifies the segwit version (which is v0 in this case), 0x14 is the bytes to push and 2f82e61a98eb7027672760c691784d5fbccf7ce3 is the hash160 of the public key. Native segwit addresses uses bech32 encoding as defined in BIP 173 and begin with bc1. Use this for reference implementations in various programming languages. The address associated with the locking script is thus bc1q97pwvx5cadczwee8vrrfz7zdt77v7l8re20cz4

  • Are you sure? but the address you entered is wrong and is not in blockchain.com or blockchain.com
    – Saeed
    May 21, 2019 at 17:08
  • @Saeed The address I have listed in the answer is correct. Most block explorers have still not implemented support for bech32 native segwit addresses. You can check the transaction containing the address here. Note the first output of the transaction. chainquery.com/bitcoin-api/getrawtransaction/…
    – Ugam Kamat
    May 21, 2019 at 17:20
  • Thank you. it seems that the address you generated is valid, but I can't generate it with bech32 which you introduced before. first I extract public key (2f82e61a98eb7027672760c691784d5fbccf7ce3 ) then encode it with sha256 and then encode it with RIPEMD160. at last, I give generated output to bech32 encoder and it generates a valid bitcoin address but it is not bc1q97pwvx5cadczwee8vrrfz7zdt77v7l8re20cz4 which you produced.
    – Saeed
    May 26, 2019 at 7:51
  • @Saeed 2f82e61a98eb7027672760c691784d5fbccf7ce3 is not the public key but the hash160 of the public key. So you do not have to calculate the hash again. Just bech32 encode 2f82e61a98eb7027672760c691784d5fbccf7ce3 using version 0.
    – Ugam Kamat
    May 26, 2019 at 10:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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