|
@@ -49,6 +49,17 @@ post_cache_wrapper!(post_swap, SwapRequest, SwapResponse);
|
|
|
post_cache_wrapper!(post_mint_bolt11, MintBolt11Request, MintBolt11Response);
|
|
|
post_cache_wrapper!(post_melt_bolt11, MeltBolt11Request, MeltQuoteBolt11Response);
|
|
|
|
|
|
+#[cfg_attr(feature = "swagger", utoipa::path(
|
|
|
+ get,
|
|
|
+ context_path = "/v1",
|
|
|
+ path = "/keys",
|
|
|
+ responses(
|
|
|
+ (status = 200, description = "Successful response", body = KeysResponse, content_type = "application/json")
|
|
|
+ )
|
|
|
+))]
|
|
|
+/// Get the public keys of the newest mint keyset
|
|
|
+///
|
|
|
+/// This endpoint returns a dictionary of all supported token values of the mint and their associated public key.
|
|
|
pub async fn get_keys(State(state): State<MintState>) -> Result<Json<KeysResponse>, Response> {
|
|
|
let pubkeys = state.mint.pubkeys().await.map_err(|err| {
|
|
|
tracing::error!("Could not get keys: {}", err);
|
|
@@ -58,6 +69,21 @@ pub async fn get_keys(State(state): State<MintState>) -> Result<Json<KeysRespons
|
|
|
Ok(Json(pubkeys))
|
|
|
}
|
|
|
|
|
|
+#[cfg_attr(feature = "swagger", utoipa::path(
|
|
|
+ get,
|
|
|
+ context_path = "/v1",
|
|
|
+ path = "/keys/{keyset_id}",
|
|
|
+ params(
|
|
|
+ ("keyset_id" = String, description = "The keyset ID"),
|
|
|
+ ),
|
|
|
+ responses(
|
|
|
+ (status = 200, description = "Successful response", body = KeysResponse, content_type = "application/json"),
|
|
|
+ (status = 500, description = "Server error", body = ErrorResponse, content_type = "application/json")
|
|
|
+ )
|
|
|
+))]
|
|
|
+/// Get the public keys of a specific keyset
|
|
|
+///
|
|
|
+/// Get the public keys of the mint from a specific keyset ID.
|
|
|
pub async fn get_keyset_pubkeys(
|
|
|
State(state): State<MintState>,
|
|
|
Path(keyset_id): Path<Id>,
|
|
@@ -70,15 +96,40 @@ pub async fn get_keyset_pubkeys(
|
|
|
Ok(Json(pubkeys))
|
|
|
}
|
|
|
|
|
|
+#[cfg_attr(feature = "swagger", utoipa::path(
|
|
|
+ get,
|
|
|
+ context_path = "/v1",
|
|
|
+ path = "/keysets",
|
|
|
+ responses(
|
|
|
+ (status = 200, description = "Successful response", body = KeysetResponse, content_type = "application/json"),
|
|
|
+ (status = 500, description = "Server error", body = ErrorResponse, content_type = "application/json")
|
|
|
+ )
|
|
|
+))]
|
|
|
+/// Get all active keyset IDs of the mint
|
|
|
+///
|
|
|
+/// This endpoint returns a list of keysets that the mint currently supports and will accept tokens from.
|
|
|
pub async fn get_keysets(State(state): State<MintState>) -> Result<Json<KeysetResponse>, Response> {
|
|
|
- let mint = state.mint.keysets().await.map_err(|err| {
|
|
|
- tracing::error!("Could not get keyset: {}", err);
|
|
|
+ let keysets = state.mint.keysets().await.map_err(|err| {
|
|
|
+ tracing::error!("Could not get keysets: {}", err);
|
|
|
into_response(err)
|
|
|
})?;
|
|
|
|
|
|
- Ok(Json(mint))
|
|
|
+ Ok(Json(keysets))
|
|
|
}
|
|
|
|
|
|
+#[cfg_attr(feature = "swagger", utoipa::path(
|
|
|
+ post,
|
|
|
+ context_path = "/v1",
|
|
|
+ path = "/mint/quote/bolt11",
|
|
|
+ request_body(content = MintQuoteBolt11Request, description = "Request params", content_type = "application/json"),
|
|
|
+ responses(
|
|
|
+ (status = 200, description = "Successful response", body = MintQuoteBolt11Response, content_type = "application/json"),
|
|
|
+ (status = 500, description = "Server error", body = ErrorResponse, content_type = "application/json")
|
|
|
+ )
|
|
|
+))]
|
|
|
+/// Request a quote for minting of new tokens
|
|
|
+///
|
|
|
+/// Request minting of new tokens. The mint responds with a Lightning invoice. This endpoint can be used for a Lightning invoice UX flow.
|
|
|
pub async fn get_mint_bolt11_quote(
|
|
|
State(state): State<MintState>,
|
|
|
Json(payload): Json<MintQuoteBolt11Request>,
|
|
@@ -92,6 +143,21 @@ pub async fn get_mint_bolt11_quote(
|
|
|
Ok(Json(quote))
|
|
|
}
|
|
|
|
|
|
+#[cfg_attr(feature = "swagger", utoipa::path(
|
|
|
+ get,
|
|
|
+ context_path = "/v1",
|
|
|
+ path = "/mint/quote/bolt11/{quote_id}",
|
|
|
+ params(
|
|
|
+ ("quote_id" = String, description = "The quote ID"),
|
|
|
+ ),
|
|
|
+ responses(
|
|
|
+ (status = 200, description = "Successful response", body = MintQuoteBolt11Response, content_type = "application/json"),
|
|
|
+ (status = 500, description = "Server error", body = ErrorResponse, content_type = "application/json")
|
|
|
+ )
|
|
|
+))]
|
|
|
+/// Get mint quote by ID
|
|
|
+///
|
|
|
+/// Get mint quote state.
|
|
|
pub async fn get_check_mint_bolt11_quote(
|
|
|
State(state): State<MintState>,
|
|
|
Path(quote_id): Path<String>,
|
|
@@ -108,6 +174,21 @@ pub async fn get_check_mint_bolt11_quote(
|
|
|
Ok(Json(quote))
|
|
|
}
|
|
|
|
|
|
+#[cfg_attr(feature = "swagger", utoipa::path(
|
|
|
+ post,
|
|
|
+ context_path = "/v1",
|
|
|
+ path = "/mint/bolt11",
|
|
|
+ request_body(content = MintBolt11Request, description = "Request params", content_type = "application/json"),
|
|
|
+ responses(
|
|
|
+ (status = 200, description = "Successful response", body = MintBolt11Response, content_type = "application/json"),
|
|
|
+ (status = 500, description = "Server error", body = ErrorResponse, content_type = "application/json")
|
|
|
+ )
|
|
|
+))]
|
|
|
+/// Mint tokens by paying a BOLT11 Lightning invoice.
|
|
|
+///
|
|
|
+/// Requests the minting of tokens belonging to a paid payment request.
|
|
|
+///
|
|
|
+/// Call this endpoint after `POST /v1/mint/quote`.
|
|
|
pub async fn post_mint_bolt11(
|
|
|
State(state): State<MintState>,
|
|
|
Json(payload): Json<MintBolt11Request>,
|
|
@@ -124,6 +205,17 @@ pub async fn post_mint_bolt11(
|
|
|
Ok(Json(res))
|
|
|
}
|
|
|
|
|
|
+#[cfg_attr(feature = "swagger", utoipa::path(
|
|
|
+ post,
|
|
|
+ context_path = "/v1",
|
|
|
+ path = "/melt/quote/bolt11",
|
|
|
+ request_body(content = MeltQuoteBolt11Request, description = "Quote params", content_type = "application/json"),
|
|
|
+ responses(
|
|
|
+ (status = 200, description = "Successful response", body = MeltQuoteBolt11Response, content_type = "application/json"),
|
|
|
+ (status = 500, description = "Server error", body = ErrorResponse, content_type = "application/json")
|
|
|
+ )
|
|
|
+))]
|
|
|
+/// Request a quote for melting tokens
|
|
|
pub async fn get_melt_bolt11_quote(
|
|
|
State(state): State<MintState>,
|
|
|
Json(payload): Json<MeltQuoteBolt11Request>,
|
|
@@ -137,6 +229,21 @@ pub async fn get_melt_bolt11_quote(
|
|
|
Ok(Json(quote))
|
|
|
}
|
|
|
|
|
|
+#[cfg_attr(feature = "swagger", utoipa::path(
|
|
|
+ get,
|
|
|
+ context_path = "/v1",
|
|
|
+ path = "/melt/quote/bolt11/{quote_id}",
|
|
|
+ params(
|
|
|
+ ("quote_id" = String, description = "The quote ID"),
|
|
|
+ ),
|
|
|
+ responses(
|
|
|
+ (status = 200, description = "Successful response", body = MeltQuoteBolt11Response, content_type = "application/json"),
|
|
|
+ (status = 500, description = "Server error", body = ErrorResponse, content_type = "application/json")
|
|
|
+ )
|
|
|
+))]
|
|
|
+/// Get melt quote by ID
|
|
|
+///
|
|
|
+/// Get melt quote state.
|
|
|
pub async fn get_check_melt_bolt11_quote(
|
|
|
State(state): State<MintState>,
|
|
|
Path(quote_id): Path<String>,
|
|
@@ -153,6 +260,19 @@ pub async fn get_check_melt_bolt11_quote(
|
|
|
Ok(Json(quote))
|
|
|
}
|
|
|
|
|
|
+#[cfg_attr(feature = "swagger", utoipa::path(
|
|
|
+ post,
|
|
|
+ context_path = "/v1",
|
|
|
+ path = "/melt/bolt11",
|
|
|
+ request_body(content = MeltBolt11Request, description = "Melt params", content_type = "application/json"),
|
|
|
+ responses(
|
|
|
+ (status = 200, description = "Successful response", body = MeltQuoteBolt11Response, content_type = "application/json"),
|
|
|
+ (status = 500, description = "Server error", body = ErrorResponse, content_type = "application/json")
|
|
|
+ )
|
|
|
+))]
|
|
|
+/// Melt tokens for a Bitcoin payment that the mint will make for the user in exchange
|
|
|
+///
|
|
|
+/// Requests tokens to be destroyed and sent out via Lightning.
|
|
|
pub async fn post_melt_bolt11(
|
|
|
State(state): State<MintState>,
|
|
|
Json(payload): Json<MeltBolt11Request>,
|
|
@@ -166,6 +286,19 @@ pub async fn post_melt_bolt11(
|
|
|
Ok(Json(res))
|
|
|
}
|
|
|
|
|
|
+#[cfg_attr(feature = "swagger", utoipa::path(
|
|
|
+ post,
|
|
|
+ context_path = "/v1",
|
|
|
+ path = "/checkstate",
|
|
|
+ request_body(content = CheckStateRequest, description = "State params", content_type = "application/json"),
|
|
|
+ responses(
|
|
|
+ (status = 200, description = "Successful response", body = CheckStateResponse, content_type = "application/json"),
|
|
|
+ (status = 500, description = "Server error", body = ErrorResponse, content_type = "application/json")
|
|
|
+ )
|
|
|
+))]
|
|
|
+/// Check whether a proof is spent already or is pending in a transaction
|
|
|
+///
|
|
|
+/// Check whether a secret has been spent already or not.
|
|
|
pub async fn post_check(
|
|
|
State(state): State<MintState>,
|
|
|
Json(payload): Json<CheckStateRequest>,
|
|
@@ -178,10 +311,34 @@ pub async fn post_check(
|
|
|
Ok(Json(state))
|
|
|
}
|
|
|
|
|
|
+#[cfg_attr(feature = "swagger", utoipa::path(
|
|
|
+ get,
|
|
|
+ context_path = "/v1",
|
|
|
+ path = "/info",
|
|
|
+ responses(
|
|
|
+ (status = 200, description = "Successful response", body = MintInfo)
|
|
|
+ )
|
|
|
+))]
|
|
|
+/// Mint information, operator contact information, and other info
|
|
|
pub async fn get_mint_info(State(state): State<MintState>) -> Result<Json<MintInfo>, Response> {
|
|
|
Ok(Json(state.mint.mint_info().clone().time(unix_time())))
|
|
|
}
|
|
|
|
|
|
+#[cfg_attr(feature = "swagger", utoipa::path(
|
|
|
+ post,
|
|
|
+ context_path = "/v1",
|
|
|
+ path = "/swap",
|
|
|
+ request_body(content = SwapRequest, description = "Swap params", content_type = "application/json"),
|
|
|
+ responses(
|
|
|
+ (status = 200, description = "Successful response", body = SwapResponse, content_type = "application/json"),
|
|
|
+ (status = 500, description = "Server error", body = ErrorResponse, content_type = "application/json")
|
|
|
+ )
|
|
|
+))]
|
|
|
+/// Swap inputs for outputs of the same value
|
|
|
+///
|
|
|
+/// Requests a set of Proofs to be swapped for another set of BlindSignatures.
|
|
|
+///
|
|
|
+/// This endpoint can be used by Alice to swap a set of proofs before making a payment to Carol. It can then used by Carol to redeem the tokens for new proofs.
|
|
|
pub async fn post_swap(
|
|
|
State(state): State<MintState>,
|
|
|
Json(payload): Json<SwapRequest>,
|
|
@@ -197,6 +354,17 @@ pub async fn post_swap(
|
|
|
Ok(Json(swap_response))
|
|
|
}
|
|
|
|
|
|
+#[cfg_attr(feature = "swagger", utoipa::path(
|
|
|
+ post,
|
|
|
+ context_path = "/v1",
|
|
|
+ path = "/restore",
|
|
|
+ request_body(content = RestoreRequest, description = "Restore params", content_type = "application/json"),
|
|
|
+ responses(
|
|
|
+ (status = 200, description = "Successful response", body = RestoreResponse, content_type = "application/json"),
|
|
|
+ (status = 500, description = "Server error", body = ErrorResponse, content_type = "application/json")
|
|
|
+ )
|
|
|
+))]
|
|
|
+/// Restores blind signature for a set of outputs.
|
|
|
pub async fn post_restore(
|
|
|
State(state): State<MintState>,
|
|
|
Json(payload): Json<RestoreRequest>,
|