3&4 fixes for Payjoin (#2358)

* fix: update Payjoin transaction details list item type to `TransactionDetailsListItem`

* fix: add error handling for unrecoverable Payjoin sender sessions

* fix: centralize Payjoin connectivity error handling with `_isPayjoinConnectivityError` function
This commit is contained in:
Konstantin Ullrich
2025-07-04 02:40:12 +03:00
committed by GitHub
parent f1acc43927
commit d9fc4d7b57
3 changed files with 21 additions and 13 deletions
+5 -2
View File
@@ -57,6 +57,9 @@ abstract class BitcoinWalletAddressesBase extends ElectrumWalletAddresses with S
return generateP2WPKHAddress(hd: hd, index: index, network: network);
}
bool _isPayjoinConnectivityError(String error) =>
["error sending request for url", "Instance of 'FfiIoError'"].any((e) => error.contains(e));
@action
Future<void> initPayjoin() async {
try {
@@ -68,7 +71,7 @@ abstract class BitcoinWalletAddressesBase extends ElectrumWalletAddresses with S
} catch (e) {
printV(e);
// Ignore Connectivity errors
if (!e.toString().contains("error sending request for url")) rethrow;
if (!_isPayjoinConnectivityError(e.toString())) rethrow;
}
}
@@ -82,7 +85,7 @@ abstract class BitcoinWalletAddressesBase extends ElectrumWalletAddresses with S
} catch (e) {
printV(e);
// Ignore Connectivity errors
if (!e.toString().contains("error sending request for url")) rethrow;
if (!_isPayjoinConnectivityError(e.toString())) rethrow;
}
}
}
+15 -10
View File
@@ -18,6 +18,7 @@ import 'package:payjoin_flutter/common.dart';
import 'package:payjoin_flutter/receive.dart';
import 'package:payjoin_flutter/send.dart';
import 'package:payjoin_flutter/src/config.dart' as pj_config;
import 'package:payjoin_flutter/src/generated/api.dart' as pj_api;
import 'package:payjoin_flutter/uri.dart' as PayjoinUri;
class PayjoinManager {
@@ -44,17 +45,21 @@ class PayjoinManager {
final allSessions = _payjoinStorage.readAllOpenSessions(_wallet.id);
final spawnedSessions = allSessions.map((session) {
if (session.isSenderSession) {
printV("Resuming Payjoin Sender Session ${session.pjUri!}");
return _spawnSender(
sender: Sender.fromJson(json: session.sender!),
pjUri: session.pjUri!,
);
try {
if (session.isSenderSession) {
printV("Resuming Payjoin Sender Session ${session.pjUri!}");
return _spawnSender(
sender: Sender.fromJson(json: session.sender!),
pjUri: session.pjUri!,
);
}
final receiver = Receiver.fromJson(json: session.receiver!);
printV("Resuming Payjoin Receiver Session ${receiver.id()}");
return spawnReceiver(receiver: receiver);
} on pj_api.FfiSerdeJsonError catch (_) {
_payjoinStorage.markSenderSessionUnrecoverable(session.pjUri!, "Outdated Session");
}
final receiver = Receiver.fromJson(json: session.receiver!);
printV("Resuming Payjoin Receiver Session ${receiver.id()}");
return spawnReceiver(receiver: receiver);
});
}).nonNulls;
printV("Resumed ${spawnedSessions.length} Payjoin Sessions");
await Future.wait(spawnedSessions);
@@ -27,7 +27,7 @@ abstract class PayjoinDetailsViewModelBase with Store {
this.transactionInfo, {
required this.payjoinSessionSource,
required this.themeStore,
}) : items = ObservableList<StandartListItem>(),
}) : items = ObservableList<TransactionDetailsListItem>(),
payjoinSession = payjoinSessionSource.get(payjoinSessionId)! {
listener = payjoinSessionSource.watch().listen((e) {
if (e.key == payjoinSessionId) _updateItems();