Skip to content

Commit

Permalink
quick connect urls for each user in properties
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-bonez committed Oct 15, 2020
1 parent 56260a3 commit 2c2e012
Showing 1 changed file with 46 additions and 3 deletions.
49 changes: 46 additions & 3 deletions src/create_env/start9.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,54 @@ enum BitcoinCoreConfig {
},
}

#[derive(serde::Serialize)]
pub struct Properties {
version: u8,
data: (Property<Vec<Property<String>>>,),
}

#[derive(serde::Serialize)]
pub struct Property<T> {
name: String,
value: T,
description: Option<String>,
copyable: bool,
qr: bool,
}

pub async fn create_env() -> Result<Env, Error> {
let cfg: Config = tokio::task::spawn_blocking(move || -> Result<_, Error> {
Ok(serde_yaml::from_reader(std::fs::File::open(
"/root/start9/config.yaml",
)?)?)
let cfg: Config =
serde_yaml::from_reader(std::fs::File::open("/root/start9/config.yaml")?)?;
let tor_addr = std::env::var("TOR_ADDRESS")?;
serde_yaml::to_writer(
std::fs::File::create("/root/start9/stats.yaml")?,
&Properties {
version: 1,
data: (Property {
name: "Quick Connect URLs".to_owned(),
value: cfg
.users
.0
.iter()
.map(|(name, info)| Property {
name: name.clone(),
value: format!(
"btcstandup://{}:{}@{}:8332/",
name, info.password, tor_addr
),
description: Some(format!("Quick Connect URL for {}", name)),
copyable: true,
qr: true,
})
.collect(),
description: Some("Quick Connect URLs for each user".to_owned()),
copyable: false,
qr: false,
},),
},
)?;
Ok(cfg)
})
.await??;
let decorator = slog_term::TermDecorator::new().build();
Expand Down

0 comments on commit 2c2e012

Please sign in to comment.