siliqua package

Submodules

siliqua.cli module

siliqua.cli.config_callback(ctx, param, value)

Load the configuration file and add it into the context

Returns

Config instance

Return type

siliqua.config.Config

siliqua.cli.main(args=None)

The main CLI entry point.

The CLI consists of two Click commands forming a two-stage CLI:

  • The first stage “cli_init” discovers the plugins selected by the user. This allows us to populate the next Click command with plugin-specific options for the second stage. This first stage should NEVER fail.

  • The second run “cli” to provide all the CLI options and start the actual execution of the application.

siliqua.cli.network_callback(ctx, param, value)

Load correct network plugin and add it into the context

siliqua.cli.plugin_callback(ctx, param, value)

Load correct plugin and add it into the context

siliqua.cli.ui_callback(ctx, param, value)

Load correct UI plugin and add it into the context

siliqua.cli.version_callback(ctx, param, value)

Print version information and abort execution

siliqua.cli.work_callback(ctx, param, value)

Load correct work plugin and add it into the context

siliqua.config module

siliqua.config.get_appdirs()
siliqua.config.get_default_config_dir()

Get the default configuration directory for the application

Returns

Configuration path

Return type

str

siliqua.config.get_default_config_path()

Get the path to the default configuration file

Returns

Configuration file path

Return type

str

siliqua.config.get_config(path=None)

Load configuration from the given path

Path str path

Path to the configuration file. Defaults to the user-specific default location.

siliqua.config.create_config_files()

Create a configuration directory and add the default files inside it

siliqua.exceptions module

exception siliqua.exceptions.ConfigurationError(field, error)

Bases: ValueError

A configuration parameter is incorrect.

exception siliqua.exceptions.InsufficientConfiguration

Bases: ValueError

The action can’t be performed due to missing configuration.

exception siliqua.exceptions.WalletFileLocked

Bases: ValueError

The wallet file is locked by another process.

siliqua.logger module

siliqua.logger.set_verbosity_level(verbosity_level=0)

Set the logging verbosity level

Parameters

verbosity_level – Verbosity level as defined in logging module

siliqua.plugins module

siliqua.plugins.get_ui_plugins()

Get all installed UI plugins

siliqua.plugins.get_work_plugins()

Get all installed work plugins

siliqua.plugins.get_network_plugins()

Get all installed network plugins

class siliqua.plugins.BasePlugin(**kwargs)

Bases: object

Base class used for plugins. Each plugin uses an siliqua.config.Config instance to check if the configuration is complete to start the plugin.

PLUGIN_NAME = None
PLUGIN_TYPE = None
get_cli_params()
property is_config_valid

Is the plugin-specific configuration valid. The plugin cannot be started if the configuration is invalid.

Note

Implement siliqua.plugins.BasePlugin.validate_config() instead of overriding this property to validate configurations.

Returns

Is configuration valid

Return type

bool

validate_config()

Method that validates the plugin-specific configuration and raises siliqua.exceptions.ConfigurationError for any incomplete or invalid configuration field

siliqua.server module

siliqua.server.WalletServer comprises of a wallet, network provider and a work provider to provide a functional wallet. It provides methods for common operations such as sending NANO and adding new accounts to the wallet.

WalletServer is designed to be run in the same thread with the GUI thread, with the instance responsible for launching new threads for network and work threads and managing the communication between them. This is done for the most part by calling the siliqua.server.WalletServer.update() in the GUI thread when the user is not using the wallet (eg. sending NANO).

class siliqua.server.MultipleWaitResult(wait_results, complete)

Bases: object

A compilation of multiple WaitResult instances

property confirmed_results

Returns all confirmed WaitResult instances

Return type

List[WaitResult]

property rejected_results

Returns all rejected WaitResult instances

Return type

List[WaitResult]

class siliqua.server.WaitResult(block, confirmed=False, rejected=False, timeout=False, error=None)

Bases: object

Wait result for a single block

A block may be either confirmed, rejected or timed out.

