@@ -1508,38 +1508,38 @@ 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 , HandleError > {
1511
+ fn mark_outbound_htlc_removed ( & mut self , htlc_id : u64 , check_preimage : Option < [ u8 ; 32 ] > , fail_reason : Option < HTLCFailReason > ) -> Result < & HTLCSource , 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 {
1515
1515
None => { } ,
1516
1516
Some ( payment_hash) =>
1517
1517
if payment_hash != htlc. payment_hash {
1518
- return Err ( HandleError { err : "Remote tried to fulfill HTLC with an incorrect preimage" , action : None } ) ;
1518
+ return Err ( ChannelError :: Close ( "Remote tried to fulfill HTLC with an incorrect preimage" ) ) ;
1519
1519
}
1520
1520
} ;
1521
1521
match htlc. state {
1522
1522
OutboundHTLCState :: LocalAnnounced =>
1523
- return Err ( HandleError { err : "Remote tried to fulfill HTLC before it had been committed" , action : None } ) ,
1523
+ return Err ( ChannelError :: Close ( "Remote tried to fulfill HTLC before it had been committed" ) ) ,
1524
1524
OutboundHTLCState :: Committed => {
1525
1525
htlc. state = OutboundHTLCState :: RemoteRemoved ;
1526
1526
htlc. fail_reason = fail_reason;
1527
1527
} ,
1528
1528
OutboundHTLCState :: AwaitingRemoteRevokeToRemove | OutboundHTLCState :: AwaitingRemovedRemoteRevoke | OutboundHTLCState :: RemoteRemoved =>
1529
- return Err ( HandleError { err : "Remote tried to fulfill HTLC that they'd already fulfilled" , action : None } ) ,
1529
+ return Err ( ChannelError :: Close ( "Remote tried to fulfill HTLC that they'd already fulfilled" ) ) ,
1530
1530
}
1531
1531
return Ok ( & htlc. source ) ;
1532
1532
}
1533
1533
}
1534
- Err ( HandleError { err : "Remote tried to fulfill/fail an HTLC we couldn't find" , action : None } )
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 , HandleError > {
1537
+ pub fn update_fulfill_htlc ( & mut self , msg : & msgs:: UpdateFulfillHTLC ) -> Result < & HTLCSource , ChannelError > {
1538
1538
if ( self . channel_state & ( ChannelState :: ChannelFunded as u32 ) ) != ( ChannelState :: ChannelFunded as u32 ) {
1539
- return Err ( HandleError { err : "Got add HTLC message when channel was not in an operational state" , action : None } ) ;
1539
+ return Err ( ChannelError :: Close ( "Got fulfill HTLC message when channel was not in an operational state" ) ) ;
1540
1540
}
1541
1541
if self . channel_state & ( ChannelState :: PeerDisconnected as u32 ) == ChannelState :: PeerDisconnected as u32 {
1542
- return Err ( HandleError { err : "Peer sent update_fulfill_htlc when we needed a channel_reestablish" , action : Some ( msgs :: ErrorAction :: SendErrorMessage { msg : msgs :: ErrorMessage { data : "Peer sent update_fulfill_htlc when we needed a channel_reestablish" . to_string ( ) , channel_id : msg . channel_id } } ) } ) ;
1542
+ return Err ( ChannelError :: Close ( "Peer sent update_fulfill_htlc when we needed a channel_reestablish" ) ) ;
1543
1543
}
1544
1544
1545
1545
let mut sha = Sha256 :: new ( ) ;
@@ -1550,23 +1550,23 @@ 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 , HandleError > {
1553
+ pub fn update_fail_htlc ( & mut self , msg : & msgs:: UpdateFailHTLC , fail_reason : HTLCFailReason ) -> Result < & HTLCSource , ChannelError > {
1554
1554
if ( self . channel_state & ( ChannelState :: ChannelFunded as u32 ) ) != ( ChannelState :: ChannelFunded as u32 ) {
1555
- return Err ( HandleError { err : "Got add HTLC message when channel was not in an operational state" , action : None } ) ;
1555
+ return Err ( ChannelError :: Close ( "Got fail HTLC message when channel was not in an operational state" ) ) ;
1556
1556
}
1557
1557
if self . channel_state & ( ChannelState :: PeerDisconnected as u32 ) == ChannelState :: PeerDisconnected as u32 {
1558
- return Err ( HandleError { err : "Peer sent update_fail_htlc when we needed a channel_reestablish" , action : Some ( msgs :: ErrorAction :: SendErrorMessage { msg : msgs :: ErrorMessage { data : "Peer sent update_fail_htlc when we needed a channel_reestablish" . to_string ( ) , channel_id : msg . channel_id } } ) } ) ;
1558
+ return Err ( ChannelError :: Close ( "Peer sent update_fail_htlc when we needed a channel_reestablish" ) ) ;
1559
1559
}
1560
1560
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 , HandleError > {
1564
+ pub fn update_fail_malformed_htlc < ' a > ( & mut self , msg : & msgs:: UpdateFailMalformedHTLC , fail_reason : HTLCFailReason ) -> Result < & HTLCSource , ChannelError > {
1565
1565
if ( self . channel_state & ( ChannelState :: ChannelFunded as u32 ) ) != ( ChannelState :: ChannelFunded as u32 ) {
1566
- return Err ( HandleError { err : "Got add HTLC message when channel was not in an operational state" , action : None } ) ;
1566
+ return Err ( ChannelError :: Close ( "Got fail malformed HTLC message when channel was not in an operational state" ) ) ;
1567
1567
}
1568
1568
if self . channel_state & ( ChannelState :: PeerDisconnected as u32 ) == ChannelState :: PeerDisconnected as u32 {
1569
- return Err ( HandleError { err : "Peer sent update_fail_malformed_htlc when we needed a channel_reestablish" , action : Some ( msgs :: ErrorAction :: SendErrorMessage { msg : msgs :: ErrorMessage { data : "Peer sent update_fail_malformed_htlc when we needed a channel_reestablish" . to_string ( ) , channel_id : msg . channel_id } } ) } ) ;
1569
+ return Err ( ChannelError :: Close ( "Peer sent update_fail_malformed_htlc when we needed a channel_reestablish" ) ) ;
1570
1570
}
1571
1571
1572
1572
self . mark_outbound_htlc_removed ( msg. htlc_id , None , Some ( fail_reason) )
0 commit comments