From 7b4c34967d7c5dd9a767c2350d271fe30ff0c711 Mon Sep 17 00:00:00 2001 From: "thesimplekid (aider)" Date: Fri, 7 Mar 2025 20:18:31 +0000 Subject: [PATCH 1/2] feat: Add tos_url to mintd config --- crates/cdk-mintd/example.config.toml | 1 + crates/cdk-mintd/src/config.rs | 2 ++ crates/cdk-mintd/src/env_vars.rs | 5 +++++ crates/cdk-mintd/src/main.rs | 4 ++++ crates/cdk/src/mint/builder.rs | 6 ++++++ 5 files changed, 18 insertions(+) diff --git a/crates/cdk-mintd/example.config.toml b/crates/cdk-mintd/example.config.toml index a982a02e8..11cf5c715 100644 --- a/crates/cdk-mintd/example.config.toml +++ b/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] diff --git a/crates/cdk-mintd/src/config.rs b/crates/cdk-mintd/src/config.rs index f4c6772bd..6c7ec97eb 100644 --- a/crates/cdk-mintd/src/config.rs +++ b/crates/cdk-mintd/src/config.rs @@ -208,6 +208,8 @@ pub struct MintInfo { pub contact_nostr_public_key: Option, /// Contact email pub contact_email: Option, + /// URL to the terms of service + pub tos_url: Option, } #[cfg(feature = "management-rpc")] diff --git a/crates/cdk-mintd/src/env_vars.rs b/crates/cdk-mintd/src/env_vars.rs index 2c82edc0b..306a347f1 100644 --- a/crates/cdk-mintd/src/env_vars.rs +++ b/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 } } diff --git a/crates/cdk-mintd/src/main.rs b/crates/cdk-mintd/src/main.rs index 1066dfa7d..0b0c0ff12 100644 --- a/crates/cdk-mintd/src/main.rs +++ b/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 diff --git a/crates/cdk/src/mint/builder.rs b/crates/cdk/src/mint/builder.rs index 9ef1deef0..f55924696 100644 --- a/crates/cdk/src/mint/builder.rs +++ b/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); From 3a4815b3a04f4d4c40be55fda81620f5f2f68522 Mon Sep 17 00:00:00 2001 From: thesimplekid Date: Fri, 7 Mar 2025 20:33:03 +0000 Subject: [PATCH 2/2] docs: tos in change log --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 140d2fde7..3faab0043 100644 --- a/CHANGELOG.md +++ b/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