@@ -2579,7 +2579,10 @@ impl ChannelMonitor {
25792579 inputs_witnesses_weight += Self :: get_witnesses_weight ( if !is_htlc { & [ InputDescriptors :: RevokedOutput ] } else if script. len ( ) == OFFERED_HTLC_SCRIPT_WEIGHT { & [ InputDescriptors :: RevokedOfferedHTLC ] } else if script. len ( ) == ACCEPTED_HTLC_SCRIPT_WEIGHT { & [ InputDescriptors :: RevokedReceivedHTLC ] } else { & [ ] } ) ;
25802580 amt += * amount;
25812581 } ,
2582- & TxMaterial :: RemoteHTLC { .. } => { return None ; } ,
2582+ & TxMaterial :: RemoteHTLC { ref preimage, ref amount, .. } => {
2583+ inputs_witnesses_weight += Self :: get_witnesses_weight ( if preimage. is_some ( ) { & [ InputDescriptors :: OfferedHTLC ] } else { & [ InputDescriptors :: ReceivedHTLC ] } ) ;
2584+ amt += * amount;
2585+ } ,
25832586 & TxMaterial :: LocalHTLC { .. } => { return None ; }
25842587 }
25852588 }
@@ -2611,7 +2614,20 @@ impl ChannelMonitor {
26112614 bumped_tx. input [ i] . witness . push ( script. clone ( ) . into_bytes ( ) ) ;
26122615 log_trace ! ( self , "Going to broadcast bumped Penalty Transaction {} claiming revoked {} output {} from {} with new feerate {}" , bumped_tx. txid( ) , if !is_htlc { "to_local" } else if script. len( ) == OFFERED_HTLC_SCRIPT_WEIGHT { "offered" } else if script. len( ) == ACCEPTED_HTLC_SCRIPT_WEIGHT { "received" } else { "" } , vout, txid, new_feerate) ;
26132616 } ,
2614- & TxMaterial :: RemoteHTLC { .. } => { } ,
2617+ & TxMaterial :: RemoteHTLC { ref script, ref key, ref preimage, ref amount } => {
2618+ let sighash_parts = bip143:: SighashComponents :: new ( & bumped_tx) ;
2619+ let sighash = hash_to_message ! ( & sighash_parts. sighash_all( & bumped_tx. input[ 0 ] , & script, * amount) [ ..] ) ;
2620+ let sig = self . secp_ctx . sign ( & sighash, & key) ;
2621+ bumped_tx. input [ 0 ] . witness . push ( sig. serialize_der ( ) . to_vec ( ) ) ;
2622+ bumped_tx. input [ 0 ] . witness [ 0 ] . push ( SigHashType :: All as u8 ) ;
2623+ if let & Some ( preimage) = preimage {
2624+ bumped_tx. input [ 0 ] . witness . push ( preimage. clone ( ) . 0 . to_vec ( ) ) ;
2625+ } else {
2626+ bumped_tx. input [ 0 ] . witness . push ( vec ! [ 0 ] ) ;
2627+ }
2628+ bumped_tx. input [ 0 ] . witness . push ( script. clone ( ) . into_bytes ( ) ) ;
2629+ log_trace ! ( self , "Going to broadcast bumped Claim Transaction {} claiming remote htlc output {} from {} with new feerate {}" , bumped_tx. txid( ) , vout, txid, new_feerate) ;
2630+ } ,
26152631 & TxMaterial :: LocalHTLC { .. } => {
26162632 //TODO : Given that Local Commitment Transaction and HTLC-Timeout/HTLC-Success are counter-signed by peer, we can't
26172633 // RBF them. Need a Lightning specs change and package relay modification :
0 commit comments