A timed out block is neither confirmed or rejected. A timeout just means that Siliqua has stopped waiting for the block’s resolution, and that the block might become confirmed or get rejected in the network later.

class siliqua.server.WalletServer(config, work, network, wallet)

Bases: object

A server comprising a wallet, network provider and work provider to provide a functioning wallet

close_wallet()

Closes the wallet by unlocking the corresponding lock file

load_wallet(path, passphrase=None)

Load a wallet from the given path

Raises

WalletFileLocked – If the wallet file is already in use by another app instance

property ready

Is the server fully usable (eg. work and network providers are up and running)

Returns

True if the server is usable, False otherwise

Return type

bool

save_wallet()

Save the wallet data

send_from(source, destination, amount, confirm=True, timeout=None, txid=None, description=None)

Send NANO from a source account to a destination account

If confirm is True, command will block until the created block is confirmed or timeout is reached

Parameters
  • source (str) – Source account ID

  • destination (str) – Destination account ID

  • amount (int or decimal.Decimal) – Amount to send in raw

  • confirm (bool) – Whether to wait until the block is confirmed

  • timeout (float) – Time to wait for confirmation if confirm is True

  • txid (str) – Unique identifier used for the block

  • description (str) – Optional description for the created block

Raises
Returns

Created block

Return type

siliqua.wallet.accounts.Block

start_network()

Start the network provider

start_work()

Start the work provider

stop()

Stop work and network providers and close the wallet

stop_network()

Stop the network provider

stop_work()

Stop the work provider

update()

The main update loop.

This should be called regularly (eg. once every second) in a wallet application when no other activity is happening (eg. NANO being sent).

wait_for_block(block, timeout=None)

Wait until the given block has been confirmed, rejected or until the optional timeout is reached

Parameters
Returns

WaitResult instance containing block result

Return type

WaitResult

wait_for_blocks(blocks, timeout=None)

Wait until the given blocks have been confirmed, rejected or until the optional timeout is reached

Parameters
  • blocks – List of blocks that await confirmation

  • timeout (float) – Maximum length of time to wait until all blocks are confirmed and/or rejected

Returns

MultipleWaitResult instance containing block results

Return type

MultipleWaitResult

siliqua.util module

siliqua.util.RawBlock

alias of nanolib.blocks.Block

class siliqua.util.BlockProxy

Bases: object

Allow an object containing ‘block’ Block instance to access underlying RawBlock fields directly.

Eg. instead of block.block.account, you can access block.account

property account
property account_id
property balance
property block_hash
property block_type
property complete
property destination
property difficulty
property has_valid_signature
property has_valid_work
property json
property previous
property representative
property sign
property signature
property solve_work
property source
property tx_type
property verify_signature
property verify_work
property work
property work_block_hash
property work_value
class siliqua.util.Callbacks(names)

Bases: object

Collection of CallbackSlot instances

Allows a collection of callbacks to be more easily passed to methods that execute callbacks

class siliqua.util.CallbackSlot(name)

Bases: object

Callback container with an identifier and arbitrary amount of callback functions

add(func, func_id=None)

Add a callback function. If func_id is not provided, an identifier for the callback function is created automatically

Parameters
  • func – Callback function to add

  • func_id (str) – Unique identifier for the callback identifier to remove the callback function later

invoke(*args, **kwargs)

Run all callback functions with the given arguments

remove(func_id)

Remove a callback function using its identifier.

Parameters

func_id (str) – Unique identifier for a callback function

class siliqua.util.AccountIDDict(**kwargs)

Bases: collections.UserDict

A dictionary that accepts NANO account IDs and uses the public key as the underlying key.

The account prefix is ignored, meaning that the same public key represented with different account prefixes are considered identical. The account checksum (last 8 chars) is also ignored to improve performance.

items() → a set-like object providing a view on D's items
keys() → a set-like object providing a view on D's keys
to_dict()
values() → an object providing a view on D's values

Module contents