Skip to content
Meheret Tesfaye edited this page Jun 10, 2020 · 3 revisions

P2PK

Pay to Public Key

Get public key hash

public_key_hash() - Get Bytom public key hash.

Parameter

public_key (str) - Bytom public key [required].

Return

hash (str) - Bytom public key ripemd160 hash.

>>> from pybytom.script import public_key_hash
>>> public_key_hash("5b5a06f6fbcb74b58ebb42293808fec6222234df6c97d7c1cff6d857a6024dc2")
"875240ba66646d900c59dd20d843351c2fcbeedc"

Get P2PKH program

p2pkh_program() - Get P2PKH program return the segwit pay to public key hash program.

Parameter

public_key_hash (str) - Bytom public key hash [required].

Return

program (str) - Bytom pay to public key hash program.

>>> from pybytom.script import p2pkh_program
>>> p2pkh_program("875240ba66646d900c59dd20d843351c2fcbeedc")
"76ab14875240ba66646d900c59dd20d843351c2fcbeedc88ae7cac"

Get P2WPKH program

p2wpkh_program() - Get P2WPKH program return the segwit pay to witness public key hash program.

Parameter

public_key_hash (str) - Bytom public key hash [required].

Return

program (str) - Bytom pay to witness public key hash program.

>>> from pybytom.script import p2wpkh_program
>>> p2wpkh_program("875240ba66646d900c59dd20d843351c2fcbeedc")
"0014875240ba66646d900c59dd20d843351c2fcbeedc"

Get P2WPKH address

p2wpkh_address() - Get P2WPKH address return the segwit pay to witness public key hash address.

Parameter

public_key_hash (str) - Bytom public key hash [required]. network (str) - Bytom network [default to solonet].

Return

address (str) - Bytom pay to witness public key hash address.

>>> from pybytom.script import p2wpkh_address
>>> p2wpkh_address("875240ba66646d900c59dd20d843351c2fcbeedc", "mainnet")
"bm1qsafypwnxv3keqrzem5sdsse4rshuhmku7kpnxq"

P2S

Pay to Script

Get script hash

script_hash() - Bytom smart contract program(bytecode) script hash.

Parameter

bytecode (str) - Bytom contract program(bytecode) [required].

Return

hash (str) - Bytom script sha3_256 hash.

>>> from pybytom.script import script_hash
>>> script_hash("01642091ff7f525ff40874c4f47f0cab42e46e3bf53adad59adef9558ad1b6448f22e220ac13c0bb1445423a641754182d53f0677cd4351a0e743e6f10b35122c3d7ea01203a26da82ead15a80533a02696656b14b5dbfd84eb14790f2e1be5e9e45820eeb741f547a6416000000557aa888537a7cae7cac631f000000537acd9f6972ae7cac00c0")
"e7e3ec6e67a48bb7a4ee323f04c251913e775507bb5c774a17aa0f905d05550c"

Get P2SH program

p2sh_program() - Get P2SH program return the segwit pay to script hash program.

Parameter

script_hash (str) - Bytom contract program(bytecode) script hash [required].

Return

program (str) - Bytom pay to script hash program.

>>> from pybytom.script import p2sh_program
>>> p2sh_program("e7e3ec6e67a48bb7a4ee323f04c251913e775507bb5c774a17aa0f905d05550c")
"76aa20e7e3ec6e67a48bb7a4ee323f04c251913e775507bb5c774a17aa0f905d05550c8808ffffffffffffffff7c00c0"

Get P2WSH program

p2wsh_program() - Get P2WSH program return the segwit pay to witness script hash program.

Parameter

script_hash (str) - Bytom contract program(bytecode) script hash [required].

Return

program (str) - Bytom pay to witness script hash program.

>>> from pybytom.script import p2wsh_program
>>> p2wsh_program("e7e3ec6e67a48bb7a4ee323f04c251913e775507bb5c774a17aa0f905d05550c")
"0020e7e3ec6e67a48bb7a4ee323f04c251913e775507bb5c774a17aa0f905d05550c"

Get P2WSH address

p2wsh_address() - Get P2WSH address return the segwit pay to witness script hash address.

Parameter

script_hash (str) - Bytom contract program(bytecode) script hash [required]. network (str) - Bytom network [default to solonet].

Return

address (str) - Bytom pay to witness script hash address.

>>> from pybytom.script import p2wsh_address
>>> p2wsh_address("e7e3ec6e67a48bb7a4ee323f04c251913e775507bb5c774a17aa0f905d05550c", "mainnet")
"bm1qul37cmn85j9m0f8wxglsfsj3jyl8w4g8hdw8wjsh4g8eqhg925xqheeud2"