Server Integration

If you only want to use bitcash for its raw speed to lessen the load on your servers, you don’t have to use any of our network capabilities.

Offline Transactions

bitcash supports the signing of transactions for keys in cold storage. First you need to prepare a transaction while connected to the internet using the prepare_transaction() class method of a private key. You must know your address.

>>> from bitcash import PrivateKeyTestnet
>>> from import NetworkAPI, satoshi_to_currency
>>> satoshi_to_currency(NetworkAPI.get_balance_testnet(address), 'usd')
>>> tx_data = PrivateKeyTestnet.prepare_transaction(address, [('n2eMqTT929pb1RDNuqEnxdaLau1rxy3efi', 1, 'jpy')])
>>> tx_data

This performs validation and returns a JSON string containing all the required information to create a transaction. You should then take this to your offline machine and use the sign_transaction() method of your private key.

>>> tx_hex = key.sign_transaction(tx_data)
>>> tx_hex

Finally, bring this transaction back to your connected device and broadcast it.

>>> from import NetworkAPI
>>> NetworkAPI.broadcast_tx_testnet(tx_hex)

Blockchain Storage (OP_RETURN)

bitcash allows you to easily store messages or data in the blockchain itself using the message parameter of create_transaction() or send():

>>> key.send(..., message='Simplicity level is over 9000!!!')

Messages will be encoded as UTF-8 when stored. Also, do note that the length of each datum must not exceed 40 bytes. Therefore, your resulting byte string will be stored in chunks to adhere to this property if it is too long.

Services Timeout

If you want to change the default timeout of 5 seconds for service API calls:

>>> from bitcash import set_service_timeout
>>> set_service_timeout(3)

Cache Times

If you want to change the default cache time of exchange rates (60 seconds) or recommended fees (10 minutes):

>>> from bitcash import set_fee_cache_time, set_rate_cache_time
>>> set_rate_cache_time(30)
>>> set_fee_cache_time(60 * 5)