Skip to content

Commit

Permalink
Derive Serialize and Deserialize for as many API types as possible
Browse files Browse the repository at this point in the history
  • Loading branch information
casey committed Nov 9, 2023
1 parent 413da8c commit d85da1d
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions json/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Address<NetworkUnchecked>>,
pub category: GetTransactionResultDetailCategory,
Expand All @@ -682,7 +682,7 @@ pub struct GetTransactionResultDetail {
pub abandoned: Option<bool>,
}

#[derive(Clone, PartialEq, Eq, Debug, Deserialize)]
#[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize)]
pub struct WalletTxInfo {
pub confirmations: i32,
pub blockhash: Option<bitcoin::BlockHash>,
Expand All @@ -699,7 +699,7 @@ pub struct WalletTxInfo {
pub wallet_conflicts: Vec<bitcoin::Txid>,
}

#[derive(Clone, PartialEq, Eq, Debug, Deserialize)]
#[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize)]
pub struct GetTransactionResult {
#[serde(flatten)]
pub info: WalletTxInfo,
Expand All @@ -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,
Expand All @@ -729,7 +729,7 @@ pub struct ListTransactionResult {
pub comment: Option<String>,
}

#[derive(Clone, PartialEq, Eq, Debug, Deserialize)]
#[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize)]
pub struct ListSinceBlockResult {
pub transactions: Vec<ListTransactionResult>,
#[serde(default)]
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -1894,7 +1894,7 @@ pub struct FundRawTransactionOptions {
pub estimate_mode: Option<EstimateMode>,
}

#[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")]
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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),
Expand Down

0 comments on commit d85da1d

Please sign in to comment.