mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-26 01:33:02 +01:00
htlcswitch: remove unused decode hop iterator
This commit is contained in:
parent
b76f733a9e
commit
42069ef2f8
@ -147,50 +147,6 @@ func (p *OnionProcessor) Stop() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// DecodeHopIterator 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) DecodeHopIterator(r io.Reader, rHash []byte,
|
||||
incomingCltv uint32) (Iterator, lnwire.FailCode) {
|
||||
|
||||
onionPkt := &sphinx.OnionPacket{}
|
||||
if err := onionPkt.Decode(r); err != nil {
|
||||
switch err {
|
||||
case sphinx.ErrInvalidOnionVersion:
|
||||
return nil, lnwire.CodeInvalidOnionVersion
|
||||
case sphinx.ErrInvalidOnionKey:
|
||||
return nil, lnwire.CodeInvalidOnionKey
|
||||
default:
|
||||
log.Errorf("unable to decode onion packet: %v", err)
|
||||
return nil, lnwire.CodeInvalidOnionKey
|
||||
}
|
||||
}
|
||||
|
||||
// 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.ProcessOnionPacket(
|
||||
onionPkt, rHash, incomingCltv,
|
||||
)
|
||||
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:
|
||||
log.Errorf("unable to process onion packet: %v", err)
|
||||
return nil, lnwire.CodeInvalidOnionKey
|
||||
}
|
||||
}
|
||||
|
||||
return makeSphinxHopIterator(onionPkt, sphinxPacket), lnwire.CodeNone
|
||||
}
|
||||
|
||||
// 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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user