File tree Expand file tree Collapse file tree 3 files changed +9
-10
lines changed Expand file tree Collapse file tree 3 files changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -770,7 +770,7 @@ impl ExtendedPubKey {
770
770
/// Returns the HASH160 of the chaincode
771
771
pub fn identifier ( & self ) -> XpubIdentifier {
772
772
let mut engine = XpubIdentifier :: engine ( ) ;
773
- engine. write ( & self . public_key . serialize ( ) ) . expect ( "engines don't error" ) ;
773
+ engine. write_all ( & self . public_key . serialize ( ) ) . expect ( "engines don't error" ) ;
774
774
XpubIdentifier :: from_engine ( engine)
775
775
}
776
776
Original file line number Diff line number Diff line change @@ -147,7 +147,8 @@ impl<Subtype> Encodable for ProprietaryKey<Subtype> where Subtype: Copy + From<u
147
147
fn consensus_encode < W : io:: Write > ( & self , mut e : W ) -> Result < usize , io:: Error > {
148
148
let mut len = self . prefix . consensus_encode ( & mut e) ? + 1 ;
149
149
e. emit_u8 ( self . subtype . into ( ) ) ?;
150
- len += e. write ( & self . key ) ?;
150
+ e. write_all ( & self . key ) ?;
151
+ len += self . key . len ( ) ;
151
152
Ok ( len)
152
153
}
153
154
}
Original file line number Diff line number Diff line change @@ -615,11 +615,10 @@ impl TaprootMerkleBranch {
615
615
616
616
/// Serialize to a writer. Returns the number of bytes written
617
617
pub fn encode < Write : io:: Write > ( & self , mut writer : Write ) -> io:: Result < usize > {
618
- let mut written = 0 ;
619
618
for hash in self . 0 . iter ( ) {
620
- written += writer. write ( hash) ?;
619
+ writer. write_all ( hash) ?;
621
620
}
622
- Ok ( written )
621
+ Ok ( self . 0 . len ( ) * sha256 :: Hash :: LEN )
623
622
}
624
623
625
624
/// Serialize self as bytes
@@ -704,11 +703,10 @@ impl ControlBlock {
704
703
/// Serialize to a writer. Returns the number of bytes written
705
704
pub fn encode < Write : io:: Write > ( & self , mut writer : Write ) -> io:: Result < usize > {
706
705
let first_byte: u8 = i32:: from ( self . output_key_parity ) as u8 | self . leaf_version . to_consensus ( ) ;
707
- let mut bytes_written = 0 ;
708
- bytes_written += writer. write ( & [ first_byte] ) ?;
709
- bytes_written += writer. write ( & self . internal_key . serialize ( ) ) ?;
710
- bytes_written += self . merkle_branch . encode ( & mut writer) ?;
711
- Ok ( bytes_written)
706
+ writer. write_all ( & [ first_byte] ) ?;
707
+ writer. write_all ( & self . internal_key . serialize ( ) ) ?;
708
+ self . merkle_branch . encode ( & mut writer) ?;
709
+ Ok ( self . size ( ) )
712
710
}
713
711
714
712
/// Serialize the control block. This would be required when
You can’t perform that action at this time.
0 commit comments