coinbits.txns package

Submodules

coinbits.txns.exceptions module

exception coinbits.txns.exceptions.KeyDecodeError[source]

Bases: exceptions.Exception

This exception is thrown when trying to decode a key from one format to another.

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,) –
__str__()[source]

This method will convert the PrivateKey to a string representation.

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
sign(data)[source]

Digest and then sign the data.

to_address()[source]

Convert to public key and then get the public address for that key.

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
to_hex()[source]

This method will convert the public key to a hex string representation.

Returns:A hex string representation of the public key
verify(signature, message)[source]

Verify the given signature of the message. Returns True if verification is successful, False otherwise.

coinbits.txns.scripts module

coinbits.txns.scripts.pay_to_pubkey_hash(key)[source]

76 A9 14 OP_DUP OP_HASH160 Bytes to push

89 AB CD EF AB BA AB BA AB BA AB BA AB BA AB BA AB BA AB BA 88 AC
Data to push OP_EQUALVERIFY OP_CHECKSIG

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.

Module contents