@@ -2579,7 +2579,10 @@ impl ChannelMonitor {
2579
2579
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 { & [ ] } ) ;
2580
2580
amt += * amount;
2581
2581
} ,
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
+ } ,
2583
2586
& TxMaterial :: LocalHTLC { .. } => { return None ; }
2584
2587
}
2585
2588
}
@@ -2611,7 +2614,20 @@ impl ChannelMonitor {
2611
2614
bumped_tx. input [ i] . witness . push ( script. clone ( ) . into_bytes ( ) ) ;
2612
2615
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) ;
2613
2616
} ,
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
+ } ,
2615
2631
& TxMaterial :: LocalHTLC { .. } => {
2616
2632
//TODO : Given that Local Commitment Transaction and HTLC-Timeout/HTLC-Success are counter-signed by peer, we can't
2617
2633
// RBF them. Need a Lightning specs change and package relay modification :
0 commit comments