From e8dc77529f114c0fcd9cac01098816e379f6bf28 Mon Sep 17 00:00:00 2001 From: sneurlax Date: Fri, 9 Feb 2024 19:10:37 -0600 Subject: [PATCH 1/2] add more logging --- lib/electrumx_rpc/electrumx_client.dart | 15 +++++++++++---- lib/wallets/wallet/impl/bitcoincash_wallet.dart | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/electrumx_rpc/electrumx_client.dart b/lib/electrumx_rpc/electrumx_client.dart index f4ce1691a..931c9334f 100644 --- a/lib/electrumx_rpc/electrumx_client.dart +++ b/lib/electrumx_rpc/electrumx_client.dart @@ -397,8 +397,8 @@ class ElectrumXClient { if (requestStrings.length > 1) { Logging.instance.log( - "Map returned instead of a list and there are ${requestStrings.length} queued.", - level: LogLevel.Error); + "ElectrumXClient.batchRequest: Map returned instead of a list and there are ${requestStrings.length} queued.", + level: LogLevel.Error); } // Could throw error here. } else { @@ -757,7 +757,7 @@ class ElectrumXClient { if (response is! Map) { final String msg = "getTransaction($txHash) returned a non-Map response" - " of type ${response.runtimeType}."; + " of type ${response.runtimeType}.\nResponse: $response"; Logging.instance.log(msg, level: LogLevel.Fatal); throw Exception(msg); } @@ -1032,7 +1032,14 @@ class ElectrumXClient { blocks, ], ); - return Decimal.parse(response["result"].toString()); + try { + return Decimal.parse(response["result"].toString()); + } catch (e, s) { + final String msg = "Error parsing fee rate. Response: $response" + "\nResult: ${response["result"]}\nError: $e\nStack trace: $s"; + Logging.instance.log(msg, level: LogLevel.Fatal); + throw Exception(msg); + } } catch (e) { rethrow; } diff --git a/lib/wallets/wallet/impl/bitcoincash_wallet.dart b/lib/wallets/wallet/impl/bitcoincash_wallet.dart index 5086866b7..1128b6e6c 100644 --- a/lib/wallets/wallet/impl/bitcoincash_wallet.dart +++ b/lib/wallets/wallet/impl/bitcoincash_wallet.dart @@ -192,7 +192,7 @@ class BitcoincashWallet extends Bip39HDWallet addresses.addAll(prevOut.addresses); } catch (e, s) { Logging.instance.log( - "Error getting prevOutJson: $s\nStack trace: $s", + "Error getting prevOutJson: $e\nStack trace: $s", level: LogLevel.Warning); } } From de1413f95552dbb987bf8e2671b3bb3131f46632 Mon Sep 17 00:00:00 2001 From: sneurlax Date: Thu, 8 Feb 2024 17:33:04 -0600 Subject: [PATCH 2/2] do not complete completed completer --- .../wallet/wallet_mixin_interfaces/electrumx_interface.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart index 1d793a012..6a044ff15 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart @@ -828,7 +828,7 @@ mixin ElectrumXInterface on Bip39HDWallet { _latestHeight = chainHeight; - if (isFirstResponse) { + if (isFirstResponse && !completer.isCompleted) { // Return the chain height. completer.complete(chainHeight); }