@@ -351,7 +351,8 @@ enum OnchainEvent {
351
351
/// inbound HTLC in backward channel. Note, in case of preimage, we pass info to upstream without delay as we can
352
352
/// only win from it, so it's never an OnchainEvent
353
353
HTLCUpdate {
354
- htlc_update : ( HTLCSource , PaymentHash ) ,
354
+ source : HTLCSource ,
355
+ payment_hash : PaymentHash ,
355
356
} ,
356
357
MaturingOutput {
357
358
descriptor : SpendableOutputDescriptor ,
@@ -818,10 +819,10 @@ impl<Signer: Sign> Writeable for ChannelMonitorImpl<Signer> {
818
819
entry. txid . write ( writer) ?;
819
820
writer. write_all ( & byte_utils:: be32_to_array ( entry. height ) ) ?;
820
821
match entry. event {
821
- OnchainEvent :: HTLCUpdate { ref htlc_update } => {
822
+ OnchainEvent :: HTLCUpdate { ref source , ref payment_hash } => {
822
823
0u8 . write ( writer) ?;
823
- htlc_update . 0 . write ( writer) ?;
824
- htlc_update . 1 . write ( writer) ?;
824
+ source . write ( writer) ?;
825
+ payment_hash . write ( writer) ?;
825
826
} ,
826
827
OnchainEvent :: MaturingOutput { ref descriptor } => {
827
828
1u8 . write ( writer) ?;
@@ -1609,17 +1610,18 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
1609
1610
self . onchain_events_awaiting_threshold_conf. retain( |ref entry| {
1610
1611
if entry. height != height { return true ; }
1611
1612
match entry. event {
1612
- OnchainEvent :: HTLCUpdate { ref htlc_update } => {
1613
- htlc_update . 0 != * * source
1614
- } ,
1615
- _ => true ,
1613
+ OnchainEvent :: HTLCUpdate { source : ref update_source , .. } => {
1614
+ * update_source != * * source
1615
+ } ,
1616
+ _ => true ,
1616
1617
}
1617
1618
} ) ;
1618
1619
let entry = OnchainEventEntry {
1619
1620
txid: * $txid,
1620
1621
height,
1621
1622
event: OnchainEvent :: HTLCUpdate {
1622
- htlc_update: ( ( * * source) . clone( ) , htlc. payment_hash. clone( ) )
1623
+ source: ( * * source) . clone( ) ,
1624
+ payment_hash: htlc. payment_hash. clone( ) ,
1623
1625
} ,
1624
1626
} ;
1625
1627
log_info!( logger, "Failing HTLC with payment_hash {} from {} counterparty commitment tx due to broadcast of revoked counterparty commitment transaction, waiting for confirmation (at height {})" , log_bytes!( htlc. payment_hash. 0 ) , $commitment_tx, entry. confirmation_threshold( ) ) ;
@@ -1675,17 +1677,18 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
1675
1677
self . onchain_events_awaiting_threshold_conf. retain( |ref entry| {
1676
1678
if entry. height != height { return true ; }
1677
1679
match entry. event {
1678
- OnchainEvent :: HTLCUpdate { ref htlc_update } => {
1679
- htlc_update . 0 != * * source
1680
- } ,
1681
- _ => true ,
1680
+ OnchainEvent :: HTLCUpdate { source : ref update_source , .. } => {
1681
+ * update_source != * * source
1682
+ } ,
1683
+ _ => true ,
1682
1684
}
1683
1685
} ) ;
1684
1686
self . onchain_events_awaiting_threshold_conf. push( OnchainEventEntry {
1685
1687
txid: * $txid,
1686
1688
height,
1687
1689
event: OnchainEvent :: HTLCUpdate {
1688
- htlc_update: ( ( * * source) . clone( ) , htlc. payment_hash. clone( ) )
1690
+ source: ( * * source) . clone( ) ,
1691
+ payment_hash: htlc. payment_hash. clone( ) ,
1689
1692
} ,
1690
1693
} ) ;
1691
1694
}
@@ -1829,16 +1832,16 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
1829
1832
self . onchain_events_awaiting_threshold_conf. retain( |ref entry| {
1830
1833
if entry. height != height { return true ; }
1831
1834
match entry. event {
1832
- OnchainEvent :: HTLCUpdate { ref htlc_update } => {
1833
- htlc_update . 0 != $source
1834
- } ,
1835
- _ => true ,
1835
+ OnchainEvent :: HTLCUpdate { source : ref update_source , .. } => {
1836
+ * update_source != $source
1837
+ } ,
1838
+ _ => true ,
1836
1839
}
1837
1840
} ) ;
1838
1841
let entry = OnchainEventEntry {
1839
1842
txid: commitment_txid,
1840
1843
height,
1841
- event: OnchainEvent :: HTLCUpdate { htlc_update : ( $source, $payment_hash) } ,
1844
+ event: OnchainEvent :: HTLCUpdate { source : $source, payment_hash : $payment_hash } ,
1842
1845
} ;
1843
1846
log_trace!( logger, "Failing HTLC with payment_hash {} from {} holder commitment tx due to broadcast of transaction, waiting confirmation (at height{})" , log_bytes!( $payment_hash. 0 ) , $commitment_tx, entry. confirmation_threshold( ) ) ;
1844
1847
self . onchain_events_awaiting_threshold_conf. push( entry) ;
@@ -2109,7 +2112,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2109
2112
let unmatured_htlcs: Vec < _ > = self . onchain_events_awaiting_threshold_conf
2110
2113
. iter ( )
2111
2114
. filter_map ( |entry| match & entry. event {
2112
- OnchainEvent :: HTLCUpdate { htlc_update } => Some ( htlc_update . 0 . clone ( ) ) ,
2115
+ OnchainEvent :: HTLCUpdate { source , .. } => Some ( source ) ,
2113
2116
OnchainEvent :: MaturingOutput { .. } => None ,
2114
2117
} )
2115
2118
. collect ( ) ;
@@ -2119,28 +2122,28 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2119
2122
// Produce actionable events from on-chain events having reached their threshold.
2120
2123
for entry in onchain_events_reaching_threshold_conf. drain ( ..) {
2121
2124
match entry. event {
2122
- OnchainEvent :: HTLCUpdate { htlc_update } => {
2125
+ OnchainEvent :: HTLCUpdate { ref source , payment_hash } => {
2123
2126
// Check for duplicate HTLC resolutions.
2124
2127
#[ cfg( debug_assertions) ]
2125
2128
{
2126
2129
debug_assert ! (
2127
- unmatured_htlcs. iter( ) . find( |& htlc| htlc == & htlc_update . 0 ) . is_none( ) ,
2130
+ unmatured_htlcs. iter( ) . find( |& htlc| htlc == & source ) . is_none( ) ,
2128
2131
"An unmature HTLC transaction conflicts with a maturing one; failed to \
2129
2132
call either transaction_unconfirmed for the conflicting transaction \
2130
2133
or block_disconnected for a block containing it.") ;
2131
2134
debug_assert ! (
2132
- matured_htlcs. iter( ) . find( |& htlc| htlc == & htlc_update . 0 ) . is_none( ) ,
2135
+ matured_htlcs. iter( ) . find( |& htlc| htlc == source ) . is_none( ) ,
2133
2136
"A matured HTLC transaction conflicts with a maturing one; failed to \
2134
2137
call either transaction_unconfirmed for the conflicting transaction \
2135
2138
or block_disconnected for a block containing it.") ;
2136
- matured_htlcs. push ( htlc_update . 0 . clone ( ) ) ;
2139
+ matured_htlcs. push ( source . clone ( ) ) ;
2137
2140
}
2138
2141
2139
- log_trace ! ( logger, "HTLC {} failure update has got enough confirmations to be passed upstream" , log_bytes!( ( htlc_update . 1 ) . 0 ) ) ;
2142
+ log_trace ! ( logger, "HTLC {} failure update has got enough confirmations to be passed upstream" , log_bytes!( payment_hash . 0 ) ) ;
2140
2143
self . pending_monitor_events . push ( MonitorEvent :: HTLCEvent ( HTLCUpdate {
2141
- payment_hash : htlc_update . 1 ,
2144
+ payment_hash : payment_hash ,
2142
2145
payment_preimage : None ,
2143
- source : htlc_update . 0 ,
2146
+ source : source . clone ( ) ,
2144
2147
} ) ) ;
2145
2148
} ,
2146
2149
OnchainEvent :: MaturingOutput { descriptor } => {
@@ -2437,16 +2440,16 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2437
2440
self . onchain_events_awaiting_threshold_conf . retain ( |ref entry| {
2438
2441
if entry. height != height { return true ; }
2439
2442
match entry. event {
2440
- OnchainEvent :: HTLCUpdate { ref htlc_update } => {
2441
- htlc_update . 0 != source
2442
- } ,
2443
- _ => true ,
2443
+ OnchainEvent :: HTLCUpdate { source : ref htlc_source , .. } => {
2444
+ * htlc_source != source
2445
+ } ,
2446
+ _ => true ,
2444
2447
}
2445
2448
} ) ;
2446
2449
let entry = OnchainEventEntry {
2447
2450
txid : tx. txid ( ) ,
2448
2451
height,
2449
- event : OnchainEvent :: HTLCUpdate { htlc_update : ( source, payment_hash) } ,
2452
+ event : OnchainEvent :: HTLCUpdate { source : source, payment_hash : payment_hash } ,
2450
2453
} ;
2451
2454
log_info ! ( logger, "Failing HTLC with payment_hash {} timeout by a spend tx, waiting for confirmation (at height{})" , log_bytes!( payment_hash. 0 ) , entry. confirmation_threshold( ) ) ;
2452
2455
self . onchain_events_awaiting_threshold_conf . push ( entry) ;
@@ -2808,7 +2811,8 @@ impl<'a, Signer: Sign, K: KeysInterface<Signer = Signer>> ReadableArgs<&'a K>
2808
2811
let htlc_source = Readable :: read ( reader) ?;
2809
2812
let hash = Readable :: read ( reader) ?;
2810
2813
OnchainEvent :: HTLCUpdate {
2811
- htlc_update : ( htlc_source, hash)
2814
+ source : htlc_source,
2815
+ payment_hash : hash,
2812
2816
}
2813
2817
} ,
2814
2818
1 => {
0 commit comments