mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-19 01:04:43 +00:00
more fixes
This commit is contained in:
parent
10c2353288
commit
a0c315c4cf
2 changed files with 21 additions and 11 deletions
|
@ -88,9 +88,6 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
|||
autorun((_) {
|
||||
this.walletAddresses.isEnabledAutoGenerateSubaddress = this.isEnabledAutoGenerateSubaddress;
|
||||
});
|
||||
CwMweb.stub().then((value) {
|
||||
_stub = value;
|
||||
});
|
||||
}
|
||||
late final Bip32Slip10Secp256k1 mwebHd;
|
||||
late final Box<MwebUtxo> mwebUtxosBox;
|
||||
|
@ -201,7 +198,7 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
|||
@action
|
||||
@override
|
||||
Future<void> startSync() async {
|
||||
print("STARTING SYNC");
|
||||
print("STARTING SYNC - MWEB ENABLED: $mwebEnabled");
|
||||
syncStatus = SyncronizingSyncStatus();
|
||||
await subscribeForUpdates();
|
||||
await updateTransactions();
|
||||
|
@ -211,6 +208,7 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
|||
_feeRatesTimer =
|
||||
Timer.periodic(const Duration(minutes: 1), (timer) async => await updateFeeRates());
|
||||
|
||||
|
||||
if (!mwebEnabled) {
|
||||
try {
|
||||
await updateAllUnspents();
|
||||
|
@ -224,10 +222,10 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
|||
return;
|
||||
}
|
||||
|
||||
await getStub();
|
||||
await updateUnspent();
|
||||
await updateBalance();
|
||||
|
||||
_stub = await CwMweb.stub();
|
||||
_syncTimer?.cancel();
|
||||
_syncTimer = Timer.periodic(const Duration(milliseconds: 1500), (timer) async {
|
||||
if (syncStatus is FailedSyncStatus) return;
|
||||
|
@ -596,6 +594,10 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
|||
@override
|
||||
Future<ElectrumBalance> fetchBalances() async {
|
||||
final balance = await super.fetchBalances();
|
||||
if (!mwebEnabled) {
|
||||
return balance;
|
||||
}
|
||||
|
||||
int confirmed = balance.confirmed;
|
||||
int unconfirmed = balance.unconfirmed;
|
||||
try {
|
||||
|
@ -618,7 +620,7 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
|||
// });
|
||||
|
||||
await updateUnspent();
|
||||
|
||||
|
||||
for (var addressRecord in walletAddresses.allAddresses) {
|
||||
addressRecord.balance = 0;
|
||||
addressRecord.txCount = 0;
|
||||
|
@ -663,8 +665,6 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return ElectrumBalance(confirmed: confirmed, unconfirmed: unconfirmed, frozen: balance.frozen);
|
||||
}
|
||||
|
||||
|
@ -835,6 +835,10 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
|||
|
||||
mwebEnabled = enabled;
|
||||
(walletAddresses as LitecoinWalletAddresses).mwebEnabled = enabled;
|
||||
if (enabled) {
|
||||
// generate inital mweb addresses:
|
||||
(walletAddresses as LitecoinWalletAddresses).topUpMweb(0);
|
||||
}
|
||||
stopSync();
|
||||
startSync();
|
||||
}
|
||||
|
|
|
@ -24,7 +24,9 @@ abstract class LitecoinWalletAddressesBase extends ElectrumWalletAddresses with
|
|||
super.initialRegularAddressIndex,
|
||||
super.initialChangeAddressIndex,
|
||||
}) : super(walletInfo) {
|
||||
topUpMweb(0);
|
||||
if (mwebEnabled) {
|
||||
topUpMweb(0);
|
||||
}
|
||||
}
|
||||
|
||||
final Bip32Slip10Secp256k1 mwebHd;
|
||||
|
@ -58,7 +60,7 @@ abstract class LitecoinWalletAddressesBase extends ElectrumWalletAddresses with
|
|||
required Bip32Slip10Secp256k1 hd,
|
||||
BitcoinAddressType? addressType,
|
||||
}) {
|
||||
if (addressType == SegwitAddresType.mweb) {
|
||||
if (addressType == SegwitAddresType.mweb && mwebEnabled) {
|
||||
topUpMweb(index);
|
||||
return hd == sideHd ? mwebAddrs[0] : mwebAddrs[index + 1];
|
||||
}
|
||||
|
@ -71,7 +73,11 @@ abstract class LitecoinWalletAddressesBase extends ElectrumWalletAddresses with
|
|||
required Bip32Slip10Secp256k1 hd,
|
||||
BitcoinAddressType? addressType,
|
||||
}) async {
|
||||
if (addressType == SegwitAddresType.mweb) {
|
||||
// if mweb isn't enabled we'll just return the regular address type which does effectively nothing
|
||||
// sort of a hack but easier than trying to pull the mweb setting into the electrum_wallet_addresses initialization code
|
||||
// (we want to avoid initializing the mweb.stub() if it's not enabled or we'd be starting the whole server for no reason and it's slow)
|
||||
// TODO: find a way to do address generation without starting the whole mweb server
|
||||
if (addressType == SegwitAddresType.mweb && mwebEnabled) {
|
||||
await topUpMweb(index);
|
||||
}
|
||||
return getAddress(index: index, hd: hd, addressType: addressType);
|
||||
|
|
Loading…
Reference in a new issue