@@ -739,17 +739,12 @@ pub fn build_htlc_input_witness(
739739 } else {
740740 EcdsaSighashType :: All
741741 } ;
742- let mut remote_sig = remote_sig. serialize_der ( ) . to_vec ( ) ;
743- remote_sig. push ( remote_sighash_type as u8 ) ;
744-
745- let mut local_sig = local_sig. serialize_der ( ) . to_vec ( ) ;
746- local_sig. push ( EcdsaSighashType :: All as u8 ) ;
747742
748743 let mut witness = Witness :: new ( ) ;
749744 // First push the multisig dummy, note that due to BIP147 (NULLDUMMY) it must be a zero-length element.
750745 witness. push ( vec ! [ ] ) ;
751- witness. push ( remote_sig) ;
752- witness. push ( local_sig) ;
746+ witness. push_bitcoin_signature ( & remote_sig. serialize_der ( ) , remote_sighash_type ) ;
747+ witness. push_bitcoin_signature ( & local_sig. serialize_der ( ) , EcdsaSighashType :: All ) ;
753748 if let Some ( preimage) = preimage {
754749 witness. push ( preimage. 0 . to_vec ( ) ) ;
755750 } else {
@@ -801,9 +796,10 @@ pub(crate) fn get_anchor_output<'a>(commitment_tx: &'a Transaction, funding_pubk
801796/// Returns the witness required to satisfy and spend an anchor input.
802797pub fn build_anchor_input_witness ( funding_key : & PublicKey , funding_sig : & Signature ) -> Witness {
803798 let anchor_redeem_script = chan_utils:: get_anchor_redeemscript ( funding_key) ;
804- let mut funding_sig = funding_sig. serialize_der ( ) . to_vec ( ) ;
805- funding_sig. push ( EcdsaSighashType :: All as u8 ) ;
806- Witness :: from_vec ( vec ! [ funding_sig, anchor_redeem_script. to_bytes( ) ] )
799+ let mut ret = Witness :: new ( ) ;
800+ ret. push_bitcoin_signature ( & funding_sig. serialize_der ( ) , EcdsaSighashType :: All ) ;
801+ ret. push ( anchor_redeem_script. as_bytes ( ) ) ;
802+ ret
807803}
808804
809805/// Per-channel data used to build transactions in conjunction with the per-commitment data (CommitmentTransaction).
@@ -1037,17 +1033,13 @@ impl HolderCommitmentTransaction {
10371033 // First push the multisig dummy, note that due to BIP147 (NULLDUMMY) it must be a zero-length element.
10381034 let mut tx = self . inner . built . transaction . clone ( ) ;
10391035 tx. input [ 0 ] . witness . push ( Vec :: new ( ) ) ;
1040- let mut ser_holder_sig = holder_sig. serialize_der ( ) . to_vec ( ) ;
1041- ser_holder_sig. push ( EcdsaSighashType :: All as u8 ) ;
1042- let mut ser_cp_sig = self . counterparty_sig . serialize_der ( ) . to_vec ( ) ;
1043- ser_cp_sig. push ( EcdsaSighashType :: All as u8 ) ;
10441036
10451037 if self . holder_sig_first {
1046- tx. input [ 0 ] . witness . push ( ser_holder_sig ) ;
1047- tx. input [ 0 ] . witness . push ( ser_cp_sig ) ;
1038+ tx. input [ 0 ] . witness . push_bitcoin_signature ( & holder_sig . serialize_der ( ) , EcdsaSighashType :: All ) ;
1039+ tx. input [ 0 ] . witness . push_bitcoin_signature ( & self . counterparty_sig . serialize_der ( ) , EcdsaSighashType :: All ) ;
10481040 } else {
1049- tx. input [ 0 ] . witness . push ( ser_cp_sig ) ;
1050- tx. input [ 0 ] . witness . push ( ser_holder_sig ) ;
1041+ tx. input [ 0 ] . witness . push_bitcoin_signature ( & self . counterparty_sig . serialize_der ( ) , EcdsaSighashType :: All ) ;
1042+ tx. input [ 0 ] . witness . push_bitcoin_signature ( & holder_sig . serialize_der ( ) , EcdsaSighashType :: All ) ;
10511043 }
10521044
10531045 tx. input [ 0 ] . witness . push ( funding_redeemscript. as_bytes ( ) . to_vec ( ) ) ;
0 commit comments