anya_core/api/
models.rs

1use serde::{Deserialize, Serialize};
2
3// Authentication
4#[derive(Debug, Deserialize)]
5pub struct LoginRequest {
6    pub username: String,
7    pub password: String,
8}
9
10#[derive(Debug, Serialize)]
11pub struct LoginResponse {
12    pub token: String,
13    pub expires_at: i64,
14}
15
16// Bitcoin wallet
17#[derive(Debug, Deserialize)]
18pub struct CreateWalletRequest {
19    pub name: Option<String>,
20    pub wallet_type: Option<String>,
21}
22
23#[derive(Debug, Serialize)]
24pub struct WalletResponse {
25    pub id: String,
26    pub network: String,
27    pub address_count: usize,
28    pub wallet_type: String,
29    pub created_at: i64,
30    pub updated_at: i64,
31}
32
33#[derive(Debug, Deserialize)]
34pub struct GenerateAddressRequest {
35    pub wallet_id: String,
36}
37
38#[derive(Debug, Serialize)]
39pub struct AddressResponse {
40    pub address: String,
41    pub path: String,
42    pub index: u32,
43}
44
45#[derive(Debug, Deserialize)]
46pub struct SendTransactionRequest {
47    pub wallet_id: String,
48    pub to_address: String,
49    pub amount_sats: u64,
50    pub fee_rate: Option<u64>,
51}
52
53#[derive(Debug, Serialize)]
54pub struct TransactionResponse {
55    pub txid: String,
56    pub hex: String,
57    pub fee: u64,
58}
59
60#[derive(Debug, Serialize)]
61pub struct BalanceResponse {
62    pub confirmed: u64,
63    pub unconfirmed: u64,
64    pub total: u64,
65}
66
67// Web5/DID
68#[derive(Debug, Deserialize)]
69pub struct CreateIdentityRequest {
70    pub name: Option<String>,
71}
72
73#[derive(Debug, Serialize)]
74pub struct IdentityResponse {
75    pub id: String,
76    pub did: String,
77    pub created_at: i64,
78    pub updated_at: i64,
79}
80
81#[derive(Debug, Deserialize)]
82pub struct CreateCredentialRequest {
83    pub subject_did: String,
84    pub claims: serde_json::Value,
85    pub expiration: Option<i64>,
86}
87
88#[derive(Debug, Serialize)]
89pub struct CredentialResponse {
90    pub id: String,
91    pub vc: serde_json::Value,
92    pub issuer: String,
93    pub subject: String,
94    pub created_at: i64,
95}
96
97// DLC
98#[derive(Debug, Deserialize)]
99pub struct CreateDlcRequest {
100    pub oracle_pubkey: String,
101    pub collateral_amount: u64,
102    pub outcomes: Vec<DlcOutcomeRequest>,
103}
104
105#[derive(Debug, Deserialize)]
106pub struct DlcOutcomeRequest {
107    pub outcome_value: String,
108    pub payout_to_offerer: u64,
109}
110
111#[derive(Debug, Serialize)]
112pub struct DlcResponse {
113    pub id: String,
114    pub status: String,
115    pub contract_id: String,
116    pub funding_txid: Option<String>,
117    pub created_at: i64,
118}
119
120// System info
121#[derive(Debug, Serialize)]
122pub struct SystemInfoResponse {
123    pub version: String,
124    pub network: String,
125    pub block_height: u32,
126    pub uptime: u64,
127    pub peer_count: usize,
128}