[skip ci] save

This commit is contained in:
Matthew Fosse 2024-09-11 14:28:58 -07:00
parent c94c10cc05
commit cd307bf6e8
2 changed files with 50 additions and 33 deletions

View file

@ -70,7 +70,6 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
unspentCoinsInfo: unspentCoinsInfo,
network: LitecoinNetwork.mainnet,
initialAddresses: initialAddresses,
initialMwebAddresses: initialMwebAddresses,
initialBalance: initialBalance,
seedBytes: seedBytes,
encryptionFileUtils: encryptionFileUtils,

View file

@ -33,10 +33,8 @@ abstract class LitecoinWalletAddressesBase extends ElectrumWalletAddresses with
mwebAddrs.add(mwebAddresses[i].address);
}
print("initialized with ${mwebAddrs.length} mweb addresses");
if (mwebAddrs.length < 1000) {
initMwebAddresses();
}
}
final Bip32Slip10Secp256k1 mwebHd;
bool mwebEnabled;
@ -73,19 +71,12 @@ abstract class LitecoinWalletAddressesBase extends ElectrumWalletAddresses with
}
Future<void> initMwebAddresses() async {
print("Initializing MWEB address timer!");
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));
print("Initializing MWEB addresses!");
if (mwebAddrs.length > 1000) {
// convert mwebAddrs to BitcoinAddressRecords:
List<BitcoinAddressRecord> mwebAddresses = mwebAddrs
if (mwebAddrs.length < 1000) {
print("Generating MWEB addresses...");
await ensureMwebAddressUpToIndexExists(1020);
List<BitcoinAddressRecord> addressRecords = mwebAddrs
.asMap()
.entries
.map((e) => BitcoinAddressRecord(
@ -95,14 +86,41 @@ abstract class LitecoinWalletAddressesBase extends ElectrumWalletAddresses with
network: network,
))
.toList();
// add them to the list of all addresses:
addAddresses(mwebAddresses);
addMwebAddresses(mwebAddresses);
print("MWEB addresses initialized ${mwebAddrs.length}");
timer.cancel();
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<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