diff options
author | Antoine A <> | 2021-12-16 13:38:01 +0100 |
---|---|---|
committer | Antoine A <> | 2021-12-16 13:38:01 +0100 |
commit | 1be9da930bd1d532109490a15fb97c27c52ce3ce (patch) | |
tree | 4515bd838dc1b9e0b1bb80f1343251250c9ac03b /taler-config/src/lib.rs | |
parent | 36a2771a15840ce42a2fc5ac582d5835de9aa601 (diff) | |
download | depolymerization-1be9da930bd1d532109490a15fb97c27c52ce3ce.tar.gz depolymerization-1be9da930bd1d532109490a15fb97c27c52ce3ce.tar.bz2 depolymerization-1be9da930bd1d532109490a15fb97c27c52ce3ce.zip |
Cleanup
Diffstat (limited to 'taler-config/src/lib.rs')
-rw-r--r-- | taler-config/src/lib.rs | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/taler-config/src/lib.rs b/taler-config/src/lib.rs index fb7af71..6273cd2 100644 --- a/taler-config/src/lib.rs +++ b/taler-config/src/lib.rs @@ -7,21 +7,36 @@ pub struct Config { pub db_url: String, pub port: u16, pub payto: Url, - pub address: String, pub confirmation: u8, + pub btc_wallet: String, + pub btc_chain: String, } impl Config { pub fn from_path(path: impl AsRef<Path>) -> Self { let conf = ini::Ini::load_from_file(path).unwrap(); - let conf = conf.section(Some("main")).unwrap(); + let ex_conf = conf.section(Some("exchange")).unwrap(); + let self_conf = conf.section(Some("depolymerizer-bitcoin")).unwrap(); Self { - base_url: Url::parse(&conf.get("BASE_URL").unwrap()).unwrap(), - db_url: conf.get("DB_URL").unwrap().to_string(), - port: conf.get("PORT").unwrap().parse().unwrap(), - payto: Url::parse(&conf.get("PAYTO").unwrap()).unwrap(), - address: conf.get("ADDRESS").unwrap().to_string(), - confirmation: conf.get("CONFIRMATION").unwrap().parse().unwrap(), + base_url: Url::parse(ex_conf.get("BASE_URL").expect("Missing config BASE_URL")) + .expect("BASE_URL is not a valid url"), + db_url: self_conf + .get("DB_URL") + .expect("Missing config DB_URL") + .to_string(), + port: self_conf + .get("PORT") + .unwrap_or("8080") + .parse() + .expect("Config PORT is not a number"), + payto: Url::parse(self_conf.get("PAYTO").unwrap()).unwrap(), + confirmation: self_conf + .get("CONFIRMATION") + .unwrap_or("1") + .parse() + .expect("Config CONFIRMATION is not a number"), + btc_wallet: self_conf.get("BTC_WALLET").unwrap_or("wire").to_string(), + btc_chain: self_conf.get("BTC_CHAIN").unwrap_or("regtest").to_string(), } } } |