mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-22 14:51:45 +02:00
htlcswitch/hop: use InvalidOnionVersion for replayed packets
The link will send an update_fail_malformed_htlc, so we need to set the BADONION bit. Since there isn't a replay-specific error, we set the failure code to InvalidOnionVersion which has the BADONION bit.
This commit is contained in:
parent
3c605dbff5
commit
75406d177b
@ -363,7 +363,14 @@ func (p *OnionProcessor) DecodeHopIterators(id []byte,
|
|||||||
if replays.Contains(uint16(i)) {
|
if replays.Contains(uint16(i)) {
|
||||||
log.Errorf("unable to process onion packet: %v",
|
log.Errorf("unable to process onion packet: %v",
|
||||||
sphinx.ErrReplayedPacket)
|
sphinx.ErrReplayedPacket)
|
||||||
resp.FailCode = lnwire.CodeTemporaryChannelFailure
|
|
||||||
|
// We set FailCode to CodeInvalidOnionVersion even
|
||||||
|
// though the ephemeral key isn't the problem. We need
|
||||||
|
// to set the BADONION bit since we're sending back a
|
||||||
|
// malformed packet, but as there isn't a specific
|
||||||
|
// failure code for replays, we reuse one of the
|
||||||
|
// failure codes that has BADONION.
|
||||||
|
resp.FailCode = lnwire.CodeInvalidOnionVersion
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,7 +219,7 @@ func testSphinxReplayPersistence(ht *lntest.HarnessTest) {
|
|||||||
// Assert that Fred receives the expected failure after Carol sent a
|
// Assert that Fred receives the expected failure after Carol sent a
|
||||||
// duplicate packet that fails due to sphinx replay detection.
|
// duplicate packet that fails due to sphinx replay detection.
|
||||||
ht.AssertPaymentStatusFromStream(payStream, lnrpc.Payment_FAILED)
|
ht.AssertPaymentStatusFromStream(payStream, lnrpc.Payment_FAILED)
|
||||||
ht.AssertLastHTLCError(fred, lnrpc.Failure_INVALID_ONION_KEY)
|
ht.AssertLastHTLCError(fred, lnrpc.Failure_INVALID_ONION_VERSION)
|
||||||
|
|
||||||
// Since the payment failed, the balance should still be left
|
// Since the payment failed, the balance should still be left
|
||||||
// unaltered.
|
// unaltered.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user