Skip to content

Commit

Permalink
Use live payjoin network resources
Browse files Browse the repository at this point in the history
  • Loading branch information
DanGould committed Dec 4, 2023
1 parent bf5f2fc commit 2b70c36
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 23 deletions.
20 changes: 10 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 17 additions & 13 deletions mutiny-core/src/nodemanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1062,21 +1062,25 @@ impl<S: MutinyStorage> NodeManager<S> {

// 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
Expand Down
6 changes: 6 additions & 0 deletions mutiny-core/src/payjoin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 2b70c36

Please sign in to comment.