bitcoin package¶
Bitcoin framework module.
Intended to create transactions with smart contracts in Bitcoin in an easy way
-
exception
bitcoin.AddressPKHLengthError[source]¶ Bases:
ValueErrorError raised when the public key hash has an incorrect length
-
exception
bitcoin.AddressSHLengthError[source]¶ Bases:
ValueErrorError raised when the redeem script hash has an incorrect length
-
class
bitcoin.P2PKHAddress(public_key_hash: bytes)[source]¶ Bases:
objectModels a legacy P2PKH Address
-
__init__(public_key_hash: bytes) → None[source]¶ Initializes a P2PKH given its public key hash.
Modifies the attribute
_script_hashParameters: public_key_hash – public key hash to set
Raises: AssertionError– public_key_hash argument is not a bytes objectAddressPKHLengthError– public_key_hash argument has not the proper length of a public key hash
-
do_things(obj: str) → bytes[source]¶ Does some things.
Parameters: obj – object of options Returns: things modified by objas bytes
-
public_key_hash¶ Returns the public key hash stored in the address.
Getter: Returns the public key hash as bytes object Setter: Sets the public key hash, while verifying the length and type
-
-
class
bitcoin.P2SHAddress(script_hash: bytes)[source]¶ Bases:
objectModels a legacy P2SH Address
-
__init__(script_hash: bytes) → None[source]¶ Initializes a P2SH given its script hash.
Modifies the attribute
_script_hashParameters: 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 objas 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.b58decode(value: str) → bytes¶ Decodes a base58 string into a bytes object.
-
bitcoin.b58encode(value: bytes) → str¶ Encodes bytes using base58 convention into an human-readable string.
- Sources