bitcoin.address.p2pkh module¶
Models P2PKH Addresses.
A P2PKH address is used by user to send bitcoins to another user who controls the private key behind the public key (whose hash appears in the address)
Most information was extracted from the Bitcoin Wiki.
-
exception
bitcoin.address.p2pkh.
AddressPKHLengthError
[source]¶ Bases:
ValueError
Error raised when the public key hash has an incorrect length
-
class
bitcoin.address.p2pkh.
P2PKHAddress
(public_key_hash: bytes)[source]¶ Bases:
object
Models a legacy P2PKH Address
-
__init__
(public_key_hash: bytes) → None[source]¶ Initializes a P2PKH given its public key hash.
Modifies the attribute
_script_hash
Parameters: 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 obj
as 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
-
-
bitcoin.address.p2pkh.
PKH_LENGTH
= 20¶ int – length of the public key hashes stored in addresses
-
bitcoin.address.p2pkh.
from_hex
(public_key_hash_hex: str) → bitcoin.address.p2pkh.P2PKHAddress[source]¶ Creates a P2PKH address from public key hash in hexadecimal.
Converts the hexadecimal string into bytes and then uses those bytes to create a P2PKH address.
>>> 1+1 2
Parameters: public_key_hash_hex – string containing public key hash in hexadecimal Returns: pay to public key hash address