فهرست منبع

feat: Add tos_url to mintd config (#636)

* feat: Add tos_url to mintd config

* docs: tos in change log
thesimplekid 1 ماه پیش
والد
کامیت
b7380dc858

+ 3 - 0
CHANGELOG.md

@@ -13,6 +13,8 @@
 ### Added
 - Added redb feature to mintd in order to meet MSRV target ([thesimplekid]).
 - cdk-sqlite: In memory sqlite database ([crodas]).
+- Add `tos_url` to `MintInfo` ([nodlAndHodl]).
+- cdk: Add tos_url setter to `MintBuilder` ([thesimplekid]).
 ### Removed
 - Remove support for Memory Database in cdk ([crodas]).
 - Remove `AmountStr` ([crodas]).
@@ -276,3 +278,4 @@ Additionally, this release introduces a Mint binary cdk-mintd that uses the cdk-
 [crodas]: https://github.com/crodas
 [tdelabro]: https://github.com/tdelabro
 [daywalker90]: https://github.com/daywalker90
+[nodlAndHodl]: https://github.com/nodlAndHodl

+ 1 - 0
crates/cdk-mintd/example.config.toml

@@ -34,6 +34,7 @@ tti = 60
 # contact_email = "hello@cashu.me"
 # Nostr pubkey of mint (Hex)
 # contact_nostr_public_key = ""
+# tos_url = "https://example.com/terms-of-service"
 
 
 [database]

+ 2 - 0
crates/cdk-mintd/src/config.rs

@@ -208,6 +208,8 @@ pub struct MintInfo {
     pub contact_nostr_public_key: Option<String>,
     /// Contact email
     pub contact_email: Option<String>,
+    /// URL to the terms of service
+    pub tos_url: Option<String>,
 }
 
 #[cfg(feature = "management-rpc")]

+ 5 - 0
crates/cdk-mintd/src/env_vars.rs

@@ -32,6 +32,7 @@ pub const ENV_MINT_ICON_URL: &str = "CDK_MINTD_MINT_ICON_URL";
 pub const ENV_MINT_MOTD: &str = "CDK_MINTD_MINT_MOTD";
 pub const ENV_MINT_CONTACT_NOSTR: &str = "CDK_MINTD_MINT_CONTACT_NOSTR";
 pub const ENV_MINT_CONTACT_EMAIL: &str = "CDK_MINTD_MINT_CONTACT_EMAIL";
+pub const ENV_MINT_TOS_URL: &str = "CDK_MINTD_MINT_TOS_URL";
 // LN
 pub const ENV_LN_BACKEND: &str = "CDK_MINTD_LN_BACKEND";
 pub const ENV_LN_INVOICE_DESCRIPTION: &str = "CDK_MINTD_LN_INVOICE_DESCRIPTION";
@@ -203,6 +204,10 @@ impl MintInfo {
             self.contact_email = Some(email);
         }
 
+        if let Ok(tos_url) = env::var(ENV_MINT_TOS_URL) {
+            self.tos_url = Some(tos_url);
+        }
+
         self
     }
 }

+ 4 - 0
crates/cdk-mintd/src/main.rs

@@ -263,6 +263,10 @@ async fn main() -> anyhow::Result<()> {
         mint_builder = mint_builder.with_motd(motd);
     }
 
+    if let Some(tos_url) = &settings.mint_info.tos_url {
+        mint_builder = mint_builder.with_tos_url(tos_url.to_string());
+    }
+
     let mnemonic = Mnemonic::from_str(&settings.info.mnemonic)?;
 
     mint_builder = mint_builder

+ 6 - 0
crates/cdk/src/mint/builder.rs

@@ -86,6 +86,12 @@ impl MintBuilder {
         self
     }
 
+    /// Set terms of service URL
+    pub fn with_tos_url(mut self, tos_url: String) -> Self {
+        self.mint_info.tos_url = Some(tos_url);
+        self
+    }
+
     /// Set description
     pub fn with_description(mut self, description: String) -> Self {
         self.mint_info.description = Some(description);