Backends

Backends are the protocols and methods used to communicate with the Monero daemon and interact with the wallet. As of the time of this writing, the only backends available in this library are:

  • jsonrpc for the HTTP based RPC server,
  • offline for running the wallet without Internet connection and even without the wallet file.

JSON RPC

This backend requires a running monero-wallet-rpc process with a Monero wallet file opened. This can be on your local system or a remote node, depending on where the wallet file lives and where the daemon is running. Refer to the quickstart for general setup information.

The Python requests library is used in order to facilitate HTTP requests to the JSON RPC interface. It makes POST requests and passes proper headers, parameters, and payload data as per the official Wallet RPC documentation.

class monero.backends.jsonrpc.JSONRPCDaemon(protocol='http', host='127.0.0.1', port=18081, path='/json_rpc', user='', password='', timeout=30)

JSON RPC backend for Monero daemon

Parameters:
  • protocolhttp or https
  • host – host name or IP
  • port – port number
  • path – path for JSON RPC requests (should not be changed)
  • timeout – request timeout
class monero.backends.jsonrpc.JSONRPCWallet(protocol='http', host='127.0.0.1', port=18088, path='/json_rpc', user='', password='', timeout=30)

JSON RPC backend for Monero wallet (monero-wallet-rpc)

Parameters:
  • protocolhttp or https
  • host – host name or IP
  • port – port number
  • path – path for JSON RPC requests (should not be changed)
  • user – username to authenticate with over RPC
  • password – password to authenticate with over RPC
  • timeout – request timeout
exception monero.backends.jsonrpc.MethodNotFound
exception monero.backends.jsonrpc.RPCError
exception monero.backends.jsonrpc.Unauthorized

Offline

This backend allows creating a Wallet instance without network connection or even without the wallet itself. In version 0.5 the only practical use is to cold-generate subaddresses like in the example below:

In [8]: w = Wallet(OfflineWallet('47ewoP19TN7JEEnFKUJHAYhGxkeTRH82sf36giEp9AcNfDBfkAtRLX7A6rZz18bbNHPNV7ex6WYbMN3aKisFRJZ8Ebsmgef', view_key='6d9056aa2c096bfcd2f272759555e5764ba204dd362604a983fa3e0aafd35901'))

In [9]: w.get_address(100,37847)
Out[9]: 883Gcsq65iqh4UL3fJTWLxY45skXyFVNQJZ4bdw4TJcqd8vafvtpX4p6HNmawqFMQ6TwJP7adzyLT1fbU6z1n9dqB9bJrfn
class monero.backends.offline.OfflineWallet(address, view_key=None, spend_key=None)

Offline backend for Monero wallet. Provides support for address generation.

exception monero.backends.offline.WalletIsOffline