stack_wallet/lib/wallets/models/incomplete_frost_wallet.dart

45 lines
1.2 KiB
Dart
Raw Normal View History

import '../../db/isar/main_db.dart';
import '../../services/node_service.dart';
import '../../utilities/flutter_secure_storage_interface.dart';
import '../../utilities/prefs.dart';
import '../isar/models/frost_wallet_info.dart';
import '../isar/models/wallet_info.dart';
import '../wallet/impl/bitcoin_frost_wallet.dart';
import '../wallet/wallet.dart';
2024-01-19 23:44:01 +00:00
class IncompleteFrostWallet {
WalletInfo? info;
String? get walletId => info?.walletId;
Future<BitcoinFrostWallet> toBitcoinFrostWallet({
required MainDB mainDB,
required SecureStorageInterface secureStorageInterface,
required NodeService nodeService,
required Prefs prefs,
}) async {
final wallet = await Wallet.create(
walletInfo: info!,
mainDB: mainDB,
secureStorageInterface: secureStorageInterface,
nodeService: nodeService,
prefs: prefs,
);
// dummy entry so updaters work when `wallet.updateWithResharedData` is called
final frostInfo = FrostWalletInfo(
walletId: info!.walletId,
knownSalts: [],
participants: [],
myName: "",
threshold: -1,
);
2024-05-03 18:22:19 +00:00
await mainDB.isar.writeTxn(() async {
await mainDB.isar.frostWalletInfo.put(frostInfo);
});
2024-01-19 23:44:01 +00:00
return wallet as BitcoinFrostWallet;
}
}