2019-09-05 14:35:39 +03:00
|
|
|
package hop
|
2017-05-01 17:46:53 +03:00
|
|
|
|
|
|
|
import (
|
2019-07-31 07:52:17 +03:00
|
|
|
"bytes"
|
|
|
|
"fmt"
|
2017-05-02 22:01:46 +03:00
|
|
|
"io"
|
2017-05-01 17:46:53 +03:00
|
|
|
|
2018-07-31 10:17:17 +03:00
|
|
|
"github.com/btcsuite/btcd/btcec"
|
2019-09-05 14:35:39 +03:00
|
|
|
sphinx "github.com/lightningnetwork/lightning-onion"
|
2017-06-17 00:38:42 +03:00
|
|
|
"github.com/lightningnetwork/lnd/lnwire"
|
2017-05-01 17:46:53 +03:00
|
|
|
)
|
|
|
|
|
2019-09-05 14:35:39 +03:00
|
|
|
// Iterator is an interface that abstracts away the routing information
|
2017-06-17 00:29:38 +03:00
|
|
|
// included in HTLC's which includes the entirety of the payment path of an
|
|
|
|
// HTLC. This interface provides two basic method which carry out: how to
|
|
|
|
// interpret the forwarding information encoded within the HTLC packet, and hop
|
|
|
|
// to encode the forwarding information for the _next_ hop.
|
2019-09-05 14:35:39 +03:00
|
|
|
type Iterator interface {
|
2019-11-05 02:10:15 +03:00
|
|
|
// HopPayload returns the set of fields that detail exactly _how_ this
|
|
|
|
// hop should forward the HTLC to the next hop. Additionally, the
|
|
|
|
// information encoded within the returned ForwardingInfo is to be used
|
|
|
|
// by each hop to authenticate the information given to it by the prior
|
|
|
|
// hop. The payload will also contain any additional TLV fields provided
|
|
|
|
// by the sender.
|
|
|
|
HopPayload() (*Payload, error)
|
2019-07-31 07:52:17 +03:00
|
|
|
|
2017-06-17 00:29:38 +03:00
|
|
|
// EncodeNextHop encodes the onion packet destined for the next hop
|
|
|
|
// into the passed io.Writer.
|
|
|
|
EncodeNextHop(w io.Writer) error
|
2018-01-16 11:36:14 +03:00
|
|
|
|
|
|
|
// ExtractErrorEncrypter returns the ErrorEncrypter needed for this hop,
|
|
|
|
// along with a failure code to signal if the decoding was successful.
|
|
|
|
ExtractErrorEncrypter(ErrorEncrypterExtracter) (ErrorEncrypter,
|
|
|
|
lnwire.FailCode)
|
2017-05-02 22:01:46 +03:00
|
|
|
}
|
2017-05-02 23:57:13 +03:00
|
|
|
|
|
|
|
// sphinxHopIterator is the Sphinx implementation of hop iterator which uses
|
2017-06-17 00:29:38 +03:00
|
|
|
// onion routing to encode the payment route in such a way so that node might
|
|
|
|
// see only the next hop in the route..
|
2017-05-02 23:57:13 +03:00
|
|
|
type sphinxHopIterator struct {
|
2018-01-16 11:36:14 +03:00
|
|
|
// ogPacket is the original packet from which the processed packet is
|
|
|
|
// derived.
|
|
|
|
ogPacket *sphinx.OnionPacket
|
2017-06-17 00:29:38 +03:00
|
|
|
|
|
|
|
// processedPacket is the outcome of processing an onion packet. It
|
|
|
|
// includes the information required to properly forward the packet to
|
|
|
|
// the next hop.
|
|
|
|
processedPacket *sphinx.ProcessedPacket
|
2017-05-02 23:57:13 +03:00
|
|
|
}
|
|
|
|
|
2018-01-16 11:36:14 +03:00
|
|
|
// makeSphinxHopIterator converts a processed packet returned from a sphinx
|
|
|
|
// router and converts it into an hop iterator for usage in the link.
|
|
|
|
func makeSphinxHopIterator(ogPacket *sphinx.OnionPacket,
|
|
|
|
packet *sphinx.ProcessedPacket) *sphinxHopIterator {
|
|
|
|
|
|
|
|
return &sphinxHopIterator{
|
|
|
|
ogPacket: ogPacket,
|
|
|
|
processedPacket: packet,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-17 00:29:38 +03:00
|
|
|
// A compile time check to ensure sphinxHopIterator implements the HopIterator
|
2017-05-02 23:57:13 +03:00
|
|
|
// interface.
|
2019-09-05 14:35:39 +03:00
|
|
|
var _ Iterator = (*sphinxHopIterator)(nil)
|
2017-05-02 23:57:13 +03:00
|
|
|
|
|
|
|
// Encode encodes iterator and writes it to the writer.
|
2017-06-17 00:29:38 +03:00
|
|
|
//
|
2017-05-02 23:57:13 +03:00
|
|
|
// NOTE: Part of the HopIterator interface.
|
2017-06-17 00:29:38 +03:00
|
|
|
func (r *sphinxHopIterator) EncodeNextHop(w io.Writer) error {
|
2018-01-16 11:36:14 +03:00
|
|
|
return r.processedPacket.NextPacket.Encode(w)
|
2017-05-02 23:57:13 +03:00
|
|
|
}
|
|
|
|
|
2019-11-05 02:10:15 +03:00
|
|
|
// HopPayload returns the set of fields that detail exactly _how_ this hop
|
|
|
|
// should forward the HTLC to the next hop. Additionally, the information
|
|
|
|
// encoded within the returned ForwardingInfo is to be used by each hop to
|
|
|
|
// authenticate the information given to it by the prior hop. The payload will
|
|
|
|
// also contain any additional TLV fields provided by the sender.
|
2017-06-17 00:29:38 +03:00
|
|
|
//
|
2017-05-02 23:57:13 +03:00
|
|
|
// NOTE: Part of the HopIterator interface.
|
2019-11-05 02:10:15 +03:00
|
|
|
func (r *sphinxHopIterator) HopPayload() (*Payload, error) {
|
2019-07-31 07:52:17 +03:00
|
|
|
switch r.processedPacket.Payload.Type {
|
2019-11-05 02:10:15 +03:00
|
|
|
|
2019-07-31 07:52:17 +03:00
|
|
|
// If this is the legacy payload, then we'll extract the information
|
|
|
|
// directly from the pre-populated ForwardingInstructions field.
|
|
|
|
case sphinx.PayloadLegacy:
|
|
|
|
fwdInst := r.processedPacket.ForwardingInstructions
|
2019-11-05 02:10:15 +03:00
|
|
|
return NewLegacyPayload(fwdInst), nil
|
2019-07-31 07:52:17 +03:00
|
|
|
|
|
|
|
// Otherwise, if this is the TLV payload, then we'll make a new stream
|
|
|
|
// to decode only what we need to make routing decisions.
|
|
|
|
case sphinx.PayloadTLV:
|
2019-11-05 02:10:15 +03:00
|
|
|
return NewPayloadFromReader(bytes.NewReader(
|
2019-07-31 07:52:17 +03:00
|
|
|
r.processedPacket.Payload.Payload,
|
|
|
|
))
|
|
|
|
|
|
|
|
default:
|
2019-11-05 02:10:15 +03:00
|
|
|
return nil, fmt.Errorf("unknown sphinx payload type: %v",
|
2019-08-31 00:11:20 +03:00
|
|
|
r.processedPacket.Payload.Type)
|
2017-05-02 23:57:13 +03:00
|
|
|
}
|
2019-07-31 07:52:17 +03:00
|
|
|
}
|
|
|
|
|
2018-01-16 11:36:14 +03:00
|
|
|
// ExtractErrorEncrypter decodes and returns the ErrorEncrypter for this hop,
|
|
|
|
// along with a failure code to signal if the decoding was successful. The
|
|
|
|
// ErrorEncrypter is used to encrypt errors back to the sender in the event that
|
|
|
|
// a payment fails.
|
|
|
|
//
|
|
|
|
// NOTE: Part of the HopIterator interface.
|
|
|
|
func (r *sphinxHopIterator) ExtractErrorEncrypter(
|
|
|
|
extracter ErrorEncrypterExtracter) (ErrorEncrypter, lnwire.FailCode) {
|
|
|
|
|
2018-03-12 23:37:00 +03:00
|
|
|
return extracter(r.ogPacket.EphemeralKey)
|
2018-01-16 11:36:14 +03:00
|
|
|
}
|
|
|
|
|
2017-06-29 16:40:45 +03:00
|
|
|
// OnionProcessor is responsible for keeping all sphinx dependent parts inside
|
2017-05-02 23:57:13 +03:00
|
|
|
// and expose only decoding function. With such approach we give freedom for
|
2017-06-17 00:29:38 +03:00
|
|
|
// subsystems which wants to decode sphinx path to not be dependable from
|
|
|
|
// sphinx at all.
|
2017-05-02 23:57:13 +03:00
|
|
|
//
|
|
|
|
// NOTE: The reason for keeping decoder separated from hop iterator is too
|
|
|
|
// maintain the hop iterator abstraction. Without it the structures which using
|
2017-06-17 00:29:38 +03:00
|
|
|
// the hop iterator should contain sphinx router which makes their creations in
|
|
|
|
// tests dependent from the sphinx internal parts.
|
2017-06-29 16:40:45 +03:00
|
|
|
type OnionProcessor struct {
|
2017-05-02 23:57:13 +03:00
|
|
|
router *sphinx.Router
|
|
|
|
}
|
|
|
|
|
2017-06-29 16:40:45 +03:00
|
|
|
// NewOnionProcessor creates new instance of decoder.
|
|
|
|
func NewOnionProcessor(router *sphinx.Router) *OnionProcessor {
|
|
|
|
return &OnionProcessor{router}
|
2017-05-02 23:57:13 +03:00
|
|
|
}
|
|
|
|
|
2018-01-16 11:36:14 +03:00
|
|
|
// Start spins up the onion processor's sphinx router.
|
|
|
|
func (p *OnionProcessor) Start() error {
|
|
|
|
return p.router.Start()
|
|
|
|
}
|
|
|
|
|
|
|
|
// Stop shutsdown the onion processor's sphinx router.
|
|
|
|
func (p *OnionProcessor) Stop() error {
|
|
|
|
p.router.Stop()
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2017-06-29 16:40:45 +03:00
|
|
|
// DecodeHopIterator attempts to decode a valid sphinx packet from the passed io.Reader
|
2017-06-17 00:29:38 +03:00
|
|
|
// instance using the rHash as the associated data when checking the relevant
|
|
|
|
// MACs during the decoding process.
|
2018-01-16 11:36:14 +03:00
|
|
|
func (p *OnionProcessor) DecodeHopIterator(r io.Reader, rHash []byte,
|
2019-09-05 14:35:39 +03:00
|
|
|
incomingCltv uint32) (Iterator, lnwire.FailCode) {
|
2017-09-12 19:10:30 +03:00
|
|
|
|
2017-05-02 23:57:13 +03:00
|
|
|
onionPkt := &sphinx.OnionPacket{}
|
|
|
|
if err := onionPkt.Decode(r); err != nil {
|
2017-09-12 19:10:30 +03:00
|
|
|
switch err {
|
|
|
|
case sphinx.ErrInvalidOnionVersion:
|
|
|
|
return nil, lnwire.CodeInvalidOnionVersion
|
|
|
|
case sphinx.ErrInvalidOnionKey:
|
|
|
|
return nil, lnwire.CodeInvalidOnionKey
|
|
|
|
default:
|
2017-12-11 02:52:26 +03:00
|
|
|
log.Errorf("unable to decode onion packet: %v", err)
|
2018-01-09 04:50:19 +03:00
|
|
|
return nil, lnwire.CodeInvalidOnionKey
|
2017-09-12 19:10:30 +03:00
|
|
|
}
|
2017-05-02 23:57:13 +03:00
|
|
|
}
|
|
|
|
|
2017-06-17 00:29:38 +03:00
|
|
|
// Attempt to process the Sphinx packet. We include the payment hash of
|
|
|
|
// the HTLC as it's authenticated within the Sphinx packet itself as
|
|
|
|
// associated data in order to thwart attempts a replay attacks. In the
|
|
|
|
// case of a replay, an attacker is *forced* to use the same payment
|
|
|
|
// hash twice, thereby losing their money entirely.
|
2018-01-16 11:36:14 +03:00
|
|
|
sphinxPacket, err := p.router.ProcessOnionPacket(
|
|
|
|
onionPkt, rHash, incomingCltv,
|
|
|
|
)
|
2017-05-02 23:57:13 +03:00
|
|
|
if err != nil {
|
2017-06-29 16:40:45 +03:00
|
|
|
switch err {
|
|
|
|
case sphinx.ErrInvalidOnionVersion:
|
|
|
|
return nil, lnwire.CodeInvalidOnionVersion
|
|
|
|
case sphinx.ErrInvalidOnionHMAC:
|
|
|
|
return nil, lnwire.CodeInvalidOnionHmac
|
|
|
|
case sphinx.ErrInvalidOnionKey:
|
|
|
|
return nil, lnwire.CodeInvalidOnionKey
|
|
|
|
default:
|
2017-12-11 02:52:26 +03:00
|
|
|
log.Errorf("unable to process onion packet: %v", err)
|
2018-01-09 04:50:19 +03:00
|
|
|
return nil, lnwire.CodeInvalidOnionKey
|
2017-06-29 16:40:45 +03:00
|
|
|
}
|
2017-05-02 23:57:13 +03:00
|
|
|
}
|
|
|
|
|
2018-01-16 11:36:14 +03:00
|
|
|
return makeSphinxHopIterator(onionPkt, sphinxPacket), lnwire.CodeNone
|
2017-06-29 16:40:45 +03:00
|
|
|
}
|
|
|
|
|
2019-08-26 15:06:57 +03:00
|
|
|
// ReconstructHopIterator attempts to decode a valid sphinx packet from the passed io.Reader
|
|
|
|
// instance using the rHash as the associated data when checking the relevant
|
|
|
|
// MACs during the decoding process.
|
|
|
|
func (p *OnionProcessor) ReconstructHopIterator(r io.Reader, rHash []byte) (
|
|
|
|
Iterator, error) {
|
|
|
|
|
|
|
|
onionPkt := &sphinx.OnionPacket{}
|
|
|
|
if err := onionPkt.Decode(r); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
// Attempt to process the Sphinx packet. We include the payment hash of
|
|
|
|
// the HTLC as it's authenticated within the Sphinx packet itself as
|
|
|
|
// associated data in order to thwart attempts a replay attacks. In the
|
|
|
|
// case of a replay, an attacker is *forced* to use the same payment
|
|
|
|
// hash twice, thereby losing their money entirely.
|
|
|
|
sphinxPacket, err := p.router.ReconstructOnionPacket(onionPkt, rHash)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return makeSphinxHopIterator(onionPkt, sphinxPacket), nil
|
|
|
|
}
|
|
|
|
|
2018-01-16 11:36:14 +03:00
|
|
|
// DecodeHopIteratorRequest encapsulates all date necessary to process an onion
|
|
|
|
// packet, perform sphinx replay detection, and schedule the entry for garbage
|
|
|
|
// collection.
|
|
|
|
type DecodeHopIteratorRequest struct {
|
|
|
|
OnionReader io.Reader
|
|
|
|
RHash []byte
|
|
|
|
IncomingCltv uint32
|
|
|
|
}
|
2017-10-11 05:36:52 +03:00
|
|
|
|
2018-01-16 11:36:14 +03:00
|
|
|
// DecodeHopIteratorResponse encapsulates the outcome of a batched sphinx onion
|
|
|
|
// processing.
|
|
|
|
type DecodeHopIteratorResponse struct {
|
2019-09-05 14:35:39 +03:00
|
|
|
HopIterator Iterator
|
2018-01-16 11:36:14 +03:00
|
|
|
FailCode lnwire.FailCode
|
|
|
|
}
|
|
|
|
|
|
|
|
// Result returns the (HopIterator, lnwire.FailCode) tuple, which should
|
|
|
|
// correspond to the index of a particular DecodeHopIteratorRequest.
|
|
|
|
//
|
|
|
|
// NOTE: The HopIterator should be considered invalid if the fail code is
|
|
|
|
// anything but lnwire.CodeNone.
|
2019-09-05 14:35:39 +03:00
|
|
|
func (r *DecodeHopIteratorResponse) Result() (Iterator, lnwire.FailCode) {
|
2018-01-16 11:36:14 +03:00
|
|
|
return r.HopIterator, r.FailCode
|
|
|
|
}
|
|
|
|
|
|
|
|
// DecodeHopIterators performs batched decoding and validation of incoming
|
|
|
|
// sphinx packets. For the same `id`, this method will return the same iterators
|
|
|
|
// and failcodes upon subsequent invocations.
|
|
|
|
//
|
|
|
|
// NOTE: In order for the responses to be valid, the caller must guarantee that
|
|
|
|
// the presented readers and rhashes *NEVER* deviate across invocations for the
|
|
|
|
// same id.
|
|
|
|
func (p *OnionProcessor) DecodeHopIterators(id []byte,
|
|
|
|
reqs []DecodeHopIteratorRequest) ([]DecodeHopIteratorResponse, error) {
|
|
|
|
|
|
|
|
var (
|
|
|
|
batchSize = len(reqs)
|
|
|
|
onionPkts = make([]sphinx.OnionPacket, batchSize)
|
|
|
|
resps = make([]DecodeHopIteratorResponse, batchSize)
|
|
|
|
)
|
|
|
|
|
|
|
|
tx := p.router.BeginTxn(id, batchSize)
|
|
|
|
|
|
|
|
for i, req := range reqs {
|
|
|
|
onionPkt := &onionPkts[i]
|
|
|
|
resp := &resps[i]
|
|
|
|
|
|
|
|
err := onionPkt.Decode(req.OnionReader)
|
2017-09-12 19:10:30 +03:00
|
|
|
switch err {
|
2018-01-16 11:36:14 +03:00
|
|
|
case nil:
|
|
|
|
// success
|
|
|
|
|
2017-09-12 19:10:30 +03:00
|
|
|
case sphinx.ErrInvalidOnionVersion:
|
2018-01-16 11:36:14 +03:00
|
|
|
resp.FailCode = lnwire.CodeInvalidOnionVersion
|
|
|
|
continue
|
|
|
|
|
2017-09-12 19:10:30 +03:00
|
|
|
case sphinx.ErrInvalidOnionKey:
|
2018-01-16 11:36:14 +03:00
|
|
|
resp.FailCode = lnwire.CodeInvalidOnionKey
|
|
|
|
continue
|
|
|
|
|
2017-09-12 19:10:30 +03:00
|
|
|
default:
|
2017-12-11 02:52:26 +03:00
|
|
|
log.Errorf("unable to decode onion packet: %v", err)
|
2018-01-16 11:36:14 +03:00
|
|
|
resp.FailCode = lnwire.CodeInvalidOnionKey
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
err = tx.ProcessOnionPacket(
|
|
|
|
uint16(i), onionPkt, req.RHash, req.IncomingCltv,
|
|
|
|
)
|
|
|
|
switch err {
|
|
|
|
case nil:
|
|
|
|
// success
|
|
|
|
|
|
|
|
case sphinx.ErrInvalidOnionVersion:
|
|
|
|
resp.FailCode = lnwire.CodeInvalidOnionVersion
|
|
|
|
continue
|
|
|
|
|
|
|
|
case sphinx.ErrInvalidOnionHMAC:
|
|
|
|
resp.FailCode = lnwire.CodeInvalidOnionHmac
|
|
|
|
continue
|
|
|
|
|
|
|
|
case sphinx.ErrInvalidOnionKey:
|
|
|
|
resp.FailCode = lnwire.CodeInvalidOnionKey
|
|
|
|
continue
|
|
|
|
|
|
|
|
default:
|
|
|
|
log.Errorf("unable to process onion packet: %v", err)
|
|
|
|
resp.FailCode = lnwire.CodeInvalidOnionKey
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// With that batch created, we will now attempt to write the shared
|
|
|
|
// secrets to disk. This operation will returns the set of indices that
|
|
|
|
// were detected as replays, and the computed sphinx packets for all
|
|
|
|
// indices that did not fail the above loop. Only indices that are not
|
|
|
|
// in the replay set should be considered valid, as they are
|
|
|
|
// opportunistically computed.
|
|
|
|
packets, replays, err := tx.Commit()
|
|
|
|
if err != nil {
|
|
|
|
log.Errorf("unable to process onion packet batch %x: %v",
|
|
|
|
id, err)
|
|
|
|
|
|
|
|
// If we failed to commit the batch to the secret share log, we
|
|
|
|
// will mark all not-yet-failed channels with a temporary
|
|
|
|
// channel failure and exit since we cannot proceed.
|
|
|
|
for i := range resps {
|
|
|
|
resp := &resps[i]
|
|
|
|
|
|
|
|
// Skip any indexes that already failed onion decoding.
|
|
|
|
if resp.FailCode != lnwire.CodeNone {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Errorf("unable to process onion packet %x-%v",
|
|
|
|
id, i)
|
|
|
|
resp.FailCode = lnwire.CodeTemporaryChannelFailure
|
2017-09-12 19:10:30 +03:00
|
|
|
}
|
2018-01-16 11:36:14 +03:00
|
|
|
|
|
|
|
// TODO(conner): return real errors to caller so link can fail?
|
|
|
|
return resps, err
|
2017-06-29 16:40:45 +03:00
|
|
|
}
|
|
|
|
|
2018-01-16 11:36:14 +03:00
|
|
|
// Otherwise, the commit was successful. Now we will post process any
|
|
|
|
// remaining packets, additionally failing any that were included in the
|
|
|
|
// replay set.
|
|
|
|
for i := range resps {
|
|
|
|
resp := &resps[i]
|
|
|
|
|
|
|
|
// Skip any indexes that already failed onion decoding.
|
|
|
|
if resp.FailCode != lnwire.CodeNone {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
// If this index is contained in the replay set, mark it with a
|
|
|
|
// temporary channel failure error code. We infer that the
|
|
|
|
// offending error was due to a replayed packet because this
|
|
|
|
// index was found in the replay set.
|
|
|
|
if replays.Contains(uint16(i)) {
|
|
|
|
log.Errorf("unable to process onion packet: %v",
|
|
|
|
sphinx.ErrReplayedPacket)
|
|
|
|
resp.FailCode = lnwire.CodeTemporaryChannelFailure
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
// Finally, construct a hop iterator from our processed sphinx
|
|
|
|
// packet, simultaneously caching the original onion packet.
|
|
|
|
resp.HopIterator = makeSphinxHopIterator(&onionPkts[i], &packets[i])
|
|
|
|
}
|
|
|
|
|
|
|
|
return resps, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ExtractErrorEncrypter takes an io.Reader which should contain the onion
|
|
|
|
// packet as original received by a forwarding node and creates an
|
|
|
|
// ErrorEncrypter instance using the derived shared secret. In the case that en
|
|
|
|
// error occurs, a lnwire failure code detailing the parsing failure will be
|
|
|
|
// returned.
|
2018-03-12 23:37:00 +03:00
|
|
|
func (p *OnionProcessor) ExtractErrorEncrypter(ephemeralKey *btcec.PublicKey) (
|
2018-01-16 11:36:14 +03:00
|
|
|
ErrorEncrypter, lnwire.FailCode) {
|
|
|
|
|
2018-03-12 23:37:00 +03:00
|
|
|
onionObfuscator, err := sphinx.NewOnionErrorEncrypter(
|
|
|
|
p.router, ephemeralKey,
|
|
|
|
)
|
2017-06-29 16:40:45 +03:00
|
|
|
if err != nil {
|
|
|
|
switch err {
|
|
|
|
case sphinx.ErrInvalidOnionVersion:
|
|
|
|
return nil, lnwire.CodeInvalidOnionVersion
|
|
|
|
case sphinx.ErrInvalidOnionHMAC:
|
|
|
|
return nil, lnwire.CodeInvalidOnionHmac
|
|
|
|
case sphinx.ErrInvalidOnionKey:
|
|
|
|
return nil, lnwire.CodeInvalidOnionKey
|
|
|
|
default:
|
2017-12-11 02:52:26 +03:00
|
|
|
log.Errorf("unable to process onion packet: %v", err)
|
2018-01-09 04:50:19 +03:00
|
|
|
return nil, lnwire.CodeInvalidOnionKey
|
2017-06-29 16:40:45 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-11 05:36:52 +03:00
|
|
|
return &SphinxErrorEncrypter{
|
|
|
|
OnionErrorEncrypter: onionObfuscator,
|
2018-03-12 23:37:00 +03:00
|
|
|
EphemeralKey: ephemeralKey,
|
2017-06-29 16:40:45 +03:00
|
|
|
}, lnwire.CodeNone
|
2017-05-02 23:57:13 +03:00
|
|
|
}
|