From dbfbaf8b22a2f6ebf7f6c5294609352e92a06bb4 Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Mon, 1 Jun 2026 20:49:32 +0000 Subject: [PATCH 01/13] serde: modernize serde imports Stop using `actual-serde` as a dependency; use `dep:` syntax. Also stop using `#[macro_use]` on the import; instead import the macros like a normal symbol. Also, rather than `use serde::{Serialize, Deserialize}`, fully-qualify the trait names every time they're used. This helps avoid compiler confusion between the serde methods and any other methods named serialize() that happen to be in scope. --- Cargo.toml | 7 ++----- src/blind.rs | 3 +-- src/lib.rs | 3 +-- src/locktime.rs | 9 +++------ src/pset/map/global.rs | 4 ++-- src/pset/map/input.rs | 2 +- src/pset/map/output.rs | 4 ++-- src/pset/mod.rs | 2 +- src/pset/raw.rs | 9 +++------ src/schnorr.rs | 2 +- src/serde_utils.rs | 6 ++---- src/taproot.rs | 13 ++++++------- src/transaction.rs | 3 +-- 13 files changed, 26 insertions(+), 41 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4ff2578c..79d9dd0b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,10 +19,10 @@ default = ["json-contract"] json-contract = ["serde_json"] "serde" = [ + "dep:serde", "bitcoin/serde", "bitcoin/serde", "secp256k1-zkp/serde", - "actual-serde", ] base64 = ["bitcoin/base64"] @@ -33,10 +33,7 @@ secp256k1-zkp = { version = "0.11.0", features = ["global-context", "hashes"] } # Used for ContractHash::from_json_contract. serde_json = { version = "1.0", optional = true } - -actual-serde = { package = "serde", version = "1.0.103", features = [ - "derive", -], optional = true } +serde = { version = "1.0.103", features = [ "derive" ], optional = true } hex = { package = "hex-conservative", version = "1.1.0" } diff --git a/src/blind.rs b/src/blind.rs index bd611259..f95b3bf0 100644 --- a/src/blind.rs +++ b/src/blind.rs @@ -224,8 +224,7 @@ impl RangeProofMessage { /// Information about Transaction Input Asset #[cfg_attr( feature = "serde", - derive(Serialize, Deserialize), - serde(crate = "actual_serde") + derive(serde::Serialize, serde::Deserialize), )] #[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)] pub struct TxOutSecrets { diff --git a/src/lib.rs b/src/lib.rs index 5002c4ad..727de00b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -34,8 +34,7 @@ pub extern crate hex; pub extern crate secp256k1_zkp; /// Re-export of serde crate #[cfg(feature = "serde")] -#[macro_use] -pub extern crate actual_serde as serde; +pub extern crate serde; #[cfg(all(test, feature = "serde"))] extern crate serde_test; diff --git a/src/locktime.rs b/src/locktime.rs index e93f10b6..0fd8c043 100644 --- a/src/locktime.rs +++ b/src/locktime.rs @@ -66,8 +66,7 @@ pub const LOCK_TIME_THRESHOLD: u32 = 500_000_000; /// ``` #[allow(clippy::derive_ord_xor_partial_ord)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum LockTime { /// A block height lock time value. /// @@ -293,8 +292,7 @@ impl Decodable for LockTime { /// An absolute block height, guaranteed to always contain a valid height value. #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Height(u32); impl Height { @@ -379,8 +377,7 @@ impl TryFrom for Height { /// `to_consensus_u32()`. Said another way, `Time(x)` means 'x seconds since epoch' _not_ '(x - /// threshold) seconds since epoch'. #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Time(u32); impl Time { diff --git a/src/pset/map/global.rs b/src/pset/map/global.rs index 4f9b0e24..0c1cb018 100644 --- a/src/pset/map/global.rs +++ b/src/pset/map/global.rs @@ -58,7 +58,7 @@ const PSBT_ELEMENTS_GLOBAL_TX_MODIFIABLE: u8 = 0x01; /// Global transaction data #[derive(Debug, Clone, PartialEq)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(crate = "actual_serde"))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct TxData { /// Transaction version. Must be 2. pub version: u32, @@ -93,7 +93,7 @@ impl Default for TxData { /// A key-value map for global data. #[derive(Clone, Debug, PartialEq)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(crate = "actual_serde"))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Global { /// Global transaction data #[cfg_attr(feature = "serde", serde(flatten))] diff --git a/src/pset/map/input.rs b/src/pset/map/input.rs index 72702525..834056a8 100644 --- a/src/pset/map/input.rs +++ b/src/pset/map/input.rs @@ -171,7 +171,7 @@ const PSBT_ELEMENTS_IN_BLINDED_ISSUANCE: u8 = 0x15; /// A key-value map for an input of the corresponding index in the unsigned /// transaction. #[derive(Clone, Debug, PartialEq)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(crate = "actual_serde"))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Input { /// The non-witness transaction this input spends from. Should only be /// [`std::option::Option::Some`] for inputs which spend non-segwit outputs or diff --git a/src/pset/map/output.rs b/src/pset/map/output.rs index d86d3389..69e361c4 100644 --- a/src/pset/map/output.rs +++ b/src/pset/map/output.rs @@ -87,7 +87,7 @@ const PSBT_ELEMENTS_OUT_BLIND_ASSET_PROOF: u8 = 0x0a; /// A key-value map for an output of the corresponding index in the unsigned /// transaction. #[derive(Clone, Default, Debug, PartialEq)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(crate = "actual_serde"))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Output { /// The redeem script for this output. pub redeem_script: Option