Skip to content

Commit fe20da9

Browse files
committed
Add serialize to structs
1 parent e99761b commit fe20da9

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/types.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ use bitcoin::Psbt;
1111

1212
use pyo3::types::PyModule;
1313
use pyo3::{IntoPy, PyObject};
14-
use serde::{Deserialize, Deserializer};
14+
use serde::{Deserialize, Deserializer, Serialize};
1515

1616
#[cfg(feature = "miniscript")]
1717
use miniscript::{Descriptor, DescriptorPublicKey};
1818
use pyo3::prelude::PyAnyMethods;
1919

2020
use crate::error::{Error, ErrorCode};
2121

22-
#[derive(Clone, Eq, PartialEq, Debug, Deserialize)]
22+
#[derive(Clone, Eq, PartialEq, Debug, Deserialize, Serialize)]
2323
pub struct HWIExtendedPubKey {
2424
pub xpub: Xpub,
2525
}
@@ -32,7 +32,7 @@ impl Deref for HWIExtendedPubKey {
3232
}
3333
}
3434

35-
#[derive(Clone, Eq, PartialEq, Debug, Deserialize)]
35+
#[derive(Clone, Eq, PartialEq, Debug, Deserialize, Serialize)]
3636
pub struct HWISignature {
3737
#[serde(deserialize_with = "from_b64")]
3838
pub signature: Vec<u8>,
@@ -55,12 +55,12 @@ impl Deref for HWISignature {
5555
}
5656
}
5757

58-
#[derive(Clone, Eq, PartialEq, Debug, Deserialize)]
58+
#[derive(Clone, Eq, PartialEq, Debug, Deserialize, Serialize)]
5959
pub struct HWIAddress {
6060
pub address: Address<NetworkUnchecked>,
6161
}
6262

63-
#[derive(Clone, Eq, PartialEq, Debug, Deserialize)]
63+
#[derive(Clone, Eq, PartialEq, Debug, Deserialize, Serialize)]
6464
pub struct HWIPartiallySignedTransaction {
6565
#[serde(deserialize_with = "deserialize_psbt")]
6666
pub psbt: Psbt,
@@ -84,7 +84,7 @@ impl ToDescriptor for String {}
8484
#[cfg(feature = "miniscript")]
8585
impl ToDescriptor for Descriptor<DescriptorPublicKey> {}
8686

87-
#[derive(Clone, Eq, PartialEq, Debug, Deserialize)]
87+
#[derive(Clone, Eq, PartialEq, Debug, Deserialize, Serialize)]
8888
pub struct HWIDescriptor<T>
8989
where
9090
T: ToDescriptor,
@@ -93,7 +93,7 @@ where
9393
pub receive: Vec<T>,
9494
}
9595

96-
#[derive(Clone, Eq, PartialEq, Debug, Deserialize)]
96+
#[derive(Clone, Eq, PartialEq, Debug, Deserialize, Serialize)]
9797
pub struct HWIKeyPoolElement {
9898
pub desc: String,
9999
pub range: Vec<u32>,
@@ -103,7 +103,7 @@ pub struct HWIKeyPoolElement {
103103
pub watchonly: bool,
104104
}
105105

106-
#[derive(Clone, Eq, PartialEq, Debug, Deserialize)]
106+
#[derive(Clone, Eq, PartialEq, Debug, Deserialize, Serialize)]
107107
#[allow(non_camel_case_types)]
108108
pub enum HWIAddressType {
109109
Legacy,
@@ -138,7 +138,7 @@ impl IntoPy<PyObject> for HWIAddressType {
138138
}
139139
}
140140

141-
#[derive(Clone, Eq, PartialEq, Debug, Deserialize)]
141+
#[derive(Clone, Eq, PartialEq, Debug, Deserialize, Serialize)]
142142
pub struct HWIChain(bitcoin::Network);
143143

144144
impl fmt::Display for HWIChain {
@@ -186,7 +186,7 @@ pub const TESTNET: HWIChain = HWIChain(Network::Testnet);
186186
// Used internally to deserialize the result of `hwi enumerate`. This might
187187
// contain an `error`, when it does, it might not contain all the fields `HWIDevice`
188188
// is supposed to have - for this reason, they're all Option.
189-
#[derive(Clone, Eq, PartialEq, Debug, Deserialize)]
189+
#[derive(Clone, Eq, PartialEq, Debug, Deserialize, Serialize)]
190190
pub(crate) struct HWIDeviceInternal {
191191
#[serde(rename(deserialize = "type"))]
192192
pub device_type: Option<String>,
@@ -199,7 +199,7 @@ pub(crate) struct HWIDeviceInternal {
199199
pub code: Option<i8>,
200200
}
201201

202-
#[derive(Clone, Eq, PartialEq, Debug, Deserialize)]
202+
#[derive(Clone, Eq, PartialEq, Debug, Deserialize, Serialize)]
203203
pub struct HWIDevice {
204204
#[serde(rename(deserialize = "type"))]
205205
pub device_type: HWIDeviceType,
@@ -238,7 +238,7 @@ impl TryFrom<HWIDeviceInternal> for HWIDevice {
238238
}
239239
}
240240

241-
#[derive(Clone, Eq, PartialEq, Debug, Deserialize)]
241+
#[derive(Clone, Eq, PartialEq, Debug, Deserialize, Serialize)]
242242
pub struct HWIStatus {
243243
pub success: bool,
244244
}
@@ -256,7 +256,7 @@ impl From<HWIStatus> for Result<(), Error> {
256256
}
257257
}
258258

259-
#[derive(Clone, Eq, PartialEq, Debug, Deserialize)]
259+
#[derive(Clone, Eq, PartialEq, Debug, Deserialize, Serialize)]
260260
#[serde(rename_all = "lowercase")]
261261
pub enum HWIDeviceType {
262262
Ledger,

0 commit comments

Comments
 (0)