generateWithDefaults static method

Future<KdfStartupConfig> generateWithDefaults({
  1. required String walletName,
  2. required String walletPassword,
  3. required bool? enableHd,
  4. String? rpcPassword,
  5. String? coinsPath,
  6. String? seed,
  7. String? dbDir,
  8. String? userHome,
  9. String? rpcIp,
  10. int? hdAccountId,
  11. bool allowWeakPassword = false,
  12. int rpcPort = 7783,
  13. int netid = kDefaultNetId,
  14. String gui = 'komodo-defi-flutter-auth',
  15. bool https = false,
  16. bool rpcLocalOnly = true,
  17. bool allowRegistrations = true,
  18. List<String>? seedNodes,
  19. bool? disableP2p,
  20. bool? iAmSeed,
  21. bool? isBootstrapNode,
})

Implementation

static Future<KdfStartupConfig> generateWithDefaults({
  required String walletName,
  required String walletPassword,
  required bool? enableHd,
  String? rpcPassword,
  String? coinsPath,
  String? seed,
  String? dbDir,
  String? userHome,
  String? rpcIp,
  int? hdAccountId,
  bool allowWeakPassword = false,
  int rpcPort = 7783,
  int netid = kDefaultNetId,
  String gui = 'komodo-defi-flutter-auth',
  bool https = false,
  bool rpcLocalOnly = true,
  bool allowRegistrations = true,
  List<String>? seedNodes,
  bool? disableP2p,
  bool? iAmSeed,
  bool? isBootstrapNode,
}) async {
  assert(
    !kIsWeb || userHome == null && dbDir == null,
    'Web does not support userHome or dbDir',
  );
  assert(
    [walletName, walletPassword].every((e) => e.isNotEmpty),
    'Wallet name and password must not be empty',
  );

  final (String? userHomePath, String? dbPath) = await _getAndSetupUserHome(
    userHome: userHome,
    dbHome: dbDir,
  );

  assert(
      hdAccountId == null,
      'HD Account ID is not supported yet in the SDK. '
      'Use at your own risk.');

  // Validate seed node configuration before creating the object
  SeedNodeValidator.validate(
    seedNodes: seedNodes,
    disableP2p: disableP2p,
    iAmSeed: iAmSeed,
    isBootstrapNode: isBootstrapNode,
  );

  return KdfStartupConfig._(
    walletName: walletName,
    walletPassword: walletPassword,
    rpcPassword: rpcPassword ?? SecurityUtils.generatePasswordSecure(32),
    seed: seed,
    dbDir: dbPath,
    userHome: userHomePath,
    allowWeakPassword: allowWeakPassword,
    netid: netid,
    gui: gui,
    coins: coinsPath ?? await _fetchCoinsData(),
    https: https,
    seedNodes: seedNodes,
    disableP2p: disableP2p,
    iAmSeed: iAmSeed,
    isBootstrapNode: isBootstrapNode,
    rpcIp: rpcIp,
    rpcPort: rpcPort,
    rpcLocalOnly: rpcLocalOnly,
    hdAccountId: hdAccountId,
    allowRegistrations: allowRegistrations,
    enableHd: enableHd,
  );
}