@@ -315,6 +315,7 @@ struct OnchainEventEntry {
315
315
txid : Txid ,
316
316
height : u32 ,
317
317
event : OnchainEvent ,
318
+ transaction : Option < Transaction > ,
318
319
}
319
320
320
321
impl OnchainEventEntry {
@@ -395,6 +396,7 @@ impl Writeable for OnchainEventEntry {
395
396
fn write < W : Writer > ( & self , writer : & mut W ) -> Result < ( ) , io:: Error > {
396
397
write_tlv_fields ! ( writer, {
397
398
( 0 , self . txid, required) ,
399
+ ( 1 , self . transaction, option) ,
398
400
( 2 , self . height, required) ,
399
401
( 4 , self . event, required) ,
400
402
} ) ;
@@ -405,15 +407,17 @@ impl Writeable for OnchainEventEntry {
405
407
impl MaybeReadable for OnchainEventEntry {
406
408
fn read < R : io:: Read > ( reader : & mut R ) -> Result < Option < Self > , DecodeError > {
407
409
let mut txid = Default :: default ( ) ;
410
+ let mut transaction = None ;
408
411
let mut height = 0 ;
409
412
let mut event = None ;
410
413
read_tlv_fields ! ( reader, {
411
414
( 0 , txid, required) ,
415
+ ( 1 , transaction, option) ,
412
416
( 2 , height, required) ,
413
417
( 4 , event, ignorable) ,
414
418
} ) ;
415
419
if let Some ( ev) = event {
416
- Ok ( Some ( Self { txid, height, event : ev } ) )
420
+ Ok ( Some ( Self { txid, transaction , height, event : ev } ) )
417
421
} else {
418
422
Ok ( None )
419
423
}
@@ -1667,8 +1671,10 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
1667
1671
/// as long as we examine both the current counterparty commitment transaction and, if it hasn't
1668
1672
/// been revoked yet, the previous one, we we will never "forget" to resolve an HTLC.
1669
1673
macro_rules! fail_unbroadcast_htlcs {
1670
- ( $self: expr, $commitment_tx_type: expr, $commitment_txid_confirmed: expr,
1674
+ ( $self: expr, $commitment_tx_type: expr, $commitment_txid_confirmed: expr, $commitment_tx_confirmed : expr ,
1671
1675
$commitment_tx_conf_height: expr, $confirmed_htlcs_list: expr, $logger: expr) => { {
1676
+ debug_assert_eq!( $commitment_tx_confirmed. txid( ) , $commitment_txid_confirmed) ;
1677
+
1672
1678
macro_rules! check_htlc_fails {
1673
1679
( $txid: expr, $commitment_tx: expr) => {
1674
1680
if let Some ( ref latest_outpoints) = $self. counterparty_claimable_outpoints. get( $txid) {
@@ -1708,6 +1714,7 @@ macro_rules! fail_unbroadcast_htlcs {
1708
1714
} ) ;
1709
1715
let entry = OnchainEventEntry {
1710
1716
txid: $commitment_txid_confirmed,
1717
+ transaction: Some ( $commitment_tx_confirmed. clone( ) ) ,
1711
1718
height: $commitment_tx_conf_height,
1712
1719
event: OnchainEvent :: HTLCUpdate {
1713
1720
source: ( * * source) . clone( ) ,
@@ -2136,13 +2143,13 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2136
2143
self . counterparty_commitment_txn_on_chain . insert ( commitment_txid, commitment_number) ;
2137
2144
2138
2145
if let Some ( per_commitment_data) = per_commitment_option {
2139
- fail_unbroadcast_htlcs ! ( self , "revoked_counterparty" , commitment_txid, height,
2146
+ fail_unbroadcast_htlcs ! ( self , "revoked_counterparty" , commitment_txid, tx , height,
2140
2147
per_commitment_data. iter( ) . map( |( htlc, htlc_source) |
2141
2148
( htlc, htlc_source. as_ref( ) . map( |htlc_source| htlc_source. as_ref( ) ) )
2142
2149
) , logger) ;
2143
2150
} else {
2144
2151
debug_assert ! ( false , "We should have per-commitment option for any recognized old commitment txn" ) ;
2145
- fail_unbroadcast_htlcs ! ( self , "revoked counterparty" , commitment_txid, height,
2152
+ fail_unbroadcast_htlcs ! ( self , "revoked counterparty" , commitment_txid, tx , height,
2146
2153
[ ] . iter( ) . map( |reference| * reference) , logger) ;
2147
2154
}
2148
2155
}
@@ -2160,7 +2167,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2160
2167
self . counterparty_commitment_txn_on_chain . insert ( commitment_txid, commitment_number) ;
2161
2168
2162
2169
log_info ! ( logger, "Got broadcast of non-revoked counterparty commitment transaction {}" , commitment_txid) ;
2163
- fail_unbroadcast_htlcs ! ( self , "counterparty" , commitment_txid, height,
2170
+ fail_unbroadcast_htlcs ! ( self , "counterparty" , commitment_txid, tx , height,
2164
2171
per_commitment_data. iter( ) . map( |( htlc, htlc_source) |
2165
2172
( htlc, htlc_source. as_ref( ) . map( |htlc_source| htlc_source. as_ref( ) ) )
2166
2173
) , logger) ;
@@ -2319,7 +2326,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2319
2326
let res = self . get_broadcasted_holder_claims ( & self . current_holder_commitment_tx , height) ;
2320
2327
let mut to_watch = self . get_broadcasted_holder_watch_outputs ( & self . current_holder_commitment_tx , tx) ;
2321
2328
append_onchain_update ! ( res, to_watch) ;
2322
- fail_unbroadcast_htlcs ! ( self , "latest holder" , commitment_txid, height,
2329
+ fail_unbroadcast_htlcs ! ( self , "latest holder" , commitment_txid, tx , height,
2323
2330
self . current_holder_commitment_tx. htlc_outputs. iter( )
2324
2331
. map( |( htlc, _, htlc_source) | ( htlc, htlc_source. as_ref( ) ) ) , logger) ;
2325
2332
} else if let & Some ( ref holder_tx) = & self . prev_holder_signed_commitment_tx {
@@ -2329,7 +2336,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2329
2336
let res = self . get_broadcasted_holder_claims ( holder_tx, height) ;
2330
2337
let mut to_watch = self . get_broadcasted_holder_watch_outputs ( holder_tx, tx) ;
2331
2338
append_onchain_update ! ( res, to_watch) ;
2332
- fail_unbroadcast_htlcs ! ( self , "previous holder" , commitment_txid, height,
2339
+ fail_unbroadcast_htlcs ! ( self , "previous holder" , commitment_txid, tx , height,
2333
2340
holder_tx. htlc_outputs. iter( ) . map( |( htlc, _, htlc_source) | ( htlc, htlc_source. as_ref( ) ) ) ,
2334
2341
logger) ;
2335
2342
}
@@ -2494,6 +2501,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2494
2501
let txid = tx. txid ( ) ;
2495
2502
self . onchain_events_awaiting_threshold_conf . push ( OnchainEventEntry {
2496
2503
txid,
2504
+ transaction : Some ( ( * tx) . clone ( ) ) ,
2497
2505
height : height,
2498
2506
event : OnchainEvent :: FundingSpendConfirmation {
2499
2507
on_local_output_csv : balance_spendable_csv,
@@ -2911,7 +2919,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2911
2919
let outbound_htlc = $holder_tx == htlc_output. offered;
2912
2920
if !outbound_htlc || revocation_sig_claim {
2913
2921
self . onchain_events_awaiting_threshold_conf. push( OnchainEventEntry {
2914
- txid: tx. txid( ) , height,
2922
+ txid: tx. txid( ) , height, transaction : Some ( tx . clone ( ) ) ,
2915
2923
event: OnchainEvent :: HTLCSpendConfirmation {
2916
2924
commitment_tx_output_idx: input. previous_output. vout,
2917
2925
preimage: if accepted_preimage_claim || offered_preimage_claim {
@@ -2963,6 +2971,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2963
2971
self . onchain_events_awaiting_threshold_conf . push ( OnchainEventEntry {
2964
2972
txid : tx. txid ( ) ,
2965
2973
height,
2974
+ transaction : Some ( tx. clone ( ) ) ,
2966
2975
event : OnchainEvent :: HTLCSpendConfirmation {
2967
2976
commitment_tx_output_idx : input. previous_output . vout ,
2968
2977
preimage : Some ( payment_preimage) ,
@@ -2983,6 +2992,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2983
2992
} else { false } ) {
2984
2993
self . onchain_events_awaiting_threshold_conf . push ( OnchainEventEntry {
2985
2994
txid : tx. txid ( ) ,
2995
+ transaction : Some ( tx. clone ( ) ) ,
2986
2996
height,
2987
2997
event : OnchainEvent :: HTLCSpendConfirmation {
2988
2998
commitment_tx_output_idx : input. previous_output . vout ,
@@ -3009,6 +3019,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
3009
3019
} ) ;
3010
3020
let entry = OnchainEventEntry {
3011
3021
txid : tx. txid ( ) ,
3022
+ transaction : Some ( tx. clone ( ) ) ,
3012
3023
height,
3013
3024
event : OnchainEvent :: HTLCUpdate {
3014
3025
source, payment_hash,
@@ -3082,6 +3093,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
3082
3093
if let Some ( spendable_output) = spendable_output {
3083
3094
let entry = OnchainEventEntry {
3084
3095
txid : tx. txid ( ) ,
3096
+ transaction : Some ( tx. clone ( ) ) ,
3085
3097
height : height,
3086
3098
event : OnchainEvent :: MaturingOutput { descriptor : spendable_output. clone ( ) } ,
3087
3099
} ;
0 commit comments