Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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" }
Expand Down
24 changes: 12 additions & 12 deletions crates/bcr-ebill-api/src/external/mint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -139,14 +139,14 @@ impl MintClient {
Ok(quote_client)
}

pub fn key_client(&self, mint_url: &url::Url) -> Result<KeysClient> {
let key_client = KeysClient::new(mint_url.to_owned());
Ok(key_client)
pub fn core_client(&self, mint_url: &url::Url) -> Result<CoreClient> {
let core_client = CoreClient::new(mint_url.to_owned());
Ok(core_client)
}

pub fn swap_client(&self, mint_url: &url::Url) -> Result<SwapClient> {
let swap_client = SwapClient::new(mint_url.to_owned());
Ok(swap_client)
pub fn treasury_client(&self, mint_url: &url::Url) -> Result<TreasuryClient> {
let treasury_client = TreasuryClient::new(mint_url.to_owned());
Ok(treasury_client)
}
}

Expand Down Expand Up @@ -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| {
Expand All @@ -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| {
Expand Down Expand Up @@ -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| {
Expand All @@ -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| {
Expand Down
19 changes: 1 addition & 18 deletions crates/bcr-ebill-api/src/service/bill_service/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions crates/bcr-ebill-api/src/service/bill_service/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(()));
Expand Down
1 change: 1 addition & 0 deletions crates/bcr-ebill-persistence/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
10 changes: 7 additions & 3 deletions crates/bcr-ebill-persistence/src/db/mint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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<MintRequestDb> = 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()
}

Expand Down