@@ -596,17 +596,15 @@ impl<ChanSigner: ChannelKeys> OnchainTxHandler<ChanSigner> {
596
596
chan_utils:: get_revokeable_redeemscript ( & chan_keys. revocation_key , * on_counterparty_tx_csv, & chan_keys. broadcaster_delayed_payment_key )
597
597
} ;
598
598
599
- if let Ok ( sig) = self . key_storage . sign_justice_transaction ( & bumped_tx, i, * amount, & per_commitment_key, htlc, & self . secp_ctx ) {
600
- bumped_tx. input [ i] . witness . push ( sig. serialize_der ( ) . to_vec ( ) ) ;
601
- bumped_tx. input [ i] . witness [ 0 ] . push ( SigHashType :: All as u8 ) ;
602
- if htlc. is_some ( ) {
603
- bumped_tx. input [ i] . witness . push ( chan_keys. revocation_key . clone ( ) . serialize ( ) . to_vec ( ) ) ;
604
- } else {
605
- bumped_tx. input [ i] . witness . push ( vec ! ( 1 ) ) ;
606
- }
607
- bumped_tx. input [ i] . witness . push ( witness_script. clone ( ) . into_bytes ( ) ) ;
608
- } else { return None ; }
609
- //TODO: panic ?
599
+ let sig = self . key_storage . sign_justice_transaction ( & bumped_tx, i, * amount, & per_commitment_key, htlc, & self . secp_ctx ) . expect ( "sign justice tx" ) ;
600
+ bumped_tx. input [ i] . witness . push ( sig. serialize_der ( ) . to_vec ( ) ) ;
601
+ bumped_tx. input [ i] . witness [ 0 ] . push ( SigHashType :: All as u8 ) ;
602
+ if htlc. is_some ( ) {
603
+ bumped_tx. input [ i] . witness . push ( chan_keys. revocation_key . clone ( ) . serialize ( ) . to_vec ( ) ) ;
604
+ } else {
605
+ bumped_tx. input [ i] . witness . push ( vec ! ( 1 ) ) ;
606
+ }
607
+ bumped_tx. input [ i] . witness . push ( witness_script. clone ( ) . into_bytes ( ) ) ;
610
608
611
609
log_trace ! ( logger, "Going to broadcast Penalty Transaction {} claiming revoked {} output {} from {} with new feerate {}..." , bumped_tx. txid( ) , if * input_descriptor == InputDescriptors :: RevokedOutput { "to_holder" } else if * input_descriptor == InputDescriptors :: RevokedOfferedHTLC { "offered" } else if * input_descriptor == InputDescriptors :: RevokedReceivedHTLC { "received" } else { "" } , outp. vout, outp. txid, new_feerate) ;
612
610
}
@@ -616,17 +614,16 @@ impl<ChanSigner: ChannelKeys> OnchainTxHandler<ChanSigner> {
616
614
let witness_script = chan_utils:: get_htlc_redeemscript_with_explicit_keys ( & htlc, & chan_keys. broadcaster_htlc_key , & chan_keys. countersignatory_htlc_key , & chan_keys. revocation_key ) ;
617
615
618
616
if !preimage. is_some ( ) { bumped_tx. lock_time = htlc. cltv_expiry } ; // Right now we don't aggregate time-locked transaction, if we do we should set lock_time before to avoid breaking hash computation
619
- if let Ok ( sig) = self . key_storage . sign_counterparty_htlc_transaction ( & bumped_tx, i, & htlc. amount_msat / 1000 , & per_commitment_point, htlc, & self . secp_ctx ) {
620
- bumped_tx. input [ i] . witness . push ( sig. serialize_der ( ) . to_vec ( ) ) ;
621
- bumped_tx. input [ i] . witness [ 0 ] . push ( SigHashType :: All as u8 ) ;
622
- if let & Some ( preimage) = preimage {
623
- bumped_tx. input [ i] . witness . push ( preimage. 0 . to_vec ( ) ) ;
624
- } else {
625
- // Due to BIP146 (MINIMALIF) this must be a zero-length element to relay.
626
- bumped_tx. input [ i] . witness . push ( vec ! [ ] ) ;
627
- }
628
- bumped_tx. input [ i] . witness . push ( witness_script. clone ( ) . into_bytes ( ) ) ;
617
+ let sig = self . key_storage . sign_counterparty_htlc_transaction ( & bumped_tx, i, & htlc. amount_msat / 1000 , & per_commitment_point, htlc, & self . secp_ctx ) . expect ( "sign counterparty HTLC tx" ) ;
618
+ bumped_tx. input [ i] . witness . push ( sig. serialize_der ( ) . to_vec ( ) ) ;
619
+ bumped_tx. input [ i] . witness [ 0 ] . push ( SigHashType :: All as u8 ) ;
620
+ if let & Some ( preimage) = preimage {
621
+ bumped_tx. input [ i] . witness . push ( preimage. 0 . to_vec ( ) ) ;
622
+ } else {
623
+ // Due to BIP146 (MINIMALIF) this must be a zero-length element to relay.
624
+ bumped_tx. input [ i] . witness . push ( vec ! [ ] ) ;
629
625
}
626
+ bumped_tx. input [ i] . witness . push ( witness_script. clone ( ) . into_bytes ( ) ) ;
630
627
log_trace ! ( logger, "Going to broadcast Claim Transaction {} claiming counterparty {} htlc output {} from {} with new feerate {}..." , bumped_tx. txid( ) , if preimage. is_some( ) { "offered" } else { "received" } , outp. vout, outp. txid, new_feerate) ;
631
628
}
632
629
} ,
@@ -936,13 +933,9 @@ impl<ChanSigner: ChannelKeys> OnchainTxHandler<ChanSigner> {
936
933
// to monitor before.
937
934
pub ( crate ) fn get_fully_signed_holder_tx ( & mut self , funding_redeemscript : & Script ) -> Option < Transaction > {
938
935
if let Some ( ref mut holder_commitment) = self . holder_commitment {
939
- match self . key_storage . sign_holder_commitment ( holder_commitment, & self . secp_ctx ) {
940
- Ok ( ( sig, htlc_sigs) ) => {
941
- self . holder_htlc_sigs = Some ( Self :: extract_holder_sigs ( holder_commitment, htlc_sigs) ) ;
942
- Some ( holder_commitment. add_holder_sig ( funding_redeemscript, sig) )
943
- } ,
944
- Err ( _) => return None ,
945
- }
936
+ let ( sig, htlc_sigs) = self . key_storage . sign_holder_commitment ( holder_commitment, & self . secp_ctx ) . expect ( "signing holder commitment" ) ;
937
+ self . holder_htlc_sigs = Some ( Self :: extract_holder_sigs ( holder_commitment, htlc_sigs) ) ;
938
+ Some ( holder_commitment. add_holder_sig ( funding_redeemscript, sig) )
946
939
} else {
947
940
None
948
941
}
@@ -951,13 +944,9 @@ impl<ChanSigner: ChannelKeys> OnchainTxHandler<ChanSigner> {
951
944
#[ cfg( any( test, feature="unsafe_revoked_tx_signing" ) ) ]
952
945
pub ( crate ) fn get_fully_signed_copy_holder_tx ( & mut self , funding_redeemscript : & Script ) -> Option < Transaction > {
953
946
if let Some ( ref mut holder_commitment) = self . holder_commitment {
954
- match self . key_storage . sign_holder_commitment ( holder_commitment, & self . secp_ctx ) {
955
- Ok ( ( sig, htlc_sigs) ) => {
956
- self . holder_htlc_sigs = Some ( Self :: extract_holder_sigs ( holder_commitment, htlc_sigs) ) ;
957
- Some ( holder_commitment. add_holder_sig ( funding_redeemscript, sig) )
958
- } ,
959
- Err ( _) => return None ,
960
- }
947
+ let ( sig, htlc_sigs) = self . key_storage . sign_holder_commitment ( holder_commitment, & self . secp_ctx ) . expect ( "sign holder commitment" ) ;
948
+ self . holder_htlc_sigs = Some ( Self :: extract_holder_sigs ( holder_commitment, htlc_sigs) ) ;
949
+ Some ( holder_commitment. add_holder_sig ( funding_redeemscript, sig) )
961
950
} else {
962
951
None
963
952
}
0 commit comments