1use crate::imports::*;
9use crate::tx::{Fees, GeneratorSummary, PaymentDestination};
10use kaspa_addresses::Address;
11
12#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
13#[serde(rename_all = "camelCase")]
14pub struct PingRequest {
15 pub message: Option<String>,
16}
17
18#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
19#[serde(rename_all = "camelCase")]
20pub struct PingResponse {
21 pub message: Option<String>,
22}
23
24#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
25#[serde(rename_all = "camelCase")]
26pub struct BatchRequest {}
27
28#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
29#[serde(rename_all = "camelCase")]
30pub struct BatchResponse {}
31
32#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
33#[serde(rename_all = "camelCase")]
34pub struct FlushRequest {
35 pub wallet_secret: Secret,
36}
37
38#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
39#[serde(rename_all = "camelCase")]
40pub struct FlushResponse {}
41
42#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
43#[serde(rename_all = "camelCase")]
44pub struct ConnectRequest {
45 pub url: Option<String>,
46 pub network_id: NetworkId,
47 pub retry_on_error: bool,
49 pub block_async_connect: bool,
52 pub require_sync: bool,
54}
55
56impl Default for ConnectRequest {
57 fn default() -> Self {
58 Self {
59 url: None,
60 network_id: NetworkId::new(NetworkType::Mainnet),
61 retry_on_error: true,
62 block_async_connect: true,
63 require_sync: true,
64 }
65 }
66}
67
68impl ConnectRequest {
69 pub fn with_url(self, url: Option<String>) -> Self {
70 ConnectRequest { url, ..self }
71 }
72
73 pub fn with_network_id(self, network_id: &NetworkId) -> Self {
74 ConnectRequest { network_id: *network_id, ..self }
75 }
76
77 pub fn with_retry_on_error(self, retry_on_error: bool) -> Self {
78 ConnectRequest { retry_on_error, ..self }
79 }
80
81 pub fn with_block_async_connect(self, block_async_connect: bool) -> Self {
82 ConnectRequest { block_async_connect, ..self }
83 }
84
85 pub fn with_require_sync(self, require_sync: bool) -> Self {
86 ConnectRequest { require_sync, ..self }
87 }
88}
89
90#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
91#[serde(rename_all = "camelCase")]
92pub struct ConnectResponse {}
93
94#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
95#[serde(rename_all = "camelCase")]
96pub struct DisconnectRequest {}
97
98#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
99#[serde(rename_all = "camelCase")]
100pub struct DisconnectResponse {}
101
102#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
103#[serde(rename_all = "camelCase")]
104pub struct ChangeNetworkIdRequest {
105 pub network_id: NetworkId,
106}
107
108#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
109#[serde(rename_all = "camelCase")]
110pub struct ChangeNetworkIdResponse {}
111
112#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
113#[serde(rename_all = "camelCase")]
114pub struct RetainContextRequest {
115 pub name: String,
116 pub data: Option<Vec<u8>>,
117}
118
119#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
120#[serde(rename_all = "camelCase")]
121pub struct RetainContextResponse {}
122
123#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
124#[serde(rename_all = "camelCase")]
125pub struct GetContextRequest {
126 pub name: String,
127}
128
129#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
130#[serde(rename_all = "camelCase")]
131pub struct GetContextResponse {
132 pub data: Option<Vec<u8>>,
133}
134
135#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
136#[serde(rename_all = "camelCase")]
137pub struct GetStatusRequest {
138 pub name: Option<String>,
139}
140
141#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
142#[serde(rename_all = "camelCase")]
143pub struct GetStatusResponse {
144 pub is_connected: bool,
145 pub is_synced: bool,
146 pub is_open: bool,
147 pub url: Option<String>,
148 pub is_wrpc_client: bool,
149 pub network_id: Option<NetworkId>,
150 pub context: Option<Arc<Vec<u8>>>,
151 pub wallet_descriptor: Option<WalletDescriptor>,
152 pub account_descriptors: Option<Vec<AccountDescriptor>>,
153 pub selected_account_id: Option<AccountId>,
154}
155
156#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
159#[serde(rename_all = "camelCase")]
160pub struct WalletEnumerateRequest {}
161
162#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
163#[serde(rename_all = "camelCase")]
164pub struct WalletEnumerateResponse {
165 pub wallet_descriptors: Vec<WalletDescriptor>,
166}
167
168#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
169#[serde(rename_all = "camelCase")]
170pub struct WalletCreateRequest {
171 pub wallet_secret: Secret,
172 pub wallet_args: WalletCreateArgs,
173}
174
175#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
176#[serde(rename_all = "camelCase")]
177pub struct WalletCreateResponse {
178 pub storage_descriptor: StorageDescriptor,
179 pub wallet_descriptor: WalletDescriptor,
180}
181
182#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
183#[serde(rename_all = "camelCase")]
184pub struct WalletOpenRequest {
185 pub wallet_secret: Secret,
186 pub filename: Option<String>,
187 pub account_descriptors: bool,
188 pub legacy_accounts: Option<bool>,
189}
190
191#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
192#[serde(rename_all = "camelCase")]
193pub struct WalletOpenResponse {
194 pub account_descriptors: Option<Vec<AccountDescriptor>>,
195}
196
197#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
198#[serde(rename_all = "camelCase")]
199pub struct WalletCloseRequest {}
200
201#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
202#[serde(rename_all = "camelCase")]
203pub struct WalletCloseResponse {}
204
205#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
206#[serde(rename_all = "camelCase")]
207pub struct WalletReloadRequest {
208 pub reactivate: bool,
209}
210
211#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
212#[serde(rename_all = "camelCase")]
213pub struct WalletReloadResponse {}
214
215#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
216#[serde(rename_all = "camelCase")]
217pub struct WalletRenameRequest {
218 pub title: Option<String>,
219 pub filename: Option<String>,
220 pub wallet_secret: Secret,
221}
222
223#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
224#[serde(rename_all = "camelCase")]
225pub struct WalletRenameResponse {}
226
227#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
228#[serde(rename_all = "camelCase")]
229pub struct WalletRenameFileResponse {}
230
231#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
232#[serde(rename_all = "camelCase")]
233pub struct WalletChangeSecretRequest {
234 pub old_wallet_secret: Secret,
235 pub new_wallet_secret: Secret,
236}
237
238#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
239#[serde(rename_all = "camelCase")]
240pub struct WalletChangeSecretResponse {}
241
242#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
243#[serde(rename_all = "camelCase")]
244pub struct WalletExportRequest {
245 pub wallet_secret: Secret,
246 pub include_transactions: bool,
247}
248
249#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
250#[serde(rename_all = "camelCase")]
251pub struct WalletExportResponse {
252 pub wallet_data: Vec<u8>,
253}
254
255#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
256#[serde(rename_all = "camelCase")]
257pub struct WalletImportRequest {
258 pub wallet_secret: Secret,
259 pub wallet_data: Vec<u8>,
260}
261
262#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
263#[serde(rename_all = "camelCase")]
264pub struct WalletImportResponse {
265 pub wallet_descriptor: WalletDescriptor,
266}
267
268#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
269#[serde(rename_all = "camelCase")]
270pub struct PrvKeyDataEnumerateRequest {}
271
272#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
273#[serde(rename_all = "camelCase")]
274pub struct PrvKeyDataEnumerateResponse {
275 pub prv_key_data_list: Vec<Arc<PrvKeyDataInfo>>,
276}
277
278#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
279#[serde(rename_all = "camelCase")]
280pub struct PrvKeyDataCreateRequest {
281 pub wallet_secret: Secret,
282 pub prv_key_data_args: PrvKeyDataCreateArgs,
283}
284
285#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
286#[serde(rename_all = "camelCase")]
287pub struct PrvKeyDataCreateResponse {
288 pub prv_key_data_id: PrvKeyDataId,
289}
290
291#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
293#[serde(rename_all = "camelCase")]
294pub struct PrvKeyDataRemoveRequest {
295 pub wallet_secret: Secret,
296 pub prv_key_data_id: PrvKeyDataId,
297}
298
299#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
300#[serde(rename_all = "camelCase")]
301pub struct PrvKeyDataRemoveResponse {}
302
303#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
304#[serde(rename_all = "camelCase")]
305pub struct PrvKeyDataGetRequest {
306 pub wallet_secret: Secret,
307 pub prv_key_data_id: PrvKeyDataId,
308}
309
310#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
311#[serde(rename_all = "camelCase")]
312pub struct PrvKeyDataGetResponse {
313 pub prv_key_data: Option<PrvKeyData>,
314}
315
316#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
317#[serde(rename_all = "camelCase")]
318pub struct AccountsEnumerateRequest {}
319
320#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
321#[serde(rename_all = "camelCase")]
322pub struct AccountsEnumerateResponse {
323 pub account_descriptors: Vec<AccountDescriptor>,
324}
325
326#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
327#[serde(rename_all = "camelCase")]
328pub struct AccountsRenameRequest {
329 pub account_id: AccountId,
330 pub name: Option<String>,
331 pub wallet_secret: Secret,
332}
333
334#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
335#[serde(rename_all = "camelCase")]
336pub struct AccountsRenameResponse {}
337
338#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize, CastFromJs)]
340#[serde(rename_all = "camelCase")]
341#[wasm_bindgen]
342pub enum AccountsDiscoveryKind {
343 Bip44,
344}
345
346impl FromStr for AccountsDiscoveryKind {
347 type Err = Error;
348 fn from_str(s: &str) -> Result<Self> {
349 match s {
350 "bip44" => Ok(Self::Bip44),
351 _ => Err(Error::custom(format!("Invalid discovery kind: {s}"))),
352 }
353 }
354}
355
356#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
357#[serde(rename_all = "camelCase")]
358pub struct AccountsDiscoveryRequest {
359 pub discovery_kind: AccountsDiscoveryKind,
360 pub address_scan_extent: u32,
361 pub account_scan_extent: u32,
362 pub bip39_passphrase: Option<Secret>,
363 pub bip39_mnemonic: Secret,
364}
365
366#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
367#[serde(rename_all = "camelCase")]
368pub struct AccountsDiscoveryResponse {
369 pub last_account_index_found: u32,
370}
371
372#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
373#[serde(rename_all = "camelCase")]
374pub struct AccountsCreateRequest {
375 pub wallet_secret: Secret,
376 pub account_create_args: AccountCreateArgs,
377}
378
379#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
380#[serde(rename_all = "camelCase")]
381pub struct AccountsCreateResponse {
382 pub account_descriptor: AccountDescriptor,
383}
384
385#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
386#[serde(rename_all = "camelCase")]
387pub struct AccountsEnsureDefaultRequest {
388 pub wallet_secret: Secret,
389 pub payment_secret: Option<Secret>,
390 pub account_kind: AccountKind,
391 pub mnemonic_phrase: Option<Secret>,
392 }
394
395#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
396#[serde(rename_all = "camelCase")]
397pub struct AccountsEnsureDefaultResponse {
398 pub account_descriptor: AccountDescriptor,
399}
400
401#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
403#[serde(rename_all = "camelCase")]
404pub struct AccountsImportRequest {}
405
406#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
407#[serde(rename_all = "camelCase")]
408pub struct AccountsImportResponse {}
409
410#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
411#[serde(rename_all = "camelCase")]
412pub struct AccountsSelectRequest {
413 pub account_id: Option<AccountId>,
414}
415
416#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
417#[serde(rename_all = "camelCase")]
418pub struct AccountsSelectResponse {}
419
420#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
421#[serde(rename_all = "camelCase")]
422pub struct AccountsActivateRequest {
423 pub account_ids: Option<Vec<AccountId>>,
424}
425
426#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
427#[serde(rename_all = "camelCase")]
428pub struct AccountsActivateResponse {}
429
430#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
431#[serde(rename_all = "camelCase")]
432pub struct AccountsDeactivateRequest {
433 pub account_ids: Option<Vec<AccountId>>,
434}
435
436#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
437#[serde(rename_all = "camelCase")]
438pub struct AccountsDeactivateResponse {}
439
440#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
441#[serde(rename_all = "camelCase")]
442pub struct AccountsGetRequest {
443 pub account_id: AccountId,
444}
445
446#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
447#[serde(rename_all = "camelCase")]
448pub struct AccountsGetResponse {
449 pub account_descriptor: AccountDescriptor,
450}
451
452#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize, CastFromJs)]
457#[serde(rename_all = "camelCase")]
458#[cfg_attr(feature = "wasm32-sdk", wasm_bindgen)]
459pub enum NewAddressKind {
460 Receive,
461 Change,
462}
463
464impl FromStr for NewAddressKind {
465 type Err = Error;
466 fn from_str(s: &str) -> Result<Self> {
467 match s {
468 "receive" => Ok(Self::Receive),
469 "change" => Ok(Self::Change),
470 _ => Err(Error::custom(format!("Invalid address kind: {s}"))),
471 }
472 }
473}
474
475#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
476#[serde(rename_all = "camelCase")]
477pub struct AccountsCreateNewAddressRequest {
478 pub account_id: AccountId,
479 #[serde(rename = "type")]
480 pub kind: NewAddressKind,
481}
482
483#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
484#[serde(rename_all = "camelCase")]
485pub struct AccountsCreateNewAddressResponse {
486 pub address: Address,
487}
488
489#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
490#[serde(rename_all = "camelCase")]
491pub struct AccountsSendRequest {
492 pub account_id: AccountId,
493 pub wallet_secret: Secret,
494 pub payment_secret: Option<Secret>,
495 pub destination: PaymentDestination,
496 pub priority_fee_sompi: Fees,
497 pub payload: Option<Vec<u8>>,
498}
499
500#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
501#[serde(rename_all = "camelCase")]
502pub struct AccountsSendResponse {
503 pub generator_summary: GeneratorSummary,
504 pub transaction_ids: Vec<TransactionId>,
505}
506
507#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
508#[serde(rename_all = "camelCase")]
509pub struct AccountsTransferRequest {
510 pub source_account_id: AccountId,
511 pub destination_account_id: AccountId,
512 pub wallet_secret: Secret,
513 pub payment_secret: Option<Secret>,
514 pub transfer_amount_sompi: u64,
515 pub priority_fee_sompi: Option<Fees>,
516 }
518
519#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
520#[serde(rename_all = "camelCase")]
521pub struct AccountsTransferResponse {
522 pub generator_summary: GeneratorSummary,
523 pub transaction_ids: Vec<TransactionId>,
524}
525
526#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
529#[serde(rename_all = "camelCase")]
530pub struct AccountsEstimateRequest {
531 pub account_id: AccountId,
532 pub destination: PaymentDestination,
533 pub priority_fee_sompi: Fees,
534 pub payload: Option<Vec<u8>>,
535}
536
537#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
538#[serde(rename_all = "camelCase")]
539pub struct AccountsEstimateResponse {
540 pub generator_summary: GeneratorSummary,
541}
542
543#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
544#[serde(rename_all = "camelCase")]
545pub struct TransactionsDataGetRequest {
546 pub account_id: AccountId,
547 pub network_id: NetworkId,
548 pub filter: Option<Vec<TransactionKind>>,
549 pub start: u64,
550 pub end: u64,
551}
552
553impl TransactionsDataGetRequest {
554 pub fn with_range(account_id: AccountId, network_id: NetworkId, range: std::ops::Range<u64>) -> Self {
555 Self { account_id, network_id, filter: None, start: range.start, end: range.end }
556 }
557}
558
559#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
560#[serde(rename_all = "camelCase")]
561pub struct TransactionsDataGetResponse {
562 pub account_id: AccountId,
563 pub transactions: Vec<Arc<TransactionRecord>>,
564 pub start: u64,
565 pub total: u64,
566}
567
568#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
569#[serde(rename_all = "camelCase")]
570pub struct TransactionsReplaceNoteRequest {
571 pub account_id: AccountId,
572 pub network_id: NetworkId,
573 pub transaction_id: TransactionId,
574 pub note: Option<String>,
575}
576
577#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
578#[serde(rename_all = "camelCase")]
579pub struct TransactionsReplaceNoteResponse {}
580
581#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
582#[serde(rename_all = "camelCase")]
583pub struct TransactionsReplaceMetadataRequest {
584 pub account_id: AccountId,
585 pub network_id: NetworkId,
586 pub transaction_id: TransactionId,
587 pub metadata: Option<String>,
588}
589
590#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
591#[serde(rename_all = "camelCase")]
592pub struct TransactionsReplaceMetadataResponse {}
593
594#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
603#[serde(rename_all = "camelCase")]
604pub struct AddressBookEnumerateRequest {}
605
606#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
607#[serde(rename_all = "camelCase")]
608pub struct AddressBookEnumerateResponse {}
609
610#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
611#[serde(rename_all = "camelCase")]
612pub struct WalletNotification {}