mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-19 09:15:11 +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((_) {
|
autorun((_) {
|
||||||
this.walletAddresses.isEnabledAutoGenerateSubaddress = this.isEnabledAutoGenerateSubaddress;
|
this.walletAddresses.isEnabledAutoGenerateSubaddress = this.isEnabledAutoGenerateSubaddress;
|
||||||
});
|
});
|
||||||
CwMweb.stub().then((value) {
|
|
||||||
_stub = value;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
late final Bip32Slip10Secp256k1 mwebHd;
|
late final Bip32Slip10Secp256k1 mwebHd;
|
||||||
late final Box<MwebUtxo> mwebUtxosBox;
|
late final Box<MwebUtxo> mwebUtxosBox;
|
||||||
|
@ -201,7 +198,7 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
||||||
@action
|
@action
|
||||||
@override
|
@override
|
||||||
Future<void> startSync() async {
|
Future<void> startSync() async {
|
||||||
print("STARTING SYNC");
|
print("STARTING SYNC - MWEB ENABLED: $mwebEnabled");
|
||||||
syncStatus = SyncronizingSyncStatus();
|
syncStatus = SyncronizingSyncStatus();
|
||||||
await subscribeForUpdates();
|
await subscribeForUpdates();
|
||||||
await updateTransactions();
|
await updateTransactions();
|
||||||
|
@ -211,6 +208,7 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
||||||
_feeRatesTimer =
|
_feeRatesTimer =
|
||||||
Timer.periodic(const Duration(minutes: 1), (timer) async => await updateFeeRates());
|
Timer.periodic(const Duration(minutes: 1), (timer) async => await updateFeeRates());
|
||||||
|
|
||||||
|
|
||||||
if (!mwebEnabled) {
|
if (!mwebEnabled) {
|
||||||
try {
|
try {
|
||||||
await updateAllUnspents();
|
await updateAllUnspents();
|
||||||
|
@ -224,10 +222,10 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await getStub();
|
||||||
await updateUnspent();
|
await updateUnspent();
|
||||||
await updateBalance();
|
await updateBalance();
|
||||||
|
|
||||||
_stub = await CwMweb.stub();
|
|
||||||
_syncTimer?.cancel();
|
_syncTimer?.cancel();
|
||||||
_syncTimer = Timer.periodic(const Duration(milliseconds: 1500), (timer) async {
|
_syncTimer = Timer.periodic(const Duration(milliseconds: 1500), (timer) async {
|
||||||
if (syncStatus is FailedSyncStatus) return;
|
if (syncStatus is FailedSyncStatus) return;
|
||||||
|
@ -596,6 +594,10 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
||||||
@override
|
@override
|
||||||
Future<ElectrumBalance> fetchBalances() async {
|
Future<ElectrumBalance> fetchBalances() async {
|
||||||
final balance = await super.fetchBalances();
|
final balance = await super.fetchBalances();
|
||||||
|
if (!mwebEnabled) {
|
||||||
|
return balance;
|
||||||
|
}
|
||||||
|
|
||||||
int confirmed = balance.confirmed;
|
int confirmed = balance.confirmed;
|
||||||
int unconfirmed = balance.unconfirmed;
|
int unconfirmed = balance.unconfirmed;
|
||||||
try {
|
try {
|
||||||
|
@ -618,7 +620,7 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
||||||
// });
|
// });
|
||||||
|
|
||||||
await updateUnspent();
|
await updateUnspent();
|
||||||
|
|
||||||
for (var addressRecord in walletAddresses.allAddresses) {
|
for (var addressRecord in walletAddresses.allAddresses) {
|
||||||
addressRecord.balance = 0;
|
addressRecord.balance = 0;
|
||||||
addressRecord.txCount = 0;
|
addressRecord.txCount = 0;
|
||||||
|
@ -663,8 +665,6 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return ElectrumBalance(confirmed: confirmed, unconfirmed: unconfirmed, frozen: balance.frozen);
|
return ElectrumBalance(confirmed: confirmed, unconfirmed: unconfirmed, frozen: balance.frozen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -835,6 +835,10 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
||||||
|
|
||||||
mwebEnabled = enabled;
|
mwebEnabled = enabled;
|
||||||
(walletAddresses as LitecoinWalletAddresses).mwebEnabled = enabled;
|
(walletAddresses as LitecoinWalletAddresses).mwebEnabled = enabled;
|
||||||
|
if (enabled) {
|
||||||
|
// generate inital mweb addresses:
|
||||||
|
(walletAddresses as LitecoinWalletAddresses).topUpMweb(0);
|
||||||
|
}
|
||||||
stopSync();
|
stopSync();
|
||||||
startSync();
|
startSync();
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,9 @@ abstract class LitecoinWalletAddressesBase extends ElectrumWalletAddresses with
|
||||||
super.initialRegularAddressIndex,
|
super.initialRegularAddressIndex,
|
||||||
super.initialChangeAddressIndex,
|
super.initialChangeAddressIndex,
|
||||||
}) : super(walletInfo) {
|
}) : super(walletInfo) {
|
||||||
topUpMweb(0);
|
if (mwebEnabled) {
|
||||||
|
topUpMweb(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final Bip32Slip10Secp256k1 mwebHd;
|
final Bip32Slip10Secp256k1 mwebHd;
|
||||||
|
@ -58,7 +60,7 @@ abstract class LitecoinWalletAddressesBase extends ElectrumWalletAddresses with
|
||||||
required Bip32Slip10Secp256k1 hd,
|
required Bip32Slip10Secp256k1 hd,
|
||||||
BitcoinAddressType? addressType,
|
BitcoinAddressType? addressType,
|
||||||
}) {
|
}) {
|
||||||
if (addressType == SegwitAddresType.mweb) {
|
if (addressType == SegwitAddresType.mweb && mwebEnabled) {
|
||||||
topUpMweb(index);
|
topUpMweb(index);
|
||||||
return hd == sideHd ? mwebAddrs[0] : mwebAddrs[index + 1];
|
return hd == sideHd ? mwebAddrs[0] : mwebAddrs[index + 1];
|
||||||
}
|
}
|
||||||
|
@ -71,7 +73,11 @@ abstract class LitecoinWalletAddressesBase extends ElectrumWalletAddresses with
|
||||||
required Bip32Slip10Secp256k1 hd,
|
required Bip32Slip10Secp256k1 hd,
|
||||||
BitcoinAddressType? addressType,
|
BitcoinAddressType? addressType,
|
||||||
}) async {
|
}) 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);
|
await topUpMweb(index);
|
||||||
}
|
}
|
||||||
return getAddress(index: index, hd: hd, addressType: addressType);
|
return getAddress(index: index, hd: hd, addressType: addressType);
|
||||||
|
|
Loading…
Reference in a new issue