Skip to content

Commit 3e7c7b1

Browse files
committed
Add BlockHeader::clear_witness method
1 parent 8b0d786 commit 3e7c7b1

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/block.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,20 @@ impl BlockHeader {
235235
}
236236
}
237237

238+
/// Remove the witness data of the block header.
239+
/// This is all the data that can be removed without changing
240+
/// the block hash.
241+
pub fn clear_witness(&mut self) {
242+
match &mut self.ext {
243+
&mut ExtData::Proof { ref mut solution, .. } => {
244+
*solution = Script::new();
245+
},
246+
&mut ExtData::Dynafed { ref mut signblock_witness, .. } => {
247+
signblock_witness.clear();
248+
},
249+
}
250+
}
251+
238252
/// Calculate the root of the dynafed params. Returns [None] when not dynafed.
239253
pub fn calculate_dynafed_params_root(&self) -> Option<sha256::Midstate> {
240254
match self.ext {

0 commit comments

Comments
 (0)