stack_wallet/lib/wallets/models/incomplete_frost_wallet.dart

43 lines
1.3 KiB
Dart
Raw Normal View History

2024-01-19 23:44:01 +00:00
import 'package:stackwallet/db/isar/main_db.dart';
import 'package:stackwallet/services/node_service.dart';
import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart';
import 'package:stackwallet/utilities/prefs.dart';
import 'package:stackwallet/wallets/isar/models/frost_wallet_info.dart';
import 'package:stackwallet/wallets/isar/models/wallet_info.dart';
import 'package:stackwallet/wallets/wallet/impl/bitcoin_frost_wallet.dart';
import 'package:stackwallet/wallets/wallet/wallet.dart';
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,
);
await mainDB.isar.frostWalletInfo.put(frostInfo);
return wallet as BitcoinFrostWallet;
}
}