Skip to content

Commit

Permalink
Merge pull request #1164 from MutinyWallet/nwc-touch-ups
Browse files Browse the repository at this point in the history
Return better NWC error code for payment failures
  • Loading branch information
TonyGiorgio authored May 8, 2024
2 parents 256876a + fcd0983 commit f05cf47
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 f05cf47

Please sign in to comment.