Skip to content

Commit 128ecc7

Browse files
added bincode to many types
1 parent 295c92d commit 128ecc7

19 files changed

+52
-0
lines changed

dash/src/blockdata/script/owned.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#[cfg(doc)]
55
use core::ops::Deref;
66

7+
use bincode::{Decode, Encode};
78
use hashes::hex;
89
use secp256k1::{Secp256k1, Verification};
910

@@ -26,6 +27,7 @@ use crate::taproot::TapNodeHash;
2627
///
2728
/// [deref coercions]: https://doc.rust-lang.org/std/ops/trait.Deref.html#more-on-deref-coercion
2829
#[derive(Default, Clone, PartialOrd, Ord, PartialEq, Eq, Hash)]
30+
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
2931
pub struct ScriptBuf(pub Vec<u8>);
3032

3133
impl ScriptBuf {

dash/src/blockdata/transaction/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ pub mod txout;
3434

3535
use core::default::Default;
3636

37+
use bincode::{Decode, Encode};
3738
use hashes::{Hash, sha256d};
3839

3940
use crate::blockdata::constants::WITNESS_SCALE_FACTOR;
@@ -158,6 +159,7 @@ impl<E> EncodeSigningDataResult<E> {
158159
/// We therefore deviate from the spec by always using the Segwit witness encoding
159160
/// for 0-input transactions, which results in unambiguously parseable transactions.
160161
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
162+
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
161163
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
162164
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
163165
pub struct Transaction {

dash/src/blockdata/transaction/outpoint.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use core::fmt;
2424
#[cfg(feature = "std")]
2525
use std::error;
2626

27+
use bincode::{Decode, Encode};
2728
use hashes::{self, Hash};
2829

2930
use crate::consensus::{Decodable, Encodable, deserialize, encode};
@@ -32,6 +33,7 @@ use crate::io;
3233

3334
/// A reference to a transaction output.
3435
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
36+
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
3537
pub struct OutPoint {
3638
/// The referenced transaction's txid.
3739
pub txid: Txid,

dash/src/blockdata/transaction/special_transaction/asset_lock.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
//!
2323
//! The special transaction type used for AssetLockTx Transactions is 8.
2424
25+
use bincode::{Decode, Encode};
26+
2527
use crate::consensus::{Decodable, Encodable, encode};
2628
use crate::prelude::*;
2729
use crate::transaction::txout::TxOut;
@@ -35,6 +37,7 @@ use crate::{VarInt, io};
3537
/// Each TxOut refers to a funding of an Identity.
3638
///
3739
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
40+
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
3841
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
3942
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
4043
pub struct AssetLockPayload {

dash/src/blockdata/transaction/special_transaction/asset_unlock/qualified_asset_unlock.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
//!
2323
//! The special transaction type used for CrWithTx Transactions is 9.
2424
25+
use bincode::{Decode, Encode};
2526
use hashes::Hash;
2627

2728
use crate::blockdata::transaction::special_transaction::SpecialTransactionBasePayloadEncodable;
@@ -46,6 +47,7 @@ pub const ASSET_UNLOCK_TX_SIZE: usize = 190;
4647
/// Transaction using it have no inputs. Hence the proof of validity lies solely on the BLS signature.
4748
///
4849
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
50+
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
4951
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
5052
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
5153
pub struct AssetUnlockPayload {

dash/src/blockdata/transaction/special_transaction/asset_unlock/request_info.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
2121
use std::mem::size_of;
2222

23+
use bincode::{Decode, Encode};
24+
2325
use crate::consensus::{Decodable, Encodable, encode};
2426
use crate::hash_types::QuorumHash;
2527
use crate::io;
@@ -29,6 +31,7 @@ use crate::prelude::*;
2931
/// This is the information about the signing quorum
3032
/// The request height should be the height at which the specified quorum is active on core.
3133
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
34+
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
3235
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
3336
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
3437
pub struct AssetUnlockRequestInfo {

dash/src/blockdata/transaction/special_transaction/asset_unlock/unqualified_asset_unlock.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
//!
2323
//! The special transaction type used for AssetUnlockTx Transactions is 9.
2424
25+
use bincode::{Decode, Encode};
26+
2527
use crate::blockdata::transaction::special_transaction::TransactionType;
2628
use crate::blockdata::transaction::special_transaction::TransactionType::AssetUnlock;
2729
use crate::consensus::{Decodable, Encodable, encode};
@@ -33,6 +35,7 @@ use crate::{ScriptBuf, TxIn, VarInt, io};
3335
/// An Asset Unlock Base payload. This is the base payload of the Asset Unlock. In order to make
3436
/// it a full payload the request info should be added.
3537
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
38+
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
3639
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
3740
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
3841
pub struct AssetUnlockBasePayload {

dash/src/blockdata/transaction/special_transaction/coinbase.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
//! It is defined in DIP4 [dip-0004](https://github.com/dashpay/dips/blob/master/dip-0004.md).
1919
//!
2020
21+
use bincode::{Decode, Encode};
22+
2123
use crate::bls_sig_utils::BLSSignature;
2224
use crate::consensus::encode::{compact_size_len, read_compact_size, write_compact_size};
2325
use crate::consensus::{Decodable, Encodable, encode};
@@ -29,6 +31,7 @@ use crate::{VarInt, io};
2931
/// The Coinbase payload is described in DIP4.
3032
///
3133
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
34+
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
3235
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
3336
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
3437
pub struct CoinbasePayload {

dash/src/blockdata/transaction/special_transaction/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
use core::convert::TryFrom;
2424
use core::fmt::{Debug, Display, Formatter};
2525

26+
use bincode::{Decode, Encode};
27+
2628
use crate::blockdata::transaction::special_transaction::TransactionPayload::{
2729
AssetLockPayloadType, AssetUnlockPayloadType, CoinbasePayloadType,
2830
ProviderRegistrationPayloadType, ProviderUpdateRegistrarPayloadType,
@@ -58,6 +60,7 @@ pub mod quorum_commitment;
5860
/// An enum wrapper around various special transaction payloads.
5961
/// Special transactions are defined in DIP 2.
6062
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
63+
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
6164
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
6265
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
6366
pub enum TransactionPayload {

dash/src/blockdata/transaction/special_transaction/provider_registration.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
//! KeyIdVoting (renamed to voting_key_hash): This is the public key ID used for proposal voting.
3535
//! Votes signed with this key are valid while the masternode is in the registered set.
3636
37+
use bincode::{Decode, Encode};
3738
use hashes::Hash;
3839
use internals::hex::Case::Lower;
3940

@@ -58,6 +59,7 @@ use crate::{Address, Network, OutPoint, ScriptBuf, VarInt, io};
5859
/// *The script payout is the script to which one wants to have the masternode pay out.
5960
/// *The inputs hash is used to guarantee the uniqueness of the payload sig.
6061
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
62+
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
6163
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
6264
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
6365
pub struct ProviderRegistrationPayload {

0 commit comments

Comments
 (0)