Skip to content

Commit

Permalink
Define payjoin network resources in mod
Browse files Browse the repository at this point in the history
  • Loading branch information
DanGould committed Dec 20, 2023
1 parent 4a681f2 commit 570e695
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 3 additions & 9 deletions mutiny-core/src/nodemanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1024,16 +1024,11 @@ impl<S: MutinyStorage> NodeManager<S> {
let pj = {
// DANGER! TODO get from &self config, do not get config directly from PAYJOIN_DIR ohttp-gateway
// That would reveal IP address
const OHTTP_RELAYS: [&str; 2] = [
"https://ohttp-relay.obscuravpn.io/payjoin",
"https://bobspace-ohttp.duckdns.org",
];
const PAYJOIN_DIR: &str = "https://payjo.in";

let http_client = reqwest::Client::builder().build().unwrap();

let ohttp_config_base64 = http_client
.get(format!("{}/ohttp-config", PAYJOIN_DIR))
.get(format!("{}/ohttp-config", crate::payjoin::PAYJOIN_DIR))
.send()
.await
.unwrap()
Expand All @@ -1042,11 +1037,10 @@ impl<S: MutinyStorage> NodeManager<S> {
.unwrap();

let mut enroller = payjoin::receive::v2::Enroller::from_relay_config(
PAYJOIN_DIR,
crate::payjoin::PAYJOIN_DIR,
&ohttp_config_base64,
OHTTP_RELAYS[0], // TODO pick ohttp relay at random
crate::payjoin::OHTTP_RELAYS[0], // TODO pick ohttp relay at random
);

// 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 570e695

Please sign in to comment.