This commit is contained in:
M 2020-08-31 17:39:12 +03:00
parent fec2ec2845
commit eaa5d48bb6
3 changed files with 9 additions and 7 deletions

View file

@ -37,7 +37,6 @@ import 'package:shared_preferences/shared_preferences.dart';
part 'bitcoin_wallet.g.dart'; part 'bitcoin_wallet.g.dart';
class BitcoinWallet = BitcoinWalletBase with _$BitcoinWallet; class BitcoinWallet = BitcoinWalletBase with _$BitcoinWallet;
abstract class BitcoinWalletBase extends WalletBase<BitcoinBalance> with Store { abstract class BitcoinWalletBase extends WalletBase<BitcoinBalance> with Store {

View file

@ -1,5 +1,4 @@
import 'dart:io'; import 'dart:io';
import 'dart:convert';
import 'package:bip39/bip39.dart' as bip39; import 'package:bip39/bip39.dart' as bip39;
import 'package:cake_wallet/bitcoin/file.dart'; import 'package:cake_wallet/bitcoin/file.dart';
import 'package:cake_wallet/bitcoin/bitcoin_wallet_creation_credentials.dart'; import 'package:cake_wallet/bitcoin/bitcoin_wallet_creation_credentials.dart';

View file

@ -1,6 +1,7 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'dart:typed_data';
import 'package:cake_wallet/bitcoin/script_hash.dart'; import 'package:cake_wallet/bitcoin/script_hash.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:rxdart/rxdart.dart'; import 'package:rxdart/rxdart.dart';
@ -52,9 +53,11 @@ class ElectrumClient {
socket = await SecureSocket.connect(host, port, timeout: connectionTimeout); socket = await SecureSocket.connect(host, port, timeout: connectionTimeout);
_setIsConnected(true); _setIsConnected(true);
socket.listen((List<int> event) {
socket.listen((Uint8List event) {
try { try {
final jsoned = json.decode(utf8.decode(event)) as Map<String, Object>; final jsoned =
json.decode(utf8.decode(event.toList())) as Map<String, Object>;
print(jsoned); print(jsoned);
final method = jsoned['method']; final method = jsoned['method'];
final id = jsoned['id'] as String; final id = jsoned['id'] as String;
@ -69,9 +72,10 @@ class ElectrumClient {
} catch (e) { } catch (e) {
print(e); print(e);
} }
}, }, onError: (Object error) {
onError: (Error _) => _setIsConnected(false), print(error.toString());
onDone: () => _setIsConnected(false)); _setIsConnected(false);
}, onDone: () => _setIsConnected(false));
keepAlive(); keepAlive();
} }