From cfd6adc8b5ada2090107e906a2b9b37fd616711e Mon Sep 17 00:00:00 2001 From: Steffen <99717310+ngutech21@users.noreply.github.com> Date: Tue, 9 Apr 2024 15:43:06 +0200 Subject: [PATCH] chore: remove legacy api (#267) * chore: remove legacy router and primitives * chore: remove legacy keysets * chore: rename split to swap * chore: remove rand --- Cargo.lock | 24 +-- moksha-core/Cargo.toml | 3 +- moksha-core/src/amount.rs | 9 -- moksha-core/src/keyset.rs | 138 ++-------------- moksha-core/src/primitives.rs | 90 +---------- moksha-mint/Cargo.toml | 1 + ...4_20.json => post_swap_request_64_20.json} | 2 +- ...n => post_swap_request_duplicate_key.json} | 2 +- moksha-mint/src/mint.rs | 61 +++----- moksha-mint/src/model.rs | 8 - moksha-mint/src/routes/default.rs | 8 +- moksha-mint/src/routes/legacy.rs | 120 -------------- moksha-mint/src/routes/mod.rs | 1 - moksha-mint/src/server.rs | 148 ++++++------------ moksha-wallet/src/client/crossplatform.rs | 4 +- moksha-wallet/src/client/mod.rs | 4 +- ..._40.json => post_swap_response_24_40.json} | 0 moksha-wallet/src/wallet.rs | 36 ++--- 18 files changed, 128 insertions(+), 531 deletions(-) rename moksha-mint/src/fixtures/{post_split_request_64_20.json => post_swap_request_64_20.json} (98%) rename moksha-mint/src/fixtures/{post_split_request_duplicate_key.json => post_swap_request_duplicate_key.json} (98%) delete mode 100644 moksha-mint/src/routes/legacy.rs rename moksha-wallet/src/fixtures/{post_split_response_24_40.json => post_swap_response_24_40.json} (100%) diff --git a/Cargo.lock b/Cargo.lock index 470b8b1a..09d4e418 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -240,7 +240,7 @@ dependencies = [ "serde_json", "serde_path_to_error", "serde_urlencoded", - "sync_wrapper 1.0.0", + "sync_wrapper 1.0.1", "tokio", "tower", "tower-layer", @@ -534,9 +534,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.15.4" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "bytemuck" @@ -558,9 +558,9 @@ checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" [[package]] name = "cc" -version = "1.0.91" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd97381a8cc6493395a5afc4c691c1084b3768db713b73aa215217aa245d153" +checksum = "2678b2e3449475e95b0aa6f9b506a28e61b3dc8996592b983695e8ebb58a8b41" [[package]] name = "cfg-if" @@ -691,9 +691,9 @@ dependencies = [ [[package]] name = "crc" -version = "3.2.0" +version = "3.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2b432c56615136f8dba245fed7ec3d5518c500a31108661067e61e72fe7e6bc" +checksum = "69e6e4d7b33a94f0991c26729976b10ebde1d34c3ee82408fb536164fa10d636" dependencies = [ "crc-catalog", ] @@ -1217,9 +1217,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06fddc2749e0528d2813f95e050e87e52c8cbbae56223b9babf73b3e53b0cc6" +checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" dependencies = [ "cfg-if", "js-sys", @@ -2016,7 +2016,6 @@ dependencies = [ "hex", "itertools 0.12.1", "pretty_assertions", - "rand", "secp256k1 0.28.2", "serde", "serde_json", @@ -2048,6 +2047,7 @@ dependencies = [ "opentelemetry", "opentelemetry-otlp", "opentelemetry_sdk", + "pretty_assertions", "reqwest 0.12.3", "secp256k1 0.28.2", "serde", @@ -3688,9 +3688,9 @@ checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" [[package]] name = "sync_wrapper" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "384595c11a4e2969895cad5a8c4029115f5ab956a9e5ef4de79d11a426e5f20c" +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" [[package]] name = "system-configuration" diff --git a/moksha-core/Cargo.toml b/moksha-core/Cargo.toml index 47052b0e..33708574 100644 --- a/moksha-core/Cargo.toml +++ b/moksha-core/Cargo.toml @@ -15,7 +15,6 @@ anyhow = "1.0.79" url = "2.5.0" base64 = "0.22.0" bitcoin_hashes = "0.13.0" -rand = "0.8.5" secp256k1 = { version = "0.28.2", features = ["rand", "serde"] } serde = { version = "1.0.196", features = ["derive"] } serde_json = "1.0.113" @@ -30,7 +29,7 @@ utoipa = { version = "4.2.0" } # getrandom is transitive dependency of rand # on wasm, we need to enable the js backend # see https://docs.rs/getrandom/latest/getrandom/#indirect-dependencies and https://docs.rs/getrandom/latest/getrandom/#webassembly-support -getrandom = { version = "0.2.11", features = ["js"] } +getrandom = { version = "0.2.14", features = ["js"] } [dev-dependencies] anyhow = "1.0.79" diff --git a/moksha-core/src/amount.rs b/moksha-core/src/amount.rs index 0689c9d4..14bd8c98 100644 --- a/moksha-core/src/amount.rs +++ b/moksha-core/src/amount.rs @@ -5,8 +5,6 @@ //! The `SplitAmount` struct represents a split amount, with a `Vec` field for the split amounts. The struct provides a `create_secrets` method that generates a vector of random strings for use as secrets in the split transaction. The struct also implements the `IntoIterator` trait, which allows it to be iterated over as a vector of `u64` values. //! //! Both the `Amount` and `SplitAmount` structs are serializable and deserializable using serde. -use rand::distributions::Alphanumeric; -use rand::Rng; #[derive(Debug, Clone)] pub struct Amount(pub u64); @@ -66,13 +64,6 @@ fn split_amount(amount: u64) -> Vec { .collect::>() } -pub fn generate_random_string() -> String { - rand::thread_rng() - .sample_iter(&Alphanumeric) - .take(24) - .map(char::from) - .collect() -} #[cfg(test)] mod tests { diff --git a/moksha-core/src/keyset.rs b/moksha-core/src/keyset.rs index 1f7e0d64..5b07f5ba 100644 --- a/moksha-core/src/keyset.rs +++ b/moksha-core/src/keyset.rs @@ -15,23 +15,16 @@ use serde::{Deserialize, Serialize}; use std::collections::HashMap; use utoipa::ToSchema; -use base64::{engine::general_purpose, Engine as _}; + use bitcoin_hashes::{sha256, Hash}; use itertools::Itertools; -use rand::RngCore; use secp256k1::{PublicKey, Secp256k1, SecretKey}; use crate::{error::MokshaCoreError, primitives::CurrencyUnit}; const MAX_ORDER: u64 = 64; -pub fn generate_hash() -> String { - let mut rng = rand::thread_rng(); - let mut random = [0u8; 32]; - rng.fill_bytes(&mut random); - sha256::Hash::hash(&random).to_string() -} #[derive(Debug, Clone)] pub struct MintKeyset { @@ -42,17 +35,6 @@ pub struct MintKeyset { } impl MintKeyset { - pub fn legacy_new(seed: &str, derivation_path: &str) -> Self { - let priv_keys = derive_keys(seed, derivation_path); - let pub_keys = derive_pubkeys(&priv_keys); - Self { - private_keys: priv_keys, - keyset_id: legacy_derive_keyset_id(&pub_keys), - public_keys: pub_keys, - mint_pubkey: derive_pubkey(seed).expect("invalid seed"), - } - } - pub fn new(seed: &str, derivation_path: &str) -> Self { let priv_keys = derive_keys(seed, derivation_path); let pub_keys = derive_pubkeys(&priv_keys); @@ -65,45 +47,24 @@ impl MintKeyset { } } -#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, Default)] +// FIXME rename to keysets +#[derive(Clone, Debug, Serialize, Deserialize, Default, ToSchema, PartialEq, Eq)] pub struct Keysets { - pub keysets: Vec, -} - -impl Keysets { - pub fn new(keysets: Vec) -> Self { - Self { keysets } - } - - pub fn current_keyset( - &self, - mint_keys: &HashMap, - ) -> Result { - let computed_id = legacy_derive_keyset_id(mint_keys); - if self.keysets.contains(&computed_id) { - Ok(computed_id) - } else { - Err(MokshaCoreError::InvalidKeysetid) - } - } -} - -#[derive(Clone, Debug, Serialize, Deserialize, Default, ToSchema)] -pub struct V1Keysets { - pub keysets: Vec, + pub keysets: Vec, } -#[derive(Clone, Debug, Serialize, Deserialize, ToSchema)] -pub struct V1Keyset { +// FIXME rename to keyset +#[derive(Clone, Debug, Serialize, Deserialize, ToSchema, PartialEq, Eq)] +pub struct Keyset { pub id: String, // FIXME use KeysetId pub unit: CurrencyUnit, pub active: bool, } -impl V1Keysets { +impl Keysets { pub fn new(id: String, unit: CurrencyUnit, active: bool) -> Self { Self { - keysets: vec![V1Keyset { id, unit, active }], + keysets: vec![Keyset { id, unit, active }], } } @@ -210,25 +171,6 @@ pub fn derive_pubkeys(keys: &HashMap) -> HashMap .collect() } -/// Derives a keyset ID from a HashMap of public keys. -/// -/// # Arguments -/// -/// * `keys` - A HashMap of public keys. -/// -/// # Returns -/// -/// A string representing the derived keyset ID. -pub fn legacy_derive_keyset_id(keys: &HashMap) -> String { - let pubkeys_concat = keys - .iter() - .sorted_by(|(amt_a, _), (amt_b, _)| amt_a.cmp(amt_b)) - .map(|(_, pubkey)| pubkey) - .join(""); - let hashed_pubkeys = sha256::Hash::hash(pubkeys_concat.as_bytes()).to_byte_array(); - general_purpose::STANDARD.encode(hashed_pubkeys)[..12].to_string() -} - fn derive_keyset_id(keys: &HashMap) -> String { let pubkeys = keys .iter() @@ -256,16 +198,11 @@ pub fn derive_pubkey(seed: &str) -> Result { #[cfg(test)] mod tests { - use crate::keyset::{derive_pubkey, generate_hash, KeysetId}; + use crate::keyset::{derive_pubkey, KeysetId}; use pretty_assertions::assert_eq; use secp256k1::PublicKey; use std::collections::HashMap; - fn public_key_from_hex(hex: &str) -> secp256k1::PublicKey { - use hex::FromHex; - let input_vec: Vec = Vec::from_hex(hex).expect("Invalid Hex String"); - secp256k1::PublicKey::from_slice(&input_vec).expect("Invalid Public Key") - } #[test] fn test_keyset_id() -> anyhow::Result<()> { @@ -274,12 +211,6 @@ mod tests { Ok(()) } - #[test] - fn test_generate_hash() { - let hash = generate_hash(); - assert_eq!(hash.len(), 64); - } - #[test] fn test_derive_pubkey() -> anyhow::Result<()> { let result = derive_pubkey("supersecretprivatekey")?; @@ -290,18 +221,7 @@ mod tests { Ok(()) } - #[test] - fn test_derive_keys_master() -> anyhow::Result<()> { - let keys = super::derive_keys("master", "0/0/0/0"); - assert_eq!(keys.len(), 64); - - let pub_keys = super::derive_pubkeys(&keys); - let id = super::legacy_derive_keyset_id(&pub_keys); - assert_eq!("JHV8eUnoAln/", id); - assert_eq!(id.len(), 12); - Ok(()) - } - + #[test] fn test_derive_keys_master_v1() -> anyhow::Result<()> { let keys = super::derive_keys("supersecretprivatekey", ""); @@ -314,42 +234,6 @@ mod tests { Ok(()) } - // uses values from cashu test_mint.py - #[test] - fn test_derive_keys_cashu_py() -> anyhow::Result<()> { - let keys = super::derive_keys("TEST_PRIVATE_KEY", "0/0/0/0"); - assert_eq!(keys.len(), 64); - - let pub_keys = super::derive_pubkeys(&keys); - let id = super::legacy_derive_keyset_id(&pub_keys); - assert_eq!("1cCNIAZ2X/w1", id); - assert_eq!(id.len(), 12); - Ok(()) - } - - #[test] - fn test_legacy_derive_keyset_id() -> anyhow::Result<()> { - let mut pubs = HashMap::new(); - pubs.insert( - 1, - public_key_from_hex( - "02a9acc1e48c25eeeb9289b5031cc57da9fe72f3fe2861d264bdc074209b107ba2", - ), - ); - - pubs.insert( - 2, - public_key_from_hex( - "020000000000000000000000000000000000000000000000000000000000000001", - ), - ); - - let keyset_id = super::legacy_derive_keyset_id(&pubs); - - assert_eq!(keyset_id.len(), 12); - assert_eq!(keyset_id, "cNbjM0O6V/Kl"); - Ok(()) - } #[test] fn test_derive_keyset_id() -> anyhow::Result<()> { diff --git a/moksha-core/src/primitives.rs b/moksha-core/src/primitives.rs index c6795521..d97ee31c 100644 --- a/moksha-core/src/primitives.rs +++ b/moksha-core/src/primitives.rs @@ -20,15 +20,6 @@ pub struct PaymentRequest { pub hash: String, // TODO use sha256::Hash } -#[derive(Clone, Debug, Serialize, Deserialize, Default)] -pub struct PostMintResponse { - pub promises: Vec, -} - -#[derive(Clone, Debug, Serialize, Deserialize)] -pub struct PostMintRequest { - pub outputs: Vec, -} #[derive(Clone, Debug, Serialize, Deserialize)] pub struct CheckFeesRequest { @@ -41,36 +32,6 @@ pub struct CheckFeesResponse { pub fee: u64, } -#[derive(Clone, Debug, Serialize, Deserialize)] -pub struct PostMeltRequest { - pub proofs: Proofs, - pub pr: String, - pub outputs: Vec, -} - -#[derive(Clone, Debug, Serialize, Deserialize, Default)] -pub struct PostMeltResponse { - pub paid: bool, - pub preimage: String, - pub change: Vec, -} - -#[derive(Clone, Debug, Serialize, Deserialize)] -pub struct PostSplitRequest { - pub proofs: Proofs, - pub outputs: Vec, -} - -#[derive(Clone, Debug, Serialize, Deserialize, Default)] -pub struct PostSplitResponse { - pub promises: Vec, -} - -impl PostSplitResponse { - pub fn with_promises(promises: Vec) -> Self { - Self { promises } - } -} #[derive(Clone, Debug, Serialize, Deserialize, ToSchema)] pub struct PostSwapRequest { @@ -89,24 +50,7 @@ pub struct CashuErrorResponse { pub detail: String, } -#[skip_serializing_none] -#[derive(Deserialize, Serialize, Debug, PartialEq, Eq)] -pub struct MintLegacyInfoResponse { - pub name: Option, - pub pubkey: PublicKey, - pub version: Option, - pub description: Option, - pub description_long: Option, - pub contact: Option>>, - pub nuts: Vec, - pub motd: Option, - pub parameter: Parameter, -} -#[derive(Deserialize, Serialize, Debug, PartialEq, Eq, Default)] -pub struct Parameter { - pub peg_out_only: bool, -} #[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq, Default, ToSchema)] pub struct KeysResponse { @@ -581,7 +525,7 @@ mod tests { dhke::public_key_from_hex, fixture::read_fixture, primitives::{ - KeyResponse, MintInfoResponse, MintLegacyInfoResponse, Nuts, Parameter, + KeyResponse, MintInfoResponse, Nuts, PostSwapResponse, }, }; @@ -606,37 +550,7 @@ mod tests { Ok(()) } - #[test] - fn test_deserialize_legacy_mint_info() -> anyhow::Result<()> { - let mint_info = MintLegacyInfoResponse { - name: Some("Bob's Cashu mint".to_string()), - pubkey: public_key_from_hex( - "02a9acc1e48c25eeeb9289b5031cc57da9fe72f3fe2861d264bdc074209b107ba2", - ), - version: Some("Nutshell/0.11.0".to_string()), - description: Some("The short mint description".to_string()), - description_long: Some("A description that can be a long piece of text.".to_string()), - contact: Some(vec![ - vec!["email".to_string(), "contact@me.com".to_string()], - vec!["twitter".to_string(), "@me".to_string()], - vec!["nostr".to_string(), "npub...".to_string()], - ]), - nuts: vec![ - "NUT-07".to_string(), - "NUT-08".to_string(), - "NUT-08".to_string(), - ], - motd: Some("Message to display to users.".to_string()), - parameter: Parameter { - peg_out_only: false, - }, - }; - let out = serde_json::to_string_pretty(&mint_info)?; - println!("{}", out); - assert!(!out.is_empty()); - - Ok(()) - } + #[test] fn test_deserialize_mint_info() -> anyhow::Result<()> { diff --git a/moksha-mint/Cargo.toml b/moksha-mint/Cargo.toml index 34ec66e4..c3d5c244 100644 --- a/moksha-mint/Cargo.toml +++ b/moksha-mint/Cargo.toml @@ -59,3 +59,4 @@ hex = "0.4.3" http-body-util = "0.1.0" testcontainers = "0.15.0" testcontainers-modules = { version = "0.3.6", features = ["postgres"] } +pretty_assertions = "1.4.0" diff --git a/moksha-mint/src/fixtures/post_split_request_64_20.json b/moksha-mint/src/fixtures/post_swap_request_64_20.json similarity index 98% rename from moksha-mint/src/fixtures/post_split_request_64_20.json rename to moksha-mint/src/fixtures/post_swap_request_64_20.json index a27cee2d..7204624e 100644 --- a/moksha-mint/src/fixtures/post_split_request_64_20.json +++ b/moksha-mint/src/fixtures/post_swap_request_64_20.json @@ -1,5 +1,5 @@ { - "proofs": [ + "inputs": [ { "amount": 64, "secret": "sYYrrhUD3IwJzGFCGsUqqXXa", diff --git a/moksha-mint/src/fixtures/post_split_request_duplicate_key.json b/moksha-mint/src/fixtures/post_swap_request_duplicate_key.json similarity index 98% rename from moksha-mint/src/fixtures/post_split_request_duplicate_key.json rename to moksha-mint/src/fixtures/post_swap_request_duplicate_key.json index a18683b5..fa65fad2 100644 --- a/moksha-mint/src/fixtures/post_split_request_duplicate_key.json +++ b/moksha-mint/src/fixtures/post_swap_request_duplicate_key.json @@ -1,5 +1,5 @@ { - "proofs": [ + "inputs": [ { "amount": 64, "secret": "sYYrrhUD3IwJzGFCGsUqqXXa", diff --git a/moksha-mint/src/mint.rs b/moksha-mint/src/mint.rs index 2013b556..dd706a26 100644 --- a/moksha-mint/src/mint.rs +++ b/moksha-mint/src/mint.rs @@ -32,8 +32,6 @@ use crate::lightning::cln::ClnLightning; pub struct Mint { pub lightning: Arc, pub lightning_type: LightningType, - // FIXME remove after v1 api release - pub keyset_legacy: MintKeyset, pub keyset: MintKeyset, pub db: DB, pub dhke: Dhke, @@ -57,11 +55,6 @@ where Self { lightning, lightning_type, - keyset_legacy: MintKeyset::legacy_new( - // FIXME - &config.privatekey.clone(), - &config.derivation_path.clone().unwrap_or_default(), - ), keyset: MintKeyset::new( &config.privatekey.clone(), &config.derivation_path.clone().unwrap_or_default(), @@ -171,7 +164,7 @@ where let amount_promises = promises.total_amount(); if sum_proofs != amount_promises { return Err(MokshaMintError::SwapAmountMismatch(format!( - "Split amount mismatch: {sum_proofs} != {amount_promises}" + "Swap amount mismatch: {sum_proofs} != {amount_promises}" ))); } @@ -450,7 +443,8 @@ mod tests { use crate::model::{Invoice, PayInvoiceResult}; use moksha_core::blind::{BlindedMessage, TotalAmount}; use moksha_core::dhke; - use moksha_core::primitives::PostSplitRequest; + use moksha_core::fixture::read_fixture_as; + use moksha_core::primitives::PostSwapRequest; use moksha_core::proof::Proofs; use moksha_core::token::TokenV3; use std::str::FromStr; @@ -458,6 +452,7 @@ mod tests { use testcontainers::clients::Cli; use testcontainers::RunnableImage; use testcontainers_modules::postgres::Postgres; + use pretty_assertions::assert_eq; #[tokio::test] async fn test_fee_reserve() -> anyhow::Result<()> { @@ -495,7 +490,7 @@ mod tests { id: "00ffd48b8f5ecf80".to_owned(), }]; - let result = mint.create_blinded_signatures(&blinded_messages, &mint.keyset_legacy)?; + let result = mint.create_blinded_signatures(&blinded_messages, &mint.keyset)?; assert_eq!(1, result.len()); assert_eq!(8, result[0].amount); @@ -530,7 +525,7 @@ mod tests { moksha_core::primitives::PaymentMethod::Bolt11, "somehash".to_string(), &outputs, - &mint.keyset_legacy, + &mint.keyset, true, ) .await?; @@ -552,7 +547,7 @@ mod tests { ) .await?; - let outputs = create_blinded_msgs_from_fixture("blinded_messages_40.json".to_string())?; + let outputs = read_fixture_as::>("blinded_messages_40.json")?; let mut tx = mint.db.begin_tx().await?; let result = mint .mint_tokens( @@ -560,7 +555,7 @@ mod tests { moksha_core::primitives::PaymentMethod::Bolt11, "somehash".to_string(), &outputs, - &mint.keyset_legacy, + &mint.keyset, true, ) .await?; @@ -569,7 +564,7 @@ mod tests { } #[tokio::test] - async fn test_split_zero() -> anyhow::Result<()> { + async fn test_swap_zero() -> anyhow::Result<()> { let docker = Cli::default(); let image = create_postgres_image(); let node = docker.run(image); @@ -583,7 +578,7 @@ mod tests { let proofs = Proofs::empty(); let result = mint - .swap(&proofs, &blinded_messages, &mint.keyset_legacy) + .swap(&proofs, &blinded_messages, &mint.keyset) .await?; assert!(result.is_empty()); @@ -591,7 +586,7 @@ mod tests { } #[tokio::test] - async fn test_split_64_in_20() -> anyhow::Result<()> { + async fn test_swap_64_in_20() -> anyhow::Result<()> { let docker = Cli::default(); let image = create_postgres_image(); let node = docker.run(image); @@ -601,10 +596,10 @@ mod tests { None, ) .await?; - let request = create_request_from_fixture("post_split_request_64_20.json".to_string())?; + let request = read_fixture_as::("post_swap_request_64_20.json")?; let result = mint - .swap(&request.proofs, &request.outputs, &mint.keyset_legacy) + .swap(&request.inputs, &request.outputs, &mint.keyset) .await?; assert_eq!(result.total_amount(), 64); @@ -617,7 +612,7 @@ mod tests { } #[tokio::test] - async fn test_split_duplicate_key() -> anyhow::Result<()> { + async fn test_swap_duplicate_key() -> anyhow::Result<()> { let docker = Cli::default(); let image = create_postgres_image(); let node = docker.run(image); @@ -627,10 +622,10 @@ mod tests { ) .await?; let request = - create_request_from_fixture("post_split_request_duplicate_key.json".to_string())?; + read_fixture_as::("post_swap_request_duplicate_key.json")?; let result = mint - .swap(&request.proofs, &request.outputs, &mint.keyset_legacy) + .swap(&request.inputs, &request.outputs, &mint.keyset) .await; assert!(result.is_err()); Ok(()) @@ -673,10 +668,10 @@ mod tests { Some(Arc::new(MockBtcOnchain::default())), ); - let tokens = create_token_from_fixture("token_60.cashu".to_string())?; + let tokens = create_token_from_fixture("token_60.cashu").expect("can not read fixture"); let invoice = "some invoice".to_string(); let change = - create_blinded_msgs_from_fixture("blinded_messages_blank_4000.json".to_string())?; + read_fixture_as::>("blinded_messages_blank_4000.json")?; let mut tx = mint.db.begin_tx().await?; let (paid, _payment_hash, change) = mint @@ -686,7 +681,7 @@ mod tests { 4, &tokens.proofs(), &change, - &mint.keyset_legacy, + &mint.keyset, ) .await?; @@ -695,26 +690,12 @@ mod tests { Ok(()) } - // FIXME refactor helper functions - fn create_token_from_fixture(fixture: String) -> Result { + fn create_token_from_fixture(fixture: &str) -> Result { let base_dir = std::env::var("CARGO_MANIFEST_DIR")?; let raw_token = std::fs::read_to_string(format!("{base_dir}/src/fixtures/{fixture}"))?; Ok(raw_token.trim().to_string().try_into()?) } - - fn create_request_from_fixture(fixture: String) -> Result { - let base_dir = std::env::var("CARGO_MANIFEST_DIR")?; - let raw_token = std::fs::read_to_string(format!("{base_dir}/src/fixtures/{fixture}"))?; - Ok(serde_json::from_str::(&raw_token)?) - } - - fn create_blinded_msgs_from_fixture( - fixture: String, - ) -> Result, anyhow::Error> { - let base_dir = std::env::var("CARGO_MANIFEST_DIR")?; - let raw_token = std::fs::read_to_string(format!("{base_dir}/src/fixtures/{fixture}"))?; - Ok(serde_json::from_str::>(&raw_token)?) - } + async fn create_mint_from_mocks( mock_db: PostgresDB, diff --git a/moksha-mint/src/model.rs b/moksha-mint/src/model.rs index 365e7a08..37f74f3d 100644 --- a/moksha-mint/src/model.rs +++ b/moksha-mint/src/model.rs @@ -1,14 +1,6 @@ use serde::{Deserialize, Serialize}; -#[derive(Debug, Serialize, Deserialize)] -pub struct GetMintQuery { - pub amount: u64, -} -#[derive(Debug, Serialize, Deserialize)] -pub struct PostMintQuery { - pub hash: String, -} #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] pub struct Invoice { diff --git a/moksha-mint/src/routes/default.rs b/moksha-mint/src/routes/default.rs index 666cc7d1..d063a0c2 100644 --- a/moksha-mint/src/routes/default.rs +++ b/moksha-mint/src/routes/default.rs @@ -3,7 +3,7 @@ use axum::{ Json, }; use moksha_core::{ - keyset::V1Keysets, + keyset::Keysets, primitives::{ Bolt11MeltQuote, Bolt11MintQuote, CurrencyUnit, KeyResponse, KeysResponse, MintInfoResponse, Nuts, PaymentMethod, PostMeltBolt11Request, PostMeltBolt11Response, @@ -96,12 +96,12 @@ pub async fn get_keys_by_id( get, path = "/v1/keysets", responses( - (status = 200, description = "get keysets", body = [V1Keysets]) + (status = 200, description = "get keysets", body = [Keysets]) ), )] #[instrument(skip(mint), err)] -pub async fn get_keysets(State(mint): State) -> Result, MokshaMintError> { - Ok(Json(V1Keysets::new( +pub async fn get_keysets(State(mint): State) -> Result, MokshaMintError> { + Ok(Json(Keysets::new( mint.keyset.keyset_id, CurrencyUnit::Sat, true, diff --git a/moksha-mint/src/routes/legacy.rs b/moksha-mint/src/routes/legacy.rs deleted file mode 100644 index c5d90f6c..00000000 --- a/moksha-mint/src/routes/legacy.rs +++ /dev/null @@ -1,120 +0,0 @@ -use std::collections::HashMap; - -use axum::{ - extract::{Query, State}, - Json, -}; -use moksha_core::{ - keyset::{generate_hash, Keysets}, - primitives::{ - CheckFeesRequest, CheckFeesResponse, PaymentMethod, PaymentRequest, PostMeltRequest, - PostMeltResponse, PostMintRequest, PostMintResponse, PostSplitRequest, PostSplitResponse, - }, -}; -use secp256k1::PublicKey; -use tracing::{event, Level}; - -use crate::database::Database; -use crate::{ - error::MokshaMintError, - mint::Mint, - model::{GetMintQuery, PostMintQuery}, -}; - -pub async fn get_legacy_keys( - State(mint): State, -) -> Result>, MokshaMintError> { - Ok(Json(mint.keyset_legacy.public_keys)) -} - -pub async fn get_legacy_keysets( - State(mint): State, -) -> Result, MokshaMintError> { - Ok(Json(Keysets::new(vec![mint.keyset_legacy.keyset_id]))) -} - -pub async fn get_legacy_mint( - State(mint): State, - Query(mint_query): Query, -) -> Result, MokshaMintError> { - let (pr, hash) = mint - .create_invoice(generate_hash(), mint_query.amount) - .await?; - Ok(Json(PaymentRequest { pr, hash })) -} - -pub async fn post_legacy_mint( - State(mint): State, - Query(mint_query): Query, - Json(blinded_messages): Json, -) -> Result, MokshaMintError> { - event!( - Level::INFO, - "post_mint: {mint_query:#?} {blinded_messages:#?}" - ); - let mut tx = mint.db.begin_tx().await?; - - let promises = mint - .mint_tokens( - &mut tx, - PaymentMethod::Bolt11, - mint_query.hash, - &blinded_messages.outputs, - &mint.keyset_legacy, - true, - ) - .await?; - Ok(Json(PostMintResponse { promises })) -} - -pub async fn post_legacy_split( - State(mint): State, - Json(swap_request): Json, -) -> Result, MokshaMintError> { - let response = mint - .swap( - &swap_request.proofs, - &swap_request.outputs, - &mint.keyset_legacy, - ) - .await?; - - Ok(Json(PostSplitResponse::with_promises(response))) -} - -pub async fn post_legacy_melt( - State(mint): State, - Json(melt_request): Json, -) -> Result, MokshaMintError> { - let mut tx = mint.db.begin_tx().await?; - let (paid, preimage, change) = mint - .melt_bolt11( - &mut tx, - melt_request.pr, - 0, // FIXME set correct fee reserve for legacy api - &melt_request.proofs, - &melt_request.outputs, - &mint.keyset_legacy, - ) - .await?; - - tx.commit().await?; - Ok(Json(PostMeltResponse { - paid, - preimage, - change, - })) -} - -pub async fn post_legacy_check_fees( - State(mint): State, - Json(_check_fees): Json, -) -> Result, MokshaMintError> { - let invoice = mint.lightning.decode_invoice(_check_fees.pr).await?; - - Ok(Json(CheckFeesResponse { - fee: mint.fee_reserve(invoice.amount_milli_satoshis().ok_or_else(|| { - crate::error::MokshaMintError::InvalidAmount("invalid invoice".to_owned()) - })?), - })) -} diff --git a/moksha-mint/src/routes/mod.rs b/moksha-mint/src/routes/mod.rs index 8c40175e..9e643136 100644 --- a/moksha-mint/src/routes/mod.rs +++ b/moksha-mint/src/routes/mod.rs @@ -1,3 +1,2 @@ pub mod btconchain; pub mod default; -pub mod legacy; diff --git a/moksha-mint/src/server.rs b/moksha-mint/src/server.rs index 8eacb3cf..42c8a85d 100644 --- a/moksha-mint/src/server.rs +++ b/moksha-mint/src/server.rs @@ -1,4 +1,4 @@ -use crate::error::MokshaMintError; + use crate::routes::btconchain::{ get_melt_btconchain, get_melt_quote_btconchain, get_mint_quote_btconchain, post_melt_btconchain, post_melt_quote_btconchain, post_mint_btconchain, @@ -8,15 +8,15 @@ use crate::routes::default::{ get_info, get_keys, get_keys_by_id, get_keysets, get_melt_quote_bolt11, get_mint_quote_bolt11, post_melt_bolt11, post_melt_quote_bolt11, post_mint_bolt11, post_mint_quote_bolt11, post_swap, }; -use axum::extract::{Request, State}; +use axum::extract::Request; use axum::http::{HeaderName, HeaderValue, StatusCode}; use axum::middleware::Next; use axum::response::IntoResponse; -use axum::routing::{get_service, post}; +use axum::routing::{get_service, post, get}; use axum::{middleware, Router}; -use axum::{routing::get, Json}; -use moksha_core::keyset::{V1Keyset, V1Keysets}; + +use moksha_core::keyset::{Keyset, Keysets}; use moksha_core::proof::Proofs; use moksha_core::proof::{P2SHScript, Proof}; @@ -28,7 +28,7 @@ use moksha_core::blind::BlindedMessage; use moksha_core::blind::BlindedSignature; use moksha_core::primitives::{ CurrencyUnit, GetMeltBtcOnchainResponse, KeyResponse, KeysResponse, MintInfoResponse, - MintLegacyInfoResponse, Nut10, Nut11, Nut12, Nut17, Nut18, Nut4, Nut5, Nut7, Nut8, Nut9, Nuts, + Nut10, Nut11, Nut12, Nut17, Nut18, Nut4, Nut5, Nut7, Nut8, Nut9, Nuts, PaymentMethod, PostMeltBolt11Request, PostMeltBolt11Response, PostMeltQuoteBolt11Request, PostMeltQuoteBolt11Response, PostMeltQuoteBtcOnchainRequest, PostMeltQuoteBtcOnchainResponse, PostMintBolt11Request, PostMintBolt11Response, PostMintQuoteBolt11Request, @@ -43,10 +43,6 @@ use tracing::info; use utoipa::OpenApi; -use crate::routes::legacy::{ - get_legacy_keys, get_legacy_keysets, get_legacy_mint, post_legacy_check_fees, post_legacy_melt, - post_legacy_mint, post_legacy_split, -}; pub async fn run_server(mint: Mint) -> anyhow::Result<()> { if let Some(ref buildtime) = mint.build_params.build_time { @@ -134,8 +130,8 @@ pub async fn run_server(mint: Mint) -> anyhow::Result<()> { PaymentMethod, KeysResponse, KeyResponse, - V1Keysets, - V1Keyset, + Keysets, + Keyset, BlindedMessage, BlindedSignature, Proof, @@ -163,15 +159,7 @@ pub async fn run_server(mint: Mint) -> anyhow::Result<()> { struct ApiDoc; fn app(mint: Mint) -> Router { - let legacy_routes = Router::new() - .route("/keys", get(get_legacy_keys)) - .route("/keysets", get(get_legacy_keysets)) - .route("/mint", get(get_legacy_mint).post(post_legacy_mint)) - .route("/checkfees", post(post_legacy_check_fees)) - .route("/melt", post(post_legacy_melt)) - .route("/split", post(post_legacy_split)) - .route("/info", get(get_legacy_info)); - + let default_routes = Router::new() .merge(SwaggerUi::new("/swagger-ui").url("/api-docs/openapi.json", ApiDoc::openapi())) .route("/v1/keys", get(get_keys)) @@ -217,7 +205,6 @@ fn app(mint: Mint) -> Router { let prefix = server_config.api_prefix.unwrap_or_else(|| "".to_owned()); let router = Router::new() - .nest(&prefix, legacy_routes) .nest(&prefix, default_routes) .nest(&prefix, btconchain_routes) .nest("", general_routes) @@ -266,35 +253,6 @@ async fn add_response_headers( Ok(res) } -async fn get_legacy_info( - State(mint): State, -) -> Result, MokshaMintError> { - let mint_info = MintLegacyInfoResponse { - name: mint.config.info.name, - pubkey: mint.keyset_legacy.mint_pubkey, - version: match mint.config.info.version { - true => Some(mint.build_params.full_version()), - _ => None, - }, - description: mint.config.info.description, - description_long: mint.config.info.description_long, - contact: None, // FIXME set contact - nuts: vec![ - "NUT-00".to_string(), - "NUT-01".to_string(), - "NUT-02".to_string(), - "NUT-03".to_string(), - "NUT-04".to_string(), - "NUT-05".to_string(), - "NUT-06".to_string(), - "NUT-08".to_string(), - "NUT-09".to_string(), - ], - motd: mint.config.info.motd, - parameter: Default::default(), - }; - Ok(Json(mint_info)) -} #[utoipa::path( get, @@ -311,7 +269,7 @@ async fn get_health() -> impl IntoResponse { #[cfg(test)] mod tests { - use std::{collections::HashMap, sync::Arc}; + use std::sync::Arc; use crate::{ btconchain::MockBtcOnchain, @@ -325,10 +283,10 @@ mod tests { }; use http_body_util::BodyExt; use moksha_core::{ - keyset::{Keysets, V1Keysets}, - primitives::{CurrencyUnit, KeysResponse, MintLegacyInfoResponse}, + keyset::Keysets, + primitives::{CurrencyUnit, KeysResponse, MintInfoResponse}, }; - use secp256k1::PublicKey; + use testcontainers::{clients::Cli, RunnableImage}; use testcontainers_modules::postgres::Postgres; use tower::ServiceExt; @@ -338,6 +296,7 @@ mod tests { lightning::{LightningType, MockLightning}, mint::Mint, }; + use pretty_assertions::assert_eq; #[tokio::test] async fn test_get_keys() -> anyhow::Result<()> { @@ -347,13 +306,13 @@ mod tests { let app = app(create_mock_mint(Default::default(), node.get_host_port_ipv4(5432)).await?); let response = app - .oneshot(Request::builder().uri("/keys").body(Body::empty())?) + .oneshot(Request::builder().uri("/v1/keys").body(Body::empty())?) .await?; assert_eq!(response.status(), StatusCode::OK); let body = response.into_body().collect().await?.to_bytes(); - let keys: HashMap = serde_json::from_slice(&body)?; - assert_eq!(64, keys.len()); + let keys: KeysResponse = serde_json::from_slice(&body)?; + assert_eq!(64, keys.keysets[0].keys.len()); Ok(()) } @@ -365,47 +324,16 @@ mod tests { let app = app(create_mock_mint(Default::default(), node.get_host_port_ipv4(5432)).await?); let response = app - .oneshot(Request::builder().uri("/keysets").body(Body::empty())?) + .oneshot(Request::builder().uri("/v1/keysets").body(Body::empty())?) .await?; - assert_eq!(response.status(), StatusCode::OK); let body = response.into_body().collect().await?.to_bytes(); let keysets = serde_json::from_slice::(&body)?; - assert_eq!(Keysets::new(vec!["53eJP2+qJyTd".to_string()]), keysets); + assert_eq!(Keysets::new("00f545318e4fad2b".to_owned(), CurrencyUnit::Sat, true), keysets); Ok(()) } - #[tokio::test] - async fn test_get_info() -> anyhow::Result<()> { - let docker = Cli::default(); - let image = create_postgres_image(); - let node = docker.run(image); - - let mint_info_settings = MintInfoConfig { - name: Some("Bob's Cashu mint".to_string()), - version: true, - description: Some("A mint for testing".to_string()), - description_long: Some("A mint for testing long".to_string()), - ..Default::default() - }; - let app = app(create_mock_mint(mint_info_settings, node.get_host_port_ipv4(5432)).await?); - let response = app - .oneshot(Request::builder().uri("/info").body(Body::empty())?) - .await?; - - assert_eq!(response.status(), StatusCode::OK); - let body = response.into_body().collect().await?.to_bytes(); - let info = serde_json::from_slice::(&body)?; - assert!(!info.parameter.peg_out_only); - assert_eq!(info.nuts.len(), 9); - assert_eq!(info.name, Some("Bob's Cashu mint".to_string())); - assert_eq!(info.description, Some("A mint for testing".to_string())); - assert_eq!( - info.description_long, - Some("A mint for testing long".to_string()) - ); - Ok(()) - } + // FIXME remove duplicated code from mint.rs async fn create_mock_db_empty(port: u16) -> anyhow::Result { @@ -480,14 +408,12 @@ mod tests { assert_eq!(response.status(), StatusCode::OK); let body = response.into_body().collect().await?.to_bytes(); - let keysets = serde_json::from_slice::(&body)?; + let keysets = serde_json::from_slice::(&body)?; assert_eq!(1, keysets.keysets.len()); assert_eq!(16, keysets.keysets[0].id.len()); Ok(()) } - // ### v1 api tests - #[tokio::test] async fn test_get_v1_keys() -> anyhow::Result<()> { let docker = Cli::default(); @@ -572,7 +498,7 @@ mod tests { assert_eq!(response.status(), StatusCode::OK); let body = response.into_body().collect().await?.to_bytes(); - let keys: V1Keysets = serde_json::from_slice(&body)?; + let keys: Keysets = serde_json::from_slice(&body)?; assert_eq!(1, keys.keysets.len()); let keyset = keys.keysets.first().expect("keyset not found"); assert!(keyset.active); @@ -595,4 +521,34 @@ mod tests { assert_eq!(response.status(), StatusCode::OK); Ok(()) } + + #[tokio::test] + async fn test_get_info() -> anyhow::Result<()> { + let docker = Cli::default(); + let image = create_postgres_image(); + let node = docker.run(image); + + let mint_info_settings = MintInfoConfig { + name: Some("Bob's Cashu mint".to_string()), + version: true, + description: Some("A mint for testing".to_string()), + description_long: Some("A mint for testing long".to_string()), + ..Default::default() + }; + let app = app(create_mock_mint(mint_info_settings, node.get_host_port_ipv4(5432)).await?); + let response = app + .oneshot(Request::builder().uri("/v1/info").body(Body::empty())?) + .await?; + + assert_eq!(response.status(), StatusCode::OK); + let body = response.into_body().collect().await?.to_bytes(); + let info = serde_json::from_slice::(&body)?; + assert_eq!(info.name, Some("Bob's Cashu mint".to_string())); + assert_eq!(info.description, Some("A mint for testing".to_string())); + assert_eq!( + info.description_long, + Some("A mint for testing long".to_string()) + ); + Ok(()) + } } diff --git a/moksha-wallet/src/client/crossplatform.rs b/moksha-wallet/src/client/crossplatform.rs index b3db8982..fda03676 100644 --- a/moksha-wallet/src/client/crossplatform.rs +++ b/moksha-wallet/src/client/crossplatform.rs @@ -2,7 +2,7 @@ use async_trait::async_trait; use moksha_core::{ blind::BlindedMessage, - keyset::V1Keysets, + keyset::Keysets, primitives::{ CurrencyUnit, GetMeltBtcOnchainResponse, KeysResponse, MintInfoResponse, PostMeltBolt11Request, PostMeltBolt11Response, PostMeltBtcOnchainRequest, @@ -36,7 +36,7 @@ impl CashuClient for CrossPlatformHttpClient { .await } - async fn get_keysets(&self, mint_url: &Url) -> Result { + async fn get_keysets(&self, mint_url: &Url) -> Result { self.do_get(&mint_url.join("v1/keysets")?).await } diff --git a/moksha-wallet/src/client/mod.rs b/moksha-wallet/src/client/mod.rs index 23482094..33d44b70 100644 --- a/moksha-wallet/src/client/mod.rs +++ b/moksha-wallet/src/client/mod.rs @@ -1,7 +1,7 @@ use async_trait::async_trait; use moksha_core::{ blind::BlindedMessage, - keyset::V1Keysets, + keyset::Keysets, primitives::{ CurrencyUnit, GetMeltBtcOnchainResponse, KeysResponse, MintInfoResponse, PostMeltBolt11Response, PostMeltBtcOnchainResponse, PostMeltQuoteBolt11Response, @@ -31,7 +31,7 @@ pub trait CashuClient { keyset_id: String, ) -> Result; - async fn get_keysets(&self, mint_url: &Url) -> Result; + async fn get_keysets(&self, mint_url: &Url) -> Result; async fn post_swap( &self, diff --git a/moksha-wallet/src/fixtures/post_split_response_24_40.json b/moksha-wallet/src/fixtures/post_swap_response_24_40.json similarity index 100% rename from moksha-wallet/src/fixtures/post_split_response_24_40.json rename to moksha-wallet/src/fixtures/post_swap_response_24_40.json diff --git a/moksha-wallet/src/wallet.rs b/moksha-wallet/src/wallet.rs index 9f6e3d1c..874e0ab7 100644 --- a/moksha-wallet/src/wallet.rs +++ b/moksha-wallet/src/wallet.rs @@ -281,7 +281,7 @@ where let selected_tokens = (wallet_keyset.mint_url.to_owned(), selected_proofs.clone()).into(); let (remaining_tokens, result) = self - .split_tokens(wallet_keyset, &selected_tokens, amount.into()) + .swap_tokens(wallet_keyset, &selected_tokens, amount.into()) .await?; let mut tx = self.localstore.begin_tx().await?; @@ -303,7 +303,7 @@ where ) -> Result<(), MokshaWalletError> { let total_amount = tokens.total_amount(); let (_, redeemed_tokens) = self - .split_tokens(wallet_keyset, tokens, total_amount.into()) + .swap_tokens(wallet_keyset, tokens, total_amount.into()) .await?; let mut tx = self.localstore.begin_tx().await?; self.localstore @@ -355,8 +355,8 @@ where let total_proofs = { let selected_tokens = (wallet_keyset.mint_url.to_owned(), selected_proofs.clone()).into(); - let split_result = self - .split_tokens(wallet_keyset, &selected_tokens, ln_amount.into()) + let swap_result = self + .swap_tokens(wallet_keyset, &selected_tokens, ln_amount.into()) .await?; let mut tx = self.localstore.begin_tx().await?; @@ -364,11 +364,11 @@ where .delete_proofs(&mut tx, &selected_proofs) .await?; self.localstore - .add_proofs(&mut tx, &split_result.0.proofs()) + .add_proofs(&mut tx, &swap_result.0.proofs()) .await?; tx.commit().await?; - split_result.1.proofs() + swap_result.1.proofs() }; let fee_blind = self @@ -455,17 +455,17 @@ where let total_proofs = { let selected_tokens = (wallet_keyset.mint_url.to_owned(), selected_proofs.clone()).into(); - let split_result = self - .split_tokens(wallet_keyset, &selected_tokens, ln_amount.into()) + let swap_result = self + .swap_tokens(wallet_keyset, &selected_tokens, ln_amount.into()) .await?; self.localstore .delete_proofs(&mut tx, &selected_proofs) .await?; self.localstore - .add_proofs(&mut tx, &split_result.0.proofs()) + .add_proofs(&mut tx, &swap_result.0.proofs()) .await?; - split_result.1.proofs() + swap_result.1.proofs() }; let melt_response = self @@ -514,7 +514,7 @@ where Ok(secret_range) } - pub async fn split_tokens( + pub async fn swap_tokens( &self, wallet_keyset: &WalletKeyset, tokens: &TokenV3, @@ -839,7 +839,7 @@ mod tests { use crate::wallet::WalletBuilder; use moksha_core::fixture::{read_fixture, read_fixture_as}; - use moksha_core::keyset::{KeysetId, MintKeyset, V1Keysets}; + use moksha_core::keyset::{KeysetId, MintKeyset, Keysets}; use moksha_core::primitives::{ CurrencyUnit, KeyResponse, KeysResponse, PaymentMethod, PostMeltBolt11Response, PostMeltQuoteBolt11Response, PostMintBolt11Response, PostSwapResponse, @@ -858,7 +858,7 @@ mod tests { }; let keys_response = KeysResponse::new(key_response.clone()); let keys_by_id_response = keys_response.clone(); - let keysets = V1Keysets::new(keys.keyset_id, CurrencyUnit::Sat, true); + let keysets = Keysets::new(keys.keyset_id, CurrencyUnit::Sat, true); let mut client = MockCashuClient::default(); client @@ -990,8 +990,8 @@ mod tests { } #[tokio::test] - async fn test_split() -> anyhow::Result<()> { - let split_response = read_fixture_as::("post_split_response_24_40.json")?; + async fn test_swap() -> anyhow::Result<()> { + let split_response = read_fixture_as::("post_swap_response_24_40.json")?; let mut client = create_mock(); client .expect_post_swap() @@ -1009,7 +1009,7 @@ mod tests { .await?; let tokens = read_fixture("token_64.cashu")?.try_into()?; - let result = wallet.split_tokens(&keyset, &tokens, 20.into()).await?; + let result = wallet.swap_tokens(&keyset, &tokens, 20.into()).await?; let first = result.0; @@ -1069,7 +1069,7 @@ mod tests { .expect_post_melt_quote_bolt11() .returning(move |_, _, _| Ok(quote_response.clone())); - let swap_response = read_fixture_as::("post_split_response_24_40.json")?; + let swap_response = read_fixture_as::("post_swap_response_24_40.json")?; mock_client .expect_post_swap() .returning(move |_, _, _| Ok(swap_response.clone())); @@ -1123,7 +1123,7 @@ mod tests { mock_client .expect_post_melt_quote_bolt11() .returning(move |_, _, _| Ok(quote_response.clone())); - let swap_response = read_fixture_as::("post_split_response_24_40.json")?; + let swap_response = read_fixture_as::("post_swap_response_24_40.json")?; mock_client .expect_post_swap() .returning(move |_, _, _| Ok(swap_response.clone()));