mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-29 23:21:12 +02:00
cnct: parse onion for resolvers
With the introduction of additional payload fields for mpp, it becomes a necessity to have their values available in the on-chain resolution flow. The incoming contest resolver notifies the invoice registry of the arrival of a payment and needs to supply all parameters for the registry to validate the htlc.
This commit is contained in:
@@ -184,6 +184,30 @@ func (p *OnionProcessor) DecodeHopIterator(r io.Reader, rHash []byte,
|
||||
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.
|
||||
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
|
||||
}
|
||||
|
||||
// DecodeHopIteratorRequest encapsulates all date necessary to process an onion
|
||||
// packet, perform sphinx replay detection, and schedule the entry for garbage
|
||||
// collection.
|
||||
|
Reference in New Issue
Block a user