From 6074461b710bd70dcf877a86edac136a76ac78db Mon Sep 17 00:00:00 2001 From: Mario Zupan Date: Thu, 5 Mar 2026 16:18:05 +0100 Subject: [PATCH] Fix minting URL and use latest bcr-common --- CHANGELOG.md | 4 ++++ Cargo.toml | 4 ++-- crates/bcr-ebill-api/src/external/mint.rs | 24 +++++++++---------- .../src/service/bill_service/service.rs | 19 +-------------- .../src/service/bill_service/tests.rs | 8 ------- crates/bcr-ebill-persistence/src/constants.rs | 1 + crates/bcr-ebill-persistence/src/db/mint.rs | 10 +++++--- 7 files changed, 27 insertions(+), 43 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bdeae1df..dc00c9d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.5.3 + +* Fix minting URL and use new bcr-common + # 0.5.2 * Add proper block validation for Company blocks diff --git a/Cargo.toml b/Cargo.toml index 6cc4c86b..bfd1e6b4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace.package] -version = "0.5.2" +version = "0.5.3" edition = "2024" license = "MIT" repository = "https://github.com/BitcreditProtocol/Bitcredit-Core" @@ -68,7 +68,7 @@ bcr-ebill-core = { path = "./crates/bcr-ebill-core" } bcr-ebill-api = { path = "./crates/bcr-ebill-api" } bcr-ebill-persistence = { path = "./crates/bcr-ebill-persistence" } bcr-ebill-transport = { path = "./crates/bcr-ebill-transport" } -bcr-common = { git = "https://github.com/BitcreditProtocol/bcr-common", rev = "6b904cca832f00df5997a9d1e241b5139c2859b5" } +bcr-common = { git = "https://github.com/BitcreditProtocol/bcr-common", rev = "42ee734f0486304a9dfb0b16ec052a4d5d956356" } surrealdb = { version = "2.3", default-features = false } strum = { version = "0.27", features = ["derive"] } url = { version = "2.5" } diff --git a/crates/bcr-ebill-api/src/external/mint.rs b/crates/bcr-ebill-api/src/external/mint.rs index f343926b..b3a8339b 100644 --- a/crates/bcr-ebill-api/src/external/mint.rs +++ b/crates/bcr-ebill-api/src/external/mint.rs @@ -2,9 +2,9 @@ use std::str::FromStr; use async_trait::async_trait; use bcr_common::cashu::{self, ProofsMethods, State, nut01 as cdk01, nut02 as cdk02}; -use bcr_common::client::keys::Client as KeysClient; +use bcr_common::client::core::Client as CoreClient; use bcr_common::client::quote::Client as QuoteClient; -use bcr_common::client::swap::Client as SwapClient; +use bcr_common::client::treasury::Client as TreasuryClient; use bcr_common::wire::quotes::{ResolveOffer, StatusReply}; use bcr_ebill_core::protocol::Sum; use bcr_ebill_core::{ @@ -139,14 +139,14 @@ impl MintClient { Ok(quote_client) } - pub fn key_client(&self, mint_url: &url::Url) -> Result { - let key_client = KeysClient::new(mint_url.to_owned()); - Ok(key_client) + pub fn core_client(&self, mint_url: &url::Url) -> Result { + let core_client = CoreClient::new(mint_url.to_owned()); + Ok(core_client) } - pub fn swap_client(&self, mint_url: &url::Url) -> Result { - let swap_client = SwapClient::new(mint_url.to_owned()); - Ok(swap_client) + pub fn treasury_client(&self, mint_url: &url::Url) -> Result { + let treasury_client = TreasuryClient::new(mint_url.to_owned()); + Ok(treasury_client) } } @@ -174,7 +174,7 @@ impl MintClientApi for MintClient { })?; let keyset_info = self - .key_client(mint_url)? + .core_client(mint_url)? .keyset_info(keyset_id_parsed) .await .map_err(|e| { @@ -189,7 +189,7 @@ impl MintClientApi for MintClient { .map_err(|_| Error::PubKey)?; let proof_states = self - .swap_client(mint_url)? + .core_client(mint_url)? .check_state(ys) .await .map_err(|e| { @@ -219,7 +219,7 @@ impl MintClientApi for MintClient { .map_err(|_| Error::PrivateKey)?; let qid = quote_id.to_owned(); let currency = self - .key_client(mint_url)? + .core_client(mint_url)? .keyset_info(keyset.id) .await .map_err(|e| { @@ -230,7 +230,7 @@ impl MintClientApi for MintClient { // mint let blinded_signatures = self - .key_client(mint_url)? + .treasury_client(mint_url)? .mint(qid, blinded_messages, secret_key) .await .map_err(|e| { diff --git a/crates/bcr-ebill-api/src/service/bill_service/service.rs b/crates/bcr-ebill-api/src/service/bill_service/service.rs index 1bc3e832..5aa3f014 100644 --- a/crates/bcr-ebill-api/src/service/bill_service/service.rs +++ b/crates/bcr-ebill-api/src/service/bill_service/service.rs @@ -375,24 +375,7 @@ impl BillService { &mint_request.mint_request_id ); - // check status to check minting-status - let updated_status = self - .mint_client - .lookup_quote_for_mint( - &mint_cfg.default_mint_url, - &mint_request.mint_request_id, - ) - .await?; - - if matches!(updated_status, QuoteStatusReply::Accepted { .. }) { - info!( - "Quote {} is accepted, but minting not enabled - skipping", - mint_request.mint_request_id - ); - return Ok(()); - } - - // Quote is Accepted and Minting Enabled - attempt to mint + // Quote is MintingEnabled - attempt to mint // check keyset and try to mint and create tokens and persist match self .mint_client diff --git a/crates/bcr-ebill-api/src/service/bill_service/tests.rs b/crates/bcr-ebill-api/src/service/bill_service/tests.rs index b03aa5da..dfcc23b0 100644 --- a/crates/bcr-ebill-api/src/service/bill_service/tests.rs +++ b/crates/bcr-ebill-api/src/service/bill_service/tests.rs @@ -6881,14 +6881,6 @@ async fn check_mint_state_minting_enabled_proofs() { ctx.mint_client .expect_mint() .returning(|_, _, _, _, _, _, _| Ok("proofs".into())); - ctx.mint_client - .expect_lookup_quote_for_mint() - .returning(|_, _| { - Ok(QuoteStatusReply::MintingEnabled { - minted_amount: bcr_common::cashu::Amount::ZERO, - keyset_id: cdk02::Id::try_from("00c7b45973e5f0fc".to_owned()).unwrap(), - }) - }); ctx.mint_store .expect_add_recovery_data_to_offer() .returning(|_, _, _| Ok(())); diff --git a/crates/bcr-ebill-persistence/src/constants.rs b/crates/bcr-ebill-persistence/src/constants.rs index 24168910..959feb4a 100644 --- a/crates/bcr-ebill-persistence/src/constants.rs +++ b/crates/bcr-ebill-persistence/src/constants.rs @@ -28,6 +28,7 @@ pub const DB_STATUS_LAST_CHECKED_TIMESTAMP: &str = "status_last_checked_timestam pub const DB_STATUS_OFFERED: &str = "status_offered"; pub const DB_STATUS_PENDING: &str = "status_pending"; pub const DB_STATUS_ACCEPTED: &str = "status_accepted"; +pub const DB_STATUS_MINTINGENABLED: &str = "status_mintingenabled"; pub const DB_MINT_NODE_ID: &str = "mint_node_id"; pub const DB_MINT_REQUEST_ID: &str = "mint_request_id"; pub const DB_PROOFS: &str = "proofs"; diff --git a/crates/bcr-ebill-persistence/src/db/mint.rs b/crates/bcr-ebill-persistence/src/db/mint.rs index 89465d0b..79bc53ee 100644 --- a/crates/bcr-ebill-persistence/src/db/mint.rs +++ b/crates/bcr-ebill-persistence/src/db/mint.rs @@ -16,8 +16,8 @@ use crate::{ Error, constants::{ DB_BILL_ID, DB_MINT_NODE_ID, DB_MINT_REQUEST_ID, DB_MINT_REQUESTER_NODE_ID, DB_PROOFS, - DB_PROOFS_SPENT, DB_RECOVERY_DATA, DB_STATUS, DB_STATUS_ACCEPTED, DB_STATUS_OFFERED, - DB_STATUS_PENDING, DB_TABLE, + DB_PROOFS_SPENT, DB_RECOVERY_DATA, DB_STATUS, DB_STATUS_ACCEPTED, DB_STATUS_MINTINGENABLED, + DB_STATUS_OFFERED, DB_STATUS_PENDING, DB_TABLE, }, mint::MintStoreApi, }; @@ -80,8 +80,12 @@ impl MintStoreApi for SurrealMintStore { bindings.add(DB_STATUS_OFFERED, MintRequestStatusDb::Offered)?; bindings.add(DB_STATUS_PENDING, MintRequestStatusDb::Pending)?; bindings.add(DB_STATUS_ACCEPTED, MintRequestStatusDb::Accepted)?; + bindings.add( + DB_STATUS_MINTINGENABLED, + MintRequestStatusDb::MintingEnabled, + )?; let results: Vec = self.db - .query("SELECT * from type::table($table) WHERE status = $status_offered OR status = $status_pending OR status = $status_accepted", bindings).await?; + .query("SELECT * from type::table($table) WHERE status = $status_offered OR status = $status_pending OR status = $status_accepted OR status = $status_mintingenabled", bindings).await?; results.into_iter().map(|c| c.try_into()).collect() }