@@ -2587,7 +2587,10 @@ impl ChannelMonitor {
2587
2587
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 { & [ ] } ) ;
2588
2588
amt += * amount;
2589
2589
} ,
2590
- & InputMaterial :: RemoteHTLC { .. } => { return None ; } ,
2590
+ & InputMaterial :: RemoteHTLC { ref preimage, ref amount, .. } => {
2591
+ inputs_witnesses_weight += Self :: get_witnesses_weight ( if preimage. is_some ( ) { & [ InputDescriptors :: OfferedHTLC ] } else { & [ InputDescriptors :: ReceivedHTLC ] } ) ;
2592
+ amt += * amount;
2593
+ } ,
2591
2594
& InputMaterial :: LocalHTLC { .. } => { return None ; }
2592
2595
}
2593
2596
}
@@ -2619,7 +2622,20 @@ impl ChannelMonitor {
2619
2622
bumped_tx. input [ i] . witness . push ( script. clone ( ) . into_bytes ( ) ) ;
2620
2623
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) ;
2621
2624
} ,
2622
- & InputMaterial :: RemoteHTLC { .. } => { } ,
2625
+ & InputMaterial :: RemoteHTLC { ref script, ref key, ref preimage, ref amount } => {
2626
+ let sighash_parts = bip143:: SighashComponents :: new ( & bumped_tx) ;
2627
+ let sighash = hash_to_message ! ( & sighash_parts. sighash_all( & bumped_tx. input[ 0 ] , & script, * amount) [ ..] ) ;
2628
+ let sig = self . secp_ctx . sign ( & sighash, & key) ;
2629
+ bumped_tx. input [ 0 ] . witness . push ( sig. serialize_der ( ) . to_vec ( ) ) ;
2630
+ bumped_tx. input [ 0 ] . witness [ 0 ] . push ( SigHashType :: All as u8 ) ;
2631
+ if let & Some ( preimage) = preimage {
2632
+ bumped_tx. input [ 0 ] . witness . push ( preimage. clone ( ) . 0 . to_vec ( ) ) ;
2633
+ } else {
2634
+ bumped_tx. input [ 0 ] . witness . push ( vec ! [ 0 ] ) ;
2635
+ }
2636
+ bumped_tx. input [ 0 ] . witness . push ( script. clone ( ) . into_bytes ( ) ) ;
2637
+ log_trace ! ( self , "Going to broadcast bumped Claim Transaction {} claiming remote htlc output {} from {} with new feerate {}" , bumped_tx. txid( ) , vout, txid, new_feerate) ;
2638
+ } ,
2623
2639
& InputMaterial :: LocalHTLC { .. } => {
2624
2640
//TODO : Given that Local Commitment Transaction and HTLC-Timeout/HTLC-Success are counter-signed by peer, we can't
2625
2641
// RBF them. Need a Lightning specs change and package relay modification :
0 commit comments