CreateWalletCommand constructor

CreateWalletCommand({
  1. required String walletId,
  2. required String walletName,
  3. String? mnemonic,
  4. String? wif,
  5. String? xpriv,
  6. String? xpub,
  7. String? passphrase,
  8. Map<String, dynamic>? walletMetadata,
  9. String? commandId,
  10. DateTime? timestamp,
  11. Map<String, dynamic>? metadata,
})

Implementation

CreateWalletCommand({
  required String walletId,
  required this.walletName,
  this.mnemonic,
  this.wif,
  this.xpriv,
  this.xpub,
  this.passphrase,
  this.walletMetadata,
  String? commandId,
  DateTime? timestamp,
  Map<String, dynamic>? metadata,
}) : super(
        walletId: walletId,
        commandId: commandId,
        timestamp: timestamp,
        metadata: metadata,
      ) {
  // Validation: At most one wallet type can be specified
  final specified = [
    mnemonic != null && mnemonic!.isNotEmpty,
    wif != null && wif!.isNotEmpty,
    xpriv != null && xpriv!.isNotEmpty,
    xpub != null && xpub!.isNotEmpty,
  ].where((x) => x).length;

  if (specified > 1) {
    throw ArgumentError(
      'Only one of mnemonic, wif, xpriv, or xpub can be specified'
    );
  }
}