bitcoin.address.p2sh module¶
Models P2SH Addresses.
A P2SH address is used by user to send bitcoins to a Bitcoin smart contract
Most information was extracted from the Bitcoin Wiki.
-
exception
bitcoin.address.p2sh.
AddressSHLengthError
[source]¶ Bases:
ValueError
Error raised when the redeem script hash has an incorrect length
-
class
bitcoin.address.p2sh.
P2SHAddress
(script_hash: bytes)[source]¶ Bases:
object
Models a legacy P2SH Address
-
__init__
(script_hash: bytes) → None[source]¶ Initializes a P2SH given its script hash.
Modifies the attribute
_script_hash
Parameters: script_hash – script hash to set
Raises: AssertionError
– script_hash argument is not a bytes objectAddressSHLengthError
– script_hash argument has not the proper length of a script hash
-
do_things
(obj: str) → bytes[source]¶ Does some things.
Parameters: obj – object of options Returns: things modified by obj
as bytes
-
script_hash
¶ Returns the public key hash stored in the address.
Getter: Returns the script hash as bytes object Setter: Sets the script hash, while verifying the length and type
-
-
bitcoin.address.p2sh.
SH_LENGTH
= 20¶ int – length of the script hashes stored in addresses
-
bitcoin.address.p2sh.
from_hex
(script_hash_hex: str) → bitcoin.address.p2sh.P2SHAddress[source]¶ Creates a P2SH address from script hash in hexadecimal.
Converts the hexadecimal string into bytes and then uses those bytes to create a P2SH address.
>>> 2+3 5
Parameters: script_hash_hex – string containing script hash in hexadecimal Returns: pay to script hash address