diff --git a/.github/workflows/cache_dependencies.yml b/.github/workflows/cache_dependencies.yml index 902a44a42..c0042bf5c 100644 --- a/.github/workflows/cache_dependencies.yml +++ b/.github/workflows/cache_dependencies.yml @@ -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" diff --git a/.github/workflows/pr_test_build_android.yml b/.github/workflows/pr_test_build_android.yml index 5dbf1610f..b7b2aaa71 100644 --- a/.github/workflows/pr_test_build_android.yml +++ b/.github/workflows/pr_test_build_android.yml @@ -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" diff --git a/cw_bitcoin/lib/electrum.dart b/cw_bitcoin/lib/electrum.dart index 28043d0c0..6ac8edd1a 100644 --- a/cw_bitcoin/lib/electrum.dart +++ b/cw_bitcoin/lib/electrum.dart @@ -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, ); diff --git a/cw_bitcoin/lib/electrum_wallet.dart b/cw_bitcoin/lib/electrum_wallet.dart index 2d0b989d7..da91a29e4 100644 --- a/cw_bitcoin/lib/electrum_wallet.dart +++ b/cw_bitcoin/lib/electrum_wallet.dart @@ -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 _setInitialHeight() async { if (_chainTipUpdateSubject != null) return; + _currentChainTip = await getUpdatedChainTip(); + if ((_currentChainTip == null || _currentChainTip! == 0) && walletInfo.restoreHeight == 0) { - await getUpdatedChainTip(); await walletInfo.updateRestoreHeight(_currentChainTip!); } diff --git a/cw_core/lib/wallet_base.dart b/cw_core/lib/wallet_base.dart index 14ba898a7..f55816bb7 100644 --- a/cw_core/lib/wallet_base.dart +++ b/cw_core/lib/wallet_base.dart @@ -95,5 +95,5 @@ abstract class WalletBase verifyMessage(String message, String signature, {String? address = null}); - bool? isTestnet; + bool isTestnet = false; } diff --git a/lib/bitcoin/cw_bitcoin.dart b/lib/bitcoin/cw_bitcoin.dart index e87773f97..5a71e3549 100644 --- a/lib/bitcoin/cw_bitcoin.dart +++ b/lib/bitcoin/cw_bitcoin.dart @@ -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 diff --git a/lib/view_model/node_list/node_list_view_model.dart b/lib/view_model/node_list/node_list_view_model.dart index ea1dd574e..2721fd7b3 100644 --- a/lib/view_model/node_list/node_list_view_model.dart +++ b/lib/view_model/node_list/node_list_view_model.dart @@ -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)!; diff --git a/lib/view_model/transaction_details_view_model.dart b/lib/view_model/transaction_details_view_model.dart index ef6474974..18715e508 100644 --- a/lib/view_model/transaction_details_view_model.dart +++ b/lib/view_model/transaction_details_view_model.dart @@ -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: