Skip to content

Commit def6ba7

Browse files
committed
Add FailureCode enum
This enum is used to specify which error code and data to send to peers when failing back an HTLC.
1 parent e0a0add commit def6ba7

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,25 @@ struct ReceiveError {
289289
msg: &'static str,
290290
}
291291

292+
/// This enum is used to specify which error data to send to peers when failing back an HTLC
293+
/// using [`ChannelManager::fail_htlc_backwards_with_reason`].
294+
///
295+
/// For more info on failure codes, see <https://github.com/lightning/bolts/blob/master/04-onion-routing.md#failure-messages>.
296+
#[derive(Clone, Copy)]
297+
pub enum FailureCode {
298+
/// We had a temporary error processing the payment. Useful if no other error codes fit
299+
/// and you want to indicate that the payer may want to retry.
300+
TemporaryNodeFailure = 0x2000 | 2,
301+
/// We have a required feature which was not in this onion. For example, you may require
302+
/// some additional metadata that was not provided with this payment.
303+
RequiredNodeFeatureMissing = 0x4000 | 0x2000 | 3,
304+
/// You may wish to use this when a `payment_preimage` is unknown, or the CLTV expiry of
305+
/// the HTLC is too close to the current block height for safe handling.
306+
/// Using this failure code in [`ChannelManager::fail_htlc_backwards_with_reason`] is
307+
/// equivalent to calling [`ChannelManager::fail_htlc_backwards`].
308+
IncorrectOrUnknownPaymentDetails = 0x4000 | 15,
309+
}
310+
292311
type ShutdownResult = (Option<(OutPoint, ChannelMonitorUpdate)>, Vec<(HTLCSource, PaymentHash, PublicKey, [u8; 32])>);
293312

294313
/// Error type returned across the peer_state mutex boundary. When an Err is generated for a

0 commit comments

Comments
 (0)