Module: Lightning::Onion::FailureMessages

Defined in:
lib/lightning/onion/failure_messages.rb,
lib/lightning/onion/failure_messages/invalid_realm.rb,
lib/lightning/onion/failure_messages/expiry_too_far.rb,
lib/lightning/onion/failure_messages/expiry_too_soon.rb,
lib/lightning/onion/failure_messages/channel_disabled.rb,
lib/lightning/onion/failure_messages/fee_insufficient.rb,
lib/lightning/onion/failure_messages/invalid_onion_key.rb,
lib/lightning/onion/failure_messages/unknown_next_peer.rb,
lib/lightning/onion/failure_messages/invalid_onion_hmac.rb,
lib/lightning/onion/failure_messages/amount_below_minimum.rb,
lib/lightning/onion/failure_messages/unknown_payment_hash.rb,
lib/lightning/onion/failure_messages/final_expiry_too_soon.rb,
lib/lightning/onion/failure_messages/incorrect_cltv_expiry.rb,
lib/lightning/onion/failure_messages/invalid_onion_version.rb,
lib/lightning/onion/failure_messages/permanent_node_failure.rb,
lib/lightning/onion/failure_messages/temporary_node_failure.rb,
lib/lightning/onion/failure_messages/incorrect_payment_amount.rb,
lib/lightning/onion/failure_messages/permanent_channel_failure.rb,
lib/lightning/onion/failure_messages/temporary_channel_failure.rb,
lib/lightning/onion/failure_messages/final_incorrect_cltv_expiry.rb,
lib/lightning/onion/failure_messages/final_incorrect_htlc_amount.rb,
lib/lightning/onion/failure_messages/required_node_feature_missing.rb,
lib/lightning/onion/failure_messages/required_channel_feature_missing.rb

Defined Under Namespace

Modules: AmountBelowMinimum, ChannelDisabled, ExpiryTooFar, ExpiryTooSoon, FeeInsufficient, FinalExpiryTooSoon, FinalIncorrectCltvExpiry, FinalIncorrectHtlcAmount, IncorrectCltvExpiry, IncorrectPaymentAmount, InvalidOnionHmac, InvalidOnionKey, InvalidOnionVersion, InvalidRealm, PermanentChannelFailure, PermanentNodeFailure, RequiredChannelFeatureMissing, RequiredNodeFeatureMissing, TemporaryChannelFailure, TemporaryNodeFailure, UnknownNextPeer, UnknownPaymentHash

Constant Summary collapse

BADONION =

unparsable onion encrypted by sending peer

0x8000
PERM =

permanent failure (otherwise transient)

0x4000
NODE =

node failure (otherwise channel)

0x2000
UPDATE =

new channel update enclosed

0x1000
TYPES =
{
  invalid_realm: PERM | 1,
  temporary_node_failure: NODE | 2,
  permanent_node_failure: PERM | NODE | 2,
  required_node_feature_missing: PERM | NODE | 3,
  invalid_onion_version: BADONION | PERM | 4,
  invalid_onion_hmac: BADONION | PERM | 5,
  invalid_onion_key: BADONION | PERM | 6,
  temporary_channel_failure: UPDATE | 7,
  permanent_channel_failure: PERM | 8,
  required_channel_feature_missing: PERM | 9,
  unknown_next_peer: PERM | 10,
  amount_below_minimum: UPDATE | 11,
  fee_insufficient: UPDATE | 12,
  incorrect_cltv_expiry: UPDATE | 13,
  expiry_too_soon: UPDATE | 14,
  unknown_payment_hash: PERM | 15,
  incorrect_payment_amount: PERM | 16,
  final_expiry_too_soon: 17,
  final_incorrect_cltv_expiry: 18,
  final_incorrect_htlc_amount: 19,
  channel_disabled: 20,
  expiry_too_far: 21
}.freeze
FailureMessage =
Algebrick.type do
  InvalidRealm = atom
  TemporaryNodeFailure = atom
  PermanentNodeFailure = atom
  RequiredNodeFeatureMissing = atom
  InvalidOnionVersion = type do
    fields! sha256_of_onion: String
  end
  InvalidOnionHmac = type do
    fields! sha256_of_onion: String
  end
  InvalidOnionKey = type do
    fields! sha256_of_onion: String
  end
  TemporaryChannelFailure = type do
    fields! channel_update: String
  end
  PermanentChannelFailure = atom
  RequiredChannelFeatureMissing = atom
  UnknownNextPeer = atom
  AmountBelowMinimum = type do
    fields! htlc_msat: Numeric,
            channel_update: String
  end
  FeeInsufficient = type do
    fields! htlc_msat: Numeric,
            channel_update: String
  end
  IncorrectCltvExpiry = type do
    fields! cltv_expiry: Numeric,
            channel_update: String
  end
  ExpiryTooSoon = type do
    fields! channel_update: String
  end
  UnknownPaymentHash = atom
  IncorrectPaymentAmount = atom
  FinalExpiryTooSoon = atom
  FinalIncorrectCltvExpiry = type do
    fields! cltv_expiry: Numeric
  end
  FinalIncorrectHtlcAmount = type do
    fields! incoming_htlc_amt: Numeric
  end
  ChannelDisabled = type do
    fields! flags: String,
            channel_update: String
  end
  ExpiryTooFar = atom
  variants  InvalidRealm,
            TemporaryNodeFailure,
            PermanentNodeFailure,
            RequiredNodeFeatureMissing,
            InvalidOnionVersion,
            InvalidOnionHmac,
            InvalidOnionKey,
            TemporaryChannelFailure,
            PermanentChannelFailure,
            RequiredChannelFeatureMissing,
            UnknownNextPeer,
            AmountBelowMinimum,
            FeeInsufficient,
            IncorrectCltvExpiry,
            ExpiryTooSoon,
            UnknownPaymentHash,
            IncorrectPaymentAmount,
            FinalExpiryTooSoon,
            FinalIncorrectCltvExpiry,
            FinalIncorrectHtlcAmount,
            ChannelDisabled,
            ExpiryTooFar
end

Class Method Summary collapse

Class Method Details

.load(payload) ⇒ Object



116
117
118
119
120
121
122
# File 'lib/lightning/onion/failure_messages.rb', line 116

def self.load(payload)
  type, rest = payload.unpack('na*')
  message_class = FailureMessage.variants.find do |t|
    TYPES[t.name.split('::').last.snake.to_sym] == type
  end
  message_class.load(rest)
end