Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into nostr-nip-60-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcaseria committed Oct 28, 2024
2 parents 850bb76 + 09b5a55 commit dac9845
Show file tree
Hide file tree
Showing 61 changed files with 1,359 additions and 520 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jobs:
-p cdk --no-default-features,
-p cdk --no-default-features --features wallet,
-p cdk --no-default-features --features mint,
-p cdk --no-default-features --features "mint swagger",
-p cdk-redb,
-p cdk-sqlite,
-p cdk-axum,
Expand Down Expand Up @@ -143,6 +144,7 @@ jobs:
-p cdk --no-default-features,
-p cdk --no-default-features --features wallet,
-p cdk --no-default-features --features mint,
-p cdk --no-default-features --features "mint swagger",
-p cdk-axum,
-p cdk-strike,
-p cdk-lnbits,
Expand Down
24 changes: 23 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,39 @@
- cdk: Bump `lightning-invoice` to `0.32.2` ([prusnak]).
- cdk: Bump `lightning` to `0.0.124` ([prusnak]).
- cdk: `PaymentMethod` as a `non_exhaustive` enum ([thesimplekid]).
- cdk: `CurrencyUnit` as a `non_exhaustive` enum ([thesimpekid]).
- cdk: `CurrencyUnit` as a `non_exhaustive` enum ([thesimplekid]).
- cdk: Enforce token is single mint ([thesimplekid]).
- cdk: Mint will return change for over paid melt even over fee reserve ([davidcaseria]).
- cdk: Refactor ln_backeds to be on the `cdk::Mint` and not with axum ([thesimplekid]).
- cdk: Change is returned in the check quote response ([thesimplekid]).
- cdk: Move unit conversion util fn to amount module ([davidcaseria]).
- cdk: Remove spent proofs from db when check state is called ([mubarak23]).
- cdk: Use `MintUrl` directly in wallet client ([ok300]).
- cdk-cli: Change cdk-cli pay command to melt ([mubarak23]).


### Added
- cdk: Added description to `MintQuoteBolt11Request` ([lollerfirst]).
- cdk(wallet): Added description to `mint_quote` ([lollerfirst]).
- cdk: Add `amount` and `fee_paid` to `Melted` ([davidcaseria]).
- cdk: Add `from_proofs` on `Melted` ([davidcaseria]).
- cdk: Add unit on `PaymentResponse` ([thesimplekid]).
- cdk: Add description for mint quote ([lollerfirst]).
- cdk-axum: Add cache to some endpoints ([lollerfirst]).
- cdk: Add Proofs trait ([ok300]).
- cdk: Wallet verifiys keyset id when first fetching keys ([thesimplekid]).
- cdk-mind: Add swagger docs ([ok300]).
- cdk: NUT18 payment request support ([thesimplekid]).

### Removed
- cdk: Remove `MintMeltSettings` since it is no longer used ([lollerfirst]).
- cdk: `PaymentMethod::Custom` ([thesimplekid]).
- cdk: Remove deprecated `MeltBolt11Response` ([thesimplekid]).

### Fixed
- cdk: Check of inputs to include fee ([thesimplekid]).
- cdk: Make unit mandatory in tokenv4 ([ok300]).




Expand Down Expand Up @@ -174,4 +195,5 @@ Additionally, this release introduces a Mint binary cdk-mintd that uses the cdk-
[ok300]: https://github.com/ok300
[lollerfirst]: https://github.com/lollerfirst
[prusnak]: https://github.com/prusnak
[mubarak23]: https://github.com/mubarak23

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
> **Warning**
> This project is in early development, it does however work with real sats! Always use amounts you don't mind loosing.
> This project is in early development, it does however work with real sats! Always use amounts you don't mind losing.

# Cashu Development Kit
Expand Down
4 changes: 4 additions & 0 deletions crates/cdk-axum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ axum = "0.6.20"
cdk = { path = "../cdk", version = "0.4.0", default-features = false, features = ["mint"] }
tokio = { version = "1", default-features = false }
tracing = { version = "0.1", default-features = false, features = ["attributes", "log"] }
utoipa = { version = "4", features = ["preserve_order", "preserve_path_order"], optional = true }
futures = { version = "0.3.28", default-features = false }
moka = { version = "0.11.1", features = ["future"] }
serde_json = "1"
paste = "1.0.15"

