Skip to content

Commit

Permalink
Merge pull request #63 from commerceblock/feat/fee-unit
Browse files Browse the repository at this point in the history
Feat/fee unit
  • Loading branch information
tomt1664 authored Jun 25, 2024
2 parents d3912c2 + 9a3aef3 commit dc40ef1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion token-server/Settings.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
processor_url = "http://0.0.0.0:18080"
api_key = "aaaaa"
fee = 10000
unit = "BTC"
delay = 3600
connection_string = "postgresql://postgres:postgres@localhost/mercury"
connection_string = "postgresql://postgres:postgres@localhost/mercury"
2 changes: 1 addition & 1 deletion token-server/src/endpoints/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ pub async fn get_lightning_invoice(token_server: &State<TokenServer>, token_id:
title: token_id.clone().to_string(),
description: "".to_string(),
amount: token_server.config.fee.clone(),
unit: "BTC".to_string(),
unit: token_server.config.unit.clone(),
redirectAfterPaid: "".to_string(),
email: "".to_string(),
emailLanguage: "en".to_string(),
Expand Down
5 changes: 5 additions & 0 deletions token-server/src/server_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ pub struct ServerConfig {
pub processor_url: String,
/// Payment processor API key
pub api_key: String,
/// Token fee unit
pub unit: String,
/// Token fee value (satoshis)
pub fee: String,
/// Invoice delay (seconds)
Expand All @@ -22,6 +24,7 @@ impl Default for ServerConfig {
ServerConfig {
processor_url: String::from("http://0.0.0.0:18080"),
api_key: String::from("aaaaa"),
unit: String::from("BTC"),
fee: String::from("10000"),
delay: 3600,
connection_string: String::from("postgresql://postgres:postgres@localhost/mercury"),
Expand All @@ -34,6 +37,7 @@ impl From<ConfigRs> for ServerConfig {
ServerConfig {
processor_url: config.get::<String>("processor_url").unwrap_or_else(|_| String::new()),
api_key: config.get::<String>("api_key").unwrap_or_else(|_| String::new()),
unit: config.get::<String>("unit").unwrap_or_else(|_| String::new()),
fee: config.get::<String>("fee").unwrap_or_else(|_| String::new()),
delay: config.get::<u64>("delay").unwrap_or(0),
connection_string: config.get::<String>("connection_string").unwrap_or_else(|_| String::new()),
Expand Down Expand Up @@ -65,6 +69,7 @@ impl ServerConfig {
ServerConfig {
processor_url: get_env_or_config("processor_url", "PROCESSOR_URL"),
api_key: get_env_or_config("api_key", "API_KEY"),
unit: get_env_or_config("unit", "UNIT"),
fee: get_env_or_config("fee", "FEE"),
delay: get_env_or_config("delay", "DELAY").parse::<u64>().unwrap(),
connection_string: get_env_or_config("connection_string", "CONNECTION_STRING"),
Expand Down

0 comments on commit dc40ef1

Please sign in to comment.