diff --git a/Cargo.lock b/Cargo.lock index 6faf2867a..f9c2a8d1a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1474,7 +1474,7 @@ dependencies = [ "mockall", "nostr", "nostr-sdk", - "payjoin 0.10.0", + "payjoin 0.11.0", "pbkdf2", "proc-macro2", "reqwest", @@ -1511,7 +1511,7 @@ dependencies = [ "mutiny-core", "nostr", "once_cell", - "payjoin 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "payjoin 0.10.0", "rexie", "serde", "serde_json", @@ -1733,27 +1733,27 @@ dependencies = [ [[package]] name = "payjoin" version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fac532e6caa3a192dd6017a88446c2a1014d31b66cc68f04c584a846a4cb0373" dependencies = [ - "bhttp", "bip21", "bitcoin 0.30.2", - "chacha20poly1305 0.10.1", "log", - "ohttp", - "rand", - "serde", "url", ] [[package]] name = "payjoin" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fac532e6caa3a192dd6017a88446c2a1014d31b66cc68f04c584a846a4cb0373" +version = "0.11.0" dependencies = [ + "bhttp", "bip21", "bitcoin 0.30.2", + "chacha20poly1305 0.10.1", "log", + "ohttp", + "rand", + "serde", "url", ] diff --git a/mutiny-core/src/nodemanager.rs b/mutiny-core/src/nodemanager.rs index 62fa26e5f..26a83c2b6 100644 --- a/mutiny-core/src/nodemanager.rs +++ b/mutiny-core/src/nodemanager.rs @@ -1062,21 +1062,25 @@ impl NodeManager { // If we are in safe mode, we don't create payjoin sessions let pj = { - // TODO get from &self config - const PJ_RELAY_URL: &str = "http://localhost:8080"; - const OH_RELAY_URL: &str = "http://localhost:8080"; - const OHTTP_CONFIG_BASE64: &str = - "AQAg7YjKSn1zBziW3LvPCQ8X18hH0dU67G-vOcMHu0-m81AABAABAAM"; + // DANGER! TODO get from &self config, do not get config directly from PAYJOIN_DIR ohttp-gateway + // That would reveal IP address + + let http_client = reqwest::Client::builder().build().unwrap(); + + let ohttp_config_base64 = http_client + .get(format!("{}/ohttp-config", crate::payjoin::PAYJOIN_DIR)) + .send() + .await + .unwrap() + .text() + .await + .unwrap(); + let mut enroller = payjoin::receive::v2::Enroller::from_relay_config( - PJ_RELAY_URL, - OHTTP_CONFIG_BASE64, - OH_RELAY_URL, - //Some("c53989e590b0f02edeec42a9c43fd1e4e960aec243bb1e6064324bd2c08ec498") + crate::payjoin::PAYJOIN_DIR, + &ohttp_config_base64, + crate::payjoin::OHTTP_RELAYS[0], // TODO pick ohttp relay at random ); - let http_client = reqwest::Client::builder() - //.danger_accept_invalid_certs(true) ? is tls unchecked :O - .build() - .unwrap(); // enroll client let (req, context) = enroller.extract_req().unwrap(); let ohttp_response = http_client diff --git a/mutiny-core/src/payjoin.rs b/mutiny-core/src/payjoin.rs index 74652dd40..60674e49a 100644 --- a/mutiny-core/src/payjoin.rs +++ b/mutiny-core/src/payjoin.rs @@ -6,6 +6,12 @@ use payjoin::receive::v2::Enrolled; use serde::{Deserialize, Serialize}; use std::collections::HashMap; +pub(crate) const OHTTP_RELAYS: [&str; 2] = [ + "https://ohttp-relay.obscuravpn.io/payjoin", + "https://bobspace-ohttp.duckdns.org", +]; +pub(crate) const PAYJOIN_DIR: &str = "https://payjo.in"; + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct Session { pub enrolled: Enrolled,