Skip to main content

bsv/wallet/
interfaces.rs

1//! WalletInterface trait and all arg/result structs.
2//!
3//! Defines the contract that all wallet implementations must satisfy.
4//! Translated from Go SDK wallet/interfaces.go and TS SDK Wallet.interfaces.ts.
5//! Uses native async fn in traits (RPITIT, Rust 1.75+) -- NOT the async-trait crate.
6
7use std::collections::HashMap;
8
9use crate::primitives::public_key::PublicKey;
10use crate::wallet::error::WalletError;
11use crate::wallet::types::{
12    BasketStringUnder300Bytes, BooleanDefaultFalse, BooleanDefaultTrue, Counterparty,
13    DescriptionString5to50Bytes, LabelStringUnder300Bytes, OutpointString,
14    OutputTagStringUnder300Bytes, PositiveIntegerDefault10Max10000, PositiveIntegerOrZero,
15    Protocol, SatoshiValue, TXIDHexString,
16};
17
18// ---------------------------------------------------------------------------
19// Serde helper modules (only compiled with "network" feature)
20// ---------------------------------------------------------------------------
21
22/// Serde helpers for custom JSON serialization of wallet types.
23/// Gated behind the "network" feature since serde is an optional dependency.
24#[cfg(feature = "network")]
25pub(crate) mod serde_helpers {
26    use crate::primitives::public_key::PublicKey;
27
28    /// Serialize/deserialize PublicKey as DER hex string.
29    pub mod public_key_hex {
30        use super::PublicKey;
31        use serde::{self, Deserialize, Deserializer, Serializer};
32
33        pub fn serialize<S>(pk: &PublicKey, serializer: S) -> Result<S::Ok, S::Error>
34        where
35            S: Serializer,
36        {
37            serializer.serialize_str(&pk.to_der_hex())
38        }
39
40        pub fn deserialize<'de, D>(deserializer: D) -> Result<PublicKey, D::Error>
41        where
42            D: Deserializer<'de>,
43        {
44            let s = String::deserialize(deserializer)?;
45            PublicKey::from_string(&s).map_err(serde::de::Error::custom)
46        }
47    }
48
49    /// Serialize/deserialize `Option<PublicKey>` as optional DER hex string.
50    #[allow(dead_code)]
51    pub mod option_public_key_hex {
52        use super::PublicKey;
53        use serde::{self, Deserialize, Deserializer, Serializer};
54
55        pub fn serialize<S>(pk: &Option<PublicKey>, serializer: S) -> Result<S::Ok, S::Error>
56        where
57            S: Serializer,
58        {
59            match pk {
60                Some(pk) => serializer.serialize_str(&pk.to_der_hex()),
61                None => serializer.serialize_none(),
62            }
63        }
64
65        pub fn deserialize<'de, D>(deserializer: D) -> Result<Option<PublicKey>, D::Error>
66        where
67            D: Deserializer<'de>,
68        {
69            let opt: Option<String> = Option::deserialize(deserializer)?;
70            match opt {
71                Some(s) if !s.is_empty() => PublicKey::from_string(&s)
72                    .map(Some)
73                    .map_err(serde::de::Error::custom),
74                _ => Ok(None),
75            }
76        }
77    }
78
79    /// Serialize/deserialize `Vec<PublicKey>` as array of DER hex strings.
80    pub mod vec_public_key_hex {
81        use super::PublicKey;
82        use serde::ser::SerializeSeq;
83        use serde::{self, Deserialize, Deserializer, Serializer};
84
85        pub fn serialize<S>(pks: &[PublicKey], serializer: S) -> Result<S::Ok, S::Error>
86        where
87            S: Serializer,
88        {
89            let mut seq = serializer.serialize_seq(Some(pks.len()))?;
90            for pk in pks {
91                seq.serialize_element(&pk.to_der_hex())?;
92            }
93            seq.end()
94        }
95
96        pub fn deserialize<'de, D>(deserializer: D) -> Result<Vec<PublicKey>, D::Error>
97        where
98            D: Deserializer<'de>,
99        {
100            let strs: Vec<String> = Vec::deserialize(deserializer)?;
101            strs.iter()
102                .map(|s| PublicKey::from_string(s).map_err(serde::de::Error::custom))
103                .collect()
104        }
105    }
106
107    /// Serialize/deserialize [u8; 32] as base64 string (matches Go SDK Bytes32Base64).
108    pub mod bytes32_base64 {
109        use serde::{self, Deserialize, Deserializer, Serializer};
110
111        pub fn serialize<S>(bytes: &[u8; 32], serializer: S) -> Result<S::Ok, S::Error>
112        where
113            S: Serializer,
114        {
115            serializer.serialize_str(&base64_encode(bytes))
116        }
117
118        pub fn deserialize<'de, D>(deserializer: D) -> Result<[u8; 32], D::Error>
119        where
120            D: Deserializer<'de>,
121        {
122            let s = String::deserialize(deserializer)?;
123            let decoded = base64_decode(&s).map_err(serde::de::Error::custom)?;
124            if decoded.len() > 32 {
125                return Err(serde::de::Error::custom(
126                    "base64 decoded value exceeds 32 bytes",
127                ));
128            }
129            let mut buf = [0u8; 32];
130            buf[..decoded.len()].copy_from_slice(&decoded);
131            Ok(buf)
132        }
133
134        fn base64_encode(data: &[u8]) -> String {
135            const CHARS: &[u8] =
136                b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
137            let mut result = String::new();
138            let chunks = data.chunks(3);
139            for chunk in chunks {
140                let b0 = chunk[0] as u32;
141                let b1 = if chunk.len() > 1 { chunk[1] as u32 } else { 0 };
142                let b2 = if chunk.len() > 2 { chunk[2] as u32 } else { 0 };
143                let triple = (b0 << 16) | (b1 << 8) | b2;
144                result.push(CHARS[((triple >> 18) & 0x3F) as usize] as char);
145                result.push(CHARS[((triple >> 12) & 0x3F) as usize] as char);
146                if chunk.len() > 1 {
147                    result.push(CHARS[((triple >> 6) & 0x3F) as usize] as char);
148                } else {
149                    result.push('=');
150                }
151                if chunk.len() > 2 {
152                    result.push(CHARS[(triple & 0x3F) as usize] as char);
153                } else {
154                    result.push('=');
155                }
156            }
157            result
158        }
159
160        fn base64_decode(s: &str) -> Result<Vec<u8>, String> {
161            fn char_to_val(c: u8) -> Result<u8, String> {
162                match c {
163                    b'A'..=b'Z' => Ok(c - b'A'),
164                    b'a'..=b'z' => Ok(c - b'a' + 26),
165                    b'0'..=b'9' => Ok(c - b'0' + 52),
166                    b'+' => Ok(62),
167                    b'/' => Ok(63),
168                    _ => Err(format!("invalid base64 character: {}", c as char)),
169                }
170            }
171            let bytes = s.as_bytes();
172            let mut result = Vec::new();
173            let mut i = 0;
174            while i < bytes.len() {
175                if bytes[i] == b'=' {
176                    break;
177                }
178                let a = char_to_val(bytes[i])?;
179                let b = if i + 1 < bytes.len() && bytes[i + 1] != b'=' {
180                    char_to_val(bytes[i + 1])?
181                } else {
182                    0
183                };
184                let c = if i + 2 < bytes.len() && bytes[i + 2] != b'=' {
185                    char_to_val(bytes[i + 2])?
186                } else {
187                    0
188                };
189                let d = if i + 3 < bytes.len() && bytes[i + 3] != b'=' {
190                    char_to_val(bytes[i + 3])?
191                } else {
192                    0
193                };
194                let triple =
195                    ((a as u32) << 18) | ((b as u32) << 12) | ((c as u32) << 6) | (d as u32);
196                result.push(((triple >> 16) & 0xFF) as u8);
197                if i + 2 < bytes.len() && bytes[i + 2] != b'=' {
198                    result.push(((triple >> 8) & 0xFF) as u8);
199                }
200                if i + 3 < bytes.len() && bytes[i + 3] != b'=' {
201                    result.push((triple & 0xFF) as u8);
202                }
203                i += 4;
204            }
205            Ok(result)
206        }
207    }
208
209    /// Serialize/deserialize `Vec<u8>` as JSON array of numbers (matches Go SDK BytesList).
210    pub mod bytes_as_array {
211        use serde::{Deserialize, Deserializer, Serializer};
212
213        pub fn serialize<S>(bytes: &[u8], serializer: S) -> Result<S::Ok, S::Error>
214        where
215            S: Serializer,
216        {
217            serializer.collect_seq(bytes.iter())
218        }
219
220        pub fn deserialize<'de, D>(deserializer: D) -> Result<Vec<u8>, D::Error>
221        where
222            D: Deserializer<'de>,
223        {
224            Vec::<u8>::deserialize(deserializer)
225        }
226    }
227
228    /// Serialize/deserialize `Option<Vec<u8>>` as optional JSON array of numbers.
229    pub mod option_bytes_as_array {
230        use serde::{Deserialize, Deserializer, Serializer};
231
232        pub fn serialize<S>(bytes: &Option<Vec<u8>>, serializer: S) -> Result<S::Ok, S::Error>
233        where
234            S: Serializer,
235        {
236            match bytes {
237                Some(b) => serializer.collect_seq(b.iter()),
238                None => serializer.serialize_none(),
239            }
240        }
241
242        pub fn deserialize<'de, D>(deserializer: D) -> Result<Option<Vec<u8>>, D::Error>
243        where
244            D: Deserializer<'de>,
245        {
246            Option::<Vec<u8>>::deserialize(deserializer)
247        }
248    }
249
250    /// Serialize/deserialize `Vec<u8>` as hex string (matches Go SDK BytesHex).
251    pub mod bytes_as_hex {
252        use serde::{self, Deserialize, Deserializer, Serializer};
253
254        pub fn serialize<S>(bytes: &[u8], serializer: S) -> Result<S::Ok, S::Error>
255        where
256            S: Serializer,
257        {
258            serializer.serialize_str(&to_hex(bytes))
259        }
260
261        pub fn deserialize<'de, D>(deserializer: D) -> Result<Vec<u8>, D::Error>
262        where
263            D: Deserializer<'de>,
264        {
265            let s = String::deserialize(deserializer)?;
266            from_hex(&s).map_err(serde::de::Error::custom)
267        }
268
269        fn to_hex(bytes: &[u8]) -> String {
270            const HEX: &[u8; 16] = b"0123456789abcdef";
271            let mut s = String::with_capacity(bytes.len() * 2);
272            for &b in bytes {
273                s.push(HEX[(b >> 4) as usize] as char);
274                s.push(HEX[(b & 0xf) as usize] as char);
275            }
276            s
277        }
278
279        pub(crate) fn from_hex(s: &str) -> Result<Vec<u8>, String> {
280            if !s.len().is_multiple_of(2) {
281                return Err("hex string has odd length".to_string());
282            }
283            let bytes = s.as_bytes();
284            let mut result = Vec::with_capacity(bytes.len() / 2);
285            for chunk in bytes.chunks(2) {
286                let hi = hex_val(chunk[0])?;
287                let lo = hex_val(chunk[1])?;
288                result.push((hi << 4) | lo);
289            }
290            Ok(result)
291        }
292
293        fn hex_val(b: u8) -> Result<u8, String> {
294            match b {
295                b'0'..=b'9' => Ok(b - b'0'),
296                b'a'..=b'f' => Ok(b - b'a' + 10),
297                b'A'..=b'F' => Ok(b - b'A' + 10),
298                _ => Err(format!("invalid hex character: {}", b as char)),
299            }
300        }
301    }
302
303    /// Serialize/deserialize `Option<Vec<u8>>` as optional hex string.
304    pub mod option_bytes_as_hex {
305        use serde::{self, Deserialize, Deserializer, Serializer};
306
307        pub fn serialize<S>(bytes: &Option<Vec<u8>>, serializer: S) -> Result<S::Ok, S::Error>
308        where
309            S: Serializer,
310        {
311            match bytes {
312                Some(b) => super::bytes_as_hex::serialize(b, serializer),
313                None => serializer.serialize_none(),
314            }
315        }
316
317        pub fn deserialize<'de, D>(deserializer: D) -> Result<Option<Vec<u8>>, D::Error>
318        where
319            D: Deserializer<'de>,
320        {
321            let opt: Option<String> = Option::deserialize(deserializer)?;
322            match opt {
323                Some(s) if !s.is_empty() => super::bytes_as_hex::from_hex(&s)
324                    .map(Some)
325                    .map_err(serde::de::Error::custom),
326                _ => Ok(None),
327            }
328        }
329    }
330}
331
332// ---------------------------------------------------------------------------
333// Enums
334// ---------------------------------------------------------------------------
335
336/// Current state of a transaction action.
337#[derive(Clone, Debug, PartialEq, Eq)]
338#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
339#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
340pub enum ActionStatus {
341    Completed,
342    Unprocessed,
343    Sending,
344    Unproven,
345    Unsigned,
346    #[cfg_attr(feature = "network", serde(rename = "nosend"))]
347    NoSend,
348    #[cfg_attr(feature = "network", serde(rename = "nonfinal"))]
349    NonFinal,
350}
351
352impl ActionStatus {
353    pub fn as_str(&self) -> &'static str {
354        match self {
355            ActionStatus::Completed => "completed",
356            ActionStatus::Unprocessed => "unprocessed",
357            ActionStatus::Sending => "sending",
358            ActionStatus::Unproven => "unproven",
359            ActionStatus::Unsigned => "unsigned",
360            ActionStatus::NoSend => "nosend",
361            ActionStatus::NonFinal => "nonfinal",
362        }
363    }
364}
365
366/// Status of a transaction result (subset of ActionStatus).
367#[derive(Clone, Debug, PartialEq, Eq)]
368#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
369#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
370pub enum ActionResultStatus {
371    Unproven,
372    Sending,
373    Failed,
374}
375
376impl ActionResultStatus {
377    pub fn as_str(&self) -> &'static str {
378        match self {
379            ActionResultStatus::Unproven => "unproven",
380            ActionResultStatus::Sending => "sending",
381            ActionResultStatus::Failed => "failed",
382        }
383    }
384}
385
386/// How multiple criteria are combined in queries.
387#[derive(Clone, Debug, PartialEq, Eq)]
388#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
389#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
390pub enum QueryMode {
391    Any,
392    All,
393}
394
395impl QueryMode {
396    pub fn as_str(&self) -> &'static str {
397        match self {
398            QueryMode::Any => "any",
399            QueryMode::All => "all",
400        }
401    }
402}
403
404/// What additional data to include with output listings.
405#[derive(Clone, Debug, PartialEq, Eq)]
406#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
407pub enum OutputInclude {
408    #[cfg_attr(feature = "network", serde(rename = "locking scripts"))]
409    LockingScripts,
410    #[cfg_attr(feature = "network", serde(rename = "entire transactions"))]
411    EntireTransactions,
412}
413
414impl OutputInclude {
415    pub fn as_str(&self) -> &'static str {
416        match self {
417            OutputInclude::LockingScripts => "locking scripts",
418            OutputInclude::EntireTransactions => "entire transactions",
419        }
420    }
421}
422
423/// Protocol for internalizing transaction outputs.
424#[derive(Clone, Debug, PartialEq, Eq)]
425#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
426pub enum InternalizeProtocol {
427    #[cfg_attr(feature = "network", serde(rename = "wallet payment"))]
428    WalletPayment,
429    #[cfg_attr(feature = "network", serde(rename = "basket insertion"))]
430    BasketInsertion,
431}
432
433impl InternalizeProtocol {
434    pub fn as_str(&self) -> &'static str {
435        match self {
436            InternalizeProtocol::WalletPayment => "wallet payment",
437            InternalizeProtocol::BasketInsertion => "basket insertion",
438        }
439    }
440}
441
442/// Protocol for certificate acquisition.
443#[derive(Clone, Debug, PartialEq, Eq)]
444#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
445#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
446pub enum AcquisitionProtocol {
447    Direct,
448    Issuance,
449}
450
451impl AcquisitionProtocol {
452    pub fn as_str(&self) -> &'static str {
453        match self {
454            AcquisitionProtocol::Direct => "direct",
455            AcquisitionProtocol::Issuance => "issuance",
456        }
457    }
458}
459
460/// Blockchain network type.
461#[derive(Clone, Debug, PartialEq, Eq)]
462#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
463#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
464pub enum Network {
465    Mainnet,
466    Testnet,
467}
468
469impl Network {
470    pub fn as_str(&self) -> &'static str {
471        match self {
472            Network::Mainnet => "mainnet",
473            Network::Testnet => "testnet",
474        }
475    }
476}
477
478/// Trust level for self-referential operations.
479#[derive(Clone, Debug, PartialEq, Eq)]
480#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
481#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
482pub enum TrustSelf {
483    Known,
484}
485
486impl TrustSelf {
487    pub fn as_str(&self) -> &'static str {
488        match self {
489            TrustSelf::Known => "known",
490        }
491    }
492}
493
494// ---------------------------------------------------------------------------
495// Core types: Certificate, CertificateType, SerialNumber, KeyringRevealer
496// ---------------------------------------------------------------------------
497
498/// Newtype wrapper for certificate type identifier (32 bytes).
499/// Serializes as base64 string matching Go SDK Bytes32Base64.
500#[derive(Clone, Debug, PartialEq, Eq, Hash)]
501pub struct CertificateType(pub [u8; 32]);
502
503#[cfg(feature = "network")]
504impl serde::Serialize for CertificateType {
505    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
506        serde_helpers::bytes32_base64::serialize(&self.0, serializer)
507    }
508}
509
510#[cfg(feature = "network")]
511impl<'de> serde::Deserialize<'de> for CertificateType {
512    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
513        serde_helpers::bytes32_base64::deserialize(deserializer).map(CertificateType)
514    }
515}
516
517impl CertificateType {
518    pub fn from_string(s: &str) -> Result<Self, WalletError> {
519        if s.len() > 32 {
520            return Err(WalletError::InvalidParameter(
521                "certificate type string longer than 32 bytes".to_string(),
522            ));
523        }
524        let mut buf = [0u8; 32];
525        buf[..s.len()].copy_from_slice(s.as_bytes());
526        Ok(CertificateType(buf))
527    }
528
529    pub fn bytes(&self) -> &[u8; 32] {
530        &self.0
531    }
532}
533
534/// Newtype wrapper for certificate serial number (32 bytes).
535/// Serializes as base64 string matching Go SDK Bytes32Base64.
536#[derive(Clone, Debug, PartialEq, Eq, Hash)]
537pub struct SerialNumber(pub [u8; 32]);
538
539#[cfg(feature = "network")]
540impl serde::Serialize for SerialNumber {
541    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
542        serde_helpers::bytes32_base64::serialize(&self.0, serializer)
543    }
544}
545
546#[cfg(feature = "network")]
547impl<'de> serde::Deserialize<'de> for SerialNumber {
548    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
549        serde_helpers::bytes32_base64::deserialize(deserializer).map(SerialNumber)
550    }
551}
552
553/// A certificate in the wallet.
554#[derive(Clone, Debug)]
555#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
556#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
557pub struct Certificate {
558    #[cfg_attr(feature = "network", serde(rename = "type"))]
559    pub cert_type: CertificateType,
560    pub serial_number: SerialNumber,
561    #[cfg_attr(feature = "network", serde(with = "serde_helpers::public_key_hex"))]
562    pub subject: PublicKey,
563    #[cfg_attr(feature = "network", serde(with = "serde_helpers::public_key_hex"))]
564    pub certifier: PublicKey,
565    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
566    pub revocation_outpoint: Option<String>,
567    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
568    pub fields: Option<HashMap<String, String>>,
569    #[cfg_attr(
570        feature = "network",
571        serde(with = "serde_helpers::option_bytes_as_hex")
572    )]
573    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
574    pub signature: Option<Vec<u8>>,
575}
576
577/// Identifies who reveals a keyring.
578#[derive(Clone, Debug)]
579pub enum KeyringRevealer {
580    /// The certifier reveals the keyring.
581    Certifier,
582    /// A specific public key reveals the keyring.
583    PubKey(PublicKey),
584}
585
586#[cfg(feature = "network")]
587impl serde::Serialize for KeyringRevealer {
588    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
589        match self {
590            KeyringRevealer::Certifier => serializer.serialize_str("certifier"),
591            KeyringRevealer::PubKey(pk) => serializer.serialize_str(&pk.to_der_hex()),
592        }
593    }
594}
595
596#[cfg(feature = "network")]
597impl<'de> serde::Deserialize<'de> for KeyringRevealer {
598    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
599        let s = String::deserialize(deserializer)?;
600        if s == "certifier" || s.is_empty() {
601            Ok(KeyringRevealer::Certifier)
602        } else {
603            PublicKey::from_string(&s)
604                .map(KeyringRevealer::PubKey)
605                .map_err(serde::de::Error::custom)
606        }
607    }
608}
609
610// ---------------------------------------------------------------------------
611// Action types (CreateAction, SignAction, AbortAction)
612// ---------------------------------------------------------------------------
613
614/// An input to be spent in a new transaction.
615#[derive(Clone, Debug)]
616#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
617#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
618pub struct CreateActionInput {
619    pub outpoint: OutpointString,
620    pub input_description: String,
621    #[cfg_attr(
622        feature = "network",
623        serde(with = "serde_helpers::option_bytes_as_hex")
624    )]
625    #[cfg_attr(
626        feature = "network",
627        serde(skip_serializing_if = "Option::is_none", default)
628    )]
629    pub unlocking_script: Option<Vec<u8>>,
630    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
631    pub unlocking_script_length: Option<u32>,
632    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
633    pub sequence_number: Option<u32>,
634}
635
636/// An output to be created in a new transaction.
637#[derive(Clone, Debug)]
638#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
639#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
640pub struct CreateActionOutput {
641    #[cfg_attr(
642        feature = "network",
643        serde(with = "serde_helpers::option_bytes_as_hex")
644    )]
645    #[cfg_attr(
646        feature = "network",
647        serde(skip_serializing_if = "Option::is_none", default)
648    )]
649    pub locking_script: Option<Vec<u8>>,
650    pub satoshis: SatoshiValue,
651    pub output_description: String,
652    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
653    pub basket: Option<BasketStringUnder300Bytes>,
654    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
655    pub custom_instructions: Option<String>,
656    #[cfg_attr(
657        feature = "network",
658        serde(skip_serializing_if = "Vec::is_empty", default)
659    )]
660    pub tags: Vec<OutputTagStringUnder300Bytes>,
661}
662
663/// Optional parameters for creating a new transaction.
664#[derive(Clone, Debug)]
665#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
666#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
667pub struct CreateActionOptions {
668    pub sign_and_process: BooleanDefaultTrue,
669    pub accept_delayed_broadcast: BooleanDefaultTrue,
670    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
671    pub trust_self: Option<TrustSelf>,
672    #[cfg_attr(
673        feature = "network",
674        serde(skip_serializing_if = "Vec::is_empty", default)
675    )]
676    pub known_txids: Vec<TXIDHexString>,
677    pub return_txid_only: BooleanDefaultFalse,
678    pub no_send: BooleanDefaultFalse,
679    #[cfg_attr(
680        feature = "network",
681        serde(skip_serializing_if = "Vec::is_empty", default)
682    )]
683    pub no_send_change: Vec<OutpointString>,
684    #[cfg_attr(
685        feature = "network",
686        serde(skip_serializing_if = "Vec::is_empty", default)
687    )]
688    pub send_with: Vec<TXIDHexString>,
689    pub randomize_outputs: BooleanDefaultTrue,
690}
691
692/// Arguments for creating a new transaction.
693#[derive(Clone, Debug)]
694#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
695#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
696pub struct CreateActionArgs {
697    pub description: DescriptionString5to50Bytes,
698    #[cfg_attr(
699        feature = "network",
700        serde(with = "serde_helpers::option_bytes_as_array")
701    )]
702    #[cfg_attr(
703        feature = "network",
704        serde(skip_serializing_if = "Option::is_none", default)
705    )]
706    #[cfg_attr(feature = "network", serde(rename = "inputBEEF"))]
707    pub input_beef: Option<Vec<u8>>,
708    #[cfg_attr(
709        feature = "network",
710        serde(skip_serializing_if = "Vec::is_empty", default)
711    )]
712    pub inputs: Vec<CreateActionInput>,
713    #[cfg_attr(
714        feature = "network",
715        serde(skip_serializing_if = "Vec::is_empty", default)
716    )]
717    pub outputs: Vec<CreateActionOutput>,
718    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
719    pub lock_time: Option<u32>,
720    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
721    pub version: Option<u32>,
722    #[cfg_attr(
723        feature = "network",
724        serde(skip_serializing_if = "Vec::is_empty", default)
725    )]
726    pub labels: Vec<LabelStringUnder300Bytes>,
727    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
728    pub options: Option<CreateActionOptions>,
729    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
730    pub reference: Option<String>,
731}
732
733/// Data needed to complete signing of a partial transaction.
734#[derive(Clone, Debug)]
735#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
736#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
737pub struct SignableTransaction {
738    #[cfg_attr(feature = "network", serde(with = "serde_helpers::bytes_as_array"))]
739    pub tx: Vec<u8>,
740    #[cfg_attr(feature = "network", serde(with = "serde_helpers::bytes_as_array"))]
741    pub reference: Vec<u8>,
742}
743
744/// Status of a transaction sent as part of a batch.
745#[derive(Clone, Debug)]
746#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
747#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
748pub struct SendWithResult {
749    pub txid: TXIDHexString,
750    pub status: ActionResultStatus,
751}
752
753/// Result of creating a transaction.
754#[derive(Clone, Debug)]
755#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
756#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
757pub struct CreateActionResult {
758    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
759    pub txid: Option<TXIDHexString>,
760    #[cfg_attr(
761        feature = "network",
762        serde(with = "serde_helpers::option_bytes_as_array")
763    )]
764    #[cfg_attr(
765        feature = "network",
766        serde(skip_serializing_if = "Option::is_none", default)
767    )]
768    pub tx: Option<Vec<u8>>,
769    #[cfg_attr(
770        feature = "network",
771        serde(skip_serializing_if = "Vec::is_empty", default)
772    )]
773    pub no_send_change: Vec<OutpointString>,
774    #[cfg_attr(
775        feature = "network",
776        serde(skip_serializing_if = "Vec::is_empty", default)
777    )]
778    pub send_with_results: Vec<SendWithResult>,
779    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
780    pub signable_transaction: Option<SignableTransaction>,
781}
782
783/// Unlocking script and sequence number for a specific input.
784#[derive(Clone, Debug)]
785#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
786#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
787pub struct SignActionSpend {
788    #[cfg_attr(feature = "network", serde(with = "serde_helpers::bytes_as_hex"))]
789    pub unlocking_script: Vec<u8>,
790    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
791    pub sequence_number: Option<u32>,
792}
793
794/// Controls signing and broadcasting behavior.
795#[derive(Clone, Debug)]
796#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
797#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
798pub struct SignActionOptions {
799    pub accept_delayed_broadcast: BooleanDefaultTrue,
800    pub return_txid_only: BooleanDefaultFalse,
801    pub no_send: BooleanDefaultFalse,
802    #[cfg_attr(
803        feature = "network",
804        serde(skip_serializing_if = "Vec::is_empty", default)
805    )]
806    pub send_with: Vec<TXIDHexString>,
807}
808
809/// Arguments for signing a previously created transaction.
810#[derive(Clone, Debug)]
811#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
812#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
813pub struct SignActionArgs {
814    #[cfg_attr(feature = "network", serde(with = "serde_helpers::bytes_as_array"))]
815    pub reference: Vec<u8>,
816    pub spends: HashMap<u32, SignActionSpend>,
817    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
818    pub options: Option<SignActionOptions>,
819}
820
821/// Result of a successful signing operation.
822#[derive(Clone, Debug)]
823#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
824#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
825pub struct SignActionResult {
826    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
827    pub txid: Option<TXIDHexString>,
828    #[cfg_attr(
829        feature = "network",
830        serde(with = "serde_helpers::option_bytes_as_array")
831    )]
832    #[cfg_attr(
833        feature = "network",
834        serde(skip_serializing_if = "Option::is_none", default)
835    )]
836    pub tx: Option<Vec<u8>>,
837    #[cfg_attr(
838        feature = "network",
839        serde(skip_serializing_if = "Vec::is_empty", default)
840    )]
841    pub send_with_results: Vec<SendWithResult>,
842}
843
844/// Arguments for aborting a transaction.
845#[derive(Clone, Debug)]
846#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
847#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
848pub struct AbortActionArgs {
849    #[cfg_attr(feature = "network", serde(with = "serde_helpers::bytes_as_array"))]
850    pub reference: Vec<u8>,
851}
852
853/// Result of aborting a transaction.
854#[derive(Clone, Debug)]
855#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
856#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
857pub struct AbortActionResult {
858    pub aborted: bool,
859}
860
861// ---------------------------------------------------------------------------
862// Action detail types (for listing)
863// ---------------------------------------------------------------------------
864
865/// A transaction input with full details.
866#[derive(Clone, Debug)]
867#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
868#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
869pub struct ActionInput {
870    pub source_outpoint: OutpointString,
871    pub source_satoshis: SatoshiValue,
872    #[cfg_attr(
873        feature = "network",
874        serde(with = "serde_helpers::option_bytes_as_hex")
875    )]
876    #[cfg_attr(
877        feature = "network",
878        serde(skip_serializing_if = "Option::is_none", default)
879    )]
880    pub source_locking_script: Option<Vec<u8>>,
881    #[cfg_attr(
882        feature = "network",
883        serde(with = "serde_helpers::option_bytes_as_hex")
884    )]
885    #[cfg_attr(
886        feature = "network",
887        serde(skip_serializing_if = "Option::is_none", default)
888    )]
889    pub unlocking_script: Option<Vec<u8>>,
890    pub input_description: String,
891    pub sequence_number: u32,
892}
893
894/// A transaction output with full details.
895#[derive(Clone, Debug)]
896#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
897#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
898pub struct ActionOutput {
899    pub satoshis: SatoshiValue,
900    #[cfg_attr(
901        feature = "network",
902        serde(with = "serde_helpers::option_bytes_as_hex")
903    )]
904    #[cfg_attr(
905        feature = "network",
906        serde(skip_serializing_if = "Option::is_none", default)
907    )]
908    pub locking_script: Option<Vec<u8>>,
909    pub spendable: bool,
910    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
911    pub custom_instructions: Option<String>,
912    pub tags: Vec<String>,
913    pub output_index: u32,
914    pub output_description: String,
915    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
916    pub basket: Option<String>,
917}
918
919/// Full details about a wallet transaction.
920#[derive(Clone, Debug)]
921#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
922#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
923pub struct Action {
924    pub txid: TXIDHexString,
925    pub satoshis: i64,
926    pub status: ActionStatus,
927    pub is_outgoing: bool,
928    pub description: String,
929    #[cfg_attr(
930        feature = "network",
931        serde(skip_serializing_if = "Vec::is_empty", default)
932    )]
933    pub labels: Vec<String>,
934    pub version: u32,
935    pub lock_time: u32,
936    #[cfg_attr(
937        feature = "network",
938        serde(skip_serializing_if = "Vec::is_empty", default)
939    )]
940    pub inputs: Vec<ActionInput>,
941    #[cfg_attr(
942        feature = "network",
943        serde(skip_serializing_if = "Vec::is_empty", default)
944    )]
945    pub outputs: Vec<ActionOutput>,
946}
947
948/// Maximum number of actions or outputs that can be returned.
949pub const MAX_ACTIONS_LIMIT: u32 = 10000;
950
951// ---------------------------------------------------------------------------
952// ListActions
953// ---------------------------------------------------------------------------
954
955/// Filtering and pagination options for listing wallet transactions.
956#[derive(Clone, Debug)]
957#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
958#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
959pub struct ListActionsArgs {
960    pub labels: Vec<LabelStringUnder300Bytes>,
961    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
962    pub label_query_mode: Option<QueryMode>,
963    pub include_labels: BooleanDefaultFalse,
964    pub include_inputs: BooleanDefaultFalse,
965    pub include_input_source_locking_scripts: BooleanDefaultFalse,
966    pub include_input_unlocking_scripts: BooleanDefaultFalse,
967    pub include_outputs: BooleanDefaultFalse,
968    pub include_output_locking_scripts: BooleanDefaultFalse,
969    pub limit: PositiveIntegerDefault10Max10000,
970    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
971    pub offset: Option<PositiveIntegerOrZero>,
972    pub seek_permission: BooleanDefaultTrue,
973}
974
975/// Paginated list of wallet transactions.
976#[derive(Clone, Debug)]
977#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
978#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
979pub struct ListActionsResult {
980    pub total_actions: u32,
981    pub actions: Vec<Action>,
982}
983
984// ---------------------------------------------------------------------------
985// InternalizeAction
986// ---------------------------------------------------------------------------
987
988/// Derivation and identity data for wallet payment outputs.
989#[derive(Clone, Debug)]
990#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
991#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
992pub struct Payment {
993    #[cfg_attr(feature = "network", serde(with = "serde_helpers::bytes_as_array"))]
994    pub derivation_prefix: Vec<u8>,
995    #[cfg_attr(feature = "network", serde(with = "serde_helpers::bytes_as_array"))]
996    pub derivation_suffix: Vec<u8>,
997    #[cfg_attr(feature = "network", serde(with = "serde_helpers::public_key_hex"))]
998    pub sender_identity_key: PublicKey,
999}
1000
1001/// Metadata for outputs being inserted into baskets.
1002#[derive(Clone, Debug)]
1003#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1004#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1005pub struct BasketInsertion {
1006    pub basket: BasketStringUnder300Bytes,
1007    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
1008    pub custom_instructions: Option<String>,
1009    #[cfg_attr(
1010        feature = "network",
1011        serde(skip_serializing_if = "Vec::is_empty", default)
1012    )]
1013    pub tags: Vec<OutputTagStringUnder300Bytes>,
1014}
1015
1016/// How to process a transaction output -- as payment or basket insertion.
1017#[derive(Clone, Debug)]
1018#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1019#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1020pub struct InternalizeOutput {
1021    pub output_index: u32,
1022    pub protocol: InternalizeProtocol,
1023    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
1024    pub payment_remittance: Option<Payment>,
1025    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
1026    pub insertion_remittance: Option<BasketInsertion>,
1027}
1028
1029/// Arguments for importing an external transaction into the wallet.
1030#[derive(Clone, Debug)]
1031#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1032#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1033pub struct InternalizeActionArgs {
1034    #[cfg_attr(feature = "network", serde(with = "serde_helpers::bytes_as_array"))]
1035    pub tx: Vec<u8>,
1036    pub description: String,
1037    #[cfg_attr(
1038        feature = "network",
1039        serde(skip_serializing_if = "Vec::is_empty", default)
1040    )]
1041    pub labels: Vec<LabelStringUnder300Bytes>,
1042    pub seek_permission: BooleanDefaultTrue,
1043    pub outputs: Vec<InternalizeOutput>,
1044}
1045
1046/// Result of internalizing a transaction.
1047#[derive(Clone, Debug)]
1048#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1049#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1050pub struct InternalizeActionResult {
1051    pub accepted: bool,
1052}
1053
1054// ---------------------------------------------------------------------------
1055// ListOutputs
1056// ---------------------------------------------------------------------------
1057
1058/// Filtering and options for listing wallet outputs.
1059#[derive(Clone, Debug)]
1060#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1061#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1062pub struct ListOutputsArgs {
1063    pub basket: BasketStringUnder300Bytes,
1064    #[cfg_attr(
1065        feature = "network",
1066        serde(skip_serializing_if = "Vec::is_empty", default)
1067    )]
1068    pub tags: Vec<OutputTagStringUnder300Bytes>,
1069    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
1070    pub tag_query_mode: Option<QueryMode>,
1071    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
1072    pub include: Option<OutputInclude>,
1073    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
1074    pub include_custom_instructions: BooleanDefaultFalse,
1075    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
1076    pub include_tags: BooleanDefaultFalse,
1077    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
1078    pub include_labels: BooleanDefaultFalse,
1079    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
1080    pub limit: PositiveIntegerDefault10Max10000,
1081    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
1082    pub offset: Option<PositiveIntegerOrZero>,
1083    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
1084    pub seek_permission: BooleanDefaultTrue,
1085}
1086
1087/// A wallet UTXO with its metadata.
1088#[derive(Clone, Debug)]
1089#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1090#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1091pub struct Output {
1092    pub satoshis: SatoshiValue,
1093    #[cfg_attr(
1094        feature = "network",
1095        serde(with = "serde_helpers::option_bytes_as_hex")
1096    )]
1097    #[cfg_attr(
1098        feature = "network",
1099        serde(skip_serializing_if = "Option::is_none", default)
1100    )]
1101    pub locking_script: Option<Vec<u8>>,
1102    pub spendable: bool,
1103    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
1104    pub custom_instructions: Option<String>,
1105    #[cfg_attr(
1106        feature = "network",
1107        serde(skip_serializing_if = "Vec::is_empty", default)
1108    )]
1109    pub tags: Vec<String>,
1110    pub outpoint: OutpointString,
1111    #[cfg_attr(
1112        feature = "network",
1113        serde(skip_serializing_if = "Vec::is_empty", default)
1114    )]
1115    pub labels: Vec<String>,
1116}
1117
1118/// Paginated list of wallet outputs.
1119#[derive(Clone, Debug)]
1120#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1121#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1122pub struct ListOutputsResult {
1123    pub total_outputs: u32,
1124    #[cfg_attr(
1125        feature = "network",
1126        serde(with = "serde_helpers::option_bytes_as_array")
1127    )]
1128    #[cfg_attr(
1129        feature = "network",
1130        serde(skip_serializing_if = "Option::is_none", default)
1131    )]
1132    #[cfg_attr(feature = "network", serde(rename = "BEEF"))]
1133    pub beef: Option<Vec<u8>>,
1134    pub outputs: Vec<Output>,
1135}
1136
1137// ---------------------------------------------------------------------------
1138// RelinquishOutput
1139// ---------------------------------------------------------------------------
1140
1141/// Arguments for relinquishing ownership of an output.
1142#[derive(Clone, Debug)]
1143#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1144#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1145pub struct RelinquishOutputArgs {
1146    pub basket: BasketStringUnder300Bytes,
1147    pub output: OutpointString,
1148}
1149
1150/// Result of relinquishing an output.
1151#[derive(Clone, Debug)]
1152#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1153#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1154pub struct RelinquishOutputResult {
1155    pub relinquished: bool,
1156}
1157
1158// ---------------------------------------------------------------------------
1159// Key/Crypto types
1160// ---------------------------------------------------------------------------
1161
1162/// Arguments for getting a public key.
1163#[derive(Clone, Debug)]
1164#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1165#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1166pub struct GetPublicKeyArgs {
1167    pub identity_key: bool,
1168    #[cfg_attr(feature = "network", serde(rename = "protocolID"))]
1169    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
1170    pub protocol_id: Option<Protocol>,
1171    #[cfg_attr(feature = "network", serde(rename = "keyID"))]
1172    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
1173    pub key_id: Option<String>,
1174    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
1175    pub counterparty: Option<Counterparty>,
1176    pub privileged: bool,
1177    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
1178    pub privileged_reason: Option<String>,
1179    pub for_self: Option<bool>,
1180    pub seek_permission: Option<bool>,
1181}
1182
1183/// Result of getting a public key.
1184#[derive(Clone, Debug)]
1185#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1186#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1187pub struct GetPublicKeyResult {
1188    #[cfg_attr(feature = "network", serde(with = "serde_helpers::public_key_hex"))]
1189    pub public_key: PublicKey,
1190}
1191
1192/// Arguments for encryption.
1193#[derive(Clone, Debug)]
1194#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1195#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1196pub struct EncryptArgs {
1197    #[cfg_attr(feature = "network", serde(rename = "protocolID"))]
1198    pub protocol_id: Protocol,
1199    #[cfg_attr(feature = "network", serde(rename = "keyID"))]
1200    pub key_id: String,
1201    pub counterparty: Counterparty,
1202    #[cfg_attr(feature = "network", serde(with = "serde_helpers::bytes_as_array"))]
1203    pub plaintext: Vec<u8>,
1204    pub privileged: bool,
1205    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
1206    pub privileged_reason: Option<String>,
1207    pub seek_permission: Option<bool>,
1208}
1209
1210/// Result of encryption.
1211#[derive(Clone, Debug)]
1212#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1213#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1214pub struct EncryptResult {
1215    #[cfg_attr(feature = "network", serde(with = "serde_helpers::bytes_as_array"))]
1216    pub ciphertext: Vec<u8>,
1217}
1218
1219/// Arguments for decryption.
1220#[derive(Clone, Debug)]
1221#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1222#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1223pub struct DecryptArgs {
1224    #[cfg_attr(feature = "network", serde(rename = "protocolID"))]
1225    pub protocol_id: Protocol,
1226    #[cfg_attr(feature = "network", serde(rename = "keyID"))]
1227    pub key_id: String,
1228    pub counterparty: Counterparty,
1229    #[cfg_attr(feature = "network", serde(with = "serde_helpers::bytes_as_array"))]
1230    pub ciphertext: Vec<u8>,
1231    pub privileged: bool,
1232    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
1233    pub privileged_reason: Option<String>,
1234    pub seek_permission: Option<bool>,
1235}
1236
1237/// Result of decryption.
1238#[derive(Clone, Debug)]
1239#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1240#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1241pub struct DecryptResult {
1242    #[cfg_attr(feature = "network", serde(with = "serde_helpers::bytes_as_array"))]
1243    pub plaintext: Vec<u8>,
1244}
1245
1246/// Arguments for creating an HMAC.
1247#[derive(Clone, Debug)]
1248#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1249#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1250pub struct CreateHmacArgs {
1251    #[cfg_attr(feature = "network", serde(rename = "protocolID"))]
1252    pub protocol_id: Protocol,
1253    #[cfg_attr(feature = "network", serde(rename = "keyID"))]
1254    pub key_id: String,
1255    pub counterparty: Counterparty,
1256    #[cfg_attr(feature = "network", serde(with = "serde_helpers::bytes_as_array"))]
1257    pub data: Vec<u8>,
1258    pub privileged: bool,
1259    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
1260    pub privileged_reason: Option<String>,
1261    pub seek_permission: Option<bool>,
1262}
1263
1264/// Result of creating an HMAC.
1265#[derive(Clone, Debug)]
1266#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1267#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1268pub struct CreateHmacResult {
1269    #[cfg_attr(feature = "network", serde(with = "serde_helpers::bytes_as_array"))]
1270    pub hmac: Vec<u8>,
1271}
1272
1273/// Arguments for verifying an HMAC.
1274#[derive(Clone, Debug)]
1275#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1276#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1277pub struct VerifyHmacArgs {
1278    #[cfg_attr(feature = "network", serde(rename = "protocolID"))]
1279    pub protocol_id: Protocol,
1280    #[cfg_attr(feature = "network", serde(rename = "keyID"))]
1281    pub key_id: String,
1282    pub counterparty: Counterparty,
1283    #[cfg_attr(feature = "network", serde(with = "serde_helpers::bytes_as_array"))]
1284    pub data: Vec<u8>,
1285    #[cfg_attr(feature = "network", serde(with = "serde_helpers::bytes_as_array"))]
1286    pub hmac: Vec<u8>,
1287    pub privileged: bool,
1288    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
1289    pub privileged_reason: Option<String>,
1290    pub seek_permission: Option<bool>,
1291}
1292
1293/// Result of verifying an HMAC.
1294#[derive(Clone, Debug)]
1295#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1296#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1297pub struct VerifyHmacResult {
1298    pub valid: bool,
1299}
1300
1301/// Arguments for creating a digital signature.
1302#[derive(Clone, Debug)]
1303#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1304#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1305pub struct CreateSignatureArgs {
1306    #[cfg_attr(feature = "network", serde(rename = "protocolID"))]
1307    pub protocol_id: Protocol,
1308    #[cfg_attr(feature = "network", serde(rename = "keyID"))]
1309    pub key_id: String,
1310    pub counterparty: Counterparty,
1311    #[cfg_attr(feature = "network", serde(with = "serde_helpers::bytes_as_array"))]
1312    pub data: Vec<u8>,
1313    pub privileged: bool,
1314    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
1315    pub privileged_reason: Option<String>,
1316    pub seek_permission: Option<bool>,
1317}
1318
1319/// Result of creating a digital signature.
1320#[derive(Clone, Debug)]
1321#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1322#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1323pub struct CreateSignatureResult {
1324    #[cfg_attr(feature = "network", serde(with = "serde_helpers::bytes_as_hex"))]
1325    pub signature: Vec<u8>,
1326}
1327
1328/// Arguments for verifying a digital signature.
1329#[derive(Clone, Debug)]
1330#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1331#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1332pub struct VerifySignatureArgs {
1333    #[cfg_attr(feature = "network", serde(rename = "protocolID"))]
1334    pub protocol_id: Protocol,
1335    #[cfg_attr(feature = "network", serde(rename = "keyID"))]
1336    pub key_id: String,
1337    pub counterparty: Counterparty,
1338    #[cfg_attr(feature = "network", serde(with = "serde_helpers::bytes_as_array"))]
1339    pub data: Vec<u8>,
1340    #[cfg_attr(feature = "network", serde(with = "serde_helpers::bytes_as_hex"))]
1341    pub signature: Vec<u8>,
1342    pub for_self: Option<bool>,
1343    pub privileged: bool,
1344    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
1345    pub privileged_reason: Option<String>,
1346    pub seek_permission: Option<bool>,
1347}
1348
1349/// Result of verifying a digital signature.
1350#[derive(Clone, Debug)]
1351#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1352#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1353pub struct VerifySignatureResult {
1354    pub valid: bool,
1355}
1356
1357// ---------------------------------------------------------------------------
1358// Certificate operations
1359// ---------------------------------------------------------------------------
1360
1361/// Arguments for acquiring a new certificate.
1362#[derive(Clone, Debug)]
1363#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1364#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1365pub struct AcquireCertificateArgs {
1366    #[cfg_attr(feature = "network", serde(rename = "type"))]
1367    pub cert_type: CertificateType,
1368    #[cfg_attr(feature = "network", serde(with = "serde_helpers::public_key_hex"))]
1369    pub certifier: PublicKey,
1370    pub acquisition_protocol: AcquisitionProtocol,
1371    #[cfg_attr(
1372        feature = "network",
1373        serde(skip_serializing_if = "HashMap::is_empty", default)
1374    )]
1375    pub fields: HashMap<String, String>,
1376    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
1377    pub serial_number: Option<SerialNumber>,
1378    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
1379    pub revocation_outpoint: Option<String>,
1380    #[cfg_attr(
1381        feature = "network",
1382        serde(with = "serde_helpers::option_bytes_as_hex")
1383    )]
1384    #[cfg_attr(
1385        feature = "network",
1386        serde(skip_serializing_if = "Option::is_none", default)
1387    )]
1388    pub signature: Option<Vec<u8>>,
1389    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
1390    pub certifier_url: Option<String>,
1391    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
1392    pub keyring_revealer: Option<KeyringRevealer>,
1393    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
1394    pub keyring_for_subject: Option<HashMap<String, String>>,
1395    pub privileged: bool,
1396    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
1397    pub privileged_reason: Option<String>,
1398}
1399
1400/// Arguments for listing certificates.
1401#[derive(Clone, Debug)]
1402#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1403#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1404pub struct ListCertificatesArgs {
1405    #[cfg_attr(feature = "network", serde(with = "serde_helpers::vec_public_key_hex"))]
1406    pub certifiers: Vec<PublicKey>,
1407    pub types: Vec<CertificateType>,
1408    pub limit: PositiveIntegerDefault10Max10000,
1409    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
1410    pub offset: Option<PositiveIntegerOrZero>,
1411    pub privileged: BooleanDefaultFalse,
1412    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
1413    pub privileged_reason: Option<String>,
1414}
1415
1416/// A certificate with its keyring and verifier.
1417#[derive(Clone, Debug)]
1418#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1419#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1420pub struct CertificateResult {
1421    #[cfg_attr(feature = "network", serde(flatten))]
1422    pub certificate: Certificate,
1423    pub keyring: HashMap<String, String>,
1424    #[cfg_attr(
1425        feature = "network",
1426        serde(with = "serde_helpers::option_bytes_as_hex")
1427    )]
1428    #[cfg_attr(
1429        feature = "network",
1430        serde(skip_serializing_if = "Option::is_none", default)
1431    )]
1432    pub verifier: Option<Vec<u8>>,
1433}
1434
1435/// Paginated list of certificates.
1436#[derive(Clone, Debug)]
1437#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1438#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1439pub struct ListCertificatesResult {
1440    pub total_certificates: u32,
1441    pub certificates: Vec<CertificateResult>,
1442}
1443
1444/// Arguments for creating a verifiable certificate.
1445#[derive(Clone, Debug)]
1446#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1447#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1448pub struct ProveCertificateArgs {
1449    pub certificate: Certificate,
1450    pub fields_to_reveal: Vec<String>,
1451    #[cfg_attr(feature = "network", serde(with = "serde_helpers::public_key_hex"))]
1452    pub verifier: PublicKey,
1453    pub privileged: BooleanDefaultFalse,
1454    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
1455    pub privileged_reason: Option<String>,
1456}
1457
1458/// Result of creating a verifiable certificate.
1459#[derive(Clone, Debug)]
1460#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1461#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1462pub struct ProveCertificateResult {
1463    pub keyring_for_verifier: HashMap<String, String>,
1464}
1465
1466/// Arguments for relinquishing ownership of a certificate.
1467#[derive(Clone, Debug)]
1468#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1469#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1470pub struct RelinquishCertificateArgs {
1471    #[cfg_attr(feature = "network", serde(rename = "type"))]
1472    pub cert_type: CertificateType,
1473    pub serial_number: SerialNumber,
1474    #[cfg_attr(feature = "network", serde(with = "serde_helpers::public_key_hex"))]
1475    pub certifier: PublicKey,
1476}
1477
1478/// Result of relinquishing a certificate.
1479#[derive(Clone, Debug)]
1480#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1481#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1482pub struct RelinquishCertificateResult {
1483    pub relinquished: bool,
1484}
1485
1486// ---------------------------------------------------------------------------
1487// Discovery types
1488// ---------------------------------------------------------------------------
1489
1490/// Information about an entity that issues identity certificates.
1491#[derive(Clone, Debug)]
1492#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1493#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1494pub struct IdentityCertifier {
1495    pub name: String,
1496    pub icon_url: String,
1497    pub description: String,
1498    pub trust: u8,
1499}
1500
1501/// An identity certificate with decoded fields and certifier info.
1502#[derive(Clone, Debug)]
1503#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1504#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1505pub struct IdentityCertificate {
1506    #[cfg_attr(feature = "network", serde(flatten))]
1507    pub certificate: Certificate,
1508    pub certifier_info: IdentityCertifier,
1509    pub publicly_revealed_keyring: HashMap<String, String>,
1510    pub decrypted_fields: HashMap<String, String>,
1511}
1512
1513/// Arguments for discovering certificates by identity key.
1514#[derive(Clone, Debug)]
1515#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1516#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1517pub struct DiscoverByIdentityKeyArgs {
1518    #[cfg_attr(feature = "network", serde(with = "serde_helpers::public_key_hex"))]
1519    pub identity_key: PublicKey,
1520    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
1521    pub limit: Option<u32>,
1522    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
1523    pub offset: Option<u32>,
1524    pub seek_permission: Option<bool>,
1525}
1526
1527/// Arguments for discovering certificates by attributes.
1528#[derive(Clone, Debug)]
1529#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1530#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1531pub struct DiscoverByAttributesArgs {
1532    pub attributes: HashMap<String, String>,
1533    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
1534    pub limit: Option<u32>,
1535    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
1536    pub offset: Option<u32>,
1537    pub seek_permission: Option<bool>,
1538}
1539
1540/// Paginated list of identity certificates found during discovery.
1541#[derive(Clone, Debug)]
1542#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1543#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1544pub struct DiscoverCertificatesResult {
1545    pub total_certificates: u32,
1546    pub certificates: Vec<IdentityCertificate>,
1547}
1548
1549// ---------------------------------------------------------------------------
1550// Key linkage types
1551// ---------------------------------------------------------------------------
1552
1553/// Arguments for revealing key linkage between counterparties.
1554#[derive(Clone, Debug)]
1555#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1556#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1557pub struct RevealCounterpartyKeyLinkageArgs {
1558    #[cfg_attr(feature = "network", serde(with = "serde_helpers::public_key_hex"))]
1559    pub counterparty: PublicKey,
1560    #[cfg_attr(feature = "network", serde(with = "serde_helpers::public_key_hex"))]
1561    pub verifier: PublicKey,
1562    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
1563    pub privileged: Option<bool>,
1564    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
1565    pub privileged_reason: Option<String>,
1566}
1567
1568/// Result of revealing counterparty key linkage.
1569#[derive(Clone, Debug)]
1570#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1571#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1572pub struct RevealCounterpartyKeyLinkageResult {
1573    #[cfg_attr(feature = "network", serde(with = "serde_helpers::public_key_hex"))]
1574    pub prover: PublicKey,
1575    #[cfg_attr(feature = "network", serde(with = "serde_helpers::public_key_hex"))]
1576    pub counterparty: PublicKey,
1577    #[cfg_attr(feature = "network", serde(with = "serde_helpers::public_key_hex"))]
1578    pub verifier: PublicKey,
1579    pub revelation_time: String,
1580    #[cfg_attr(feature = "network", serde(with = "serde_helpers::bytes_as_array"))]
1581    pub encrypted_linkage: Vec<u8>,
1582    #[cfg_attr(feature = "network", serde(with = "serde_helpers::bytes_as_array"))]
1583    pub encrypted_linkage_proof: Vec<u8>,
1584}
1585
1586/// Arguments for revealing specific key linkage.
1587#[derive(Clone, Debug)]
1588#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1589#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1590pub struct RevealSpecificKeyLinkageArgs {
1591    pub counterparty: Counterparty,
1592    #[cfg_attr(feature = "network", serde(with = "serde_helpers::public_key_hex"))]
1593    pub verifier: PublicKey,
1594    #[cfg_attr(feature = "network", serde(rename = "protocolID"))]
1595    pub protocol_id: Protocol,
1596    #[cfg_attr(feature = "network", serde(rename = "keyID"))]
1597    pub key_id: String,
1598    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
1599    pub privileged: Option<bool>,
1600    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
1601    pub privileged_reason: Option<String>,
1602}
1603
1604/// Result of revealing specific key linkage.
1605#[derive(Clone, Debug)]
1606#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1607#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1608pub struct RevealSpecificKeyLinkageResult {
1609    #[cfg_attr(feature = "network", serde(with = "serde_helpers::bytes_as_array"))]
1610    pub encrypted_linkage: Vec<u8>,
1611    #[cfg_attr(feature = "network", serde(with = "serde_helpers::bytes_as_array"))]
1612    pub encrypted_linkage_proof: Vec<u8>,
1613    #[cfg_attr(feature = "network", serde(with = "serde_helpers::public_key_hex"))]
1614    pub prover: PublicKey,
1615    #[cfg_attr(feature = "network", serde(with = "serde_helpers::public_key_hex"))]
1616    pub verifier: PublicKey,
1617    #[cfg_attr(feature = "network", serde(with = "serde_helpers::public_key_hex"))]
1618    pub counterparty: PublicKey,
1619    #[cfg_attr(feature = "network", serde(rename = "protocolID"))]
1620    pub protocol_id: Protocol,
1621    #[cfg_attr(feature = "network", serde(rename = "keyID"))]
1622    pub key_id: String,
1623    pub proof_type: u8,
1624}
1625
1626// ---------------------------------------------------------------------------
1627// Auth/Info types
1628// ---------------------------------------------------------------------------
1629
1630/// Whether the current session is authenticated.
1631#[derive(Clone, Debug)]
1632#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1633#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1634pub struct AuthenticatedResult {
1635    pub authenticated: bool,
1636}
1637
1638/// Current blockchain height.
1639#[derive(Clone, Debug)]
1640#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1641#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1642pub struct GetHeightResult {
1643    pub height: u32,
1644}
1645
1646/// Arguments for retrieving a blockchain header at a specific height.
1647#[derive(Clone, Debug)]
1648#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1649#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1650pub struct GetHeaderArgs {
1651    pub height: u32,
1652}
1653
1654/// Blockchain header data for the requested height.
1655#[derive(Clone, Debug)]
1656#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1657#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1658pub struct GetHeaderResult {
1659    #[cfg_attr(feature = "network", serde(with = "serde_helpers::bytes_as_hex"))]
1660    pub header: Vec<u8>,
1661}
1662
1663/// Current blockchain network.
1664#[derive(Clone, Debug)]
1665#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1666#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1667pub struct GetNetworkResult {
1668    pub network: Network,
1669}
1670
1671/// Version information about the wallet implementation.
1672#[derive(Clone, Debug)]
1673#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
1674#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
1675pub struct GetVersionResult {
1676    pub version: String,
1677}
1678
1679// ---------------------------------------------------------------------------
1680// WalletInterface trait
1681// ---------------------------------------------------------------------------
1682
1683/// The core wallet interface with all 28 async methods.
1684///
1685/// Uses native async fn in traits (RPITIT, Rust 1.75+) so this trait
1686/// is NOT object-safe. Use generics (not dyn dispatch) when parameterizing
1687/// over wallet implementations.
1688///
1689/// Every method takes `originator: Option<&str>` as the last parameter,
1690/// identifying the calling application domain.
1691#[allow(async_fn_in_trait)]
1692pub trait WalletInterface {
1693    // -- Action methods --
1694
1695    async fn create_action(
1696        &self,
1697        args: CreateActionArgs,
1698        originator: Option<&str>,
1699    ) -> Result<CreateActionResult, WalletError>;
1700
1701    async fn sign_action(
1702        &self,
1703        args: SignActionArgs,
1704        originator: Option<&str>,
1705    ) -> Result<SignActionResult, WalletError>;
1706
1707    async fn abort_action(
1708        &self,
1709        args: AbortActionArgs,
1710        originator: Option<&str>,
1711    ) -> Result<AbortActionResult, WalletError>;
1712
1713    async fn list_actions(
1714        &self,
1715        args: ListActionsArgs,
1716        originator: Option<&str>,
1717    ) -> Result<ListActionsResult, WalletError>;
1718
1719    async fn internalize_action(
1720        &self,
1721        args: InternalizeActionArgs,
1722        originator: Option<&str>,
1723    ) -> Result<InternalizeActionResult, WalletError>;
1724
1725    // -- Output methods --
1726
1727    async fn list_outputs(
1728        &self,
1729        args: ListOutputsArgs,
1730        originator: Option<&str>,
1731    ) -> Result<ListOutputsResult, WalletError>;
1732
1733    async fn relinquish_output(
1734        &self,
1735        args: RelinquishOutputArgs,
1736        originator: Option<&str>,
1737    ) -> Result<RelinquishOutputResult, WalletError>;
1738
1739    // -- Key/Crypto methods --
1740
1741    async fn get_public_key(
1742        &self,
1743        args: GetPublicKeyArgs,
1744        originator: Option<&str>,
1745    ) -> Result<GetPublicKeyResult, WalletError>;
1746
1747    async fn reveal_counterparty_key_linkage(
1748        &self,
1749        args: RevealCounterpartyKeyLinkageArgs,
1750        originator: Option<&str>,
1751    ) -> Result<RevealCounterpartyKeyLinkageResult, WalletError>;
1752
1753    async fn reveal_specific_key_linkage(
1754        &self,
1755        args: RevealSpecificKeyLinkageArgs,
1756        originator: Option<&str>,
1757    ) -> Result<RevealSpecificKeyLinkageResult, WalletError>;
1758
1759    async fn encrypt(
1760        &self,
1761        args: EncryptArgs,
1762        originator: Option<&str>,
1763    ) -> Result<EncryptResult, WalletError>;
1764
1765    async fn decrypt(
1766        &self,
1767        args: DecryptArgs,
1768        originator: Option<&str>,
1769    ) -> Result<DecryptResult, WalletError>;
1770
1771    async fn create_hmac(
1772        &self,
1773        args: CreateHmacArgs,
1774        originator: Option<&str>,
1775    ) -> Result<CreateHmacResult, WalletError>;
1776
1777    async fn verify_hmac(
1778        &self,
1779        args: VerifyHmacArgs,
1780        originator: Option<&str>,
1781    ) -> Result<VerifyHmacResult, WalletError>;
1782
1783    async fn create_signature(
1784        &self,
1785        args: CreateSignatureArgs,
1786        originator: Option<&str>,
1787    ) -> Result<CreateSignatureResult, WalletError>;
1788
1789    async fn verify_signature(
1790        &self,
1791        args: VerifySignatureArgs,
1792        originator: Option<&str>,
1793    ) -> Result<VerifySignatureResult, WalletError>;
1794
1795    // -- Certificate methods --
1796
1797    async fn acquire_certificate(
1798        &self,
1799        args: AcquireCertificateArgs,
1800        originator: Option<&str>,
1801    ) -> Result<Certificate, WalletError>;
1802
1803    async fn list_certificates(
1804        &self,
1805        args: ListCertificatesArgs,
1806        originator: Option<&str>,
1807    ) -> Result<ListCertificatesResult, WalletError>;
1808
1809    async fn prove_certificate(
1810        &self,
1811        args: ProveCertificateArgs,
1812        originator: Option<&str>,
1813    ) -> Result<ProveCertificateResult, WalletError>;
1814
1815    async fn relinquish_certificate(
1816        &self,
1817        args: RelinquishCertificateArgs,
1818        originator: Option<&str>,
1819    ) -> Result<RelinquishCertificateResult, WalletError>;
1820
1821    // -- Discovery methods --
1822
1823    async fn discover_by_identity_key(
1824        &self,
1825        args: DiscoverByIdentityKeyArgs,
1826        originator: Option<&str>,
1827    ) -> Result<DiscoverCertificatesResult, WalletError>;
1828
1829    async fn discover_by_attributes(
1830        &self,
1831        args: DiscoverByAttributesArgs,
1832        originator: Option<&str>,
1833    ) -> Result<DiscoverCertificatesResult, WalletError>;
1834
1835    // -- Auth/Info methods --
1836
1837    async fn is_authenticated(
1838        &self,
1839        originator: Option<&str>,
1840    ) -> Result<AuthenticatedResult, WalletError>;
1841
1842    async fn wait_for_authentication(
1843        &self,
1844        originator: Option<&str>,
1845    ) -> Result<AuthenticatedResult, WalletError>;
1846
1847    async fn get_height(&self, originator: Option<&str>) -> Result<GetHeightResult, WalletError>;
1848
1849    async fn get_header_for_height(
1850        &self,
1851        args: GetHeaderArgs,
1852        originator: Option<&str>,
1853    ) -> Result<GetHeaderResult, WalletError>;
1854
1855    async fn get_network(&self, originator: Option<&str>) -> Result<GetNetworkResult, WalletError>;
1856
1857    async fn get_version(&self, originator: Option<&str>) -> Result<GetVersionResult, WalletError>;
1858}