Skip to content

Commit

Permalink
Update lib.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
gruve-p committed Sep 2, 2023
1 parent 9e38374 commit 10b8454
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions json/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ use groestlcoin::block::Version;
use groestlcoin::consensus::encode;
use groestlcoin::hashes::hex::FromHex;
use groestlcoin::hashes::sha256;
use groestlcoin::{Address, Amount, PrivateKey, PublicKey, SignedAmount, Transaction, ScriptBuf, Script, bip158, bip32};
use groestlcoin::{
bip158, bip32, Address, Amount, PrivateKey, PublicKey, Script, ScriptBuf, SignedAmount,
Transaction,
};
use serde::de::Error as SerdeError;
use serde::{Deserialize, Serialize};
use std::fmt;
Expand All @@ -51,7 +54,7 @@ pub mod serde_hex {

pub fn deserialize<'de, D: Deserializer<'de>>(d: D) -> Result<Vec<u8>, D::Error> {
let hex_str: String = ::serde::Deserialize::deserialize(d)?;
Ok(FromHex::from_hex(&hex_str).map_err(D::Error::custom)?)
FromHex::from_hex(&hex_str).map_err(D::Error::custom)
}

pub mod opt {
Expand Down Expand Up @@ -134,6 +137,22 @@ pub struct LoadWalletResult {
pub warning: Option<String>,
}

#[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize)]
pub struct Descriptor {
pub desc: String,
pub timestamp: Timestamp,
pub active: bool,
pub internal: Option<bool>,
pub range: Option<(u64, u64)>,
pub next: Option<u64>,
}

#[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize)]
pub struct ListDescriptorsResult {
pub wallet_name: String,
pub descriptors: Vec<Descriptor>,
}

#[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize)]
pub struct UnloadWalletResult {
pub warning: Option<String>,
Expand Down Expand Up @@ -643,7 +662,7 @@ impl GetRawTransactionResult {
}

pub fn transaction(&self) -> Result<Transaction, encode::Error> {
Ok(encode::deserialize(&self.hex)?)
encode::deserialize(&self.hex)
}
}

Expand Down Expand Up @@ -712,7 +731,7 @@ pub struct GetTransactionResult {

impl GetTransactionResult {
pub fn transaction(&self) -> Result<Transaction, encode::Error> {
Ok(encode::deserialize(&self.hex)?)
encode::deserialize(&self.hex)
}
}

Expand Down Expand Up @@ -825,7 +844,7 @@ pub struct SignRawTransactionResult {

impl SignRawTransactionResult {
pub fn transaction(&self) -> Result<Transaction, encode::Error> {
Ok(encode::deserialize(&self.hex)?)
encode::deserialize(&self.hex)
}
}

Expand Down Expand Up @@ -1149,7 +1168,7 @@ impl<'a> serde::Serialize for ImportMultiRequestScriptPubkey<'a> {
S: serde::Serializer,
{
match *self {
ImportMultiRequestScriptPubkey::Address(ref addr) => {
ImportMultiRequestScriptPubkey::Address(addr) => {
#[derive(Serialize)]
struct Tmp<'a> {
pub address: &'a Address,
Expand Down Expand Up @@ -1406,8 +1425,6 @@ pub enum GetPeerInfoResultNetwork {
Ipv4,
Ipv6,
Onion,
#[deprecated]
Unroutable,
NotPubliclyRoutable,
I2p,
Cjdns,
Expand Down

0 comments on commit 10b8454

Please sign in to comment.