@@ -2533,7 +2533,10 @@ impl ChannelMonitor {
2533
2533
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 { & [ ] } ) ;
2534
2534
amt = * amount;
2535
2535
} ,
2536
- & TxMaterial :: RemoteHTLC { .. } => { } ,
2536
+ & TxMaterial :: RemoteHTLC { ref preimage, ref amount, .. } => {
2537
+ inputs_witnesses_weight += Self :: get_witnesses_weight ( if preimage. is_some ( ) { & [ InputDescriptors :: OfferedHTLC ] } else { & [ InputDescriptors :: ReceivedHTLC ] } ) ;
2538
+ amt = * amount;
2539
+ } ,
2537
2540
& TxMaterial :: LocalHTLC { .. } => { } ,
2538
2541
}
2539
2542
}
@@ -2564,7 +2567,20 @@ impl ChannelMonitor {
2564
2567
bumped_tx. input [ i] . witness . push ( script. clone ( ) . into_bytes ( ) ) ;
2565
2568
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) ;
2566
2569
} ,
2567
- & TxMaterial :: RemoteHTLC { .. } => { } ,
2570
+ & TxMaterial :: RemoteHTLC { ref script, ref key, ref preimage, ref amount } => {
2571
+ let sighash_parts = bip143:: SighashComponents :: new ( & bumped_tx) ;
2572
+ let sighash = hash_to_message ! ( & sighash_parts. sighash_all( & bumped_tx. input[ 0 ] , & script, * amount) [ ..] ) ;
2573
+ let sig = self . secp_ctx . sign ( & sighash, & key) ;
2574
+ bumped_tx. input [ 0 ] . witness . push ( sig. serialize_der ( ) . to_vec ( ) ) ;
2575
+ bumped_tx. input [ 0 ] . witness [ 0 ] . push ( SigHashType :: All as u8 ) ;
2576
+ if let & Some ( preimage) = preimage {
2577
+ bumped_tx. input [ 0 ] . witness . push ( preimage. clone ( ) . 0 . to_vec ( ) ) ;
2578
+ } else {
2579
+ bumped_tx. input [ 0 ] . witness . push ( vec ! [ 0 ] ) ;
2580
+ }
2581
+ bumped_tx. input [ 0 ] . witness . push ( script. clone ( ) . into_bytes ( ) ) ;
2582
+ log_trace ! ( self , "Going to broadcast bumped Claim Transaction {} claiming remote htlc output {} from {} with new feerate {}" , bumped_tx. txid( ) , vout, txid, new_feerate) ;
2583
+ } ,
2568
2584
& TxMaterial :: LocalHTLC { .. } => {
2569
2585
//TODO : Given that Local Commitment Transaction and HTLC-Timeout/HTLC-Success are counter-signed by peer, we can't
2570
2586
// RBF them. Need a Lightning specs change and package relay modification :
0 commit comments