From d85da1de7746d8d0bd6d49763bae345a0aa23e3e Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Wed, 5 Oct 2022 10:26:19 -0700 Subject: [PATCH] Derive Serialize and Deserialize for as many API types as possible --- json/src/lib.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/json/src/lib.rs b/json/src/lib.rs index f6b13675..9913cfd9 100644 --- a/json/src/lib.rs +++ b/json/src/lib.rs @@ -669,7 +669,7 @@ pub enum GetTransactionResultDetailCategory { Orphan, } -#[derive(Clone, PartialEq, Eq, Debug, Deserialize)] +#[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize)] pub struct GetTransactionResultDetail { pub address: Option>, pub category: GetTransactionResultDetailCategory, @@ -682,7 +682,7 @@ pub struct GetTransactionResultDetail { pub abandoned: Option, } -#[derive(Clone, PartialEq, Eq, Debug, Deserialize)] +#[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize)] pub struct WalletTxInfo { pub confirmations: i32, pub blockhash: Option, @@ -699,7 +699,7 @@ pub struct WalletTxInfo { pub wallet_conflicts: Vec, } -#[derive(Clone, PartialEq, Eq, Debug, Deserialize)] +#[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize)] pub struct GetTransactionResult { #[serde(flatten)] pub info: WalletTxInfo, @@ -718,7 +718,7 @@ impl GetTransactionResult { } } -#[derive(Clone, PartialEq, Eq, Debug, Deserialize)] +#[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize)] pub struct ListTransactionResult { #[serde(flatten)] pub info: WalletTxInfo, @@ -729,7 +729,7 @@ pub struct ListTransactionResult { pub comment: Option, } -#[derive(Clone, PartialEq, Eq, Debug, Deserialize)] +#[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize)] pub struct ListSinceBlockResult { pub transactions: Vec, #[serde(default)] @@ -1853,7 +1853,7 @@ impl serde::Serialize for SigHashType { } // Used for createrawtransaction argument. -#[derive(Serialize, Clone, PartialEq, Eq, Debug)] +#[derive(Serialize, Clone, PartialEq, Eq, Debug, Deserialize)] #[serde(rename_all = "camelCase")] pub struct CreateRawTransactionInput { pub txid: bitcoin::Txid, @@ -1894,7 +1894,7 @@ pub struct FundRawTransactionOptions { pub estimate_mode: Option, } -#[derive(Deserialize, Clone, PartialEq, Eq, Debug)] +#[derive(Deserialize, Clone, PartialEq, Eq, Debug, Serialize)] #[serde(rename_all = "camelCase")] pub struct FundRawTransactionResult { #[serde(with = "crate::serde_hex")] @@ -1905,7 +1905,7 @@ pub struct FundRawTransactionResult { pub change_position: i32, } -#[derive(Deserialize, Clone, PartialEq, Eq, Debug)] +#[derive(Deserialize, Clone, PartialEq, Eq, Debug, Serialize)] pub struct GetBalancesResultEntry { #[serde(with = "bitcoin::amount::serde::as_btc")] pub trusted: Amount, @@ -1915,7 +1915,7 @@ pub struct GetBalancesResultEntry { pub immature: Amount, } -#[derive(Deserialize, Clone, PartialEq, Eq, Debug)] +#[derive(Deserialize, Clone, PartialEq, Eq, Debug, Serialize)] #[serde(rename_all = "camelCase")] pub struct GetBalancesResult { pub mine: GetBalancesResultEntry, @@ -1929,7 +1929,7 @@ impl FundRawTransactionResult { } // Used for signrawtransaction argument. -#[derive(Serialize, Clone, PartialEq, Debug)] +#[derive(Serialize, Clone, PartialEq, Debug, Deserialize)] #[serde(rename_all = "camelCase")] pub struct SignRawTransactionInput { pub txid: bitcoin::Txid, @@ -1946,7 +1946,7 @@ pub struct SignRawTransactionInput { } /// Used to represent UTXO set hash type -#[derive(Clone, Serialize, PartialEq, Eq, Debug)] +#[derive(Clone, Serialize, PartialEq, Eq, Debug, Deserialize)] #[serde(rename_all = "snake_case")] pub enum TxOutSetHashType { HashSerialized2, @@ -1955,7 +1955,7 @@ pub enum TxOutSetHashType { } /// Used to specify a block hash or a height -#[derive(Clone, Serialize, PartialEq, Eq, Debug)] +#[derive(Clone, Serialize, PartialEq, Eq, Debug, Deserialize)] #[serde(untagged)] pub enum HashOrHeight { BlockHash(bitcoin::BlockHash),