@@ -315,6 +315,7 @@ struct OnchainEventEntry {
315
315
txid : Txid ,
316
316
height : u32 ,
317
317
event : OnchainEvent ,
318
+ transaction : Option < Transaction > , // Added as optional, but always filled in, in LDK 0.0.110
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 = Txid :: all_zeros ( ) ;
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
}
@@ -1683,8 +1687,10 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
1683
1687
/// as long as we examine both the current counterparty commitment transaction and, if it hasn't
1684
1688
/// been revoked yet, the previous one, we we will never "forget" to resolve an HTLC.
1685
1689
macro_rules! fail_unbroadcast_htlcs {
1686
- ( $self: expr, $commitment_tx_type: expr, $commitment_txid_confirmed: expr,
1690
+ ( $self: expr, $commitment_tx_type: expr, $commitment_txid_confirmed: expr, $commitment_tx_confirmed : expr ,
1687
1691
$commitment_tx_conf_height: expr, $confirmed_htlcs_list: expr, $logger: expr) => { {
1692
+ debug_assert_eq!( $commitment_tx_confirmed. txid( ) , $commitment_txid_confirmed) ;
1693
+
1688
1694
macro_rules! check_htlc_fails {
1689
1695
( $txid: expr, $commitment_tx: expr) => {
1690
1696
if let Some ( ref latest_outpoints) = $self. counterparty_claimable_outpoints. get( $txid) {
@@ -1724,6 +1730,7 @@ macro_rules! fail_unbroadcast_htlcs {
1724
1730
} ) ;
1725
1731
let entry = OnchainEventEntry {
1726
1732
txid: $commitment_txid_confirmed,
1733
+ transaction: Some ( $commitment_tx_confirmed. clone( ) ) ,
1727
1734
height: $commitment_tx_conf_height,
1728
1735
event: OnchainEvent :: HTLCUpdate {
1729
1736
source: ( * * source) . clone( ) ,
@@ -2155,13 +2162,13 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2155
2162
self . counterparty_commitment_txn_on_chain . insert ( commitment_txid, commitment_number) ;
2156
2163
2157
2164
if let Some ( per_commitment_data) = per_commitment_option {
2158
- fail_unbroadcast_htlcs ! ( self , "revoked_counterparty" , commitment_txid, height,
2165
+ fail_unbroadcast_htlcs ! ( self , "revoked_counterparty" , commitment_txid, tx , height,
2159
2166
per_commitment_data. iter( ) . map( |( htlc, htlc_source) |
2160
2167
( htlc, htlc_source. as_ref( ) . map( |htlc_source| htlc_source. as_ref( ) ) )
2161
2168
) , logger) ;
2162
2169
} else {
2163
2170
debug_assert ! ( false , "We should have per-commitment option for any recognized old commitment txn" ) ;
2164
- fail_unbroadcast_htlcs ! ( self , "revoked counterparty" , commitment_txid, height,
2171
+ fail_unbroadcast_htlcs ! ( self , "revoked counterparty" , commitment_txid, tx , height,
2165
2172
[ ] . iter( ) . map( |reference| * reference) , logger) ;
2166
2173
}
2167
2174
}
@@ -2179,7 +2186,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2179
2186
self . counterparty_commitment_txn_on_chain . insert ( commitment_txid, commitment_number) ;
2180
2187
2181
2188
log_info ! ( logger, "Got broadcast of non-revoked counterparty commitment transaction {}" , commitment_txid) ;
2182
- fail_unbroadcast_htlcs ! ( self , "counterparty" , commitment_txid, height,
2189
+ fail_unbroadcast_htlcs ! ( self , "counterparty" , commitment_txid, tx , height,
2183
2190
per_commitment_data. iter( ) . map( |( htlc, htlc_source) |
2184
2191
( htlc, htlc_source. as_ref( ) . map( |htlc_source| htlc_source. as_ref( ) ) )
2185
2192
) , logger) ;
@@ -2338,7 +2345,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2338
2345
let res = self . get_broadcasted_holder_claims ( & self . current_holder_commitment_tx , height) ;
2339
2346
let mut to_watch = self . get_broadcasted_holder_watch_outputs ( & self . current_holder_commitment_tx , tx) ;
2340
2347
append_onchain_update ! ( res, to_watch) ;
2341
- fail_unbroadcast_htlcs ! ( self , "latest holder" , commitment_txid, height,
2348
+ fail_unbroadcast_htlcs ! ( self , "latest holder" , commitment_txid, tx , height,
2342
2349
self . current_holder_commitment_tx. htlc_outputs. iter( )
2343
2350
. map( |( htlc, _, htlc_source) | ( htlc, htlc_source. as_ref( ) ) ) , logger) ;
2344
2351
} else if let & Some ( ref holder_tx) = & self . prev_holder_signed_commitment_tx {
@@ -2348,7 +2355,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2348
2355
let res = self . get_broadcasted_holder_claims ( holder_tx, height) ;
2349
2356
let mut to_watch = self . get_broadcasted_holder_watch_outputs ( holder_tx, tx) ;
2350
2357
append_onchain_update ! ( res, to_watch) ;
2351
- fail_unbroadcast_htlcs ! ( self , "previous holder" , commitment_txid, height,
2358
+ fail_unbroadcast_htlcs ! ( self , "previous holder" , commitment_txid, tx , height,
2352
2359
holder_tx. htlc_outputs. iter( ) . map( |( htlc, _, htlc_source) | ( htlc, htlc_source. as_ref( ) ) ) ,
2353
2360
logger) ;
2354
2361
}
@@ -2514,6 +2521,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2514
2521
let txid = tx. txid ( ) ;
2515
2522
self . onchain_events_awaiting_threshold_conf . push ( OnchainEventEntry {
2516
2523
txid,
2524
+ transaction : Some ( ( * tx) . clone ( ) ) ,
2517
2525
height : height,
2518
2526
event : OnchainEvent :: FundingSpendConfirmation {
2519
2527
on_local_output_csv : balance_spendable_csv,
@@ -2932,7 +2940,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2932
2940
let outbound_htlc = $holder_tx == htlc_output. offered;
2933
2941
if !outbound_htlc || revocation_sig_claim {
2934
2942
self . onchain_events_awaiting_threshold_conf. push( OnchainEventEntry {
2935
- txid: tx. txid( ) , height,
2943
+ txid: tx. txid( ) , height, transaction : Some ( tx . clone ( ) ) ,
2936
2944
event: OnchainEvent :: HTLCSpendConfirmation {
2937
2945
commitment_tx_output_idx: input. previous_output. vout,
2938
2946
preimage: if accepted_preimage_claim || offered_preimage_claim {
@@ -2984,6 +2992,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2984
2992
self . onchain_events_awaiting_threshold_conf . push ( OnchainEventEntry {
2985
2993
txid : tx. txid ( ) ,
2986
2994
height,
2995
+ transaction : Some ( tx. clone ( ) ) ,
2987
2996
event : OnchainEvent :: HTLCSpendConfirmation {
2988
2997
commitment_tx_output_idx : input. previous_output . vout ,
2989
2998
preimage : Some ( payment_preimage) ,
@@ -3004,6 +3013,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
3004
3013
} else { false } ) {
3005
3014
self . onchain_events_awaiting_threshold_conf . push ( OnchainEventEntry {
3006
3015
txid : tx. txid ( ) ,
3016
+ transaction : Some ( tx. clone ( ) ) ,
3007
3017
height,
3008
3018
event : OnchainEvent :: HTLCSpendConfirmation {
3009
3019
commitment_tx_output_idx : input. previous_output . vout ,
@@ -3030,6 +3040,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
3030
3040
} ) ;
3031
3041
let entry = OnchainEventEntry {
3032
3042
txid : tx. txid ( ) ,
3043
+ transaction : Some ( tx. clone ( ) ) ,
3033
3044
height,
3034
3045
event : OnchainEvent :: HTLCUpdate {
3035
3046
source, payment_hash,
@@ -3103,6 +3114,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
3103
3114
if let Some ( spendable_output) = spendable_output {
3104
3115
let entry = OnchainEventEntry {
3105
3116
txid : tx. txid ( ) ,
3117
+ transaction : Some ( tx. clone ( ) ) ,
3106
3118
height : height,
3107
3119
event : OnchainEvent :: MaturingOutput { descriptor : spendable_output. clone ( ) } ,
3108
3120
} ;
0 commit comments