@@ -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 = 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
}
@@ -1679,8 +1683,10 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
1679
1683
/// as long as we examine both the current counterparty commitment transaction and, if it hasn't
1680
1684
/// been revoked yet, the previous one, we we will never "forget" to resolve an HTLC.
1681
1685
macro_rules! fail_unbroadcast_htlcs {
1682
- ( $self: expr, $commitment_tx_type: expr, $commitment_txid_confirmed: expr,
1686
+ ( $self: expr, $commitment_tx_type: expr, $commitment_txid_confirmed: expr, $commitment_tx_confirmed : expr ,
1683
1687
$commitment_tx_conf_height: expr, $confirmed_htlcs_list: expr, $logger: expr) => { {
1688
+ debug_assert_eq!( $commitment_tx_confirmed. txid( ) , $commitment_txid_confirmed) ;
1689
+
1684
1690
macro_rules! check_htlc_fails {
1685
1691
( $txid: expr, $commitment_tx: expr) => {
1686
1692
if let Some ( ref latest_outpoints) = $self. counterparty_claimable_outpoints. get( $txid) {
@@ -1720,6 +1726,7 @@ macro_rules! fail_unbroadcast_htlcs {
1720
1726
} ) ;
1721
1727
let entry = OnchainEventEntry {
1722
1728
txid: $commitment_txid_confirmed,
1729
+ transaction: Some ( $commitment_tx_confirmed. clone( ) ) ,
1723
1730
height: $commitment_tx_conf_height,
1724
1731
event: OnchainEvent :: HTLCUpdate {
1725
1732
source: ( * * source) . clone( ) ,
@@ -2151,13 +2158,13 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2151
2158
self . counterparty_commitment_txn_on_chain . insert ( commitment_txid, commitment_number) ;
2152
2159
2153
2160
if let Some ( per_commitment_data) = per_commitment_option {
2154
- fail_unbroadcast_htlcs ! ( self , "revoked_counterparty" , commitment_txid, height,
2161
+ fail_unbroadcast_htlcs ! ( self , "revoked_counterparty" , commitment_txid, tx , height,
2155
2162
per_commitment_data. iter( ) . map( |( htlc, htlc_source) |
2156
2163
( htlc, htlc_source. as_ref( ) . map( |htlc_source| htlc_source. as_ref( ) ) )
2157
2164
) , logger) ;
2158
2165
} else {
2159
2166
debug_assert ! ( false , "We should have per-commitment option for any recognized old commitment txn" ) ;
2160
- fail_unbroadcast_htlcs ! ( self , "revoked counterparty" , commitment_txid, height,
2167
+ fail_unbroadcast_htlcs ! ( self , "revoked counterparty" , commitment_txid, tx , height,
2161
2168
[ ] . iter( ) . map( |reference| * reference) , logger) ;
2162
2169
}
2163
2170
}
@@ -2175,7 +2182,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2175
2182
self . counterparty_commitment_txn_on_chain . insert ( commitment_txid, commitment_number) ;
2176
2183
2177
2184
log_info ! ( logger, "Got broadcast of non-revoked counterparty commitment transaction {}" , commitment_txid) ;
2178
- fail_unbroadcast_htlcs ! ( self , "counterparty" , commitment_txid, height,
2185
+ fail_unbroadcast_htlcs ! ( self , "counterparty" , commitment_txid, tx , height,
2179
2186
per_commitment_data. iter( ) . map( |( htlc, htlc_source) |
2180
2187
( htlc, htlc_source. as_ref( ) . map( |htlc_source| htlc_source. as_ref( ) ) )
2181
2188
) , logger) ;
@@ -2334,7 +2341,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2334
2341
let res = self . get_broadcasted_holder_claims ( & self . current_holder_commitment_tx , height) ;
2335
2342
let mut to_watch = self . get_broadcasted_holder_watch_outputs ( & self . current_holder_commitment_tx , tx) ;
2336
2343
append_onchain_update ! ( res, to_watch) ;
2337
- fail_unbroadcast_htlcs ! ( self , "latest holder" , commitment_txid, height,
2344
+ fail_unbroadcast_htlcs ! ( self , "latest holder" , commitment_txid, tx , height,
2338
2345
self . current_holder_commitment_tx. htlc_outputs. iter( )
2339
2346
. map( |( htlc, _, htlc_source) | ( htlc, htlc_source. as_ref( ) ) ) , logger) ;
2340
2347
} else if let & Some ( ref holder_tx) = & self . prev_holder_signed_commitment_tx {
@@ -2344,7 +2351,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2344
2351
let res = self . get_broadcasted_holder_claims ( holder_tx, height) ;
2345
2352
let mut to_watch = self . get_broadcasted_holder_watch_outputs ( holder_tx, tx) ;
2346
2353
append_onchain_update ! ( res, to_watch) ;
2347
- fail_unbroadcast_htlcs ! ( self , "previous holder" , commitment_txid, height,
2354
+ fail_unbroadcast_htlcs ! ( self , "previous holder" , commitment_txid, tx , height,
2348
2355
holder_tx. htlc_outputs. iter( ) . map( |( htlc, _, htlc_source) | ( htlc, htlc_source. as_ref( ) ) ) ,
2349
2356
logger) ;
2350
2357
}
@@ -2510,6 +2517,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2510
2517
let txid = tx. txid ( ) ;
2511
2518
self . onchain_events_awaiting_threshold_conf . push ( OnchainEventEntry {
2512
2519
txid,
2520
+ transaction : Some ( ( * tx) . clone ( ) ) ,
2513
2521
height : height,
2514
2522
event : OnchainEvent :: FundingSpendConfirmation {
2515
2523
on_local_output_csv : balance_spendable_csv,
@@ -2928,7 +2936,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2928
2936
let outbound_htlc = $holder_tx == htlc_output. offered;
2929
2937
if !outbound_htlc || revocation_sig_claim {
2930
2938
self . onchain_events_awaiting_threshold_conf. push( OnchainEventEntry {
2931
- txid: tx. txid( ) , height,
2939
+ txid: tx. txid( ) , height, transaction : Some ( tx . clone ( ) ) ,
2932
2940
event: OnchainEvent :: HTLCSpendConfirmation {
2933
2941
commitment_tx_output_idx: input. previous_output. vout,
2934
2942
preimage: if accepted_preimage_claim || offered_preimage_claim {
@@ -2980,6 +2988,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2980
2988
self . onchain_events_awaiting_threshold_conf . push ( OnchainEventEntry {
2981
2989
txid : tx. txid ( ) ,
2982
2990
height,
2991
+ transaction : Some ( tx. clone ( ) ) ,
2983
2992
event : OnchainEvent :: HTLCSpendConfirmation {
2984
2993
commitment_tx_output_idx : input. previous_output . vout ,
2985
2994
preimage : Some ( payment_preimage) ,
@@ -3000,6 +3009,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
3000
3009
} else { false } ) {
3001
3010
self . onchain_events_awaiting_threshold_conf . push ( OnchainEventEntry {
3002
3011
txid : tx. txid ( ) ,
3012
+ transaction : Some ( tx. clone ( ) ) ,
3003
3013
height,
3004
3014
event : OnchainEvent :: HTLCSpendConfirmation {
3005
3015
commitment_tx_output_idx : input. previous_output . vout ,
@@ -3026,6 +3036,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
3026
3036
} ) ;
3027
3037
let entry = OnchainEventEntry {
3028
3038
txid : tx. txid ( ) ,
3039
+ transaction : Some ( tx. clone ( ) ) ,
3029
3040
height,
3030
3041
event : OnchainEvent :: HTLCUpdate {
3031
3042
source, payment_hash,
@@ -3099,6 +3110,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
3099
3110
if let Some ( spendable_output) = spendable_output {
3100
3111
let entry = OnchainEventEntry {
3101
3112
txid : tx. txid ( ) ,
3113
+ transaction : Some ( tx. clone ( ) ) ,
3102
3114
height : height,
3103
3115
event : OnchainEvent :: MaturingOutput { descriptor : spendable_output. clone ( ) } ,
3104
3116
} ;
0 commit comments