@@ -36,7 +36,7 @@ use bitcoin::secp256k1::ecdh::SharedSecret;
36
36
use bitcoin:: secp256k1:: { PublicKey , Scalar , Secp256k1 , SecretKey } ;
37
37
38
38
use crate :: io:: { Cursor , Read } ;
39
- use core:: ops:: Deref ;
39
+ use core:: { fmt , ops:: Deref } ;
40
40
41
41
#[ allow( unused_imports) ]
42
42
use crate :: prelude:: * ;
@@ -1713,6 +1713,86 @@ impl From<u16> for LocalHTLCFailureReason {
1713
1713
}
1714
1714
}
1715
1715
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 implement 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 public key of the onion packet is unparseable" ) ,
1731
+ Self :: TemporaryChannelFailure => write ! ( f, "Node indicated 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 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
+ Self :: IncorrectCLTVExpiry => write ! ( f, "CLTV expiry does not meet the cltv_expiry_delta advertised by the outgoing channel" ) ,
1768
+ Self :: CLTVExpiryTooSoon => write ! ( f, "CLTV expiry is too close to the current block height for safe relay" ) ,
1769
+ Self :: OutgoingCLTVTooSoon => {
1770
+ write ! ( f, "Outgoing CLTV value is too close to the current block height for safe relay" )
1771
+ } ,
1772
+ Self :: IncorrectPaymentDetails => write ! ( f, "Payment made with incorrect or unknown payment information" ) ,
1773
+ Self :: PaymentClaimBuffer => write ! ( f, "Payment arrived too close to its expiry height to be safely claimed" ) ,
1774
+ Self :: InvalidKeysendPreimage => write ! ( f, "Invalid or missing keysend preimage" ) ,
1775
+ Self :: FinalIncorrectCLTVExpiry => {
1776
+ write ! ( f, "Final node received a CLTV expiry that does not match the value in the onion" )
1777
+ } ,
1778
+ Self :: FinalIncorrectHTLCAmount => {
1779
+ write ! ( f, "Final node received an amount that does not match the value in the onion" )
1780
+ } ,
1781
+ Self :: ChannelDisabled => write ! ( f, "Channel has been disconnected for some time" ) ,
1782
+ Self :: CLTVExpiryTooFar => write ! ( f, "CLTV expiry is too far in the future" ) ,
1783
+ Self :: InvalidOnionPayload => {
1784
+ write ! ( f, "Onion payload could not be parsed" )
1785
+ } ,
1786
+ Self :: InvalidTrampolinePayload => {
1787
+ write ! ( f, "Trampoline payload could not be parsed" )
1788
+ } ,
1789
+ Self :: MPPTimeout => write ! ( f, "Multi-part payment timed out before completion" ) ,
1790
+ Self :: InvalidOnionBlinding => write ! ( f, "Invalid onion blinding information" ) ,
1791
+ Self :: UnknownFailureCode { code } => write ! ( f, "Unknown failure code: {}" , code) ,
1792
+ }
1793
+ }
1794
+ }
1795
+
1716
1796
impl_writeable_tlv_based_enum ! ( LocalHTLCFailureReason ,
1717
1797
( 1 , TemporaryNodeFailure ) => { } ,
1718
1798
( 3 , PermanentNodeFailure ) => { } ,
0 commit comments