diff --git a/clients/Cargo.toml b/clients/Cargo.toml index 1cfb1ca..3f18b3d 100644 --- a/clients/Cargo.toml +++ b/clients/Cargo.toml @@ -25,4 +25,5 @@ serde_json = "1.0.89" time = "0.3.21" tokio = {version = "1.21.2", features=["rt-multi-thread", "sync", "signal", "macros", "process", "time", "fs", "net"]} tokio-tungstenite = {version = "0.20.0", features = ["rustls-tls-webpki-roots", "rustls"] } +urlencoding = "2.1.3" uuid = {version="1.2.2", features=["v4"]} \ No newline at end of file diff --git a/clients/src/api/responses.rs b/clients/src/api/responses.rs index 5a7cd8a..b4848fe 100644 --- a/clients/src/api/responses.rs +++ b/clients/src/api/responses.rs @@ -12,108 +12,108 @@ use dg_xch_core::blockchain::unfinished_block::UnfinishedBlock; use dg_xch_core::blockchain::wallet_balance::WalletBalance; use dg_xch_core::blockchain::wallet_info::WalletInfo; -use serde::Deserialize; +use serde::{Deserialize, Serialize}; use std::collections::HashMap; -#[derive(Debug, Clone, Deserialize)] +#[derive(Debug, Clone, Deserialize, Serialize)] pub struct AdditionsAndRemovalsResp { pub additions: Vec, pub removals: Vec, pub success: bool, } -#[derive(Debug, Clone, Deserialize)] +#[derive(Debug, Clone, Deserialize, Serialize)] pub struct BlockchainStateResp { pub blockchain_state: BlockchainState, pub success: bool, } -#[derive(Debug, Clone, Deserialize)] +#[derive(Debug, Clone, Deserialize, Serialize)] pub struct BlockRecordResp { pub block_record: BlockRecord, pub success: bool, } -#[derive(Debug, Clone, Deserialize)] +#[derive(Debug, Clone, Deserialize, Serialize)] pub struct BlockRecordAryResp { pub block_records: Vec, pub success: bool, } -#[derive(Debug, Clone, Deserialize)] +#[derive(Debug, Clone, Deserialize, Serialize)] pub struct CoinRecordResp { pub coin_record: Option, pub success: bool, } -#[derive(Debug, Clone, Deserialize)] +#[derive(Debug, Clone, Deserialize, Serialize)] pub struct CoinRecordAryResp { pub coin_records: Vec, pub success: bool, } -#[derive(Debug, Clone, Deserialize)] +#[derive(Debug, Clone, Deserialize, Serialize)] pub struct CoinSpendResp { pub coin_solution: CoinSpend, pub success: bool, } -#[derive(Debug, Clone, Deserialize)] +#[derive(Debug, Clone, Deserialize, Serialize)] pub struct FullBlockResp { pub block: FullBlock, pub success: bool, } -#[derive(Debug, Clone, Deserialize)] +#[derive(Debug, Clone, Deserialize, Serialize)] pub struct FullBlockAryResp { pub blocks: Vec, pub success: bool, } -#[derive(Debug, Clone, Deserialize)] +#[derive(Debug, Clone, Deserialize, Serialize)] pub struct InitialFreezePeriodResp { pub initial_freeze_end_timestamp: u64, pub success: bool, } -#[derive(Debug, Clone, Deserialize)] +#[derive(Debug, Clone, Deserialize, Serialize)] pub struct LoginResp { pub fingerprint: u32, pub success: bool, } -#[derive(Debug, Clone, Deserialize)] +#[derive(Debug, Clone, Deserialize, Serialize)] pub struct MempoolItemResp { pub mempool_item: MempoolItem, pub success: bool, } -#[derive(Debug, Clone, Deserialize)] +#[derive(Debug, Clone, Deserialize, Serialize)] pub struct MempoolItemsResp { pub mempool_items: HashMap, pub success: bool, } -#[derive(Debug, Clone, Deserialize)] +#[derive(Debug, Clone, Deserialize, Serialize)] pub struct MempoolTXResp { pub tx_ids: Vec, pub success: bool, } -#[derive(Debug, Clone, Deserialize)] +#[derive(Debug, Clone, Deserialize, Serialize)] pub struct NetworkInfoResp { pub network_name: String, pub network_prefix: String, pub success: bool, } -#[derive(Debug, Clone, Deserialize)] +#[derive(Debug, Clone, Deserialize, Serialize)] pub struct NetSpaceResp { pub space: u64, pub success: bool, } -#[derive(Debug, Clone, Deserialize)] +#[derive(Debug, Clone, Deserialize, Serialize)] pub struct SignagePointOrEOSResp { pub signage_point: Option, pub eos: Option, @@ -122,43 +122,43 @@ pub struct SignagePointOrEOSResp { pub success: bool, } -#[derive(Debug, Clone, Deserialize)] +#[derive(Debug, Clone, Deserialize, Serialize)] pub struct SignedTransactionRecordResp { pub signed_tx: TransactionRecord, pub success: bool, } -#[derive(Debug, Clone, Deserialize)] +#[derive(Debug, Clone, Deserialize, Serialize)] pub struct TXResp { pub status: TXStatus, pub success: bool, } -#[derive(Debug, Clone, Deserialize)] +#[derive(Debug, Clone, Deserialize, Serialize)] pub struct TransactionRecordResp { pub transaction: TransactionRecord, pub success: bool, } -#[derive(Debug, Clone, Deserialize)] +#[derive(Debug, Clone, Deserialize, Serialize)] pub struct UnfinishedBlockAryResp { pub headers: Vec, pub success: bool, } -#[derive(Debug, Clone, Deserialize)] +#[derive(Debug, Clone, Deserialize, Serialize)] pub struct WalletBalanceResp { pub wallets: Vec, pub success: bool, } -#[derive(Debug, Clone, Deserialize)] +#[derive(Debug, Clone, Deserialize, Serialize)] pub struct WalletInfoResp { pub wallets: Vec, pub success: bool, } -#[derive(Debug, Clone, Deserialize)] +#[derive(Debug, Clone, Deserialize, Serialize)] pub struct WalletSyncResp { pub genesis_initialized: bool, pub synced: bool, diff --git a/clients/src/websocket/mod.rs b/clients/src/websocket/mod.rs index 7dcded7..8ada069 100644 --- a/clients/src/websocket/mod.rs +++ b/clients/src/websocket/mod.rs @@ -30,6 +30,7 @@ use tokio_tungstenite::tungstenite::Message; use tokio_tungstenite::{ connect_async_tls_with_config, Connector, MaybeTlsStream, WebSocketStream, }; +use urlencoding::encode; use uuid::Uuid; pub async fn await_termination() -> Result<(), Error> { @@ -151,6 +152,21 @@ pub async fn get_client_generated_tls( format!("Failed to Parse Request: {}", e), ) })?; + request.headers_mut().insert( + HeaderName::from_str("chia-client-cert").map_err(|e| { + Error::new( + ErrorKind::InvalidData, + format!("Failed to Parse Header Name chia-client-cert,\r\n {}", e), + ) + })?, + HeaderValue::from_str(encode(&String::from_utf8(cert_bytes).unwrap_or_default()).as_ref()) + .map_err(|e| { + Error::new( + ErrorKind::InvalidData, + format!("Failed to Parse Header value CHIA_CA_CRT,\r\n {}", e), + ) + })?, + ); if let Some(m) = additional_headers { for (k, v) in m { request.headers_mut().insert(