Account
The account module provides a series of methods related to Mystiko accounts.
Data Structure
An account is an object generated from protobuf with the following properties:
Property | Type | Description |
---|---|---|
id | String | The unique identifier of the account. |
createdAt | Int64 | The timestamp when the account was created. |
updatedAt | Int64 | The timestamp when the account was last updated. |
name | String | The name of the account. |
shieldedAddress | String | The shielded address of the account. |
publicKey | String | The public key of the account. |
encryptedSecretKey | String | The encrypted secret key of the account. |
walletId | String | The unique identifier of the wallet to which the account belongs. |
scannedToId | String | The unique identifier of the last scanned transaction. |
Create
Create an Account.
import 'package:mystiko_flutter/mystiko_flutter.dart';
MystikoAccountApi api = await Mystiko.mystikoAccountApi();
Response<Account, AccountError> response = await api.create(CreateAccountOptions(walletPassword: 'pass@word1!'));
The parameter list for CreateAccountOptions
:
Parameter | Required | Description |
---|---|---|
walletPassword | true | The password of the encrypted wallet. |
name | false | The name of the account. |
secretKey | false | The secret key of the account. |
Count
Query the number of accounts in the wallet based on specific conditions.
import 'package:mystiko_flutter/mystiko_flutter.dart';
MystikoAccountApi api = await Mystiko.mystikoAccountApi();
Response<Int64, AccountError> response = await accountApi.count(QueryFilter(conditions: [
Condition(subFilters: [
ExtendedSubFilter.equal('shieldAddress', columnValueFrom('xxx'))
])
]));
CountAll
Query the total number of accounts in the wallet.
import 'package:mystiko_flutter/mystiko_flutter.dart';
MystikoAccountApi api = await Mystiko.mystikoAccountApi();
Response<Int64, AccountError> response = await accountApi.countAll();
Find
Query accounts based on specific conditions.
import 'package:mystiko_flutter/mystiko_flutter.dart';
MystikoAccountApi api = await Mystiko.mystikoAccountApi();
Response<List<Account>, AccountError> response = await accountApi.find(QueryFilter(conditions: [
Condition(subFilters: [
ExtendedSubFilter.equal('name', columnValueFrom('xxx'))
])
]));
FindAll
Query all accounts in the wallet.
import 'package:mystiko_flutter/mystiko_flutter.dart';
MystikoAccountApi api = await Mystiko.mystikoAccountApi();
Response<List<Account>, AccountError> response = await accountApi.findAll();
FindById
Query an account by its unique identifier.
import 'package:mystiko_flutter/mystiko_flutter.dart';
MystikoAccountApi api = await Mystiko.mystikoAccountApi();
Response<Account, AccountError> response = await accountApi.findById('id');
FindByShieldedAddress
Query an account by its shielded address.
import 'package:mystiko_flutter/mystiko_flutter.dart';
MystikoAccountApi api = await Mystiko.mystikoAccountApi();
Response<Account, AccountError> response = await accountApi.findByShieldedAddress('shieldedAddress');
FindByPublicKey
Query an account by its public key.
import 'package:mystiko_flutter/mystiko_flutter.dart';
MystikoAccountApi api = await Mystiko.mystikoAccountApi();
Response<Account, AccountError> response = await accountApi.findByPublicKey('publicKey');
Update
The parameter list for UpdateAccountOptions
:
Parameter | Required | Description |
---|---|---|
walletPassword | true | The password of the encrypted wallet. |
name | false | The name of the account. |
UpdateById
Update an account by its unique identifier.
import 'package:mystiko_flutter/mystiko_flutter.dart';
MystikoAccountApi api = await Mystiko.mystikoAccountApi();
Response<Account, AccountError> response = await accountApi.updateById('id', UpdateAccountOptions(
walletPassword: 'pass@word1!',
name: 'name',
));
UpdateByShieldedAddress
Update an account by its shielded address.
import 'package:mystiko_flutter/mystiko_flutter.dart';
MystikoAccountApi api = await Mystiko.mystikoAccountApi();
Response<Account, AccountError> response = await accountApi.updateByShieldedAddress('shieldedAddress', UpdateAccountOptions(
walletPassword: 'pass@word1!',
name: 'name',
));
UpdateByPublicKey
Update an account by its public key.
import 'package:mystiko_flutter/mystiko_flutter.dart';
MystikoAccountApi api = await Mystiko.mystikoAccountApi();
Response<Account, AccountError> response = await accountApi.updateByPublicKey('publicKey', UpdateAccountOptions(
walletPassword: 'pass@word1!',
name: 'name',
));
UpdateEncryption
Update the encryption of an account.
import 'package:mystiko_flutter/mystiko_flutter.dart';
MystikoAccountApi api = await Mystiko.mystikoAccountApi();
Response<List<Account>, AccountError> response = await accountApi.updateEncryption('oldWalletPassword', 'newWalletPassword');
Export
ExportSecretKeyById
Export the secret key of an account by its unique identifier.
import 'package:mystiko_flutter/mystiko_flutter.dart';
MystikoAccountApi api = await Mystiko.mystikoAccountApi();
Response<String, AccountError> response = await accountApi.exportSecretKeyById('walletPassword', 'id');
ExportSecretKeyByPublicKey
Export the secret key of an account by its public key.
import 'package:mystiko_flutter/mystiko_flutter.dart';
MystikoAccountApi api = await Mystiko.mystikoAccountApi();
Response<String, AccountError> response = await accountApi.exportSecretKeyByPublicKey('walletPassword', 'publicKey');
ExportSecretKeyByShieldedAddress
Export the secret key of an account by its shielded address.
import 'package:mystiko_flutter/mystiko_flutter.dart';
MystikoAccountApi api = await Mystiko.mystikoAccountApi();
Response<String, AccountError> response = await accountApi.exportSecretKeyByShieldedAddress('walletPassword', 'shieldedAddress');