diff --git a/cw_bitcoin/lib/litecoin_wallet_addresses.dart b/cw_bitcoin/lib/litecoin_wallet_addresses.dart index 6ff9f955e..8f5aefcc8 100644 --- a/cw_bitcoin/lib/litecoin_wallet_addresses.dart +++ b/cw_bitcoin/lib/litecoin_wallet_addresses.dart @@ -33,7 +33,6 @@ abstract class LitecoinWalletAddressesBase extends ElectrumWalletAddresses with mwebAddrs.add(mwebAddresses[i].address); } print("initialized with ${mwebAddrs.length} mweb addresses"); - initMwebAddresses(); } final Bip32Slip10Secp256k1 mwebHd; @@ -47,8 +46,14 @@ abstract class LitecoinWalletAddressesBase extends ElectrumWalletAddresses with @override Future init() async { + await initMwebAddresses(); await super.init(); - initMwebAddresses(); + } + + @computed + @override + List get allAddresses { + return List.from(super.allAddresses)..addAll(mwebAddresses); } Future ensureMwebAddressUpToIndexExists(int index) async { @@ -60,16 +65,6 @@ abstract class LitecoinWalletAddressesBase extends ElectrumWalletAddresses with } } - Future generateNumAddresses(int num) async { - Uint8List scan = Uint8List.fromList(scanSecret); - Uint8List spend = Uint8List.fromList(spendPubkey); - for (int i = 0; i < num; i++) { - final address = await CwMweb.address(scan, spend, mwebAddrs.length); - mwebAddrs.add(address!); - await Future.delayed(Duration.zero); - } - } - Future initMwebAddresses() async { print("Initializing MWEB addresses!"); @@ -86,41 +81,10 @@ abstract class LitecoinWalletAddressesBase extends ElectrumWalletAddresses with network: network, )) .toList(); - addAddresses(addressRecords); addMwebAddresses(addressRecords); print("added ${addressRecords.length} mweb addresses"); return; } - - // Timer.periodic(const Duration(seconds: 2), (timer) async { - // if (super.allAddresses.length > 1000) { - // timer.cancel(); - // return; - // } - // print("Generating MWEB addresses..."); - // await generateNumAddresses(250); - // await Future.delayed(const Duration(milliseconds: 1500)); - - // if (mwebAddrs.length > 1000) { - // // convert mwebAddrs to BitcoinAddressRecords: - // List mwebAddresses = mwebAddrs - // .asMap() - // .entries - // .map((e) => BitcoinAddressRecord( - // e.value, - // index: e.key, - // type: SegwitAddresType.mweb, - // network: network, - // )) - // .toList(); - // // add them to the list of all addresses: - // addAddresses(mwebAddresses); - // addMwebAddresses(mwebAddresses); - // print("MWEB addresses initialized ${mwebAddrs.length}"); - // timer.cancel(); - // return; - // } - // }); } @override