[features]
swagger = ["cdk/swagger", "dep:utoipa"]
111 changes: 110 additions & 1 deletion crates/cdk-axum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,133 @@
#![warn(rustdoc::bare_urls)]

use std::sync::Arc;
use std::time::Duration;

use anyhow::Result;
use axum::routing::{get, post};
use axum::Router;
use cdk::mint::Mint;
use moka::future::Cache;
use router_handlers::*;
use std::time::Duration;

mod router_handlers;

#[cfg(feature = "swagger")]
mod swagger_imports {
pub use cdk::amount::Amount;
pub use cdk::error::{ErrorCode, ErrorResponse};
pub use cdk::nuts::nut00::{
BlindSignature, BlindedMessage, CurrencyUnit, PaymentMethod, Proof, Witness,
};
pub use cdk::nuts::nut01::{Keys, KeysResponse, PublicKey, SecretKey};
pub use cdk::nuts::nut02::{Id, KeySet, KeySetInfo, KeySetVersion, KeysetResponse};
pub use cdk::nuts::nut03::{SwapRequest, SwapResponse};
pub use cdk::nuts::nut04;
pub use cdk::nuts::nut04::{
MintBolt11Request, MintBolt11Response, MintMethodSettings, MintQuoteBolt11Request,
MintQuoteBolt11Response,
};
pub use cdk::nuts::nut05;
pub use cdk::nuts::nut05::{
MeltBolt11Request, MeltMethodSettings, MeltQuoteBolt11Request, MeltQuoteBolt11Response,
};
pub use cdk::nuts::nut06::{ContactInfo, MintInfo, MintVersion, Nuts, SupportedSettings};
pub use cdk::nuts::nut07::{CheckStateRequest, CheckStateResponse, ProofState, State};
pub use cdk::nuts::nut09::{RestoreRequest, RestoreResponse};
pub use cdk::nuts::nut11::P2PKWitness;
pub use cdk::nuts::nut12::{BlindSignatureDleq, ProofDleq};
pub use cdk::nuts::nut14::HTLCWitness;
pub use cdk::nuts::nut15;
pub use cdk::nuts::nut15::{Mpp, MppMethodSettings};
pub use cdk::nuts::{MeltQuoteState, MintQuoteState};
}

#[cfg(feature = "swagger")]
use swagger_imports::*;

/// CDK Mint State
#[derive(Clone)]
pub struct MintState {
mint: Arc<Mint>,
cache: Cache<String, String>,
}

#[cfg(feature = "swagger")]
#[derive(utoipa::OpenApi)]
#[openapi(
components(schemas(
Amount,
BlindedMessage,
BlindSignature,
BlindSignatureDleq,
CheckStateRequest,
CheckStateResponse,
ContactInfo,
CurrencyUnit,
ErrorCode,
ErrorResponse,
HTLCWitness,
Id,
Keys,
KeysResponse,
KeysetResponse,
KeySet,
KeySetInfo,
KeySetVersion,
MeltBolt11Request,
MeltQuoteBolt11Request,
MeltQuoteBolt11Response,
MeltQuoteState,
MeltMethodSettings,
MintBolt11Request,
MintBolt11Response,
MintInfo,
MintQuoteBolt11Request,
MintQuoteBolt11Response,
MintQuoteState,
MintMethodSettings,
MintVersion,
Mpp,
MppMethodSettings,
Nuts,
P2PKWitness,
PaymentMethod,
Proof,
ProofDleq,
ProofState,
PublicKey,
RestoreRequest,
RestoreResponse,
SecretKey,
State,
SupportedSettings,
SwapRequest,
SwapResponse,
Witness,
nut04::Settings,
nut05::Settings,
nut15::Settings
)),
info(description = "Cashu CDK mint APIs", title = "cdk-mintd",),
paths(
get_keys,
get_keyset_pubkeys,
get_keysets,
get_mint_info,
get_mint_bolt11_quote,
get_check_mint_bolt11_quote,
post_mint_bolt11,
get_melt_bolt11_quote,
get_check_melt_bolt11_quote,
post_melt_bolt11,
post_swap,
post_check,
post_restore
)
)]
/// OpenAPI spec for the mint's v1 APIs
pub struct ApiDocV1;

/// Create mint [`Router`] with required endpoints for cashu mint
pub async fn create_mint_router(mint: Arc<Mint>, cache_ttl: u64, cache_tti: u64) -> Result<Router> {
let state = MintState {
Expand Down
Loading

0 comments on commit dac9845

Please sign in to comment.