@@ -739,17 +739,12 @@ pub fn build_htlc_input_witness(
739
739
} else {
740
740
EcdsaSighashType :: All
741
741
} ;
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 ) ;
747
742
748
743
let mut witness = Witness :: new ( ) ;
749
744
// First push the multisig dummy, note that due to BIP147 (NULLDUMMY) it must be a zero-length element.
750
745
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 ) ;
753
748
if let Some ( preimage) = preimage {
754
749
witness. push ( preimage. 0 . to_vec ( ) ) ;
755
750
} else {
@@ -801,9 +796,10 @@ pub(crate) fn get_anchor_output<'a>(commitment_tx: &'a Transaction, funding_pubk
801
796
/// Returns the witness required to satisfy and spend an anchor input.
802
797
pub fn build_anchor_input_witness ( funding_key : & PublicKey , funding_sig : & Signature ) -> Witness {
803
798
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
807
803
}
808
804
809
805
/// Per-channel data used to build transactions in conjunction with the per-commitment data (CommitmentTransaction).
@@ -1037,17 +1033,13 @@ impl HolderCommitmentTransaction {
1037
1033
// First push the multisig dummy, note that due to BIP147 (NULLDUMMY) it must be a zero-length element.
1038
1034
let mut tx = self . inner . built . transaction . clone ( ) ;
1039
1035
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 ) ;
1044
1036
1045
1037
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 ) ;
1048
1040
} 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 ) ;
1051
1043
}
1052
1044
1053
1045
tx. input [ 0 ] . witness . push ( funding_redeemscript. as_bytes ( ) . to_vec ( ) ) ;
0 commit comments