Skip to content

Commit

Permalink
Rename serde-feature to serde
Browse files Browse the repository at this point in the history
  • Loading branch information
RCasatta committed Oct 3, 2022
1 parent 7a53252 commit 6039cc4
Show file tree
Hide file tree
Showing 14 changed files with 26 additions and 22 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
@@ -1,5 +1,6 @@
# unreleased

- the feature "serde-feature" is now renamed to just "serde"
- update MSRV to 1.41.1
- breaking change in serde in how the Nonce is serialized
- `Block`, `BlockHeader`, `PeginData`, `PegoutData` loose the Default impl
Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Expand Up @@ -14,10 +14,10 @@ default = [ "json-contract" ]
integration = [ "elementsd" ]

json-contract = [ "serde_json" ]
"serde-feature" = [
"serde" = [
"bitcoin/serde",
"secp256k1-zkp/use-serde",
"serde"
"actual-serde"
]
"fuzztarget" = []

Expand All @@ -34,7 +34,7 @@ bitcoin_hashes = "0.11.0"
# Used for ContractHash::from_json_contract.
serde_json = { version = "1.0", optional = true }

serde = { version = "1.0", features=["derive"], optional = true }
actual-serde = { package="serde", version = "1.0", features=["derive"], optional = true }

# This should be an optional dev-dependency (only needed for integration tests),
# but dev-dependency cannot be optional, and without optionality older toolchain try to compile it and fails
Expand Down
2 changes: 1 addition & 1 deletion contrib/test.sh
@@ -1,6 +1,6 @@
#!/bin/sh -ex

FEATURES="serde-feature"
FEATURES="serde"

# Use toolchain if explicitly specified
if [ -n "$TOOLCHAIN" ]
Expand Down
2 changes: 1 addition & 1 deletion fuzz/Cargo.toml
Expand Up @@ -15,7 +15,7 @@ honggfuzz_fuzz = ["honggfuzz"]
[dependencies]
honggfuzz = { version = "0.5", optional = true, default-features = false }
afl = { version = "0.11", optional = true }
elements = { path = "..", features = ["fuzztarget", "serde-feature"] }
elements = { path = "..", features = ["fuzztarget", "serde"] }

# Prevent this from interfering with workspaces
[workspace]
Expand Down
2 changes: 1 addition & 1 deletion src/blind.rs
Expand Up @@ -210,7 +210,7 @@ impl RangeProofMessage {
}

/// Information about Transaction Input Asset
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(crate = "actual_serde"))]
#[derive(Debug, PartialEq, Eq, Clone, Hash)]
pub struct TxOutSecrets {
/// Asset
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Expand Up @@ -30,7 +30,7 @@ pub extern crate bitcoin;
extern crate bitcoin_hashes as just_imported_for_the_macros;
extern crate slip21;
pub extern crate secp256k1_zkp;
#[cfg(feature = "serde")] #[macro_use] extern crate serde;
#[cfg(feature = "serde")] #[macro_use] extern crate actual_serde as serde;
#[cfg(all(test, feature = "serde"))] extern crate serde_test;

#[cfg(test)] extern crate rand;
Expand Down
4 changes: 2 additions & 2 deletions src/pset/map/global.rs
Expand Up @@ -56,7 +56,7 @@ const PSBT_ELEMENTS_GLOBAL_TX_MODIFIABLE: u8 = 0x01;

/// Global transaction data
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(crate = "actual_serde"))]
pub struct TxData {
/// Transaction version. Must be 2.
pub version: u32,
Expand Down Expand Up @@ -91,7 +91,7 @@ impl Default for TxData{

/// A key-value map for global data.
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(crate = "actual_serde"))]
pub struct Global {
/// Global transaction data
#[cfg_attr(feature = "serde", serde(flatten))]
Expand Down
2 changes: 1 addition & 1 deletion src/pset/map/input.rs
Expand Up @@ -148,7 +148,7 @@ const PSBT_ELEMENTS_IN_ISSUANCE_BLIND_INFLATION_KEYS_PROOF: u8 = 0x10;
/// 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))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(crate = "actual_serde"))]
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
Expand Down
4 changes: 2 additions & 2 deletions src/pset/map/output.rs
Expand Up @@ -87,7 +87,7 @@ const PSBT_ELEMENTS_OUT_BLIND_ASSET_PROOF: u8 = 0x10;
/// 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))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(crate = "actual_serde"))]
pub struct Output {
/// The redeem script for this output.
pub redeem_script: Option<Script>,
Expand Down Expand Up @@ -140,7 +140,7 @@ pub struct Output {

/// Taproot Tree representing a finalized [`TaprootBuilder`] (a complete binary tree)
#[derive(Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(crate = "actual_serde"))]
pub struct TapTree(pub(crate) TaprootBuilder);

impl PartialEq for TapTree {
Expand Down
2 changes: 1 addition & 1 deletion src/pset/mod.rs
Expand Up @@ -47,7 +47,7 @@ use self::map::Map;

/// A Partially Signed Transaction.
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(crate = "actual_serde"))]
pub struct PartiallySignedTransaction {
/// The key-value pairs for all global data.
pub global: Global,
Expand Down
6 changes: 3 additions & 3 deletions src/pset/raw.rs
Expand Up @@ -25,7 +25,7 @@ use super::Error;
use crate::VarInt;
/// A PSET key in its raw byte form.
#[derive(Debug, PartialEq, Hash, Eq, Clone, Ord, PartialOrd)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(crate = "actual_serde"))]
pub struct Key {
/// The type of this PSET key.
pub type_value: u8,
Expand All @@ -48,7 +48,7 @@ impl Key{

/// A PSET key-value pair in its raw byte form.
#[derive(Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(crate = "actual_serde"))]
pub struct Pair {
/// The key of this key-value pair.
pub key: Key,
Expand All @@ -63,7 +63,7 @@ pub type ProprietaryType = u8;
/// Proprietary keys (i.e. keys starting with 0xFC byte) with their internal
/// structure according to BIP 174.
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(crate = "actual_serde"))]
pub struct ProprietaryKey<Subtype = ProprietaryType> where Subtype: Copy + From<u8> + Into<u8> {
/// Proprietary type prefix used for grouping together keys under some
/// application and avoid namespace collision
Expand Down
2 changes: 1 addition & 1 deletion src/schnorr.rs
Expand Up @@ -94,7 +94,7 @@ impl TweakedPublicKey {

/// A BIP340-341 serialized schnorr signature with the corresponding hash type.
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(crate = "actual_serde"))]
pub struct SchnorrSig {
/// The underlying schnorr signature
pub sig: secp256k1_zkp::schnorr::Signature,
Expand Down
2 changes: 2 additions & 0 deletions src/serde_utils.rs
Expand Up @@ -147,6 +147,7 @@ pub mod btreemap_as_seq_byte_values {

/// A custom key-value pair type that serialized the bytes as hex.
#[derive(Debug, Deserialize)]
#[serde(crate = "actual_serde")]
struct OwnedPair<T>(
T,
#[serde(deserialize_with = "crate::serde_utils::hex_bytes::deserialize")]
Expand All @@ -155,6 +156,7 @@ pub mod btreemap_as_seq_byte_values {

/// A custom key-value pair type that serialized the bytes as hex.
#[derive(Debug, Serialize)]
#[serde(crate = "actual_serde")]
struct BorrowedPair<'a, T: 'static>(
&'a T,
#[serde(serialize_with = "crate::serde_utils::hex_bytes::serialize")]
Expand Down
11 changes: 6 additions & 5 deletions src/taproot.rs
Expand Up @@ -333,7 +333,7 @@ impl TaprootSpendInfo {
/// branches in a DFS(Depth first search) walk to construct this tree.
// Similar to Taproot Builder in bitcoin core
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(crate = "actual_serde"))]
pub struct TaprootBuilder {
// The following doc-comment is from bitcoin core, but modified for rust
// The comment below describes the current state of the builder for a given tree.
Expand Down Expand Up @@ -483,7 +483,7 @@ impl TaprootBuilder {

/// Structure to represent the node information in taproot tree
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(crate = "actual_serde"))]
pub struct NodeInfo {
/// Merkle Hash for this node
pub(crate) hash: sha256::Hash,
Expand Down Expand Up @@ -537,7 +537,7 @@ impl NodeInfo {

/// Data Structure to store information about taproot leaf node
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(crate = "actual_serde"))]
pub struct LeafInfo {
// The underlying script
pub(crate) script: Script,
Expand Down Expand Up @@ -569,6 +569,7 @@ impl LeafInfo {
// both TapBranchHash and TapLeafHash
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
pub struct TaprootMerkleBranch(Vec<sha256::Hash>);

impl TaprootMerkleBranch {
Expand Down Expand Up @@ -640,7 +641,7 @@ impl TaprootMerkleBranch {

/// Control Block data structure used in Tapscript satisfaction
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(crate = "actual_serde"))]
pub struct ControlBlock {
/// The tapleaf version,
pub leaf_version: LeafVersion,
Expand Down Expand Up @@ -749,7 +750,7 @@ impl ControlBlock {

/// The leaf version for tapleafs
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(crate = "actual_serde"))]
pub struct LeafVersion(u8);

impl Default for LeafVersion {
Expand Down

0 comments on commit 6039cc4

Please sign in to comment.