vta_sdk/protocols/key_management/
create.rs1use chrono::{DateTime, Utc};
2use serde::{Deserialize, Serialize};
3
4use crate::keys::{KeyOrigin, KeyStatus, KeyType};
5
6#[derive(Clone, Serialize, Deserialize)]
7#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
8pub struct CreateKeyBody {
9 pub key_type: KeyType,
10 pub derivation_path: String,
11 pub mnemonic: Option<String>,
12 pub label: Option<String>,
13 pub context_id: Option<String>,
14}
15
16impl std::fmt::Debug for CreateKeyBody {
20 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21 f.debug_struct("CreateKeyBody")
22 .field("key_type", &self.key_type)
23 .field("derivation_path", &self.derivation_path)
24 .field("mnemonic", &self.mnemonic.as_ref().map(|_| "<redacted>"))
25 .field("label", &self.label)
26 .field("context_id", &self.context_id)
27 .finish()
28 }
29}
30
31#[derive(Debug, Clone, Serialize, Deserialize)]
32#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
33pub struct CreateKeyResultBody {
34 pub key_id: String,
35 pub key_type: KeyType,
36 pub derivation_path: String,
37 pub public_key: String,
38 pub status: KeyStatus,
39 pub label: Option<String>,
40 #[serde(default = "default_derived")]
41 pub origin: KeyOrigin,
42 pub created_at: DateTime<Utc>,
43}
44
45fn default_derived() -> KeyOrigin {
46 KeyOrigin::Derived
47}