[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, unspentCoinsInfo: unspentCoinsInfo,
network: LitecoinNetwork.mainnet, network: LitecoinNetwork.mainnet,
initialAddresses: initialAddresses, initialAddresses: initialAddresses,
initialMwebAddresses: initialMwebAddresses,
initialBalance: initialBalance, initialBalance: initialBalance,
seedBytes: seedBytes, seedBytes: seedBytes,
encryptionFileUtils: encryptionFileUtils, encryptionFileUtils: encryptionFileUtils,

View file

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