mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-03-12 09:32:33 +00:00
fix: auto switch node broken
This commit is contained in:
parent
23d6221302
commit
615db5a6d4
4 changed files with 17 additions and 12 deletions
|
@ -331,15 +331,20 @@ class CWBitcoin extends Bitcoin {
|
|||
}
|
||||
|
||||
@override
|
||||
Future<void> setScanningActive(Object wallet, SettingsStore settingsStore, bool active) async {
|
||||
Future<void> setScanningActive(Object wallet, bool active) async {
|
||||
final bitcoinWallet = wallet as ElectrumWallet;
|
||||
|
||||
// TODO: always when setting to scanning active, will force switch nodes. Remove when not needed anymore
|
||||
if (!getNodeIsCakeElectrs(wallet)) {
|
||||
final node = Node(useSSL: false, uri: '198.58.111.154:50002');
|
||||
final node = Node(
|
||||
useSSL: false,
|
||||
uri: '198.58.111.154:${(wallet.network == BitcoinNetwork.testnet ? 50002 : 50001)}',
|
||||
);
|
||||
node.type = WalletType.bitcoin;
|
||||
settingsStore.nodes[WalletType.bitcoin] = node;
|
||||
|
||||
await bitcoinWallet.connectToNode(node: node);
|
||||
}
|
||||
|
||||
bitcoinWallet.setSilentPaymentsScanning(active);
|
||||
}
|
||||
|
||||
|
@ -353,14 +358,15 @@ class CWBitcoin extends Bitcoin {
|
|||
int getHeightByDate({required DateTime date}) => getBitcoinHeightByDate(date: date);
|
||||
|
||||
@override
|
||||
Future<void> rescan(Object wallet, SettingsStore settingsStore,
|
||||
{required int height, bool? doSingleScan}) async {
|
||||
Future<void> rescan(Object wallet, {required int height, bool? doSingleScan}) async {
|
||||
final bitcoinWallet = wallet as ElectrumWallet;
|
||||
// TODO: always when setting to scanning active, will force switch nodes. Remove when not needed anymore
|
||||
if (!getNodeIsCakeElectrs(wallet)) {
|
||||
final node = Node(useSSL: false, uri: '198.58.111.154:50002');
|
||||
final node = Node(
|
||||
useSSL: false,
|
||||
uri: '198.58.111.154:${(wallet.network == BitcoinNetwork.testnet ? 50002 : 50001)}',
|
||||
);
|
||||
node.type = WalletType.bitcoin;
|
||||
settingsStore.nodes[WalletType.bitcoin] = node;
|
||||
await bitcoinWallet.connectToNode(node: node);
|
||||
}
|
||||
bitcoinWallet.rescan(height: height, doSingleScan: doSingleScan);
|
||||
|
|
|
@ -319,7 +319,7 @@ abstract class DashboardViewModelBase with Store {
|
|||
silentPaymentsScanningActive = active;
|
||||
|
||||
if (hasSilentPayments) {
|
||||
bitcoin!.setScanningActive(wallet, settingsStore, active);
|
||||
bitcoin!.setScanningActive(wallet, active);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ abstract class RescanViewModelBase with Store {
|
|||
wallet.rescan(height: restoreHeight);
|
||||
wallet.transactionHistory.clear();
|
||||
} else {
|
||||
bitcoin!.rescan(wallet, settingsStore, height: restoreHeight, doSingleScan: doSingleScan);
|
||||
bitcoin!.rescan(wallet, height: restoreHeight, doSingleScan: doSingleScan);
|
||||
}
|
||||
state = RescanWalletState.none;
|
||||
}
|
||||
|
|
|
@ -161,7 +161,7 @@ abstract class Bitcoin {
|
|||
BitcoinAddressType getOptionToType(ReceivePageOption option);
|
||||
bool hasTaprootInput(PendingTransaction pendingTransaction);
|
||||
bool getScanningActive(Object wallet);
|
||||
Future<void> setScanningActive(Object wallet, SettingsStore settingsStore, bool active);
|
||||
Future<void> setScanningActive(Object wallet, bool active);
|
||||
bool isTestnet(Object wallet);
|
||||
|
||||
Future<PendingTransaction> replaceByFee(Object wallet, String transactionHash, String fee);
|
||||
|
@ -170,8 +170,7 @@ abstract class Bitcoin {
|
|||
int getFeeAmountForPriority(Object wallet, TransactionPriority priority, int inputsCount, int outputsCount, {int? size});
|
||||
int getFeeAmountWithFeeRate(Object wallet, int feeRate, int inputsCount, int outputsCount, {int? size});
|
||||
int getHeightByDate({required DateTime date});
|
||||
Future<void> rescan(Object wallet, SettingsStore settingsStore,
|
||||
{required int height, bool? doSingleScan});
|
||||
Future<void> rescan(Object wallet, {required int height, bool? doSingleScan});
|
||||
bool getNodeIsCakeElectrs(Object wallet);
|
||||
void deleteSilentPaymentAddress(Object wallet, String address);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue