@@ -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
}
@@ -1675,8 +1679,10 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
1675
1679
/// as long as we examine both the current counterparty commitment transaction and, if it hasn't
1676
1680
/// been revoked yet, the previous one, we we will never "forget" to resolve an HTLC.
1677
1681
macro_rules! fail_unbroadcast_htlcs {
1678
- ( $self: expr, $commitment_tx_type: expr, $commitment_txid_confirmed: expr,
1682
+ ( $self: expr, $commitment_tx_type: expr, $commitment_txid_confirmed: expr, $commitment_tx_confirmed : expr ,
1679
1683
$commitment_tx_conf_height: expr, $confirmed_htlcs_list: expr, $logger: expr) => { {
1684
+ debug_assert_eq!( $commitment_tx_confirmed. txid( ) , $commitment_txid_confirmed) ;
1685
+
1680
1686
macro_rules! check_htlc_fails {
1681
1687
( $txid: expr, $commitment_tx: expr) => {
1682
1688
if let Some ( ref latest_outpoints) = $self. counterparty_claimable_outpoints. get( $txid) {
@@ -1716,6 +1722,7 @@ macro_rules! fail_unbroadcast_htlcs {
1716
1722
} ) ;
1717
1723
let entry = OnchainEventEntry {
1718
1724
txid: $commitment_txid_confirmed,
1725
+ transaction: Some ( $commitment_tx_confirmed. clone( ) ) ,
1719
1726
height: $commitment_tx_conf_height,
1720
1727
event: OnchainEvent :: HTLCUpdate {
1721
1728
source: ( * * source) . clone( ) ,
@@ -2147,13 +2154,13 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2147
2154
self . counterparty_commitment_txn_on_chain . insert ( commitment_txid, commitment_number) ;
2148
2155
2149
2156
if let Some ( per_commitment_data) = per_commitment_option {
2150
- fail_unbroadcast_htlcs ! ( self , "revoked_counterparty" , commitment_txid, height,
2157
+ fail_unbroadcast_htlcs ! ( self , "revoked_counterparty" , commitment_txid, tx , height,
2151
2158
per_commitment_data. iter( ) . map( |( htlc, htlc_source) |
2152
2159
( htlc, htlc_source. as_ref( ) . map( |htlc_source| htlc_source. as_ref( ) ) )
2153
2160
) , logger) ;
2154
2161
} else {
2155
2162
debug_assert ! ( false , "We should have per-commitment option for any recognized old commitment txn" ) ;
2156
- fail_unbroadcast_htlcs ! ( self , "revoked counterparty" , commitment_txid, height,
2163
+ fail_unbroadcast_htlcs ! ( self , "revoked counterparty" , commitment_txid, tx , height,
2157
2164
[ ] . iter( ) . map( |reference| * reference) , logger) ;
2158
2165
}
2159
2166
}
@@ -2171,7 +2178,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2171
2178
self . counterparty_commitment_txn_on_chain . insert ( commitment_txid, commitment_number) ;
2172
2179
2173
2180
log_info ! ( logger, "Got broadcast of non-revoked counterparty commitment transaction {}" , commitment_txid) ;
2174
- fail_unbroadcast_htlcs ! ( self , "counterparty" , commitment_txid, height,
2181
+ fail_unbroadcast_htlcs ! ( self , "counterparty" , commitment_txid, tx , height,
2175
2182
per_commitment_data. iter( ) . map( |( htlc, htlc_source) |
2176
2183
( htlc, htlc_source. as_ref( ) . map( |htlc_source| htlc_source. as_ref( ) ) )
2177
2184
) , logger) ;
@@ -2330,7 +2337,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2330
2337
let res = self . get_broadcasted_holder_claims ( & self . current_holder_commitment_tx , height) ;
2331
2338
let mut to_watch = self . get_broadcasted_holder_watch_outputs ( & self . current_holder_commitment_tx , tx) ;
2332
2339
append_onchain_update ! ( res, to_watch) ;
2333
- fail_unbroadcast_htlcs ! ( self , "latest holder" , commitment_txid, height,
2340
+ fail_unbroadcast_htlcs ! ( self , "latest holder" , commitment_txid, tx , height,
2334
2341
self . current_holder_commitment_tx. htlc_outputs. iter( )
2335
2342
. map( |( htlc, _, htlc_source) | ( htlc, htlc_source. as_ref( ) ) ) , logger) ;
2336
2343
} else if let & Some ( ref holder_tx) = & self . prev_holder_signed_commitment_tx {
@@ -2340,7 +2347,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2340
2347
let res = self . get_broadcasted_holder_claims ( holder_tx, height) ;
2341
2348
let mut to_watch = self . get_broadcasted_holder_watch_outputs ( holder_tx, tx) ;
2342
2349
append_onchain_update ! ( res, to_watch) ;
2343
- fail_unbroadcast_htlcs ! ( self , "previous holder" , commitment_txid, height,
2350
+ fail_unbroadcast_htlcs ! ( self , "previous holder" , commitment_txid, tx , height,
2344
2351
holder_tx. htlc_outputs. iter( ) . map( |( htlc, _, htlc_source) | ( htlc, htlc_source. as_ref( ) ) ) ,
2345
2352
logger) ;
2346
2353
}
@@ -2506,6 +2513,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2506
2513
let txid = tx. txid ( ) ;
2507
2514
self . onchain_events_awaiting_threshold_conf . push ( OnchainEventEntry {
2508
2515
txid,
2516
+ transaction : Some ( ( * tx) . clone ( ) ) ,
2509
2517
height : height,
2510
2518
event : OnchainEvent :: FundingSpendConfirmation {
2511
2519
on_local_output_csv : balance_spendable_csv,
@@ -2924,7 +2932,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2924
2932
let outbound_htlc = $holder_tx == htlc_output. offered;
2925
2933
if !outbound_htlc || revocation_sig_claim {
2926
2934
self . onchain_events_awaiting_threshold_conf. push( OnchainEventEntry {
2927
- txid: tx. txid( ) , height,
2935
+ txid: tx. txid( ) , height, transaction : Some ( tx . clone ( ) ) ,
2928
2936
event: OnchainEvent :: HTLCSpendConfirmation {
2929
2937
commitment_tx_output_idx: input. previous_output. vout,
2930
2938
preimage: if accepted_preimage_claim || offered_preimage_claim {
@@ -2976,6 +2984,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2976
2984
self . onchain_events_awaiting_threshold_conf . push ( OnchainEventEntry {
2977
2985
txid : tx. txid ( ) ,
2978
2986
height,
2987
+ transaction : Some ( tx. clone ( ) ) ,
2979
2988
event : OnchainEvent :: HTLCSpendConfirmation {
2980
2989
commitment_tx_output_idx : input. previous_output . vout ,
2981
2990
preimage : Some ( payment_preimage) ,
@@ -2996,6 +3005,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2996
3005
} else { false } ) {
2997
3006
self . onchain_events_awaiting_threshold_conf . push ( OnchainEventEntry {
2998
3007
txid : tx. txid ( ) ,
3008
+ transaction : Some ( tx. clone ( ) ) ,
2999
3009
height,
3000
3010
event : OnchainEvent :: HTLCSpendConfirmation {
3001
3011
commitment_tx_output_idx : input. previous_output . vout ,
@@ -3022,6 +3032,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
3022
3032
} ) ;
3023
3033
let entry = OnchainEventEntry {
3024
3034
txid : tx. txid ( ) ,
3035
+ transaction : Some ( tx. clone ( ) ) ,
3025
3036
height,
3026
3037
event : OnchainEvent :: HTLCUpdate {
3027
3038
source, payment_hash,
@@ -3095,6 +3106,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
3095
3106
if let Some ( spendable_output) = spendable_output {
3096
3107
let entry = OnchainEventEntry {
3097
3108
txid : tx. txid ( ) ,
3109
+ transaction : Some ( tx. clone ( ) ) ,
3098
3110
height : height,
3099
3111
event : OnchainEvent :: MaturingOutput { descriptor : spendable_output. clone ( ) } ,
3100
3112
} ;
0 commit comments