mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-11-17 01:37:40 +00:00
[skip ci] [wip] check if node supports mweb
This commit is contained in:
parent
767b507a8d
commit
04afc64b41
4 changed files with 46 additions and 0 deletions
|
@ -569,6 +569,29 @@ abstract class ElectrumWalletBase
|
|||
return node!.supportsSilentPayments!;
|
||||
}
|
||||
|
||||
Future<bool> getNodeSupportsMweb() async {
|
||||
final version = await electrumClient.version();
|
||||
|
||||
if (node == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (version.isNotEmpty) {
|
||||
final server = version[0];
|
||||
print("server: $server");
|
||||
|
||||
return false;
|
||||
|
||||
// if (server.toLowerCase().contains('electrs')) {
|
||||
// node!.isElectrs = true;
|
||||
// node!.save();
|
||||
// return node!.isElectrs!;
|
||||
// }
|
||||
}
|
||||
|
||||
return node!.supportsMweb!;
|
||||
}
|
||||
|
||||
@action
|
||||
@override
|
||||
Future<void> connectToNode({required Node node}) async {
|
||||
|
|
|
@ -9,6 +9,7 @@ import 'package:crypto/crypto.dart';
|
|||
import 'package:cw_bitcoin/bitcoin_transaction_credentials.dart';
|
||||
import 'package:cw_core/cake_hive.dart';
|
||||
import 'package:cw_core/mweb_utxo.dart';
|
||||
import 'package:cw_core/node.dart';
|
||||
import 'package:cw_mweb/mwebd.pbgrpc.dart';
|
||||
import 'package:fixnum/fixnum.dart';
|
||||
import 'package:bip39/bip39.dart' as bip39;
|
||||
|
@ -287,6 +288,15 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
|||
await (walletAddresses as LitecoinWalletAddresses).ensureMwebAddressUpToIndexExists(1020);
|
||||
}
|
||||
|
||||
@action
|
||||
@override
|
||||
Future<void> connectToNode({required Node node}) async {
|
||||
await super.connectToNode(node: node);
|
||||
if (await getNodeSupportsMweb()) {
|
||||
await CwMweb.setNodeUriOverride(node.uri.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
@override
|
||||
Future<void> startSync() async {
|
||||
|
|
|
@ -79,6 +79,9 @@ class Node extends HiveObject with Keyable {
|
|||
@HiveField(9)
|
||||
bool? supportsSilentPayments;
|
||||
|
||||
@HiveField(10)
|
||||
bool? supportsMweb;
|
||||
|
||||
bool get isSSL => useSSL ?? false;
|
||||
|
||||
bool get useSocksProxy => socksProxyAddress == null ? false : socksProxyAddress!.isNotEmpty;
|
||||
|
|
|
@ -15,6 +15,16 @@ class CwMweb {
|
|||
static int? _port;
|
||||
static const TIMEOUT_DURATION = Duration(seconds: 15);
|
||||
static Timer? logTimer;
|
||||
static String? nodeUriOverride;
|
||||
|
||||
|
||||
static Future<void> setNodeUriOverride(String uri) async {
|
||||
nodeUriOverride = uri;
|
||||
if (_rpcClient != null) {
|
||||
await stop();
|
||||
await _initializeClient();
|
||||
}
|
||||
}
|
||||
|
||||
static void readFileWithTimer(String filePath) {
|
||||
final file = File(filePath);
|
||||
|
|
Loading…
Reference in a new issue