diff --git a/src/block.rs b/src/block.rs index 4a88d576..e19a943b 100644 --- a/src/block.rs +++ b/src/block.rs @@ -223,6 +223,32 @@ pub struct BlockHeader { serde_struct_impl!(BlockHeader, version, prev_blockhash, merkle_root, time, height, ext); impl BlockHeader { + /// Returns true if this is a block with dynamic federations enabled. + pub fn is_dynafed(&self) -> bool { + if let ExtData::Dynafed { + .. + } = self.ext + { + true + } else { + false + } + } + + /// Remove the witness data of the block header. + /// This is all the data that can be removed without changing + /// the block hash. + pub fn clear_witness(&mut self) { + match &mut self.ext { + &mut ExtData::Proof { ref mut solution, .. } => { + *solution = Script::new(); + }, + &mut ExtData::Dynafed { ref mut signblock_witness, .. } => { + signblock_witness.clear(); + }, + } + } + /// Calculate the root of the dynafed params. Returns [None] when not dynafed. pub fn calculate_dynafed_params_root(&self) -> Option { match self.ext {