Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions node/src/router_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,38 @@ async fn lnurlp_known_address_returns_pay_request() {
assert!(resp.metadata.contains("zkCoins"));
}

#[cfg(feature = "lnurl")]
#[tokio::test]
async fn lnurlp_localhost_host_returns_http_callback() {
// Pins the `host.contains("localhost")` branch of `lnurlp_handler`'s
// scheme selection: when the request's Host header points at a local
// dev instance, the LNURL callback URL must be served back as `http://`
// so wallets following the redirect don't hit a TLS error against
// the dev node. The api.zkcoins.app path (covered by
// `lnurlp_known_address_returns_pay_request`) already pins the
// `https://` arm.
let full_hex = hex::encode(zkcoins_program::hash::digest_to_bytes(
&zkcoins_program::types::MINTING_ADDRESS,
));
let prefix = &full_hex[..8];

let uri = format!("/.well-known/lnurlp/{}", prefix);
let req = Request::get(&uri)
.header("host", "localhost:8080")
.body(Body::empty())
.unwrap();
let (status, body) = send_request(req).await;

assert_eq!(status, StatusCode::OK);

let resp: LnurlpResponse = serde_json::from_str(&body).expect("valid JSON");
assert!(
resp.callback.starts_with("http://localhost:8080/"),
"callback should use http://localhost:8080 — got {}",
resp.callback
);
}

// --- GET /lnurl/pay/{username} ---

#[cfg(feature = "lnurl")]
Expand Down
Loading