coinbits.txns package¶
Submodules¶
coinbits.txns.exceptions module¶
coinbits.txns.keys module¶
- class coinbits.txns.keys.PrivateKey(hexkey=None)[source]¶
Bases: object
This is a representation for Bitcoin private keys. In this class you’ll find methods to import/export keys from multiple formats. Use a hex string representation to construct a new PublicKey or use the clas methods to import from another format.
Construct a new PrivateKey object, based optionally on an existing hex representation.
Parameters: - hexkey – The key in hex string format. If one isn’t
- a new private key will be generated. (provided,) –
- classmethod from_string(klass, stringkey)[source]¶
This method will create a new Private Key using the specified string data.
Parameters: stringkey – The key in string format Returns: A new PrivateKey
- classmethod from_wif(klass, wifkey)[source]¶
This method will create a new PrivateKey from a WIF format string.
Parameters: wifkey – The private key in WIF format Returns: A new PrivateKey
- get_public_key()[source]¶
This method will create a new PublicKey based on this PrivateKey.
Returns: A new PublicKey
- to_hex()[source]¶
This method will convert the Private Key to a hex string representation.
Returns: Hex string representation of this PrivateKey
- to_wif()[source]¶
This method will export the Private Key to WIF (Wallet Import Format).
Returns: The PrivateKey in WIF format.
- wif_prefix = '\x80'¶
- class coinbits.txns.keys.PublicKey(hexkey)[source]¶
Bases: object
This is a representation for Bitcoin public keys. In this class you’ll find methods to import/export keys from multiple formats. Use a hex string representation to construct a new public key or use the clas methods to import from another format.
Initialize a public key object. Requires an existing version of this key in hex.
Parameters: hexkey – The key in hex string format - __str__()[source]¶
This method will convert the public key to a string representation.
Returns: A string representation of the public key
- classmethod from_private_key(klass, private_key)[source]¶
This class method will create a new PublicKey based on a PrivateKey.
Parameters: private_key – The PrivateKey Returns: A new PublicKey
- key_prefix = '\x04'¶
- to_address()[source]¶
This method will convert the public key to a bitcoin address.
Returns: A bitcoin address for the public key
coinbits.txns.scripts module¶
coinbits.txns.wallet module¶
- class coinbits.txns.wallet.Teller(private_key)[source]¶
Bases: object
A Teller can be used to create transactions.
Args: private_key: a PrivateKey
- make_standard_tx(output, destination, amount, fee=10000)[source]¶
Create a standard transaction.
Parameters: - output – The previous output transaction reference, as an OutPoint structure
- destination – The address to transfer to
- amount – The amount to transfer (in Satoshis)
- fee – The amount to reserve for the miners. Default is 10K Satoshi’s.
Returns: A Tx object suitable for serialization / transfer on the wire.