The Strax/Cirrus wallet is a full-featured HD wallet. This tutorial will cover some basics for setting up a new wallet on a StratisFullNode using pystratis.
Note: The same wallet will be used in all of the examples. The tutorial on sending transactions can be found here.
from pystratis.nodes import StraxNode
from typing import List
node = StraxNode()
# Returns the mnemonic representing the HD wallet seed.
mnemonic: List[str] = node.wallet.create(name='ExampleWallet', password='abc123')# Loads a known wallet from the data dir with the given name and decrypts the wallet.
node.wallet.load(name='ExampleWallet', password='abc123')node.wallet.recover(mnemonic=mnemonic, password='abc123', name='RecoveredWallet')wallets: dict = node.wallet.list_wallets()account_name = node.wallet.account(wallet_name='ExampleWallet', password='abc123')node.wallet.accounts(wallet_name='ExampleWallet')unused_address = node.wallet.unused_address(wallet_name='ExampleWallet')addresses = node.wallet.addresses(wallet_name='ExampleWallet')node.wallet.general_info(name='ExampleWallet')history = node.wallet.history(wallet_name='ExampleWallet')node.wallet.remove_transactions(
wallet_name='ExampleWallet',
remove_all=True,
resync=True
)wallet_balance = node.wallet.balance(
wallet_name='ExampleWallet',
include_balance_by_address=False
)Note: The wallet does not track value in non-owned addresses. If you need to check the balance of a specific address on the blockchain:
- Ensure
addressindex=1in node configuration. - Use
blockstore.get_addresses_balancesorblockstore.get_verbose_addresses_balancesAPI method.
wallet_balance = node.wallet.balance(
wallet_name='ExampleWallet',
include_balance_by_address=True
)signature = node.wallet.sign_message(
wallet_name='ExampleWallet',
password='abc123',
external_address=unused_address,
message='Blockchain made easy.'
)
assert node.wallet.verify_message(
signature=signature,
external_address=unused_address,
message='Blockchain made easy.'
)