Skip to content

Commit

Permalink
feat: display failed payments
Browse files Browse the repository at this point in the history
fixes #1140
  • Loading branch information
Restioson committed Aug 25, 2023
1 parent 720fc36 commit 3892963
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion mobile/lib/features/wallet/domain/wallet_history.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:get_10101/features/wallet/wallet_history_item.dart';
import 'payment_flow.dart';
import 'package:get_10101/bridge_generated/bridge_definitions.dart' as rust;

enum WalletHistoryStatus { pending, expired, confirmed }
enum WalletHistoryStatus { pending, expired, confirmed, failed }

abstract class WalletHistoryItemData {
final PaymentFlow flow;
Expand All @@ -24,6 +24,7 @@ abstract class WalletHistoryItemData {
rust.Status.Pending => WalletHistoryStatus.pending,
rust.Status.Expired => WalletHistoryStatus.expired,
rust.Status.Confirmed => WalletHistoryStatus.confirmed,
rust.Status.Failed => WalletHistoryStatus.failed,
};

DateTime timestamp = DateTime.fromMillisecondsSinceEpoch(item.timestamp * 1000);
Expand Down
4 changes: 3 additions & 1 deletion mobile/lib/features/wallet/wallet_history_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ abstract class WalletHistoryItem extends StatelessWidget {
WalletHistoryStatus.confirmed =>
const Icon(Icons.check_circle, color: Colors.green, size: statusIconSize),
WalletHistoryStatus.expired =>
const Icon(Icons.timer_off, color: Colors.red, size: statusIconSize)
const Icon(Icons.timer_off, color: Colors.red, size: statusIconSize),
WalletHistoryStatus.failed =>
const Icon(Icons.error, color: Colors.red, size: statusIconSize),
};

const double flowIconSize = 30;
Expand Down
1 change: 1 addition & 0 deletions mobile/native/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ pub enum Status {
Pending,
Confirmed,
Expired,
Failed,
}

pub fn calculate_margin(price: f32, quantity: f32, leverage: f32) -> SyncReturn<u64> {
Expand Down
3 changes: 1 addition & 2 deletions mobile/native/src/ln_dlc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,7 @@ fn keep_wallet_balance_and_history_up_to_date(node: &Node) -> Result<()> {
HTLCStatus::Pending if expired => api::Status::Expired,
HTLCStatus::Pending => api::Status::Pending,
HTLCStatus::Succeeded => api::Status::Confirmed,
// TODO: Handle failed payments
HTLCStatus::Failed => return None,
HTLCStatus::Failed => api::Status::Failed,
};

let flow = match details.flow {
Expand Down

0 comments on commit 3892963

Please sign in to comment.