Skip to content

Commit

Permalink
primitives: add ControlBlock constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Oct 6, 2023
1 parent fc16f58 commit 0c041da
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
4 changes: 2 additions & 2 deletions primitives/src/coding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ impl ConsensusEncode for ControlBlock {
self.leaf_version.to_consensus_u8() & self.output_key_parity.to_consensus_u8();
first_byte.consensus_encode(writer)?;

counter += self.internal_key.consensus_encode(writer)?;
counter += self.internal_pk.consensus_encode(writer)?;
for step in &self.merkle_branch {
counter += step.consensus_encode(writer)?;
}
Expand Down Expand Up @@ -526,7 +526,7 @@ impl ConsensusDecode for ControlBlock {
Ok(ControlBlock {
leaf_version,
output_key_parity,
internal_key,
internal_pk: internal_key,
merkle_branch,
})
}
Expand Down
19 changes: 18 additions & 1 deletion primitives/src/taproot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,24 @@ pub struct ControlBlock {
/// XONLY).
pub output_key_parity: Parity,
/// The internal key.
pub internal_key: InternalPk,
pub internal_pk: InternalPk,
/// The merkle proof of a script associated with this leaf.
pub merkle_branch: TapMerklePath,
}

impl ControlBlock {
#[inline]
pub fn with(
leaf_version: LeafVer,
internal_pk: InternalPk,
output_key_parity: Parity,
merkle_branch: TapMerklePath,
) -> Self {
ControlBlock {
leaf_version,
output_key_parity,
internal_pk,
merkle_branch,
}
}
}

0 comments on commit 0c041da

Please sign in to comment.