Skip to content

feat: basic ferment integration #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 81 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
76b2750
feat: ferment transactions
pankcuf Jan 21, 2025
b070b55
chore: include hashes, make public
pankcuf Jan 21, 2025
7d12f2a
chore: refine TxOut import
pankcuf Jan 21, 2025
dc50bc0
chore: refine txout
pankcuf Jan 21, 2025
be8759c
chore: export instantlock
pankcuf Jan 21, 2025
7dd0282
chore: import vec
pankcuf Jan 21, 2025
eb173d2
chore: remove vec import
pankcuf Jan 21, 2025
4128656
chore: refine islock imports
pankcuf Jan 21, 2025
6f7c7af
chore: hash_newtype + ferment
pankcuf Jan 21, 2025
d16e862
chore: direct fermentation
pankcuf Jan 23, 2025
49dbc11
chore: reset pub hashes
pankcuf Jan 23, 2025
55476ce
chore: reset Hash pub
pankcuf Jan 23, 2025
cd13a23
Merge branch 'master' into feat/ferment
pankcuf Feb 25, 2025
6d62218
chore: update with latest master
pankcuf Feb 25, 2025
16ade0a
chore: llmqtype fermented
pankcuf Feb 25, 2025
26f19af
chore: switch ferment onto master branch
pankcuf Feb 25, 2025
94489ca
chore: tmp switch bls-signature to apple
pankcuf Feb 25, 2025
a28495f
chore: add some ferment exports for masternode lists
pankcuf Feb 25, 2025
fde599b
chore: cargo.lock
pankcuf Feb 25, 2025
6623623
chore: adjust imports for ferment
pankcuf Feb 25, 2025
9ae30cd
Merge branch 'master' into feat/ferment
pankcuf Feb 28, 2025
73b5df6
Merge branch 'master' into feat/ferment
pankcuf Feb 28, 2025
c8b35fd
cleanup of imports
QuantumExplorer Feb 28, 2025
b17e4a4
Merge branch 'master' into feat/ferment
QuantumExplorer Mar 3, 2025
0a7e342
wrapped apple
QuantumExplorer Mar 3, 2025
e6027b9
chore: convert entry_hash sha256d::Hash <-> Sha256dHash
pankcuf Mar 4, 2025
7efb245
fix: sha256d::hash
pankcuf Mar 4, 2025
00ee68c
chore: add find_quorum_public_key method
pankcuf Mar 5, 2025
ead6df7
chore: tmp ferment QuorumSnapshot
pankcuf Mar 5, 2025
beef9fd
chore: export quorum errors
pankcuf Mar 8, 2025
5df4261
chore: pub message_request_verification
pankcuf Mar 8, 2025
de0019c
chore: export chainlock
pankcuf Mar 8, 2025
f9f71da
chore: pub MessageVerificationError
pankcuf Mar 8, 2025
d72b6ef
chore: pub mod prelude
pankcuf Mar 9, 2025
80f14ca
chore: force bincode to 2.0.0-rc.3
pankcuf Mar 9, 2025
59f10e3
chore: bump up bincode to 2.0.0
pankcuf Mar 9, 2025
0a29b27
chore: back to bincode 2.0.0-rc.3
pankcuf Mar 10, 2025
ca6342a
chore: export llmq type helpers
pankcuf Mar 10, 2025
11865a4
chore: add clear method for engine
pankcuf Mar 10, 2025
6bd8705
chore: fix macro
pankcuf Mar 11, 2025
e1a4ebd
chore: change apply_diff return type
pankcuf Mar 11, 2025
841e189
chore: refine quorum entry
pankcuf Mar 11, 2025
4fcb9bc
Merge branch 'master' into feat/ferment
pankcuf Mar 13, 2025
8f2f79c
chore: delete Cargo.lock
pankcuf Mar 13, 2025
8562906
chore: pub dip9
pankcuf Mar 17, 2025
872dc7c
chore: helpers for operatorpublickey
pankcuf Mar 18, 2025
d6b81c7
chore: refine txout imports
pankcuf Mar 19, 2025
a385d58
chore: refine script imports
pankcuf Mar 19, 2025
1c80643
chore: refine typealias
pankcuf Mar 19, 2025
6351ba0
chore: refine txin imports
pankcuf Mar 19, 2025
37ce04e
chore: refine outpoint import
pankcuf Mar 19, 2025
e9590c2
Merge branch 'master' into feat/ferment
pankcuf Mar 25, 2025
1459f41
chore: fix merge
pankcuf Mar 25, 2025
6afc508
Merge branch 'master' into feat/ferment
pankcuf Mar 25, 2025
f748f6e
chore: remove unused constraint
pankcuf Mar 25, 2025
df893fb
chore: oops
pankcuf Mar 25, 2025
c051fcc
chore: export VerifyingChainLockSignaturesType
pankcuf Mar 25, 2025
3899a54
chore: export SMLError
pankcuf Mar 25, 2025
61d8ec5
chore: bls-signatures update
pankcuf Mar 29, 2025
f6c2837
chore: try one trick
pankcuf Apr 1, 2025
534ba33
chore: one more bls trick
pankcuf Apr 1, 2025
aa4e98a
chore: bls with lower ios target
pankcuf Apr 4, 2025
9cd29dd
chore: ferment 0.2
pankcuf Apr 6, 2025
729d5e1
Merge branch 'master' into feat/ferment
pankcuf Apr 8, 2025
f5213fe
chore: update bls-signatures version
pankcuf Apr 8, 2025
1aeeb4b
chore: update bls-signatures
pankcuf Apr 8, 2025
d7ef308
Merge branch 'master' into feat/ferment
pankcuf Apr 10, 2025
ff4a39c
Merge branch 'master' into feat/ferment
pankcuf Apr 14, 2025
eb511ff
chore: fix testnet genesis
pankcuf Apr 16, 2025
7d23770
chore: fix: message impl
pankcuf Apr 16, 2025
6b336b9
chore: add Vec<i32> consensus_encode impl
pankcuf Apr 16, 2025
6dd3799
Merge branch 'master' into feat/ferment
pankcuf Apr 16, 2025
d47b46a
chore: fix imports
pankcuf May 8, 2025
85af260
chore: export ProviderMasternodeType
pankcuf May 24, 2025
d06736d
chore: update bls-signatures
pankcuf May 25, 2025
b0cc920
chore: up bls-signatures
pankcuf May 25, 2025
3952ddb
chore: update bls-signatures
pankcuf May 25, 2025
1ce8a11
chore: update bls-signatures
pankcuf May 25, 2025
a9221ef
chore: update bls-signatures
pankcuf May 25, 2025
90f28c4
chore: export some tx stuff
pankcuf May 28, 2025
122c0ca
chore: ferment some
pankcuf May 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions dash/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ eddsa = ["ed25519-dalek"]
quorum_validation = ["bls", "bls-signatures"]
message_verification = ["bls"]
bincode = [ "dep:bincode", "dashcore_hashes/bincode" ]
apple = [ "ferment", "ferment-macro", "bls-signatures/legacy", "bls-signatures/bip32", "bls-signatures/apple", "bls-signatures/use_serde" ]

