@@ -36,7 +36,7 @@ use bitcoin::secp256k1::ecdh::SharedSecret;
3636use bitcoin:: secp256k1:: { PublicKey , Scalar , Secp256k1 , SecretKey } ;
3737
3838use crate :: io:: { Cursor , Read } ;
39- use core:: ops:: Deref ;
39+ use core:: { fmt , ops:: Deref } ;
4040
4141#[ allow( unused_imports) ]
4242use crate :: prelude:: * ;
@@ -1713,6 +1713,87 @@ impl From<u16> for LocalHTLCFailureReason {
17131713 }
17141714}
17151715
1716+ impl fmt:: Display for LocalHTLCFailureReason {
1717+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1718+ match self {
1719+ Self :: TemporaryNodeFailure => write ! ( f, "Node indicated a temporary failure which may resolve on retry" ) ,
1720+ Self :: ForwardExpiryBuffer => {
1721+ write ! ( f, "HTLC forward's outgoing expiry is too close to current block height for safe handling" )
1722+ } ,
1723+ Self :: PermanentNodeFailure => write ! ( f, "Node indicated a permanent failure which will not resolve on retry" ) ,
1724+ Self :: RequiredNodeFeature => {
1725+ write ! ( f, "HTLC does not implmement a feature that is required by the node" )
1726+ } ,
1727+ Self :: PaymentSecretRequired => write ! ( f, "Payment secret field is missing for payment where it is required" ) ,
1728+ Self :: InvalidOnionVersion => write ! ( f, "Node does not understand the onion version received" ) ,
1729+ Self :: InvalidOnionHMAC => write ! ( f, "The HMAC of the onion packet is incorrect" ) ,
1730+ Self :: InvalidOnionKey => write ! ( f, "The ephemeral publick key of the onion packet is unparseable" ) ,
1731+ Self :: TemporaryChannelFailure => write ! ( f, "Node indiciated a temporary channel failure which may resolve on retry" ) ,
1732+ Self :: DustLimitHolder => {
1733+ write ! ( f, "HTLC exceeds our dust limit on holder commitment tx" )
1734+ } ,
1735+ Self :: DustLimitCounterparty => {
1736+ write ! ( f, "HTLC exceeds our dust limit on counterparty commitment tx" )
1737+ } ,
1738+ Self :: FeeSpikeBuffer => {
1739+ write ! ( f, "HTLC exceeds fee spike buffer reserved on counterparty's balance" )
1740+ } ,
1741+ Self :: ChannelNotReady => {
1742+ write ! ( f, "Channel is not ready to be utilized for forwards" )
1743+ } ,
1744+ Self :: AmountExceedsCapacity => {
1745+ write ! ( f, "Amount is greater than channel capacity" )
1746+ } ,
1747+ Self :: ZeroAmount => write ! ( f, "Zero amount HTLC not allowed" ) ,
1748+ Self :: HTLCMinimum => write ! ( f, "Amount is less than channel's current liquidity minimum" ) ,
1749+ Self :: HTLCMaximum => {
1750+ write ! ( f, "Amount is more than the channel's current liquidity maximum" )
1751+ } ,
1752+ Self :: PeerOffline => write ! ( f, "Outgoing channel counterparty is offline" ) ,
1753+ Self :: PermanentChannelFailure => write ! ( f, "Node indicated a permanent channel failure which will not resolve on retry" ) ,
1754+ Self :: ChannelClosed => write ! ( f, "Channel is has been closed" ) ,
1755+ Self :: OnChainTimeout => write ! ( f, "HTLC timed out on chain" ) ,
1756+ Self :: RequiredChannelFeature => {
1757+ write ! ( f, "HTLC does not implement a feature that is required by the channel" )
1758+ } ,
1759+ Self :: UnknownNextPeer => write ! ( f, "Requested outgoing channel is unknown" ) ,
1760+ Self :: PrivateChannelForward => write ! ( f, "Forward over private channel rejected" ) ,
1761+ Self :: RealSCIDForward => {
1762+ write ! ( f, "Forward using real scid over aliased channel rejected" )
1763+ } ,
1764+ Self :: InvalidTrampolineForward => write ! ( f, "Invalid trampoline forward" ) ,
1765+ Self :: AmountBelowMinimum => write ! ( f, "Amount is less than the required minimum for the outbound channel" ) ,
1766+ Self :: FeeInsufficient => write ! ( f, "Fee amount does not meet the amount required by the outgoing channel's advertised policy" ) ,
1767+
1768+ Self :: IncorrectCLTVExpiry => write ! ( f, "CLTV expiry does not meet the cltv_expiry_delta advertised by the outgoing channel" ) ,
1769+ Self :: CLTVExpiryTooSoon => write ! ( f, "CLTV expiry is too close to the current block height for safe relay" ) ,
1770+ Self :: OutgoingCLTVTooSoon => {
1771+ write ! ( f, "Outgoing CLTV value is too close to the current block height for safe relay" )
1772+ } ,
1773+ Self :: IncorrectPaymentDetails => write ! ( f, "Payment made with incorrect or unknown payment information" ) ,
1774+ Self :: PaymentClaimBuffer => write ! ( f, "Payment arrived too close to its expiry height to be safely claimed" ) ,
1775+ Self :: InvalidKeysendPreimage => write ! ( f, "Invalid or missing keysend preimage" ) ,
1776+ Self :: FinalIncorrectCLTVExpiry => {
1777+ write ! ( f, "Final node received a CLTV expiry that does not match the value in the onion" )
1778+ } ,
1779+ Self :: FinalIncorrectHTLCAmount => {
1780+ write ! ( f, "Final node received an amount that does not match the value in the onion" )
1781+ } ,
1782+ Self :: ChannelDisabled => write ! ( f, "Channel has been disconnected for some time" ) ,
1783+ Self :: CLTVExpiryTooFar => write ! ( f, "CLTV expiry is too far in the future" ) ,
1784+ Self :: InvalidOnionPayload => {
1785+ write ! ( f, "Onion payload could not be parsed" )
1786+ } ,
1787+ Self :: InvalidTrampolinePayload => {
1788+ write ! ( f, "Tramopline payload could not be parsed" )
1789+ } ,
1790+ Self :: MPPTimeout => write ! ( f, "Multi-part payment timed out before completion" ) ,
1791+ Self :: InvalidOnionBlinding => write ! ( f, "Invalid onion blinding information" ) ,
1792+ Self :: UnknownFailureCode { code } => write ! ( f, "Unknown failure code: {}" , code) ,
1793+ }
1794+ }
1795+ }
1796+
17161797impl_writeable_tlv_based_enum ! ( LocalHTLCFailureReason ,
17171798 ( 1 , TemporaryNodeFailure ) => { } ,
17181799 ( 3 , PermanentNodeFailure ) => { } ,
0 commit comments