Skip to content

Commit

Permalink
fix: sendpay_failure (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
darioAnongba authored Aug 23, 2024
1 parent 3d0743a commit 05cbb17
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions config/default.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# App
invoice_expiry = "12h"
domain = "numeraire.tech"
host = "https://swissknife.numeraire.tech"
host = "https://api.numeraire.tech"
fee_buffer = 0.02
ln_provider = "breez"
auth_provider = "jwt"
Expand Down Expand Up @@ -33,7 +33,7 @@ retry_delay = "5s"
endpoint = "http://localhost:3010"
rune = "CHANGE_ME"
connect_timeout = "5s"
timeout = "30s"
timeout = "90s"
connection_verbose = true
accept_invalid_certs = false
accept_invalid_hostnames = false
Expand Down
8 changes: 5 additions & 3 deletions src/domains/ln_address/ln_address_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,19 @@ impl LnAddressUseCases for LnAddressService {
async fn register(
&self,
wallet_id: Uuid,
username: String,
mut username: String,
) -> Result<LnAddress, ApplicationError> {
debug!(%wallet_id, username, "Registering lightning address");

username = username.to_lowercase();

if username.len() < MIN_USERNAME_LENGTH || username.len() > MAX_USERNAME_LENGTH {
return Err(DataError::Validation("Invalid username length.".to_string()).into());
}

// Regex validation for allowed characters
let email_username_re = Regex::new(r"^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+$")
.expect("should not fail as a constant");
let email_username_re =
Regex::new(r"^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$").expect("should not fail as a constant");
if !email_username_re.is_match(&username) {
return Err(DataError::Validation("Invalid username format.".to_string()).into());
}
Expand Down
5 changes: 4 additions & 1 deletion src/infra/lightning/cln/cln_websocket_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ fn on_message(
if sendpay_success.status != "complete" {
warn!(
payment_hash = sendpay_success.payment_hash,
status = sendpay_success.status,
"Invalid payment status. Expected Complete."
);
return;
Expand All @@ -145,9 +146,11 @@ fn on_message(
if sendpay_failure.data.status != "failed" {
warn!(
payment_hash = sendpay_failure.data.payment_hash,
status = sendpay_failure.data.status,
"Invalid payment status. Expected Failed."
);
return;
// We must accept the payment as failed until this is fixed: https://github.com/ElementsProject/lightning/issues/7561
// return;
}

if let Err(err) =
Expand Down

0 comments on commit 05cbb17

Please sign in to comment.