Skip to main content

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:

PropertyTypeDescription
idString
The unique identifier of the account.
createdAtInt64
The timestamp when the account was created.
updatedAtInt64
The timestamp when the account was last updated.
nameString
The name of the account.
shieldedAddressString
The shielded address of the account.
publicKeyString
The public key of the account.
encryptedSecretKeyString
The encrypted secret key of the account.
walletIdString
The unique identifier of the wallet to which the account belongs.
scannedToIdString
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:

ParameterRequiredDescription
walletPasswordtrue
The password of the encrypted wallet.
namefalse
The name of the account.
secretKeyfalse
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:

ParameterRequiredDescription
walletPasswordtrue
The password of the encrypted wallet.
namefalse
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');