From 42069ef2f8f4f7351acaa5ed84003615838d2527 Mon Sep 17 00:00:00 2001 From: Carla Kirk-Cohen Date: Mon, 21 Nov 2022 08:35:02 -0500 Subject: [PATCH] htlcswitch: remove unused decode hop iterator --- htlcswitch/hop/iterator.go | 44 -------------------------------------- 1 file changed, 44 deletions(-) diff --git a/htlcswitch/hop/iterator.go b/htlcswitch/hop/iterator.go index 96a5c5f2b..1ae669e28 100644 --- a/htlcswitch/hop/iterator.go +++ b/htlcswitch/hop/iterator.go @@ -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.