Skip to content
Merged
Show file tree
Hide file tree
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
1,806 changes: 614 additions & 1,192 deletions Cargo.lock

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,13 @@ lnurl-service:
cert-path: "/etc/ssl/certs/lnurl-cert.pem"
# Path to TLS private key file
key-path: "/etc/ssl/certs/lnurl-key.pem"

# QR module width x height
bech32-qr-scale: 8
# QR light gray level
bech32-qr-light: 255
# QR dark gray level
bech32-qr-dark: 0
```

### Consistent Backend-Selection
Expand Down
4 changes: 2 additions & 2 deletions migration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ license = "Apache-2.0"
publish = true

[dependencies]
async-std = { version = "1", features = ["attributes", "tokio1"] }
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }

[dependencies.sea-orm-migration]
version = "1.1.0"
version = "1.1"
features = [
"runtime-tokio-rustls",
"sqlx-postgres", "sqlx-mysql", "sqlx-sqlite"
Expand Down
2 changes: 1 addition & 1 deletion migration/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use sea_orm_migration::prelude::*;

#[async_std::main]
#[tokio::main]
async fn main() {
cli::run_cli(switchgear_migration::DiscoveryBackendMigrator).await;
cli::run_cli(switchgear_migration::OfferMigrator).await;
Expand Down
25 changes: 12 additions & 13 deletions pingora/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,22 @@ categories = ["network-programming", "web-programming"]
publish = true

[dependencies]
arc-swap = "1.7.1"
async-trait = "0.1.88"
axum = { version = "0.8.4", features = ["macros"] }
arc-swap = "1.7"
async-trait = "0.1"
axum = { version = "0.8", features = ["macros"] }
backoff = { version = "0.4", features = ["tokio"] }
chrono = { version = "0.4.41", features = ["serde"] }
chrono = { version = "0.4", features = ["serde"] }
switchgear-service = { version = "0.1.7", path = "../service" }
log = "0.4"
pingora-core = { version = "0.5.0", features = ["boringssl"] }
pingora-error = { version = "0.5.0" }
pingora-load-balancing = { version = "0.5.0" }
thiserror = "2.0.12"
pingora-core = { version = "0.6", features = ["rustls"] }
pingora-error = { version = "0.6" }
pingora-load-balancing = { version = "0.6" }
thiserror = "2.0"
tokio = { version = "1", features = ["full"] }
uuid = { version = "1.17.0", features = ["v4", "serde"] }
url = "2.5.4"
uuid = { version = "1.17", features = ["v4", "serde"] }
url = "2.5"

[dev-dependencies]
chrono = "0.4.41"
secp256k1 = { version = "0.29.1", features = ["recovery", "serde", "rand"] }
chrono = "0.4"
tokio = { version = "1", features = ["full"] }
uuid = "1.17.0"
uuid = "1.17"
46 changes: 22 additions & 24 deletions server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,48 +15,46 @@ publish = true
[dependencies]
anyhow = "1.0"
async-trait = "0.1"
axum-server = { version = "0.7.2", features = ["tokio-rustls", "tls-rustls"] }
backoff = "0.4.0"
chrono = { version = "0.4.41", features = ["serde"] }
clap = { version = "4", features = ["derive"] }
axum-server = { version = "0.7", features = ["tokio-rustls", "tls-rustls"] }
backoff = "0.4"
chrono = { version = "0.4", features = ["serde"] }
clap = { version = "4.5", features = ["derive"] }
env_logger = "0.11"
futures-util = "0.3"
hyper = ">=1.4, <1.8"
hyper-util = ">=0.1.2, <0.1.17"
jemallocator = "0.5.4"
jsonwebtoken = "9.3.1"
jemallocator = "0.5"
jsonwebtoken = "10.2"
log = "0.4"
p256 = { version = "0.13", features = ["ecdsa"] }
pingora-load-balancing = { version = "0.5.0" }
pingora-load-balancing = { version = "0.6" }
pkcs8 = { version = "0.10", features = ["pem"] }
rand = "0.8"
reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls"] }
rustls = { version = "0.23.28", features = ["ring"] }
rustls-pemfile = "2.1"
rustls = { version = "0.23", features = ["ring"] }
rustls-pemfile = "2"
serde = { version = "1", features = ["derive"] }
serde_json = "1.0"
serde_yaml = "0.9"
shellexpand = "3.1.1"
serde-saphyr = "0.0.8"
shellexpand = "3.1"
signal-hook = "0.3"
signal-hook-tokio = { version = "0.3", features = ["futures-v0_3"] }
simplelog = {version = "0.12.2", features = ["paris"] }
simplelog = {version = "0.12", features = ["paris"] }
switchgear-pingora = { version = "0.1.7",path = "../pingora" }
switchgear-service = { version = "0.1.7",path = "../service" }
tokio = { version = "1", features = ["full"] }
uuid = { version = "1.17.0", features = ["v4", "serde"] }
uuid = { version = "1.17", features = ["v4", "serde"] }

[dev-dependencies]
chrono = { version = "0.4.41", features = ["serde"] }
lightning-invoice = { version = "0.33.2", features = ["serde", "std"] }
chrono = { version = "0.4", features = ["serde"] }
lightning-invoice = { version = "0.33", features = ["serde", "std"] }
switchgear-testing = { version = "0.1.7", path = "../testing" }
rcgen = { version = "0.14.1", features = ["crypto"] }
reqwest = { version = "0.12.20", default-features = false, features = ["json", "rustls-tls"] }
serde_yaml = "0.9"
sysinfo = "0.32"
rcgen = { version = "0.14", features = ["crypto"] }
reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls"] }
serde-saphyr = "0.0.8"
sysinfo = "0.37"
tempfile = "3.0"
toml = "0.8"
uuid = { version = "1.17.0", features = ["v4", "serde"] }
jemallocator = "0.5.4"
toml = "0.9"
uuid = { version = "1.17", features = ["v4", "serde"] }
jemallocator = "0.5"

[lib]
name = "switchgear_server"
Expand Down
4 changes: 3 additions & 1 deletion server/config/lnurl-standalone.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ lnurl-service:
tls:
cert-path: "${LNURL_SERVICE_TLS_CERT_PATH:-/etc/ssl/certs/lnurl-cert.pem}"
key-path: "${LNURL_SERVICE_TLS_KEY_PATH:-/etc/ssl/certs/lnurl-key.pem}"

bech32-qr-scale: 8
bech32-qr-light: 255
bech32-qr-dark: 0

# Remote storage configuration
# Connect to external discovery and offers services
Expand Down
3 changes: 3 additions & 0 deletions server/config/memory-basic-no-tls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ lnurl-service:
max-elapsed-time-secs: 2.5
backend-selection: "round-robin"
selection-capacity-bias: -0.2
bech32-qr-scale: 8
bech32-qr-light: 255
bech32-qr-dark: 0

discovery-service:
address: "${DISCOVERY_SERVICE_ADDRESS:-127.0.0.1:8081}"
Expand Down
5 changes: 4 additions & 1 deletion server/config/memory-basic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ lnurl-service:
tls:
cert-path: "${LNURL_SERVICE_TLS_CERT_PATH:-/etc/ssl/certs/lnurl-cert.pem}"
key-path: "${LNURL_SERVICE_TLS_KEY_PATH:-/etc/ssl/certs/lnurl-key.pem}"

bech32-qr-scale: 8
bech32-qr-light: 255
bech32-qr-dark: 0

discovery-service:
address: "${DISCOVERY_SERVICE_ADDRESS:-127.0.0.1:8081}"
auth-authority: "${DISCOVERY_SERVICE_AUTH_AUTHORITY_PATH:-/etc/ssl/certs/discovery-auth-authority.pem}"
Expand Down
6 changes: 4 additions & 2 deletions server/config/mixed-persistence.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ lnurl-service:
max-elapsed-time-secs: 2.5
backend-selection: "round-robin"
selection-capacity-bias: -0.2

tls:
cert-path: "${LNURL_SERVICE_TLS_CERT_PATH:-/etc/ssl/certs/lnurl-cert.pem}"
key-path: "${LNURL_SERVICE_TLS_KEY_PATH:-/etc/ssl/certs/lnurl-key.pem}"

bech32-qr-scale: 8
bech32-qr-light: 255
bech32-qr-dark: 0

discovery-service:
address: "${DISCOVERY_SERVICE_ADDRESS:-127.0.0.1:8081}"
auth-authority: "${DISCOVERY_SERVICE_AUTH_AUTHORITY_PATH:-/etc/ssl/certs/discovery-auth-authority.pem}"
Expand Down
6 changes: 4 additions & 2 deletions server/config/sqlite-persistent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ lnurl-service:
max-elapsed-time-secs: 2.5
backend-selection: "round-robin"
selection-capacity-bias: -0.2

tls:
cert-path: "${LNURL_SERVICE_TLS_CERT_PATH:-/etc/ssl/certs/lnurl-cert.pem}"
key-path: "${LNURL_SERVICE_TLS_KEY_PATH:-/etc/ssl/certs/lnurl-key.pem}"

bech32-qr-scale: 8
bech32-qr-light: 255
bech32-qr-dark: 0

discovery-service:
address: "${DISCOVERY_SERVICE_ADDRESS:-127.0.0.1:8081}"
auth-authority: "${DISCOVERY_SERVICE_AUTH_AUTHORITY_PATH:-/etc/ssl/certs/discovery-auth-authority.pem}"
Expand Down
1 change: 1 addition & 0 deletions server/src/commands/offer/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ pub fn new_offer(partition: &str, metadata_id: &Uuid, output: Option<&Path>) ->
metadata_id: *metadata_id,
#[allow(clippy::expect_used)]
timestamp: DateTime::<Utc>::from_timestamp_secs(0).expect("unix epoch"),
#[allow(clippy::expect_used)]
expires: Some(
DateTime::<Utc>::from_timestamp_secs(86_400).expect("unix epoch + 24 hours"),
),
Expand Down
3 changes: 3 additions & 0 deletions server/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ pub struct LnUrlBalancerServiceConfig {
pub ln_client_timeout_secs: f64,
pub selection_capacity_bias: Option<f64>,
pub comment_allowed: Option<u32>,
pub bech32_qr_scale: usize,
pub bech32_qr_light: u8,
pub bech32_qr_dark: u8,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand Down
2 changes: 1 addition & 1 deletion server/src/di/inject/injectors/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl ServerConfigInjector {
)
})?;

let config: ServerConfig = serde_yaml::from_str(&expanded_config).with_context(|| {
let config: ServerConfig = serde_saphyr::from_str(&expanded_config).with_context(|| {
format!(
"parsing YAML configuration from file '{}'",
config_path.to_string_lossy()
Expand Down
3 changes: 3 additions & 0 deletions server/src/di/inject/injectors/service/balance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ impl BalancerServiceInjector {
scheme,
service_config.allowed_hosts.clone(),
service_config.comment_allowed,
service_config.bech32_qr_scale,
service_config.bech32_qr_light,
service_config.bech32_qr_dark,
))
.layer(ClfLogger::new("lnurl"))
.into_make_service_with_connect_info::<SocketAddr>();
Expand Down
9 changes: 5 additions & 4 deletions server/tests/features/common/step_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ pub async fn step_given_an_invalid_configuration_file_exists(
let config_content = std::fs::read_to_string(config_path)
.with_context(|| format!("reading config file: {}", config_path.display()))?;

// Try to parse with serde_yaml and assert that it fails
// Try to parse with serde_saphyr and assert that it fails
let parse_result =
serde_yaml::from_str::<switchgear_server::config::ServerConfig>(&config_content);
serde_saphyr::from_str::<switchgear_server::config::ServerConfig>(&config_content);

if parse_result.is_ok() {
bail_log!(
Expand Down Expand Up @@ -99,8 +99,9 @@ pub async fn step_given_the_lnurl_server_is_ready_to_start(ctx: &mut GlobalConte
)
})?;

let _config = serde_yaml::from_str::<switchgear_server::config::ServerConfig>(&config_content)
.with_context(|| format!("parsing config file: {}", config_path.display()))?;
let _config =
serde_saphyr::from_str::<switchgear_server::config::ServerConfig>(&config_content)
.with_context(|| format!("parsing config file: {}", config_path.display()))?;

Ok(())
}
Expand Down
72 changes: 36 additions & 36 deletions service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,57 +13,57 @@ categories = ["network-programming", "web-programming", "cryptography::cryptocur
publish = true

[dependencies]
#bitcoin = { version = "0.32.2", default-features = false, features = ["secp-recovery", "serde"] }
async-trait = "0.1.88"
axum = { version = "0.8.4", features = ["macros"] }
axum-extra = { version = "0.10", features = ["typed-header"] }
axum-forwarded-header = "0.1.0"
async-trait = "0.1"
axum = { version = "0.8", features = ["macros"] }
axum-extra = { version = "0.12", features = ["typed-header"] }
backoff = { version = "0.4", features = ["tokio"] }
base64 = "0.22.1"
bech32 = "0.11.0"
chrono = { version = "0.4.41", features = ["serde"] }
client-ip = { version = "0.1.1", features = ["forwarded-header"] }
email_address = "0.2.9"
fs4 = { version = "0.13.1", features = ["tokio"] }
base64 = "0.22"
bech32 = "0.11"
chrono = { version = "0.4", features = ["serde"] }
client-ip = { version = "0.1", features = ["forwarded-header"] }
email_address = "0.2"
hex = "0.4"
http = "1.3.1"
hyper-rustls = { version = "0.27.7", features = ["http2", "tls12"], default-features = false }
http = "1.3"
hyper-rustls = { version = "0.27", features = ["http2", "tls12"], default-features = false }
hyper-timeout = "0.5"
hyper-util = "0.1"
image = "0.25.6"
jsonwebtoken = "9.3.1"
lightning-invoice = { version = "0.33.2", features = ["serde", "std"] }
image = { version = "0.25", default-features = false, features = ["png"] }
jsonwebtoken = { version = "10.2", features = ["aws_lc_rs"] }
log = "0.4"
prost = { version = "0.14.1" }
qrcode = "0.14.1"
prost = { version = "0.14" }
qrcode = { version = "0.14", default-features = false, features = ["image"] }
reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls"] }
rustls = { version = "0.23", features = ["ring"] }
rustls-pemfile = "2.0"
sea-orm = { version = "1.1.14", features = ["sqlx-mysql", "sqlx-sqlite", "sqlx-postgres", "runtime-tokio-rustls", "macros"] }
secp256k1 = { version = "0.29.1", features = ["recovery", "serde"] }
serde = "1.0.219"
serde_json = "1.0.140"
sha2 = "0.10.9"
sqlx = { version = "0.8.6", features = ["runtime-tokio-rustls", "tls-rustls", "sqlite", "macros", "migrate"] }
sea-orm = { version = "1.1", features = ["sqlx-mysql", "sqlx-sqlite", "sqlx-postgres", "runtime-tokio-rustls", "macros"] }
secp256k1 = { version = "0.31", features = ["recovery", "serde"] }
serde = "1.0"
serde_json = "1.0"
sha2 = "0.10"
sqlx = { version = "0.8", features = ["runtime-tokio-rustls", "tls-rustls", "sqlite", "macros", "migrate"] }
switchgear-migration = { version = "0.1.7", path = "../migration" }
tempfile = "3.0"
thiserror = "2.0.12"
thiserror = "2.0"
tokio = { version = "1", features = ["full"] }
tonic = { version = "0.14.2", features = ["transport", "tls-ring"] }
tonic-prost = "0.14.2"
tower = { version = "0.5.2", features = ["balance"] }
url = { version = "2.5.4", features = ["serde"] }
uuid = { version = "1.17.0", features = ["v4", "serde"] }
tonic = { version = "0.14", features = ["transport", "tls-ring"] }
tonic-prost = "0.14"
tower = { version = "0.5", features = ["balance"] }
url = { version = "2.5", features = ["serde"] }
uuid = { version = "1.17", features = ["v4", "serde"] }

[build-dependencies]
tonic-prost-build = { version = "0.14.2" }
tonic-prost-build = { version = "0.14" }

[dev-dependencies]
anyhow = "1.0"
axum-test = "17.3.0"
switchgear-testing = { version = "0.1.7", path = "../testing" }
axum-test = "18.3"
bitcoin_hashes = "0.14"
hyper-util = "0.1"
lightning-invoice = { version = "0.33", features = ["serde", "std"] }
p256 = { version = "0.13", features = ["ecdsa"] }
pkcs8 = { version = "0.10", features = ["pem"] }
rand = "0.8.5"
rqrr = "0.7.1"
hyper-util = "0.1"
png = "0.18"
rand = "0.8"
rqrr = "0.10"
secp256k1_0_29 = { package = "secp256k1", version = "0.29", features = ["recovery", "serde"] }
switchgear-testing = { version = "0.1.7", path = "../testing" }
24 changes: 10 additions & 14 deletions service/src/api/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,11 @@ mod test {

#[test]
fn serialize_when_discovery_backend_then_returns_json_with_flattened_fields() {
let key = SecretKey::from_slice(
&[
0xe1, 0x26, 0xf6, 0x8f, 0x7e, 0xaf, 0xcc, 0x8b, 0x74, 0xf5, 0x4d, 0x26, 0x9f, 0xe2,
0x06, 0xbe, 0x71, 0x50, 0x00, 0xf9, 0x4d, 0xac, 0x06, 0x7d, 0x1c, 0x04, 0xa8, 0xca,
0x3b, 0x2d, 0xb7, 0x34,
][..],
)
let key = SecretKey::from_byte_array([
0xe1, 0x26, 0xf6, 0x8f, 0x7e, 0xaf, 0xcc, 0x8b, 0x74, 0xf5, 0x4d, 0x26, 0x9f, 0xe2,
0x06, 0xbe, 0x71, 0x50, 0x00, 0xf9, 0x4d, 0xac, 0x06, 0x7d, 0x1c, 0x04, 0xa8, 0xca,
0x3b, 0x2d, 0xb7, 0x34,
])
.unwrap();
let key = key.public_key(&Secp256k1::new());

Expand Down Expand Up @@ -223,13 +221,11 @@ mod test {

#[test]
fn deserialize_when_valid_json_then_creates_discovery_backend_with_flattened_fields() {
let key = SecretKey::from_slice(
&[
0xe1, 0x26, 0xf6, 0x8f, 0x7e, 0xaf, 0xcc, 0x8b, 0x74, 0xf5, 0x4d, 0x26, 0x9f, 0xe2,
0x06, 0xbe, 0x71, 0x50, 0x00, 0xf9, 0x4d, 0xac, 0x06, 0x7d, 0x1c, 0x04, 0xa8, 0xca,
0x3b, 0x2d, 0xb7, 0x34,
][..],
)
let key = SecretKey::from_byte_array([
0xe1, 0x26, 0xf6, 0x8f, 0x7e, 0xaf, 0xcc, 0x8b, 0x74, 0xf5, 0x4d, 0x26, 0x9f, 0xe2,
0x06, 0xbe, 0x71, 0x50, 0x00, 0xf9, 0x4d, 0xac, 0x06, 0x7d, 0x1c, 0x04, 0xa8, 0xca,
0x3b, 0x2d, 0xb7, 0x34,
])
.unwrap();
let key = key.public_key(&Secp256k1::new());

Expand Down
Loading