Skip to content
module

neo3.wallet.wallet

Containers following the NEP-6 wallet standard.

Classes
  • DiskWallet Specialised wallet for persisting to media.
  • Wallet Base container.
class

neo3.wallet.wallet.DiskWallet(path, name=None, version='1.0', scrypt_params=None, accounts=None, default_account=None, extra=None)

Bases
neo3.wallet.wallet.Wallet neo3.core.interfaces.IJson

Specialised wallet for persisting to media.

Attributes
  • account_default (Optional) Return the default account if at least one account is present.
Methods
  • account_add(acc, is_default) (bool) Add account in the wallet.
  • account_delete(acc) (bool) Remove an account from the wallet.
  • account_delete_by_label(label) (bool) Remove an account from the wallet given its label.
  • account_get_by_label(label) (Optional) Get an account given its label. Returns None if not found.
  • account_new(password, label, is_default) (Account) Create a new account and adds it in the wallet.
  • import_multisig_address(signing_threshold, public_keys) (Account) Import a multi-signature account into the container.
  • save() Persist the wallet to disk.
  • to_json() (dict) Convert object into JSON representation.
  • default(path, name) (DiskWallet) Create a new wallet with the default settings.
  • from_file(path, passwords) Load wallet from file.
  • from_json(json, passwords) Parse object out of JSON data.
classmethod

default(path='./wallet.json', name='wallet.json') → DiskWallet

Create a new wallet with the default settings.

Parameters
  • path (str, optional) the JSON's path.
  • name (Optional, optional) the wallet name.
classmethod

from_file(path, passwords=None)

Load wallet from file.

Parameters
  • path (str) path as passed to open().
  • passwords (Optional, optional) the password to decrypt the account data.
classmethod

from_json(json, passwords=None)

Parse object out of JSON data.

Parameters
  • json (dict) a dictionary.
  • passwords (Optional, optional) the password to decrypt the account data.
Raises
  • KeyError if the data supplied does not contain the necessary keys.
  • ValueError if the version property is under 1.0 or is not a valid string.
method

save()

Persist the wallet to disk.

method

account_add(acc, is_default=False) → bool

Add account in the wallet.

Parameters
  • acc (Account) the account to be added.
  • is_default (optional) set the created account as the default.
Raises
  • ValueError if the account's label is already used by another one.
method

account_delete(acc) → bool

Remove an account from the wallet.

Parameters
  • acc (Account) the account to be removed.
method

account_delete_by_label(label) → bool

Remove an account from the wallet given its label.

Parameters
  • label (str) unique identifier of the account.
method

account_get_by_label(label) → Optional

Get an account given its label. Returns None if not found.

Parameters
  • label (str) unique identifier of the account.
method

account_new(password, label=None, is_default=False) → Account

Create a new account and adds it in the wallet.

Parameters
  • password (str) the password to encrypt the account.
  • label (Optional, optional) optional label to identify the account.
  • is_default (optional) set the created account as the default.
method

import_multisig_address(signing_threshold, public_keys) → Account

Import a multi-signature account into the container.

Parameters
  • signing_threshold (int) minimum number of keys required for signing.
  • public_keys (Sequence) the public keys the multisignature address consists off.
Raises
  • ValueError if the signing treshold exceeds 1024.if the signing treshold exceeds the number of public_keys.
method

to_json() → dict

Convert object into JSON representation.

class

neo3.wallet.wallet.Wallet(name=None, version='1.0', scrypt_params=None, accounts=None, default_account=None, extra=None)

Bases
neo3.core.interfaces.IJson

Base container.

Attributes
  • account_default (Optional) Return the default account if at least one account is present.
Methods
  • account_add(acc, is_default) (bool) Add account in the wallet.
  • account_delete(acc) (bool) Remove an account from the wallet.
  • account_delete_by_label(label) (bool) Remove an account from the wallet given its label.
  • account_get_by_label(label) (Optional) Get an account given its label. Returns None if not found.
  • account_new(password, label, is_default) (Account) Create a new account and adds it in the wallet.
  • import_multisig_address(signing_threshold, public_keys) (Account) Import a multi-signature account into the container.
  • save() Save the wallet.
  • to_json() (dict) Convert object into JSON representation.
  • from_file(path, passwords) Load wallet from file.
  • from_json(json, passwords) Parse object out of JSON data.
method

account_add(acc, is_default=False) → bool

Add account in the wallet.

Parameters
  • acc (Account) the account to be added.
  • is_default (optional) set the created account as the default.
Raises
  • ValueError if the account's label is already used by another one.
method

account_delete(acc) → bool

Remove an account from the wallet.

Parameters
  • acc (Account) the account to be removed.
method

account_delete_by_label(label) → bool

Remove an account from the wallet given its label.

Parameters
  • label (str) unique identifier of the account.
method

account_get_by_label(label) → Optional

Get an account given its label. Returns None if not found.

Parameters
  • label (str) unique identifier of the account.
method

account_new(password, label=None, is_default=False) → Account

Create a new account and adds it in the wallet.

Parameters
  • password (str) the password to encrypt the account.
  • label (Optional, optional) optional label to identify the account.
  • is_default (optional) set the created account as the default.
classmethod

from_file(path, passwords=None)

Load wallet from file.

Parameters
  • path (str) path as passed to open().
  • passwords (Optional, optional) the password to decrypt the account data.
classmethod

from_json(json, passwords=None)

Parse object out of JSON data.

Parameters
  • json (dict) a dictionary.
  • passwords (Optional, optional) the password to decrypt the account data.
Raises
  • KeyError if the data supplied does not contain the necessary keys.
  • ValueError if the version property is under 1.0 or is not a valid string.
method

import_multisig_address(signing_threshold, public_keys) → Account

Import a multi-signature account into the container.

Parameters
  • signing_threshold (int) minimum number of keys required for signing.
  • public_keys (Sequence) the public keys the multisignature address consists off.
Raises
  • ValueError if the signing treshold exceeds 1024.if the signing treshold exceeds the number of public_keys.
method

save()

Save the wallet.

This is called automatically when using the context manager.

See Also
method

to_json() → dict

Convert object into JSON representation.