serde_util: Rename the btreemap module to btreemap_as_seq

So that we can later distinguish other modules over maps.
This commit is contained in:
Steven Roose 2020-12-27 20:44:54 +00:00 committed by Sebastian
parent a9c13272a0
commit a05f8feec6
4 changed files with 10 additions and 12 deletions

View File

@ -1,7 +1,7 @@
//! Module for special serde serializations.
pub mod btreemap {
pub mod btreemap_as_seq {
//! Module for serialization of BTreeMaps because serde_json will
//! not serialize hashmaps with non-string keys be default.
#![allow(missing_docs)]
@ -60,7 +60,7 @@ pub mod btreemap {
}
}
pub mod btreemap_byte_values {
pub mod btreemap_as_seq_byte_values {
//! Module for serialization of BTreeMaps with Vec<u8> values because
//! serde_json will not serialize hashmaps with non-string keys be default.
#![allow(missing_docs)]

View File

@ -46,13 +46,12 @@ pub struct Global {
pub version: u32,
/// A global map from extended public keys to the used key fingerprint and
/// derivation path as defined by BIP 32
#[cfg_attr(feature = "serde", serde(with = "::serde_utils::btreemap"))]
pub xpub: BTreeMap<ExtendedPubKey, KeySource>,
/// Global proprietary key-value pairs.
#[cfg_attr(feature = "serde", serde(with = "::serde_utils::btreemap_byte_values"))]
#[cfg_attr(feature = "serde", serde(with = "::serde_utils::btreemap_as_seq_byte_values"))]
pub proprietary: BTreeMap<raw::ProprietaryKey, Vec<u8>>,
/// Unknown global key-value pairs.
#[cfg_attr(feature = "serde", serde(with = "::serde_utils::btreemap_byte_values"))]
#[cfg_attr(feature = "serde", serde(with = "::serde_utils::btreemap_as_seq_byte_values"))]
pub unknown: BTreeMap<raw::Key, Vec<u8>>,
}

View File

@ -70,7 +70,6 @@ pub struct Input {
pub witness_utxo: Option<TxOut>,
/// A map from public keys to their corresponding signature as would be
/// pushed to the stack from a scriptSig or witness.
#[cfg_attr(feature = "serde", serde(with = "::serde_utils::btreemap_byte_values"))]
pub partial_sigs: BTreeMap<PublicKey, Vec<u8>>,
/// The sighash type to be used for this input. Signatures for this input
/// must use the sighash type.
@ -81,7 +80,7 @@ pub struct Input {
pub witness_script: Option<Script>,
/// A map from public keys needed to sign this input to their corresponding
/// master key fingerprints and derivation paths.
#[cfg_attr(feature = "serde", serde(with = "::serde_utils::btreemap"))]
#[cfg_attr(feature = "serde", serde(with = "::serde_utils::btreemap_as_seq"))]
pub bip32_derivation: BTreeMap<PublicKey, KeySource>,
/// The finalized, fully-constructed scriptSig with signatures and any other
/// scripts necessary for this input to pass validation.
@ -99,10 +98,10 @@ pub struct Input {
/// HAS256 hash to preimage map
pub hash256_preimages: BTreeMap<sha256d::Hash, Vec<u8>>,
/// Proprietary key-value pairs for this input.
#[cfg_attr(feature = "serde", serde(with = "::serde_utils::btreemap_byte_values"))]
#[cfg_attr(feature = "serde", serde(with = "::serde_utils::btreemap_as_seq_byte_values"))]
pub proprietary: BTreeMap<raw::ProprietaryKey, Vec<u8>>,
/// Unknown key-value pairs for this input.
#[cfg_attr(feature = "serde", serde(with = "::serde_utils::btreemap_byte_values"))]
#[cfg_attr(feature = "serde", serde(with = "::serde_utils::btreemap_as_seq_byte_values"))]
pub unknown: BTreeMap<raw::Key, Vec<u8>>,
}

View File

@ -44,13 +44,13 @@ pub struct Output {
pub witness_script: Option<Script>,
/// A map from public keys needed to spend this output to their
/// corresponding master key fingerprints and derivation paths.
#[cfg_attr(feature = "serde", serde(with = "::serde_utils::btreemap"))]
#[cfg_attr(feature = "serde", serde(with = "::serde_utils::btreemap_as_seq"))]
pub bip32_derivation: BTreeMap<PublicKey, KeySource>,
/// Proprietary key-value pairs for this output.
#[cfg_attr(feature = "serde", serde(with = "::serde_utils::btreemap_byte_values"))]
#[cfg_attr(feature = "serde", serde(with = "::serde_utils::btreemap_as_seq_byte_values"))]
pub proprietary: BTreeMap<raw::ProprietaryKey, Vec<u8>>,
/// Unknown key-value pairs for this output.
#[cfg_attr(feature = "serde", serde(with = "::serde_utils::btreemap_byte_values"))]
#[cfg_attr(feature = "serde", serde(with = "::serde_utils::btreemap_as_seq_byte_values"))]
pub unknown: BTreeMap<raw::Key, Vec<u8>>,
}