feat: add onError exception (#1743)
Some checks failed
Cache Dependencies / test (push) Has been cancelled

This commit is contained in:
Rafael 2024-10-10 11:10:12 -03:00 committed by GitHub
parent 62f55ae8f5
commit 8acf8bdfb2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1315,7 +1315,7 @@ abstract class ElectrumWalletBase
// Set the balance of all non-silent payment addresses to 0 before updating // Set the balance of all non-silent payment addresses to 0 before updating
walletAddresses.allAddresses.forEach((addr) { walletAddresses.allAddresses.forEach((addr) {
if(addr is! BitcoinSilentPaymentAddressRecord) addr.balance = 0; if (addr is! BitcoinSilentPaymentAddressRecord) addr.balance = 0;
}); });
await Future.wait(walletAddresses.allAddresses.map((address) async { await Future.wait(walletAddresses.allAddresses.map((address) async {
@ -1825,6 +1825,8 @@ abstract class ElectrumWalletBase
Future<Map<String, ElectrumTransactionInfo>> _fetchAddressHistory( Future<Map<String, ElectrumTransactionInfo>> _fetchAddressHistory(
BitcoinAddressRecord addressRecord, int? currentHeight) async { BitcoinAddressRecord addressRecord, int? currentHeight) async {
String txid = "";
try { try {
final Map<String, ElectrumTransactionInfo> historiesWithDetails = {}; final Map<String, ElectrumTransactionInfo> historiesWithDetails = {};
@ -1834,7 +1836,7 @@ abstract class ElectrumWalletBase
addressRecord.setAsUsed(); addressRecord.setAsUsed();
await Future.wait(history.map((transaction) async { await Future.wait(history.map((transaction) async {
final txid = transaction['tx_hash'] as String; txid = transaction['tx_hash'] as String;
final height = transaction['height'] as int; final height = transaction['height'] as int;
final storedTx = transactionHistory.transactions[txid]; final storedTx = transactionHistory.transactions[txid];
@ -1865,8 +1867,12 @@ abstract class ElectrumWalletBase
} }
return historiesWithDetails; return historiesWithDetails;
} catch (e) { } catch (e, stacktrace) {
print(e.toString()); _onError?.call(FlutterErrorDetails(
exception: "$txid - $e",
stack: stacktrace,
library: this.runtimeType.toString(),
));
return {}; return {};
} }
} }