mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-06-28 12:29:51 +00:00
CW-1091-payjoin-error-handeling (#2317)
* feat: stop polling payjoin on switch wallet * refactor: improve Payjoin session handling and cleanup unused methods - Replaced `initReceiver` with `getUnusedReceiver` to reuse existing Payjoin sessions. - Streamlined session initialization by removing `spawnNewReceiver`. - Adjusted wallet sync reactions to resume Payjoin sessions when necessary. * fix: Receiver.fromJson correctly handle parameter format in Payjoin manager * fix: try reloading unspents if unspents are empty; No Unpsents available are now recoverable errors * fix: ensure transaction details display only if transactionInfo is available and adjust payjoin success status handling * fix: adjust payjoin success status handling for pending transactions * fix: add error handling for Payjoin initialization and receiver creation [skip-ci] * fix: add unrecoverable error handling for Payjoin sender sessions
This commit is contained in:
parent
21d5c51cc9
commit
4b137bc968
9 changed files with 82 additions and 53 deletions
|
@ -65,7 +65,7 @@ void startCurrentWalletChangeReaction(
|
|||
|
||||
final node = settingsStore.getCurrentNode(wallet.type);
|
||||
|
||||
startWalletSyncStatusChangeReaction(wallet, fiatConversionStore);
|
||||
startWalletSyncStatusChangeReaction(wallet, settingsStore);
|
||||
startCheckConnectionReaction(wallet, settingsStore);
|
||||
|
||||
await Future.delayed(Duration.zero);
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import 'package:cake_wallet/store/dashboard/fiat_conversion_store.dart';
|
||||
import 'package:cake_wallet/bitcoin/bitcoin.dart';
|
||||
import 'package:cake_wallet/store/settings_store.dart';
|
||||
import 'package:cw_core/utils/print_verbose.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:cw_core/transaction_history.dart';
|
||||
import 'package:cw_core/wallet_base.dart';
|
||||
|
@ -12,7 +14,7 @@ ReactionDisposer? _onWalletSyncStatusChangeReaction;
|
|||
|
||||
void startWalletSyncStatusChangeReaction(
|
||||
WalletBase<Balance, TransactionHistoryBase<TransactionInfo>, TransactionInfo> wallet,
|
||||
FiatConversionStore fiatConversionStore) {
|
||||
SettingsStore settingsStore) {
|
||||
_onWalletSyncStatusChangeReaction?.reaction.dispose();
|
||||
_onWalletSyncStatusChangeReaction = reaction((_) => wallet.syncStatus, (SyncStatus status) async {
|
||||
try {
|
||||
|
@ -25,6 +27,12 @@ void startWalletSyncStatusChangeReaction(
|
|||
if (status is SyncedSyncStatus || status is FailedSyncStatus) {
|
||||
await WakelockPlus.disable();
|
||||
}
|
||||
|
||||
if (status is SyncedSyncStatus &&
|
||||
wallet.type == WalletType.bitcoin &&
|
||||
settingsStore.usePayjoin) {
|
||||
bitcoin!.resumePayjoinSessions(wallet);
|
||||
}
|
||||
} catch (e) {
|
||||
printV(e.toString());
|
||||
}
|
||||
|
|
|
@ -20,9 +20,8 @@ class PayjoinTransactionListItem extends ActionListItem {
|
|||
String get status {
|
||||
switch (session.status) {
|
||||
case 'success':
|
||||
if (transaction?.isPending == true)
|
||||
return S.current.payjoin_request_awaiting_tx;
|
||||
return S.current.successful;
|
||||
if (transaction?.isPending == false) return S.current.successful;
|
||||
return S.current.payjoin_request_awaiting_tx;
|
||||
case 'inProgress':
|
||||
return S.current.payjoin_request_in_progress;
|
||||
case 'unrecoverable':
|
||||
|
|
|
@ -69,7 +69,7 @@ abstract class PayjoinDetailsViewModelBase with Store {
|
|||
title: S.current.error,
|
||||
value: payjoinSession.error!,
|
||||
),
|
||||
if (payjoinSession.txId?.isNotEmpty == true)
|
||||
if (payjoinSession.txId?.isNotEmpty == true && transactionInfo != null)
|
||||
StandartListItem(
|
||||
title: S.current.transaction_details_transaction_id,
|
||||
value: payjoinSession.txId!,
|
||||
|
@ -107,9 +107,8 @@ abstract class PayjoinDetailsViewModelBase with Store {
|
|||
String _getStatusString() {
|
||||
switch (payjoinSession.status) {
|
||||
case 'success':
|
||||
if (transactionInfo?.isPending == true)
|
||||
return S.current.payjoin_request_awaiting_tx;
|
||||
return S.current.successful;
|
||||
if (transactionInfo?.isPending == false) return S.current.successful;
|
||||
return S.current.payjoin_request_awaiting_tx;
|
||||
case 'inProgress':
|
||||
return S.current.payjoin_request_in_progress;
|
||||
case 'unrecoverable':
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue