Skip to content

Commit

Permalink
Return better NWC error code for payment failures
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman committed May 8, 2024
1 parent cb64198 commit fcd0983
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion mutiny-core/src/nostr/nwc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit fcd0983

Please sign in to comment.