# At least one of std, no-std must be enabled.
#
Expand Down Expand Up @@ -62,14 +63,15 @@ hex_lit = "0.1.1"
anyhow = { version= "1.0" }
hex = { version= "0.4" }
bincode = { version= "=2.0.0-rc.3", optional = true }
bincode_derive = { version= "=2.0.0-rc.3", optional = true }
bitflags = "2.9.0"
blsful = { version = "3.0.0-pre8", optional = true }
ed25519-dalek = { version = "2.1", features = ["rand_core"], optional = true }
blake3 = "1.8.1"
thiserror = "2"
# version 1.3.5 is 0bb5c5b03249c463debb5cef5f7e52ee66f3aaab
bls-signatures = { git = "https://github.com/dashpay/bls-signatures", rev = "0bb5c5b03249c463debb5cef5f7e52ee66f3aaab", optional = true }

bls-signatures = { git = "https://github.com/dashpay/bls-signatures", rev = "b840e447227dbe6e9a302c97acdf45b95c4d3b21", optional = true }
ferment = { version = "0.2", package = "ferment", optional = true }
ferment-macro = { version = "0.2", package = "ferment-macro", optional = true }
[dev-dependencies]
serde_json = "1.0.140"
serde_test = "1.0.177"
Expand Down
2 changes: 1 addition & 1 deletion dash/src/bip158.rs
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ mod test {
use serde_json::Value;

use super::*;
use crate::ScriptBuf;
use crate::blockdata::script::ScriptBuf;
use crate::consensus::encode::deserialize;
use crate::hash_types::BlockHash;
use crate::internal_macros::hex;
Expand Down
4 changes: 2 additions & 2 deletions dash/src/blockdata/script/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ use crate::{OutPoint, io};
mod borrowed;
mod builder;
mod instruction;
mod owned;
pub mod owned;
mod push_bytes;
#[cfg(test)]
mod tests;

pub use self::borrowed::*;
pub use self::builder::*;
pub use self::instruction::*;
pub use self::owned::*;
pub use self::owned::ScriptBuf;
pub use self::push_bytes::*;

/// Encodes an integer in script(minimal CScriptNum) format.
Expand Down
1 change: 1 addition & 0 deletions dash/src/blockdata/script/owned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use crate::taproot::TapNodeHash;
/// [deref coercions]: https://doc.rust-lang.org/std/ops/trait.Deref.html#more-on-deref-coercion
#[derive(Default, Clone, PartialOrd, Ord, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
#[cfg_attr(feature = "apple", ferment_macro::export)]
pub struct ScriptBuf(pub Vec<u8>);

impl ScriptBuf {
Expand Down
65 changes: 35 additions & 30 deletions dash/src/blockdata/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use hashes::{Hash, sha256d};
use crate::blockdata::constants::WITNESS_SCALE_FACTOR;
#[cfg(feature = "bitcoinconsensus")]
use crate::blockdata::script;
use crate::blockdata::script::Script;
use crate::blockdata::script::{Script, ScriptBuf};
use crate::blockdata::transaction::hash_type::EcdsaSighashType;
use crate::blockdata::transaction::special_transaction::{TransactionPayload, TransactionType};
use crate::blockdata::transaction::txin::TxIn;
Expand All @@ -52,8 +52,8 @@ use crate::consensus::{Decodable, Encodable, encode};
use crate::hash_types::{InputsHash, Txid, Wtxid};
use crate::prelude::*;
use crate::sighash::LegacySighash;
pub use crate::transaction::outpoint::*;
use crate::{ScriptBuf, Weight, io};
pub use self::outpoint::OutPoint;
use crate::{Weight, io};

/// Used for signature hash for invalid use of SIGHASH_SINGLE.
const UINT256_ONE: [u8; 32] = [
Expand Down Expand Up @@ -165,6 +165,7 @@ impl<E> EncodeSigningDataResult<E> {
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
#[cfg_attr(feature = "apple", ferment_macro::export)]
pub struct Transaction {
/// The protocol version, is currently expected to be 1 or 2 (BIP 68).
pub version: u16,
Expand All @@ -178,29 +179,8 @@ pub struct Transaction {
pub special_transaction_payload: Option<TransactionPayload>,
}

#[cfg_attr(feature = "apple", ferment_macro::export)]
impl Transaction {
/// Computes a "normalized TXID" which does not include any signatures.
/// This gives a way to identify a transaction that is "the same" as
/// another in the sense of having same inputs and outputs.
pub fn ntxid(&self) -> sha256d::Hash {
let cloned_tx = Transaction {
version: self.version,
lock_time: self.lock_time,
input: self
.input
.iter()
.map(|txin| TxIn {
script_sig: ScriptBuf::new(),
witness: Witness::default(),
..*txin
})
.collect(),
output: self.output.clone(),
special_transaction_payload: self.special_transaction_payload.clone(),
};
cloned_tx.txid().into()
}

/// Computes the txid. For non-segwit transactions this will be identical
/// to the output of `wtxid()`, but for segwit transactions,
/// this will give the correct txid (not including witnesses) while `wtxid`
Expand Down Expand Up @@ -228,6 +208,36 @@ impl Transaction {
TransactionType::from_optional_payload(&self.special_transaction_payload)
}

/// Is this a coin base transaction?
pub fn is_coin_base(&self) -> bool {
self.input.len() == 1 && self.input[0].previous_output.is_null()
}

}

impl Transaction {
/// Computes a "normalized TXID" which does not include any signatures.
/// This gives a way to identify a transaction that is "the same" as
/// another in the sense of having same inputs and outputs.
pub fn ntxid(&self) -> sha256d::Hash {
let cloned_tx = Transaction {
version: self.version,
lock_time: self.lock_time,
input: self
.input
.iter()
.map(|txin| TxIn {
script_sig: ScriptBuf::new(),
witness: Witness::default(),
..*txin
})
.collect(),
output: self.output.clone(),
special_transaction_payload: self.special_transaction_payload.clone(),
};
cloned_tx.txid().into()
}

/// Computes SegWit-version of the transaction id (wtxid). For transaction with the witness
/// data this hash includes witness, for pre-witness transaction it is equal to the normal
/// value returned by txid() function.
Expand Down Expand Up @@ -556,11 +566,6 @@ impl Transaction {
Ok(())
}

/// Is this a coin base transaction?
pub fn is_coin_base(&self) -> bool {
self.input.len() == 1 && self.input[0].previous_output.is_null()
}

/// Returns `true` if the transaction itself opted in to be BIP-125-replaceable (RBF). This
/// **does not** cover the case where a transaction becomes replaceable due to ancestors being
/// RBF.
Expand Down
2 changes: 2 additions & 0 deletions dash/src/blockdata/transaction/outpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use crate::io;
/// A reference to a transaction output.
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
#[cfg_attr(feature = "apple", ferment_macro::export)]
pub struct OutPoint {
/// The referenced transaction's txid.
pub txid: Txid,
Expand Down Expand Up @@ -68,6 +69,7 @@ impl From<OutPoint> for [u8; 36] {
}
}

#[cfg_attr(feature = "apple", ferment_macro::export)]
impl OutPoint {
/// Creates a new [`OutPoint`].
#[inline]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use bincode::{Decode, Encode};

use crate::consensus::{Decodable, Encodable, encode};
use crate::prelude::*;
use crate::transaction::txout::TxOut;
use crate::blockdata::transaction::txout::TxOut;
use crate::{VarInt, io};

/// An Asset Lock payload. This is contained as the payload of an asset lock special transaction.
Expand All @@ -41,11 +41,13 @@ use crate::{VarInt, io};
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
#[cfg_attr(feature = "apple", ferment_macro::export)]
pub struct AssetLockPayload {
pub version: u8,
pub credit_outputs: Vec<TxOut>,
}

#[cfg_attr(feature = "apple", ferment_macro::export)]
impl AssetLockPayload {
/// The size of the payload in bytes.
pub fn size(&self) -> usize {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ pub const ASSET_UNLOCK_TX_SIZE: usize = 190;
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
#[cfg_attr(feature = "apple", ferment_macro::export)]
pub struct AssetUnlockPayload {
/// The base information about the asset unlock. This base information is the information that
/// should be put into a queue.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use crate::prelude::*;
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
#[cfg_attr(feature = "apple", ferment_macro::export)]
pub struct AssetUnlockRequestInfo {
/// The core request height of the transaction. This should match a period where the quorum_hash
/// is still active
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,23 @@
#[cfg(feature = "bincode")]
use bincode::{Decode, Encode};

use crate::blockdata::script::ScriptBuf;
use crate::blockdata::transaction::special_transaction::TransactionType;
use crate::blockdata::transaction::special_transaction::TransactionType::AssetUnlock;
use crate::blockdata::transaction::txin::TxIn;
use crate::blockdata::transaction::txout::TxOut;
use crate::consensus::{Decodable, Encodable, encode};
use crate::hash_types::{PubkeyHash, ScriptHash};
use crate::prelude::*;
use crate::transaction::TxOut;
use crate::{ScriptBuf, TxIn, VarInt, io};
use crate::{VarInt, io};

/// An Asset Unlock Base payload. This is the base payload of the Asset Unlock. In order to make
/// it a full payload the request info should be added.
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
#[cfg_attr(feature = "apple", ferment_macro::export)]
pub struct AssetUnlockBasePayload {
/// The payload protocol version, is currently expected to be 0.
pub version: u8,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use crate::io::{Error, ErrorKind};
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
#[cfg_attr(feature = "apple", ferment_macro::export)]
pub struct CoinbasePayload {
pub version: u16,
pub height: u32,
Expand All @@ -45,6 +46,7 @@ pub struct CoinbasePayload {
pub asset_locked_amount: Option<u64>,
}

#[cfg_attr(feature = "apple", ferment_macro::export)]
impl CoinbasePayload {
/// The size of the payload in bytes.
/// version(2) + height(4) + merkle_root_masternode_list(32) + merkle_root_quorums(32)
Expand Down
6 changes: 6 additions & 0 deletions dash/src/blockdata/transaction/special_transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ pub mod quorum_commitment;
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
#[cfg_attr(feature = "apple", ferment_macro::export)]
pub enum TransactionPayload {
/// A wrapper for a Masternode Registration payload
ProviderRegistrationPayloadType(ProviderRegistrationPayload),
Expand Down Expand Up @@ -98,6 +99,7 @@ impl Encodable for TransactionPayload {
}
}

#[cfg_attr(feature = "apple", ferment_macro::export)]
impl TransactionPayload {
/// Gets the Transaction Type for a Special Transaction Payload
pub fn get_type(&self) -> TransactionType {
Expand Down Expand Up @@ -128,6 +130,9 @@ impl TransactionPayload {
}
}

}
impl TransactionPayload {

/// Convenience method that assumes the payload to be a provider registration payload to get it
/// easier.
/// Errors if it is not a provider registration payload.
Expand Down Expand Up @@ -254,6 +259,7 @@ impl TransactionPayload {
///
#[derive(Clone, Copy, PartialEq, Eq)]
#[repr(u16)]
#[cfg_attr(feature = "apple", ferment_macro::export)]
pub enum TransactionType {
/// A Classic transaction
Classic = 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,20 @@ use hashes::Hash;
use internals::hex::Case::Lower;

use crate::address::Payload;
use crate::blockdata::script::ScriptBuf;
use crate::blockdata::transaction::OutPoint;
use crate::blockdata::transaction::special_transaction::SpecialTransactionBasePayloadEncodable;
use crate::bls_sig_utils::BLSPublicKey;
use crate::consensus::{Decodable, Encodable, encode};
use crate::hash_types::{InputsHash, PubkeyHash, SpecialTransactionPayloadHash};
use crate::prelude::*;
use crate::{Address, Network, OutPoint, ScriptBuf, VarInt, io};
use crate::{Address, Network, VarInt, io};

#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash, Copy)]
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
#[cfg_attr(feature = "apple", ferment_macro::export)]
pub enum ProviderMasternodeType {
Regular = 0,
HighPerformance = 1,
Expand Down Expand Up @@ -97,6 +100,7 @@ impl Decodable for ProviderMasternodeType {
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
#[cfg_attr(feature = "apple", ferment_macro::export)]
pub struct ProviderRegistrationPayload {
pub version: u16,
pub masternode_type: ProviderMasternodeType,
Expand All @@ -114,7 +118,23 @@ pub struct ProviderRegistrationPayload {
pub platform_p2p_port: Option<u16>,
pub platform_http_port: Option<u16>,
}

#[cfg_attr(feature = "apple", ferment_macro::export)]
impl ProviderRegistrationPayload {
/// The size of the payload in bytes.
/// version(2) + provider_type(2) + provider_mode(2) + collateral_outpoint(32 + 4) + ip_address(16) +
/// port(2) + owner_key_hash(20) + operator_public_key(48) + voting_key_hash(20) + operator_reward(2) +
/// script_payout(VarInt(script_payout_len).len() + script_payout_len) +
/// inputs_hash(32) +
/// payload_sig(VarInt(payload_sig_len).len() + payload_sig_len)
pub fn size(&self) -> usize {
let mut size = 2 + 2 + 2 + 32 + 4 + 16 + 2 + 20 + 48 + 20 + 2 + 32; // 182 bytes
let script_payout_len = self.script_payout.0.len();
let signature_len = self.signature.len();
size += VarInt(script_payout_len as u64).len() + script_payout_len;
size += VarInt(signature_len as u64).len() + signature_len;
size
}
}
impl ProviderRegistrationPayload {
/// A convenience method to get the address from payout script
pub fn payout_address(&self, network: Network) -> Result<Address, encode::Error> {
Expand Down Expand Up @@ -149,21 +169,6 @@ impl ProviderRegistrationPayload {
base_payload_hash.as_byte_array().to_hex_string(Lower)
))
}

/// The size of the payload in bytes.
/// version(2) + provider_type(2) + provider_mode(2) + collateral_outpoint(32 + 4) + ip_address(16) +
/// port(2) + owner_key_hash(20) + operator_public_key(48) + voting_key_hash(20) + operator_reward(2) +
/// script_payout(VarInt(script_payout_len).len() + script_payout_len) +
/// inputs_hash(32) +
/// payload_sig(VarInt(payload_sig_len).len() + payload_sig_len)
pub fn size(&self) -> usize {
let mut size = 2 + 2 + 2 + 32 + 4 + 16 + 2 + 20 + 48 + 20 + 2 + 32; // 182 bytes
let script_payout_len = self.script_payout.0.len();
let signature_len = self.signature.len();
size += VarInt(script_payout_len as u64).len() + script_payout_len;
size += VarInt(signature_len as u64).len() + signature_len;
size
}
}

impl SpecialTransactionBasePayloadEncodable for ProviderRegistrationPayload {
Expand Down
Loading
Loading