mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-03 09:29:48 +00:00
Generic fixes (#1716)
Some checks failed
Cache Dependencies / test (push) Has been cancelled
Some checks failed
Cache Dependencies / test (push) Has been cancelled
* reset brightness after using * set default qr to auto detect * minor safety enhancement * close socket after checking connectivity * fix incorrect parent exception class * pump medium and fast priorities even if they are equal to slow * Add Ton to exchange * fix silent payments add Seth bitcoin node * deselect quantex add seth node for existing users * fix node uri
This commit is contained in:
parent
d933743a72
commit
6dba73a1d5
11 changed files with 119 additions and 43 deletions
|
@ -6,3 +6,6 @@
|
||||||
isDefault: true
|
isDefault: true
|
||||||
-
|
-
|
||||||
uri: electrs.cakewallet.com:50001
|
uri: electrs.cakewallet.com:50001
|
||||||
|
-
|
||||||
|
uri: fulcrum.sethforprivacy.com:50002
|
||||||
|
useSSL: true
|
||||||
|
|
BIN
assets/images/ton_icon.png
Normal file
BIN
assets/images/ton_icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
|
@ -479,8 +479,14 @@ abstract class ElectrumWalletBase
|
||||||
|
|
||||||
final result = json.decode(response.body) as Map<String, num>;
|
final result = json.decode(response.body) as Map<String, num>;
|
||||||
final slowFee = result['economyFee']?.toInt() ?? 0;
|
final slowFee = result['economyFee']?.toInt() ?? 0;
|
||||||
final mediumFee = result['hourFee']?.toInt() ?? 0;
|
int mediumFee = result['hourFee']?.toInt() ?? 0;
|
||||||
final fastFee = result['fastestFee']?.toInt() ?? 0;
|
int fastFee = result['fastestFee']?.toInt() ?? 0;
|
||||||
|
if (slowFee == mediumFee) {
|
||||||
|
mediumFee++;
|
||||||
|
}
|
||||||
|
while (fastFee <= mediumFee) {
|
||||||
|
fastFee++;
|
||||||
|
}
|
||||||
_feeRates = [slowFee, mediumFee, fastFee];
|
_feeRates = [slowFee, mediumFee, fastFee];
|
||||||
return;
|
return;
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
|
@ -813,6 +819,8 @@ abstract class ElectrumWalletBase
|
||||||
network: network,
|
network: network,
|
||||||
memo: memo,
|
memo: memo,
|
||||||
feeRate: feeRate,
|
feeRate: feeRate,
|
||||||
|
inputPrivKeyInfos: utxoDetails.inputPrivKeyInfos,
|
||||||
|
vinOutpoints: utxoDetails.vinOutpoints,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (fee == 0) {
|
if (fee == 0) {
|
||||||
|
@ -1639,7 +1647,8 @@ abstract class ElectrumWalletBase
|
||||||
if (verboseTransaction.isEmpty) {
|
if (verboseTransaction.isEmpty) {
|
||||||
transactionHex = await electrumClient.getTransactionHex(hash: hash);
|
transactionHex = await electrumClient.getTransactionHex(hash: hash);
|
||||||
|
|
||||||
if (height != null && await checkIfMempoolAPIIsEnabled()) {
|
if (height != null && height > 0 && await checkIfMempoolAPIIsEnabled()) {
|
||||||
|
try {
|
||||||
final blockHash = await http.get(
|
final blockHash = await http.get(
|
||||||
Uri.parse(
|
Uri.parse(
|
||||||
"http://mempool.cakewallet.com:8999/api/v1/block-height/$height",
|
"http://mempool.cakewallet.com:8999/api/v1/block-height/$height",
|
||||||
|
@ -1660,6 +1669,7 @@ abstract class ElectrumWalletBase
|
||||||
time = int.parse(jsonDecode(blockResponse.body)['timestamp'].toString());
|
time = int.parse(jsonDecode(blockResponse.body)['timestamp'].toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (_) {}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
transactionHex = verboseTransaction['hex'] as String;
|
transactionHex = verboseTransaction['hex'] as String;
|
||||||
|
|
|
@ -49,6 +49,15 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.11.0"
|
version: "2.11.0"
|
||||||
|
bech32:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
path: "."
|
||||||
|
ref: HEAD
|
||||||
|
resolved-ref: "05755063b593aa6cca0a4820a318e0ce17de6192"
|
||||||
|
url: "https://github.com/cake-tech/bech32.git"
|
||||||
|
source: git
|
||||||
|
version: "0.2.2"
|
||||||
bip32:
|
bip32:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -78,8 +87,8 @@ packages:
|
||||||
dependency: "direct overridden"
|
dependency: "direct overridden"
|
||||||
description:
|
description:
|
||||||
path: "."
|
path: "."
|
||||||
ref: cake-update-v7
|
ref: cake-update-v8
|
||||||
resolved-ref: f577e83fe78766b2655ea0602baa9299b953a31b
|
resolved-ref: fc045a11db3d85d806ca67f75e8b916c706745a2
|
||||||
url: "https://github.com/cake-tech/bitcoin_base"
|
url: "https://github.com/cake-tech/bitcoin_base"
|
||||||
source: git
|
source: git
|
||||||
version: "4.7.0"
|
version: "4.7.0"
|
||||||
|
@ -308,13 +317,13 @@ packages:
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.3.1"
|
version: "1.3.1"
|
||||||
ffi:
|
ffi:
|
||||||
dependency: transitive
|
dependency: "direct overridden"
|
||||||
description:
|
description:
|
||||||
name: ffi
|
name: ffi
|
||||||
sha256: "16ed7b077ef01ad6170a3d0c57caa4a112a38d7a2ed5602e0aca9ca6f3d98da6"
|
sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.3"
|
version: "2.1.0"
|
||||||
ffigen:
|
ffigen:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -450,6 +459,14 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.2"
|
version: "1.2.2"
|
||||||
|
http2:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: http2
|
||||||
|
sha256: "9ced024a160b77aba8fb8674e38f70875e321d319e6f303ec18e87bd5a4b0c1d"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.3.0"
|
||||||
http_multi_server:
|
http_multi_server:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -693,13 +710,13 @@ packages:
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.8"
|
version: "2.1.8"
|
||||||
pointycastle:
|
pointycastle:
|
||||||
dependency: transitive
|
dependency: "direct overridden"
|
||||||
description:
|
description:
|
||||||
name: pointycastle
|
name: pointycastle
|
||||||
sha256: "4be0097fcf3fd3e8449e53730c631200ebc7b88016acecab2b0da2f0149222fe"
|
sha256: "43ac87de6e10afabc85c445745a7b799e04de84cebaa4fd7bf55a5e1e9604d29"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.9.1"
|
version: "3.7.4"
|
||||||
pool:
|
pool:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -709,13 +726,13 @@ packages:
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.5.1"
|
version: "1.5.1"
|
||||||
protobuf:
|
protobuf:
|
||||||
dependency: transitive
|
dependency: "direct overridden"
|
||||||
description:
|
description:
|
||||||
name: protobuf
|
name: protobuf
|
||||||
sha256: "01dd9bd0fa02548bf2ceee13545d4a0ec6046459d847b6b061d8a27237108a08"
|
sha256: "68645b24e0716782e58948f8467fd42a880f255096a821f9e7d0ec625b00c84d"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.0"
|
version: "3.1.0"
|
||||||
provider:
|
provider:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
|
@ -106,6 +106,7 @@ class CryptoCurrency extends EnumerableItem<int> with Serializable<int> implemen
|
||||||
CryptoCurrency.usdcTrc20,
|
CryptoCurrency.usdcTrc20,
|
||||||
CryptoCurrency.tbtc,
|
CryptoCurrency.tbtc,
|
||||||
CryptoCurrency.wow,
|
CryptoCurrency.wow,
|
||||||
|
CryptoCurrency.ton,
|
||||||
];
|
];
|
||||||
|
|
||||||
static const havenCurrencies = [
|
static const havenCurrencies = [
|
||||||
|
@ -223,6 +224,7 @@ class CryptoCurrency extends EnumerableItem<int> with Serializable<int> implemen
|
||||||
static const usdcTrc20 = CryptoCurrency(title: 'USDC', tag: 'TRX', fullName: 'USDC Coin', raw: 92, name: 'usdctrc20', iconPath: 'assets/images/usdc_icon.png', decimals: 6);
|
static const usdcTrc20 = CryptoCurrency(title: 'USDC', tag: 'TRX', fullName: 'USDC Coin', raw: 92, name: 'usdctrc20', iconPath: 'assets/images/usdc_icon.png', decimals: 6);
|
||||||
static const tbtc = CryptoCurrency(title: 'tBTC', fullName: 'Testnet Bitcoin', raw: 93, name: 'tbtc', iconPath: 'assets/images/tbtc.png', decimals: 8);
|
static const tbtc = CryptoCurrency(title: 'tBTC', fullName: 'Testnet Bitcoin', raw: 93, name: 'tbtc', iconPath: 'assets/images/tbtc.png', decimals: 8);
|
||||||
static const wow = CryptoCurrency(title: 'WOW', fullName: 'Wownero', raw: 94, name: 'wow', iconPath: 'assets/images/wownero_icon.png', decimals: 11);
|
static const wow = CryptoCurrency(title: 'WOW', fullName: 'Wownero', raw: 94, name: 'wow', iconPath: 'assets/images/wownero_icon.png', decimals: 11);
|
||||||
|
static const ton = CryptoCurrency(title: 'TON', fullName: 'Toncoin', raw: 95, name: 'ton', iconPath: 'assets/images/ton_icon.png', decimals: 8);
|
||||||
|
|
||||||
|
|
||||||
static final Map<int, CryptoCurrency> _rawCurrencyMap =
|
static final Map<int, CryptoCurrency> _rawCurrencyMap =
|
||||||
|
|
|
@ -239,12 +239,15 @@ class Node extends HiveObject with Keyable {
|
||||||
// you try to communicate with it
|
// you try to communicate with it
|
||||||
Future<bool> requestElectrumServer() async {
|
Future<bool> requestElectrumServer() async {
|
||||||
try {
|
try {
|
||||||
|
final Socket socket;
|
||||||
if (useSSL == true) {
|
if (useSSL == true) {
|
||||||
await SecureSocket.connect(uri.host, uri.port,
|
socket = await SecureSocket.connect(uri.host, uri.port,
|
||||||
timeout: Duration(seconds: 5), onBadCertificate: (_) => true);
|
timeout: Duration(seconds: 5), onBadCertificate: (_) => true);
|
||||||
} else {
|
} else {
|
||||||
await Socket.connect(uri.host, uri.port, timeout: Duration(seconds: 5));
|
socket = await Socket.connect(uri.host, uri.port, timeout: Duration(seconds: 5));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
socket.destroy();
|
||||||
return true;
|
return true;
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import 'dart:convert';
|
||||||
import 'dart:io' show Directory, File, Platform;
|
import 'dart:io' show Directory, File, Platform;
|
||||||
import 'package:cake_wallet/bitcoin/bitcoin.dart';
|
import 'package:cake_wallet/bitcoin/bitcoin.dart';
|
||||||
import 'package:cake_wallet/core/secure_storage.dart';
|
import 'package:cake_wallet/core/secure_storage.dart';
|
||||||
|
@ -234,7 +235,8 @@ Future<void> defaultSettingsMigration(
|
||||||
break;
|
break;
|
||||||
case 36:
|
case 36:
|
||||||
await addWowneroNodeList(nodes: nodes);
|
await addWowneroNodeList(nodes: nodes);
|
||||||
await changeWowneroCurrentNodeToDefault(sharedPreferences: sharedPreferences, nodes: nodes);
|
await changeWowneroCurrentNodeToDefault(
|
||||||
|
sharedPreferences: sharedPreferences, nodes: nodes);
|
||||||
break;
|
break;
|
||||||
case 37:
|
case 37:
|
||||||
await replaceTronDefaultNode(sharedPreferences: sharedPreferences, nodes: nodes);
|
await replaceTronDefaultNode(sharedPreferences: sharedPreferences, nodes: nodes);
|
||||||
|
@ -249,6 +251,10 @@ Future<void> defaultSettingsMigration(
|
||||||
case 40:
|
case 40:
|
||||||
await removeMoneroWorld(sharedPreferences: sharedPreferences, nodes: nodes);
|
await removeMoneroWorld(sharedPreferences: sharedPreferences, nodes: nodes);
|
||||||
break;
|
break;
|
||||||
|
case 41:
|
||||||
|
_deselectQuantex(sharedPreferences);
|
||||||
|
await _addSethNode(nodes, sharedPreferences);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -263,6 +269,19 @@ Future<void> defaultSettingsMigration(
|
||||||
await sharedPreferences.setInt(PreferencesKey.currentDefaultSettingsMigrationVersion, version);
|
await sharedPreferences.setInt(PreferencesKey.currentDefaultSettingsMigrationVersion, version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _deselectQuantex(SharedPreferences sharedPreferences) {
|
||||||
|
final Map<String, dynamic> exchangeProvidersSelection =
|
||||||
|
json.decode(sharedPreferences.getString(PreferencesKey.exchangeProvidersSelection) ?? "{}")
|
||||||
|
as Map<String, dynamic>;
|
||||||
|
|
||||||
|
exchangeProvidersSelection['Quantex'] = false;
|
||||||
|
|
||||||
|
sharedPreferences.setString(
|
||||||
|
PreferencesKey.exchangeProvidersSelection,
|
||||||
|
json.encode(exchangeProvidersSelection),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
void _fixNodesUseSSLFlag(Box<Node> nodes) {
|
void _fixNodesUseSSLFlag(Box<Node> nodes) {
|
||||||
for (Node node in nodes.values) {
|
for (Node node in nodes.values) {
|
||||||
switch (node.uriRaw) {
|
switch (node.uriRaw) {
|
||||||
|
@ -887,7 +906,30 @@ Future<void> changeDefaultBitcoinNode(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> _addSethNode(Box<Node> nodeSource, SharedPreferences sharedPreferences) async {
|
||||||
|
_addBitcoinNode(
|
||||||
|
nodeSource: nodeSource,
|
||||||
|
sharedPreferences: sharedPreferences,
|
||||||
|
nodeUri: "fulcrum.sethforprivacy.com:50002",
|
||||||
|
useSSL: false,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _addElectRsNode(Box<Node> nodeSource, SharedPreferences sharedPreferences) async {
|
Future<void> _addElectRsNode(Box<Node> nodeSource, SharedPreferences sharedPreferences) async {
|
||||||
|
_addBitcoinNode(
|
||||||
|
nodeSource: nodeSource,
|
||||||
|
sharedPreferences: sharedPreferences,
|
||||||
|
nodeUri: cakeWalletSilentPaymentsElectrsUri,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _addBitcoinNode({
|
||||||
|
required Box<Node> nodeSource,
|
||||||
|
required SharedPreferences sharedPreferences,
|
||||||
|
required String nodeUri,
|
||||||
|
bool replaceExisting = false,
|
||||||
|
bool useSSL = false,
|
||||||
|
}) async {
|
||||||
const cakeWalletBitcoinNodeUriPattern = '.cakewallet.com';
|
const cakeWalletBitcoinNodeUriPattern = '.cakewallet.com';
|
||||||
final currentBitcoinNodeId =
|
final currentBitcoinNodeId =
|
||||||
sharedPreferences.getInt(PreferencesKey.currentBitcoinElectrumSererIdKey);
|
sharedPreferences.getInt(PreferencesKey.currentBitcoinElectrumSererIdKey);
|
||||||
|
@ -896,12 +938,11 @@ Future<void> _addElectRsNode(Box<Node> nodeSource, SharedPreferences sharedPrefe
|
||||||
final needToReplaceCurrentBitcoinNode =
|
final needToReplaceCurrentBitcoinNode =
|
||||||
currentBitcoinNode.uri.toString().contains(cakeWalletBitcoinNodeUriPattern);
|
currentBitcoinNode.uri.toString().contains(cakeWalletBitcoinNodeUriPattern);
|
||||||
|
|
||||||
final newElectRsBitcoinNode =
|
final newElectRsBitcoinNode = Node(uri: nodeUri, type: WalletType.bitcoin, useSSL: useSSL);
|
||||||
Node(uri: cakeWalletSilentPaymentsElectrsUri, type: WalletType.bitcoin, useSSL: false);
|
|
||||||
|
|
||||||
await nodeSource.add(newElectRsBitcoinNode);
|
await nodeSource.add(newElectRsBitcoinNode);
|
||||||
|
|
||||||
if (needToReplaceCurrentBitcoinNode) {
|
if (needToReplaceCurrentBitcoinNode && replaceExisting) {
|
||||||
await sharedPreferences.setInt(
|
await sharedPreferences.setInt(
|
||||||
PreferencesKey.currentBitcoinElectrumSererIdKey, newElectRsBitcoinNode.key as int);
|
PreferencesKey.currentBitcoinElectrumSererIdKey, newElectRsBitcoinNode.key as int);
|
||||||
}
|
}
|
||||||
|
@ -1262,7 +1303,8 @@ Future<void> removeMoneroWorld(
|
||||||
const cakeWalletMoneroNodeUriPattern = '.moneroworld.com';
|
const cakeWalletMoneroNodeUriPattern = '.moneroworld.com';
|
||||||
final currentMoneroNodeId = sharedPreferences.getInt(PreferencesKey.currentNodeIdKey);
|
final currentMoneroNodeId = sharedPreferences.getInt(PreferencesKey.currentNodeIdKey);
|
||||||
final currentMoneroNode = nodes.values.firstWhere((node) => node.key == currentMoneroNodeId);
|
final currentMoneroNode = nodes.values.firstWhere((node) => node.key == currentMoneroNodeId);
|
||||||
final needToReplaceCurrentMoneroNode = currentMoneroNode.uri.toString().contains(cakeWalletMoneroNodeUriPattern);
|
final needToReplaceCurrentMoneroNode =
|
||||||
|
currentMoneroNode.uri.toString().contains(cakeWalletMoneroNodeUriPattern);
|
||||||
|
|
||||||
nodes.values.forEach((node) async {
|
nodes.values.forEach((node) async {
|
||||||
if (node.type == WalletType.monero &&
|
if (node.type == WalletType.monero &&
|
||||||
|
|
|
@ -192,7 +192,7 @@ Future<void> initializeAppConfigs() async {
|
||||||
transactionDescriptions: transactionDescriptions,
|
transactionDescriptions: transactionDescriptions,
|
||||||
secureStorage: secureStorage,
|
secureStorage: secureStorage,
|
||||||
anonpayInvoiceInfo: anonpayInvoiceInfo,
|
anonpayInvoiceInfo: anonpayInvoiceInfo,
|
||||||
initialMigrationVersion: 40,
|
initialMigrationVersion: 41,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,8 @@ Timer? _checkConnectionTimer;
|
||||||
void startCheckConnectionReaction(WalletBase wallet, SettingsStore settingsStore,
|
void startCheckConnectionReaction(WalletBase wallet, SettingsStore settingsStore,
|
||||||
{int timeInterval = 5}) {
|
{int timeInterval = 5}) {
|
||||||
_checkConnectionTimer?.cancel();
|
_checkConnectionTimer?.cancel();
|
||||||
|
// TODO: check the validity of this code, and if it's working fine, then no need for
|
||||||
|
// having the connect function in electrum.dart when the syncstatus is lost or failed and add the not connected state
|
||||||
_checkConnectionTimer = Timer.periodic(Duration(seconds: timeInterval), (_) async {
|
_checkConnectionTimer = Timer.periodic(Duration(seconds: timeInterval), (_) async {
|
||||||
if (wallet.type == WalletType.bitcoin && wallet.syncStatus is SyncingSyncStatus) {
|
if (wallet.type == WalletType.bitcoin && wallet.syncStatus is SyncingSyncStatus) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -23,7 +23,7 @@ class QrImage extends StatelessWidget {
|
||||||
return qr.QrImageView(
|
return qr.QrImageView(
|
||||||
data: data,
|
data: data,
|
||||||
errorCorrectionLevel: errorCorrectionLevel,
|
errorCorrectionLevel: errorCorrectionLevel,
|
||||||
version: version ?? 9, // Previous value: 7 something happened after flutter upgrade monero wallets addresses are longer than ver. 7 ???
|
version: version ?? qr.QrVersions.auto,
|
||||||
size: size,
|
size: size,
|
||||||
foregroundColor: foregroundColor,
|
foregroundColor: foregroundColor,
|
||||||
backgroundColor: backgroundColor,
|
backgroundColor: backgroundColor,
|
||||||
|
|
|
@ -9,15 +9,12 @@ class BrightnessUtil {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the current brightness:
|
|
||||||
final brightness = await DeviceDisplayBrightness.getBrightness();
|
|
||||||
|
|
||||||
// ignore: unawaited_futures
|
// ignore: unawaited_futures
|
||||||
DeviceDisplayBrightness.setBrightness(1.0);
|
DeviceDisplayBrightness.setBrightness(1.0);
|
||||||
|
|
||||||
await func();
|
await func();
|
||||||
|
|
||||||
// ignore: unawaited_futures
|
// ignore: unawaited_futures
|
||||||
DeviceDisplayBrightness.setBrightness(brightness);
|
DeviceDisplayBrightness.resetBrightness();
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue