From eaa5d48bb6847103645a48f1241e0e34325d6725 Mon Sep 17 00:00:00 2001 From: M Date: Mon, 31 Aug 2020 17:39:12 +0300 Subject: [PATCH] Fixes --- lib/bitcoin/bitcoin_wallet.dart | 1 - lib/bitcoin/bitcoin_wallet_service.dart | 1 - lib/bitcoin/electrum.dart | 14 +++++++++----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/bitcoin/bitcoin_wallet.dart b/lib/bitcoin/bitcoin_wallet.dart index b69bccb9b..4fc46f8fa 100644 --- a/lib/bitcoin/bitcoin_wallet.dart +++ b/lib/bitcoin/bitcoin_wallet.dart @@ -37,7 +37,6 @@ import 'package:shared_preferences/shared_preferences.dart'; part 'bitcoin_wallet.g.dart'; - class BitcoinWallet = BitcoinWalletBase with _$BitcoinWallet; abstract class BitcoinWalletBase extends WalletBase with Store { diff --git a/lib/bitcoin/bitcoin_wallet_service.dart b/lib/bitcoin/bitcoin_wallet_service.dart index e18692968..cb2d241fb 100644 --- a/lib/bitcoin/bitcoin_wallet_service.dart +++ b/lib/bitcoin/bitcoin_wallet_service.dart @@ -1,5 +1,4 @@ import 'dart:io'; -import 'dart:convert'; import 'package:bip39/bip39.dart' as bip39; import 'package:cake_wallet/bitcoin/file.dart'; import 'package:cake_wallet/bitcoin/bitcoin_wallet_creation_credentials.dart'; diff --git a/lib/bitcoin/electrum.dart b/lib/bitcoin/electrum.dart index fbd219ddb..bd1ac09ac 100644 --- a/lib/bitcoin/electrum.dart +++ b/lib/bitcoin/electrum.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'dart:convert'; import 'dart:io'; +import 'dart:typed_data'; import 'package:cake_wallet/bitcoin/script_hash.dart'; import 'package:flutter/foundation.dart'; import 'package:rxdart/rxdart.dart'; @@ -52,9 +53,11 @@ class ElectrumClient { socket = await SecureSocket.connect(host, port, timeout: connectionTimeout); _setIsConnected(true); - socket.listen((List event) { + + socket.listen((Uint8List event) { try { - final jsoned = json.decode(utf8.decode(event)) as Map; + final jsoned = + json.decode(utf8.decode(event.toList())) as Map; print(jsoned); final method = jsoned['method']; final id = jsoned['id'] as String; @@ -69,9 +72,10 @@ class ElectrumClient { } catch (e) { print(e); } - }, - onError: (Error _) => _setIsConnected(false), - onDone: () => _setIsConnected(false)); + }, onError: (Object error) { + print(error.toString()); + _setIsConnected(false); + }, onDone: () => _setIsConnected(false)); keepAlive(); }