Merge branch 'main' into flags

This commit is contained in:
Omar Hatem 2024-08-22 03:42:18 +03:00 committed by GitHub
commit 9390ceb323
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 22 additions and 16 deletions

View file

@ -23,9 +23,10 @@ jobs:
docker-images: true
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
- uses: actions/setup-java@v2
with:
java-version: "17.x"
distribution: "temurin"
java-version: "17"
- name: Configure placeholder git details
run: |
git config --global user.email "CI@cakewallet.com"

View file

@ -39,9 +39,10 @@ jobs:
docker-images: true
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
- uses: actions/setup-java@v2
with:
java-version: "17.x"
distribution: "temurin"
java-version: "17"
- name: Configure placeholder git details
run: |
git config --global user.email "CI@cakewallet.com"

View file

@ -119,9 +119,11 @@ class ElectrumClient {
_setConnectionStatus(ConnectionStatus.failed);
},
onDone: () {
socket = null;
unterminatedString = '';
if (host == socket?.address.host) _setConnectionStatus(ConnectionStatus.disconnected);
if (host == socket?.address.host) {
socket = null;
_setConnectionStatus(ConnectionStatus.disconnected);
}
},
cancelOnError: true,
);

View file

@ -42,7 +42,6 @@ import 'package:flutter/foundation.dart';
import 'package:hive/hive.dart';
import 'package:mobx/mobx.dart';
import 'package:rxdart/subjects.dart';
import 'package:http/http.dart' as http;
import 'package:sp_scanner/sp_scanner.dart';
part 'electrum_wallet.g.dart';
@ -89,7 +88,7 @@ abstract class ElectrumWalletBase
}
: {}),
this.unspentCoinsInfo = unspentCoinsInfo,
this.isTestnet = network == BitcoinNetwork.testnet,
this.isTestnet = !network.isMainnet,
this._mnemonic = mnemonic,
super(walletInfo) {
this.electrumClient = electrumClient ?? ElectrumClient();
@ -182,7 +181,7 @@ abstract class ElectrumWalletBase
BasedUtxoNetwork network;
@override
bool? isTestnet;
bool isTestnet;
bool get hasSilentPaymentsScanning => type == WalletType.bitcoin;
@ -426,7 +425,7 @@ abstract class ElectrumWalletBase
await updateTransactions();
await updateAllUnspents();
await updateBalance();
updateFeeRates();
await updateFeeRates();
_updateFeeRateTimer ??=
Timer.periodic(const Duration(minutes: 1), (timer) async => await updateFeeRates());
@ -448,6 +447,8 @@ abstract class ElectrumWalletBase
final feeRates = await electrumClient.feeRates(network: network);
if (feeRates != [0, 0, 0]) {
_feeRates = feeRates;
} else if (isTestnet) {
_feeRates = [1, 1, 1];
}
}
@ -1005,7 +1006,7 @@ abstract class ElectrumWalletBase
if (estimatedTx.inputPrivKeyInfos.isEmpty) {
error += "\nNo private keys generated.";
} else {
error += "\nAddress: ${utxo.ownerDetails.address.toAddress()}";
error += "\nAddress: ${utxo.ownerDetails.address.toAddress(network)}";
key = estimatedTx.inputPrivKeyInfos.firstWhereOrNull((element) {
final elemPubkey = element.privkey.getPublic().toHex();
@ -1944,8 +1945,9 @@ abstract class ElectrumWalletBase
Future<void> _setInitialHeight() async {
if (_chainTipUpdateSubject != null) return;
_currentChainTip = await getUpdatedChainTip();
if ((_currentChainTip == null || _currentChainTip! == 0) && walletInfo.restoreHeight == 0) {
await getUpdatedChainTip();
await walletInfo.updateRestoreHeight(_currentChainTip!);
}

View file

@ -95,5 +95,5 @@ abstract class WalletBase<BalanceType extends Balance, HistoryType extends Trans
Future<bool> verifyMessage(String message, String signature, {String? address = null});
bool? isTestnet;
bool isTestnet = false;
}

View file

@ -516,7 +516,7 @@ class CWBitcoin extends Bitcoin {
@override
bool isTestnet(Object wallet) {
final bitcoinWallet = wallet as ElectrumWallet;
return bitcoinWallet.isTestnet ?? false;
return bitcoinWallet.isTestnet;
}
@override

View file

@ -52,7 +52,7 @@ abstract class NodeListViewModelBase with Store {
switch (_appStore.wallet!.type) {
case WalletType.bitcoin:
if (_appStore.wallet!.isTestnet == true) {
if (_appStore.wallet!.isTestnet) {
node = getBitcoinTestnetDefaultElectrumServer(nodes: _nodeSource)!;
} else {
node = getBitcoinDefaultElectrumServer(nodes: _nodeSource)!;

View file

@ -152,7 +152,7 @@ abstract class TransactionDetailsViewModelBase with Store {
case WalletType.monero:
return 'https://monero.com/tx/${txId}';
case WalletType.bitcoin:
return 'https://mempool.space/${wallet.isTestnet == true ? "testnet/" : ""}tx/${txId}';
return 'https://mempool.space/${wallet.isTestnet ? "testnet/" : ""}tx/${txId}';
case WalletType.litecoin:
return 'https://blockchair.com/litecoin/transaction/${txId}';
case WalletType.bitcoinCash: