From fcd0983ac55d80678fe2ebc944503f113e801c37 Mon Sep 17 00:00:00 2001 From: benthecarman Date: Tue, 30 Apr 2024 14:31:54 -0500 Subject: [PATCH] Return better NWC error code for payment failures --- mutiny-core/src/nostr/nwc.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mutiny-core/src/nostr/nwc.rs b/mutiny-core/src/nostr/nwc.rs index 92676d734..0b0ded1eb 100644 --- a/mutiny-core/src/nostr/nwc.rs +++ b/mutiny-core/src/nostr/nwc.rs @@ -1038,10 +1038,18 @@ impl NostrWalletConnect { } } + let code = match e { + MutinyError::InsufficientBalance => { + ErrorCode::InsufficientBalance + } + MutinyError::PaymentTimeout => return Ok(None), // don't send error message for timeout, it can still complete + _ => ErrorCode::PaymentFailed, + }; + Response { result_type: Method::PayInvoice, error: Some(NIP47Error { - code: ErrorCode::InsufficientBalance, + code, message: format!("Failed to pay invoice: {e}"), }), result: None,