use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct RegisterResponse {
pub user_id: String,
pub primary_key: String,
pub secondary_key: String,
pub recovery_passphrase: String,
}
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct MeResponse {
pub user_id: String,
pub key_name: Option<String>,
pub wallet_id: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct WalletResponse {
pub wallet_id: String,
pub name: String,
pub balance: i64,
pub on_hold: i64,
pub available: i64,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct UpdateWalletRequest {
pub name: String,
}
impl UpdateWalletRequest {
pub fn new(name: impl Into<String>) -> Self {
Self { name: name.into() }
}
}
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct CreateWalletResponse {
pub wallet_id: String,
pub name: String,
pub address: String,
}
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct WalletListItem {
pub wallet_id: String,
pub name: String,
}
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct WalletKeyResponse {
pub key: String,
}
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct WalletKeyInfoResponse {
pub hint: String,
pub created_at: Option<String>,
pub last_used_at: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct RotateApiKeyResponse {
pub key: String,
pub name: String,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
#[non_exhaustive]
pub enum InvoiceStatus {
Pending,
Settled,
Expired,
#[serde(other)]
Unknown,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CreateInvoiceRequest {
pub amount: i64,
#[serde(skip_serializing_if = "Option::is_none")]
pub reference: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub memo: Option<String>,
}
impl CreateInvoiceRequest {
pub fn new(amount: i64) -> Self {
Self {
amount,
reference: None,
memo: None,
}
}
#[must_use]
pub fn memo(mut self, memo: impl Into<String>) -> Self {
self.memo = Some(memo.into());
self
}
#[must_use]
pub fn reference(mut self, reference: impl Into<String>) -> Self {
self.reference = Some(reference.into());
self
}
}
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct InvoiceResponse {
pub number: i32,
pub status: InvoiceStatus,
pub amount: i64,
pub bolt11: String,
pub reference: Option<String>,
pub memo: Option<String>,
pub preimage: Option<String>,
pub tx_number: Option<i32>,
pub created_at: Option<String>,
pub settled_at: Option<String>,
pub expires_at: Option<String>,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CreateInvoiceForWalletRequest {
pub wallet_id: String,
pub amount: i64,
#[serde(skip_serializing_if = "Option::is_none")]
pub reference: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub comment: Option<String>,
}
impl CreateInvoiceForWalletRequest {
pub fn new(wallet_id: impl Into<String>, amount: i64) -> Self {
Self {
wallet_id: wallet_id.into(),
amount,
reference: None,
comment: None,
}
}
#[must_use]
pub fn reference(mut self, reference: impl Into<String>) -> Self {
self.reference = Some(reference.into());
self
}
#[must_use]
pub fn comment(mut self, comment: impl Into<String>) -> Self {
self.comment = Some(comment.into());
self
}
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CreateInvoiceForAddressRequest {
pub address: String,
pub amount: i64,
#[serde(skip_serializing_if = "Option::is_none")]
pub tag: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub comment: Option<String>,
}
impl CreateInvoiceForAddressRequest {
pub fn new(address: impl Into<String>, amount: i64) -> Self {
Self {
address: address.into(),
amount,
tag: None,
comment: None,
}
}
#[must_use]
pub fn tag(mut self, tag: impl Into<String>) -> Self {
self.tag = Some(tag.into());
self
}
#[must_use]
pub fn comment(mut self, comment: impl Into<String>) -> Self {
self.comment = Some(comment.into());
self
}
}
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct AddressInvoiceResponse {
pub bolt11: String,
pub amount: i64,
pub expires_at: Option<String>,
}
#[derive(Debug, Clone, Default)]
pub struct ListParams {
pub limit: Option<i32>,
pub after: Option<i32>,
}
impl ListParams {
#[must_use]
pub fn limit(mut self, limit: i32) -> Self {
self.limit = Some(limit);
self
}
#[must_use]
pub fn after(mut self, after: i32) -> Self {
self.after = Some(after);
self
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum InvoiceEventType {
Settled,
Expired,
Unknown(String),
}
impl From<&str> for InvoiceEventType {
fn from(s: &str) -> Self {
match s {
"settled" => Self::Settled,
"expired" => Self::Expired,
other => Self::Unknown(other.to_string()),
}
}
}
#[derive(Debug, Clone)]
#[non_exhaustive]
pub struct InvoiceEvent {
pub event: InvoiceEventType,
pub data: InvoiceResponse,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
#[non_exhaustive]
pub enum PaymentStatus {
Pending,
Processing,
Settled,
Failed,
#[serde(other)]
Unknown,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CreatePaymentRequest {
pub target: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub amount: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub idempotency_key: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub max_fee: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub reference: Option<String>,
}
impl CreatePaymentRequest {
pub fn new(target: impl Into<String>) -> Self {
Self {
target: target.into(),
amount: None,
idempotency_key: None,
max_fee: None,
reference: None,
}
}
#[must_use]
pub fn amount(mut self, amount: i64) -> Self {
self.amount = Some(amount);
self
}
#[must_use]
pub fn idempotency_key(mut self, key: impl Into<String>) -> Self {
self.idempotency_key = Some(key.into());
self
}
#[must_use]
pub fn max_fee(mut self, fee: i64) -> Self {
self.max_fee = Some(fee);
self
}
#[must_use]
pub fn reference(mut self, reference: impl Into<String>) -> Self {
self.reference = Some(reference.into());
self
}
}
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct PaymentResponse {
pub number: i32,
pub status: PaymentStatus,
pub amount: i64,
pub max_fee: i64,
pub service_fee: i64,
pub actual_fee: Option<i64>,
pub address: String,
pub reference: Option<String>,
pub preimage: Option<String>,
pub tx_number: Option<i32>,
pub failure_reason: Option<String>,
pub created_at: Option<String>,
pub settled_at: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct ResolveTargetResponse {
pub target: String,
#[serde(rename = "type")]
pub target_type: String,
pub amount: Option<i64>,
pub description: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum PaymentEventType {
Settled,
Failed,
Unknown(String),
}
impl From<&str> for PaymentEventType {
fn from(s: &str) -> Self {
match s {
"settled" => Self::Settled,
"failed" => Self::Failed,
other => Self::Unknown(other.to_string()),
}
}
}
#[derive(Debug, Clone)]
#[non_exhaustive]
pub struct PaymentEvent {
pub event: PaymentEventType,
pub data: PaymentResponse,
}
#[derive(Debug, Clone, Serialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct CreateAddressRequest {
#[serde(skip_serializing_if = "Option::is_none")]
pub address: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct AddressResponse {
pub address: String,
pub generated: bool,
pub cost: i64,
pub created_at: Option<String>,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct TransferAddressRequest {
pub target_wallet_key: String,
}
impl TransferAddressRequest {
pub fn new(target_wallet_key: impl Into<String>) -> Self {
Self {
target_wallet_key: target_wallet_key.into(),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct TransferAddressResponse {
pub address: String,
pub transferred_to: String,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
#[non_exhaustive]
pub enum TransactionType {
Credit,
Debit,
#[serde(other)]
Unknown,
}
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct TransactionResponse {
pub number: i32,
#[serde(rename = "type")]
pub tx_type: TransactionType,
pub amount: i64,
pub balance_after: i64,
pub network_fee: i64,
pub service_fee: i64,
pub payment_hash: Option<String>,
pub preimage: Option<String>,
pub reference: Option<String>,
pub note: Option<String>,
pub created_at: Option<String>,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CreateWebhookRequest {
pub url: String,
}
impl CreateWebhookRequest {
pub fn new(url: impl Into<String>) -> Self {
Self { url: url.into() }
}
}
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct CreateWebhookResponse {
pub id: String,
pub url: String,
pub secret: String,
pub created_at: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct WebhookResponse {
pub id: String,
pub url: String,
pub active: bool,
pub created_at: Option<String>,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct WalletEvent {
pub event: String,
pub created_at: String,
pub data: serde_json::Value,
}
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
#[non_exhaustive]
pub struct RecoveryBackupResponse {
pub passphrase: String,
}
#[derive(Debug, Clone, Serialize)]
pub struct RecoveryRestoreRequest {
pub passphrase: String,
}
impl RecoveryRestoreRequest {
pub fn new(passphrase: impl Into<String>) -> Self {
Self {
passphrase: passphrase.into(),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct RecoveryRestoreResponse {
pub wallet_id: String,
pub name: String,
pub primary_key: String,
pub secondary_key: String,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct BackupPasskeyBeginResponse {
pub session_id: String,
pub options: HashMap<String, serde_json::Value>,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct BackupPasskeyCompleteRequest {
pub session_id: String,
pub attestation: HashMap<String, serde_json::Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct RestorePasskeyBeginResponse {
pub session_id: String,
pub options: HashMap<String, serde_json::Value>,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct RestorePasskeyCompleteRequest {
pub session_id: String,
pub assertion: HashMap<String, serde_json::Value>,
}
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct RestorePasskeyCompleteResponse {
pub wallet_id: String,
pub name: String,
pub primary_key: String,
pub secondary_key: String,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CreateL402ChallengeRequest {
pub amount: i64,
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub expiry_seconds: Option<i32>,
#[serde(skip_serializing_if = "Option::is_none")]
pub caveats: Option<Vec<String>>,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct L402ChallengeResponse {
pub macaroon: String,
pub invoice: String,
pub payment_hash: String,
pub expires_at: String,
pub www_authenticate: String,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct VerifyL402Request {
pub authorization: String,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct VerifyL402Response {
pub valid: bool,
pub payment_hash: Option<String>,
pub caveats: Option<Vec<String>>,
pub error: Option<String>,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct PayL402Request {
pub www_authenticate: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub max_fee: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub reference: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub wait: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub timeout: Option<i32>,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct L402PayResponse {
pub authorization: Option<String>,
pub payment_hash: String,
pub preimage: Option<String>,
pub amount: i64,
pub fee: Option<i64>,
pub payment_number: i32,
pub status: String,
}