Take look at example code in example/lib/*.dart
Before any wallet operation, set up a node:
ZanoWallet zanoWallet = ZanoWallet();
zanoWallet.setupNode();
isWalletExists = zanoWallet.isWalletExist(path: await Utils.pathForWallet(name: 'wallet name'));
There shouldn't be a wallet file at provided path!
final path = await Utils.pathForWallet(name: 'wallet name');
final result = zanoWallet.createWallet(path: path, password: 'default password');
if (result != null) {
_parseCreateWalletResult(result);
_connected = true
. . .
There shouldn't be a wallet file at provided path!
final path = await Utils.pathForWallet(name: 'wallet name');
final result = zanoWallet.restoreWalletFromSeed(path: path, password: 'default password', seed: 'seed');
if (result != null) {
_parseCreateWalletResult(result);
_connected = true;
. . .
Check file's existence before calling
final path = await Utils.pathForWallet(name: 'wallet name');
final result = zanoWallet.loadWallet(path: path, password: 'default password');
if (result != null) {
_parseCreateWalletResult(result);
_connected = true;
. . .
Wallet status [GetWalletStatusResult] contains of:
- current daemon height (int)
- current wallet height (int)
- is daemon connected (bool)
- is in long refresh (bool)
- progress (current progress of refreshing, int)
- wallet state (1-syncing, 2-ready, 3-error)
See example below
Wallet information ([GetWalletInfoResult]) contains of:
- [Wi] structure (address, balances, path, etc.)
- [WiExtended] structure (seed, private and public keys)
Note, you can call getWalletInfo ONLY if getWalletStatus returns NOT is in long refresh and wallet state is 2 (ready)
final walletStatusResult = zanoWallet.getWalletStatus();
if (!walletStatusResult!.isInLongRefresh && walletStatusResult!.walletState == 2) {
walletSyncing = false;
final walletInfoResult = await zanoWallet.getWalletInfo();
. . .
} else {
walletSyncing = true;
}
Priority can be 0 (default), 1 (unimportant), 2 (normal), 3 (elevated), 4 (priority)
int getCurrentTxFee({required int priority});
addressInfoResult = zanoWallet.getAddressInfo(address: address);
print(addressInfoResult.valid);
storeResult = await zanoWallet.store();
print(storeResult.walletFileSize);
Parameters of a tranfer ([TransferParams])
- List of [Destination]
- fee (int)
- mixin (10, int)
- paymentId (hex string, can be ommited)
- comment (string, can be ommited)
- push payer (bool)
- hide receiver (bool)
Results of a transfer ([TransferParams]): hash (string), size (int)
try {
txFee = zanoWallet.getCurrentTxFee(priority: 0);
transferResult = await zanoWallet.transfer(TransferParams(
destinations: [
Destination(
amount: _mulBy10_12(double.parse(amount)),
address: destinationAddress,
assetId: assetIds.keys.first,
)
],
fee: txFee,
mixin: mixin,
paymentId: paymentId,
comment: comment,
pushPayer: pushPayer,
hideReceiver: hideReceiver,
));
transferError = null;
} catch (e) {
transferResult = null;
transferError = e.toString();
}
await zanoWallet.getRecentTxsAndInfo(GetRecentTxsAndInfoParams(offset: 0, count: 30));