coinbits package

Submodules

coinbits.client module

class coinbits.client.BitcoinClient(peerip, port=8333)[source]

Bases: object

The base class for a Bitcoin network client. This class will handle the initial handshake and responding to pings.

coin = 'bitcoin'
connected()[source]

Called once we’ve exchanged version information and can make calls on the network.

handle_ping(message_header, message)[source]

This method will handle the Ping message and then will answer every Ping message with a Pong message using the nonce received.

Parameters:
  • message_header – The header of the Ping message
  • message – The Ping message
handle_version(message_header, message)[source]

This method will handle the Version message and will send a VerAck message when it receives the Version message.

Parameters:
  • message_header – The Version message header
  • message – The Version message
loop()[source]

This is the main method of the client, it will enter in a receive/send loop.

message_received(message_header, message)[source]

This method will be called for every message, and then will delegate to the appropriate handle_* function for the given message (if it exists).

Parameters:
  • message_header – The message header
  • message – The message object
send_message(message)[source]

This method will serialize the message using the appropriate serializer based on the message command and then it will send it to the socket stream.

Parameters:message – The message object to send

coinbits.encoding module

coinbits.encoding.b256encode(n)[source]
coinbits.encoding.b58_check_decode(s)[source]
coinbits.encoding.b58decode(s)[source]
coinbits.encoding.b58encode(n)[source]

Module contents

Coinbits is a Python library for bitcoin peer to peer communication.