@@ -1508,7 +1508,7 @@ impl Channel {
1508
1508
1509
1509
/// Removes an outbound HTLC which has been commitment_signed by the remote end
1510
1510
#[ inline]
1511
- fn mark_outbound_htlc_removed ( & mut self , htlc_id : u64 , check_preimage : Option < [ u8 ; 32 ] > , fail_reason : Option < HTLCFailReason > ) -> Result < & HTLCSource , ChannelError > {
1511
+ fn mark_outbound_htlc_removed ( & mut self , htlc_id : u64 , check_preimage : Option < [ u8 ; 32 ] > , fail_reason : Option < HTLCFailReason > ) -> Result < ( & HTLCSource , [ u8 ; 32 ] ) , ChannelError > {
1512
1512
for htlc in self . pending_outbound_htlcs . iter_mut ( ) {
1513
1513
if htlc. htlc_id == htlc_id {
1514
1514
match check_preimage {
@@ -1528,13 +1528,13 @@ impl Channel {
1528
1528
OutboundHTLCState :: AwaitingRemoteRevokeToRemove | OutboundHTLCState :: AwaitingRemovedRemoteRevoke | OutboundHTLCState :: RemoteRemoved =>
1529
1529
return Err ( ChannelError :: Close ( "Remote tried to fulfill HTLC that they'd already fulfilled" ) ) ,
1530
1530
}
1531
- return Ok ( & htlc. source ) ;
1531
+ return Ok ( ( & htlc. source , htlc . payment_hash ) ) ;
1532
1532
}
1533
1533
}
1534
1534
Err ( ChannelError :: Close ( "Remote tried to fulfill/fail an HTLC we couldn't find" ) )
1535
1535
}
1536
1536
1537
- pub fn update_fulfill_htlc ( & mut self , msg : & msgs:: UpdateFulfillHTLC ) -> Result < & HTLCSource , ChannelError > {
1537
+ pub fn update_fulfill_htlc ( & mut self , msg : & msgs:: UpdateFulfillHTLC ) -> Result < ( & HTLCSource , [ u8 ; 32 ] ) , ChannelError > {
1538
1538
if ( self . channel_state & ( ChannelState :: ChannelFunded as u32 ) ) != ( ChannelState :: ChannelFunded as u32 ) {
1539
1539
return Err ( ChannelError :: Close ( "Got fulfill HTLC message when channel was not in an operational state" ) ) ;
1540
1540
}
@@ -1550,7 +1550,7 @@ impl Channel {
1550
1550
self . mark_outbound_htlc_removed ( msg. htlc_id , Some ( payment_hash) , None )
1551
1551
}
1552
1552
1553
- pub fn update_fail_htlc ( & mut self , msg : & msgs:: UpdateFailHTLC , fail_reason : HTLCFailReason ) -> Result < & HTLCSource , ChannelError > {
1553
+ pub fn update_fail_htlc ( & mut self , msg : & msgs:: UpdateFailHTLC , fail_reason : HTLCFailReason ) -> Result < ( & HTLCSource , [ u8 ; 32 ] ) , ChannelError > {
1554
1554
if ( self . channel_state & ( ChannelState :: ChannelFunded as u32 ) ) != ( ChannelState :: ChannelFunded as u32 ) {
1555
1555
return Err ( ChannelError :: Close ( "Got fail HTLC message when channel was not in an operational state" ) ) ;
1556
1556
}
@@ -1561,7 +1561,7 @@ impl Channel {
1561
1561
self . mark_outbound_htlc_removed ( msg. htlc_id , None , Some ( fail_reason) )
1562
1562
}
1563
1563
1564
- pub fn update_fail_malformed_htlc < ' a > ( & mut self , msg : & msgs:: UpdateFailMalformedHTLC , fail_reason : HTLCFailReason ) -> Result < & HTLCSource , ChannelError > {
1564
+ pub fn update_fail_malformed_htlc < ' a > ( & mut self , msg : & msgs:: UpdateFailMalformedHTLC , fail_reason : HTLCFailReason ) -> Result < ( & HTLCSource , [ u8 ; 32 ] ) , ChannelError > {
1565
1565
if ( self . channel_state & ( ChannelState :: ChannelFunded as u32 ) ) != ( ChannelState :: ChannelFunded as u32 ) {
1566
1566
return Err ( ChannelError :: Close ( "Got fail malformed HTLC message when channel was not in an operational state" ) ) ;
1567
1567
}
@@ -2928,7 +2928,7 @@ impl Channel {
2928
2928
/// those explicitly stated to be allowed after shutdown completes, eg some simple getters).
2929
2929
/// Also returns the list of payment_hashes for channels which we can safely fail backwards
2930
2930
/// immediately (others we will have to allow to time out).
2931
- pub fn force_shutdown ( & mut self ) -> ( Vec < Transaction > , Vec < ( HTLCSource , [ u8 ; 32 ] ) > ) {
2931
+ pub fn force_shutdown ( & mut self ) -> ( Vec < Transaction > , Vec < ( HTLCSource , [ u8 ; 32 ] ) > , Vec < [ u8 ; 32 ] > ) {
2932
2932
assert ! ( self . channel_state != ChannelState :: ShutdownComplete as u32 ) ;
2933
2933
2934
2934
// We go ahead and "free" any holding cell HTLCs or HTLCs we haven't yet committed to and
@@ -2943,17 +2943,19 @@ impl Channel {
2943
2943
}
2944
2944
}
2945
2945
2946
- for _htlc in self . pending_outbound_htlcs . drain ( ..) {
2947
- //TODO: Do something with the remaining HTLCs
2948
- //(we need to have the ChannelManager monitor them so we can claim the inbound HTLCs
2949
- //which correspond)
2946
+ let mut unsolved_htlcs = Vec :: with_capacity ( self . pending_outbound_htlcs . len ( ) + self . pending_inbound_htlcs . len ( ) ) ;
2947
+ for outbound_htlcs in self . pending_outbound_htlcs . iter ( ) {
2948
+ unsolved_htlcs. push ( outbound_htlcs. payment_hash ) ;
2949
+ }
2950
+ for inbound_htlcs in self . pending_inbound_htlcs . iter ( ) {
2951
+ unsolved_htlcs. push ( inbound_htlcs. payment_hash ) ;
2950
2952
}
2951
2953
2952
2954
self . channel_state = ChannelState :: ShutdownComplete as u32 ;
2953
2955
self . channel_update_count += 1 ;
2954
2956
let mut res = Vec :: new ( ) ;
2955
2957
mem:: swap ( & mut res, & mut self . last_local_commitment_txn ) ;
2956
- ( res, dropped_outbound_htlcs)
2958
+ ( res, dropped_outbound_htlcs, unsolved_htlcs )
2957
2959
}
2958
2960
}
2959
2961
0 commit comments