Cryptoassets helper service

Service main

Cryptoassets helper service is a standalone process managing cryptoasset backend connections and transaction updates.

Manages asynchronous tasks for sending and receiving cryptocurrency over various APIs. This includes

  • Broadcasting transactions to the cryptocurrency network asynchronously
  • Handle incoming transactions and write them to the database, calls your application via event handlers
  • Updates confirmation counts of open transactions
cryptoassets.core.service.main.logger = None

Must be instiated after the logging configure is passed in

cryptoassets.core.service.main.splash_version()[source]

Log out cryptoassets.core package version.

class cryptoassets.core.service.main.Service(config, subsystems=[<Subsystem.database: 1>, <Subsystem.backend: 3>], daemon=False, logging=True)[source]

Main cryptoassets helper service.

This class runs cryptoassets helper service process itself and various command line utilities (initialize-database, etc.)

We uses Advanced Python Scheduler to run timed jobs (broadcasts, confirmatino updates).

Status server (cryptoassets.core.service.status) can be started for inspecting our backend connections are running well.

Parameters:
  • config – cryptoassets configuration dictionary
  • subsystems – List of subsystems needed to initialize for this process
  • daemon – Run as a service
status_server = None

Status server instance

incoming_transaction_runnables = None

coin name -> IncomingTransactionRunnable

broadcast_period = None

How often we check out for outgoing transactions

config(config, logging_)[source]

Load configuration from Python dict.

Initialize logging system if necessary.

setup()[source]

Start background threads and such.

setup_session()[source]

Setup database sessions and conflict resolution.

initialize_db()[source]
start_status_server()[source]

Start the status server on HTTP.

The server is previously set up by configure module.We need just to pass the status report generator of this service to it before starting it up.

setup_incoming_notifications()[source]

Start incoming transaction handlers.

setup_sigterm()[source]

Capture SIGTERM and shutdown on it.

poll_broadcast()[source]

“A scheduled task to broadcast any new transactions to the bitcoin network.

Each wallet is broadcasted in its own transaction.

poll_network_transaction_confirmations()[source]

Scan incoming open transactions.

Returns:Number of rescans attempted
scan_received()[source]

Scan through all received transactions, see if we missed some through walletnotify.

start()[source]

Start cryptoassets helper service.

Keep running until we get SIGTERM or CTRL+C.

Returns:Process exit code
run_thread_monitor()[source]

Run thread monitor until terminated by SIGTERM.

check_threads()[source]

Check all the critical threads are running and do shutdown if any of the threads has died unexpectly.

Returns:True if all threads stil alive
shutdown(unclean=False)[source]

Shutdown the service process.

Parameters:unclean – True if we terminate due to exception