From 3d487e3ca3a89990a944bd154591874e09d4a754 Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Mon, 12 Mar 2018 13:37:00 -0700 Subject: [PATCH] htlcswitch/iterator: extract error encrypter from ephemeral key --- htlcswitch/iterator.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/htlcswitch/iterator.go b/htlcswitch/iterator.go index 8218b586..09f88cd3 100644 --- a/htlcswitch/iterator.go +++ b/htlcswitch/iterator.go @@ -6,6 +6,7 @@ import ( "github.com/lightningnetwork/lightning-onion" "github.com/lightningnetwork/lnd/lnwire" + "github.com/roasbeef/btcd/btcec" ) // NetworkHop indicates the blockchain network that is intended to be the next @@ -167,7 +168,7 @@ func (r *sphinxHopIterator) ForwardingInstructions() ForwardingInfo { func (r *sphinxHopIterator) ExtractErrorEncrypter( extracter ErrorEncrypterExtracter) (ErrorEncrypter, lnwire.FailCode) { - return extracter(r.ogPacket) + return extracter(r.ogPacket.EphemeralKey) } // OnionProcessor is responsible for keeping all sphinx dependent parts inside @@ -401,11 +402,12 @@ func (p *OnionProcessor) DecodeHopIterators(id []byte, // 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. -func (p *OnionProcessor) ExtractErrorEncrypter(onionPkt *sphinx.OnionPacket) ( +func (p *OnionProcessor) ExtractErrorEncrypter(ephemeralKey *btcec.PublicKey) ( ErrorEncrypter, lnwire.FailCode) { - onionObfuscator, err := sphinx.NewOnionErrorEncrypter(p.router, - onionPkt.EphemeralKey) + onionObfuscator, err := sphinx.NewOnionErrorEncrypter( + p.router, ephemeralKey, + ) if err != nil { switch err { case sphinx.ErrInvalidOnionVersion: @@ -422,6 +424,6 @@ func (p *OnionProcessor) ExtractErrorEncrypter(onionPkt *sphinx.OnionPacket) ( return &SphinxErrorEncrypter{ OnionErrorEncrypter: onionObfuscator, - ogPacket: onionPkt, + EphemeralKey: ephemeralKey, }, lnwire.CodeNone }