address generation issues mostly resolved

This commit is contained in:
Matthew Fosse 2024-09-11 18:17:45 -07:00
parent 554df09c99
commit f8d76fb2e1

View file

@ -33,7 +33,6 @@ abstract class LitecoinWalletAddressesBase extends ElectrumWalletAddresses with
mwebAddrs.add(mwebAddresses[i].address); mwebAddrs.add(mwebAddresses[i].address);
} }
print("initialized with ${mwebAddrs.length} mweb addresses"); print("initialized with ${mwebAddrs.length} mweb addresses");
initMwebAddresses();
} }
final Bip32Slip10Secp256k1 mwebHd; final Bip32Slip10Secp256k1 mwebHd;
@ -47,8 +46,14 @@ abstract class LitecoinWalletAddressesBase extends ElectrumWalletAddresses with
@override @override
Future<void> init() async { Future<void> init() async {
await initMwebAddresses();
await super.init(); await super.init();
initMwebAddresses(); }
@computed
@override
List<BitcoinAddressRecord> get allAddresses {
return List.from(super.allAddresses)..addAll(mwebAddresses);
} }
Future<void> ensureMwebAddressUpToIndexExists(int index) async { Future<void> ensureMwebAddressUpToIndexExists(int index) async {
@ -60,16 +65,6 @@ abstract class LitecoinWalletAddressesBase extends ElectrumWalletAddresses with
} }
} }
Future<void> 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<void> initMwebAddresses() async { Future<void> initMwebAddresses() async {
print("Initializing MWEB addresses!"); print("Initializing MWEB addresses!");
@ -86,41 +81,10 @@ abstract class LitecoinWalletAddressesBase extends ElectrumWalletAddresses with
network: network, network: network,
)) ))
.toList(); .toList();
addAddresses(addressRecords);
addMwebAddresses(addressRecords); addMwebAddresses(addressRecords);
print("added ${addressRecords.length} mweb addresses"); print("added ${addressRecords.length} mweb addresses");
return; 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<BitcoinAddressRecord> 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 @override