From 4aa4877eb352c3aa95b9ebd00bca37b57e12e947 Mon Sep 17 00:00:00 2001 From: ngutech21 Date: Fri, 2 Aug 2024 09:01:58 +0200 Subject: [PATCH] fix: compatibility with nutshell v0.16.0 fixes #315 --- docker-compose.yml | 2 +- .../fixtures/nutshell_mint_info_v0.16.0.json | 42 +++++++++++++++++++ moksha-core/src/primitives.rs | 14 +++++-- 3 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 moksha-core/src/fixtures/nutshell_mint_info_v0.16.0.json diff --git a/docker-compose.yml b/docker-compose.yml index a79b32d6..e36a577b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -120,7 +120,7 @@ services: - itest nutshell: - image: cashubtc/nutshell:0.15.3 + image: cashubtc/nutshell:0.16.0 container_name: nutshell ports: - "2228:3338" diff --git a/moksha-core/src/fixtures/nutshell_mint_info_v0.16.0.json b/moksha-core/src/fixtures/nutshell_mint_info_v0.16.0.json new file mode 100644 index 00000000..3d226e28 --- /dev/null +++ b/moksha-core/src/fixtures/nutshell_mint_info_v0.16.0.json @@ -0,0 +1,42 @@ +{ + "name": "nutshell", + "pubkey": "0296d0aa13b6a31cf0cd974249f28c7b7176d7274712c95a41c7d8066d3f29d679", + "version": "Nutshell/0.16.0", + "contact": [], + "nuts": { + "4": { + "methods": [ + { "method": "bolt11", "unit": "sat" }, + { "method": "bolt11", "unit": "usd" } + ], + "disabled": false + }, + "5": { + "methods": [ + { "method": "bolt11", "unit": "sat" }, + { "method": "bolt11", "unit": "usd" } + ], + "disabled": false + }, + "7": { "supported": true }, + "8": { "supported": true }, + "9": { "supported": true }, + "10": { "supported": true }, + "11": { "supported": true }, + "12": { "supported": true }, + "17": { + "supported": [ + { + "method": "bolt11", + "unit": "sat", + "commands": ["bolt11_melt_quote", "proof_state", "bolt11_mint_quote"] + }, + { + "method": "bolt11", + "unit": "usd", + "commands": ["bolt11_melt_quote", "proof_state", "bolt11_mint_quote"] + } + ] + } + } +} diff --git a/moksha-core/src/primitives.rs b/moksha-core/src/primitives.rs index 5f16de25..a31a2751 100644 --- a/moksha-core/src/primitives.rs +++ b/moksha-core/src/primitives.rs @@ -613,9 +613,7 @@ pub struct Nut16 { } #[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq, Default, ToSchema)] -pub struct Nut17 { - pub supported: bool, -} +pub struct Nut17 {} #[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq, ToSchema)] pub struct Nut18 { @@ -752,6 +750,16 @@ mod tests { Ok(()) } + #[test] + fn test_deserialize_nustash_v_0_16_0_mint_info() -> anyhow::Result<()> { + let mint_info = read_fixture("nutshell_mint_info_v0.16.0.json")?; + let info = serde_json::from_str::(&mint_info); + assert!(info.is_ok()); + let info = info?; + assert_eq!("Nutshell/0.16.0", info.version.unwrap()); + Ok(()) + } + #[test] fn test_deserialize_incomplete_mint_info() -> anyhow::Result<()> { let mint_info = read_fixture("incomplete_mint_info.json")?;