Account

Account Management

Account management for Saline SDK.

This module provides comprehensive account management for the Saline protocol, including both individual subaccounts (key pairs) and multi-account management.

class saline_sdk.account.Account[source]

Bases: object

High-level account management.

Acts as a container for subaccounts and provides a user-friendly interface for managing keys and performing wallet operations.

Initialize an empty account.

classmethod create()[source]

Create a new account with a random mnemonic.

Return type:

Account

classmethod from_mnemonic(mnemonic, base_path='m/12381/997')[source]

Create an account from a mnemonic phrase.

Parameters:
  • mnemonic (str) – 24-word mnemonic phrase

  • base_path (str) – Optional base path for derivation (default: m/12381/997)

Return type:

Account

Returns:

Account instance

Raises:

ValueError – If the mnemonic is invalid or the base_path is invalid

__contains__(name)[source]

Check if subaccount exists.

Return type:

bool

Parameters:

name (str)

__getitem__(name)[source]

Dict-like access to subaccounts.

Return type:

Subaccount

Parameters:

name (str)

__init__()[source]

Initialize an empty account.

__iter__()[source]

Iterate over subaccount names.

__len__()[source]

Number of subaccounts.

Return type:

int

__str__()[source]

String representation.

Return type:

str

create_subaccount(label, path=None)[source]

Create a new subaccount.

Parameters:
  • label (str) – Subaccount label

  • path (Optional[str]) – Optional derivation path (default: m/12381/997/0/0/{next_index})

Return type:

Subaccount

Returns:

Created subaccount

Raises:

ValueError – If account not initialized or name exists

get_subaccount(label)[source]

Get a subaccount by label.

Parameters:

label (str) – Subaccount label

Return type:

Subaccount

Returns:

Subaccount instance

Raises:

KeyError – If subaccount not found

list_subaccounts()[source]

Get a list of all subaccounts.

Return type:

Dict[str, str]

Returns:

Dict mapping subaccount names to public keys

set_default_subaccount(label)[source]

Set the default subaccount.

Parameters:

label (str) – Subaccount label

Raises:

KeyError – If subaccount not found

Return type:

None

transfer(to, amount, currency='USDC', from_subaccount=None)[source]

Create a transfer transaction.

Parameters:
  • to (str) – Recipient address (public key)

  • amount (Union[int, float]) – Amount to transfer

  • currency (str) – Currency to transfer (default: USDC)

  • from_subaccount (Optional[str]) – Source subaccount name (uses default if None)

Return type:

bytes

Returns:

Signed transaction

Raises:

ValueError – If no source subaccount specified or found

class saline_sdk.account.Subaccount(private_key_bytes, public_key_bytes=None, path=None, label=None)[source]

Bases: object

Individual Saline subaccount representing a single key pair. Handles cryptographic operations and always derived from an Account.

Initialize a subaccount with private key bytes.

Parameters:
  • private_key_bytes (bytes) – The private key in bytes

  • public_key_bytes (Optional[bytes]) – Optional public key bytes (will be derived if not provided)

  • path (Optional[str]) – Optional derivation path

  • label (Optional[str]) – Optional subaccount label

__init__(private_key_bytes, public_key_bytes=None, path=None, label=None)[source]

Initialize a subaccount with private key bytes.

Parameters:
  • private_key_bytes (bytes) – The private key in bytes

  • public_key_bytes (Optional[bytes]) – Optional public key bytes (will be derived if not provided)

  • path (Optional[str]) – Optional derivation path

  • label (Optional[str]) – Optional subaccount label

__str__()[source]

String representation of the subaccount.

Return type:

str

sign(message)[source]

Sign a message with this subaccount’s private key.

Return type:

bytes

Parameters:

message (bytes)

property public_key: str

Get the public key as hex string.