Merge pull request #5230 from carlaKC/5059-interceptorchanupdate

multi: send channel update for failed interceptor packets
This commit is contained in:
Olaoluwa Osuntokun 2021-04-26 15:45:43 -07:00 committed by GitHub
commit 9ef00d98a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

@ -139,7 +139,16 @@ func (f *interceptedForward) Resume() error {
// Fail forward a failed packet to the switch.
func (f *interceptedForward) Fail() error {
reason, err := f.packet.obfuscator.EncryptFirstHop(lnwire.NewTemporaryChannelFailure(nil))
update, err := f.htlcSwitch.cfg.FetchLastChannelUpdate(
f.packet.incomingChanID,
)
if err != nil {
return err
}
reason, err := f.packet.obfuscator.EncryptFirstHop(
lnwire.NewTemporaryChannelFailure(update),
)
if err != nil {
return fmt.Errorf("failed to encrypt failure reason %v", err)
}

@ -128,6 +128,15 @@ func testForwardInterceptor(net *lntest.NetworkHarness, t *harnessTest) {
require.Equal(t.t, lnrpc.HTLCAttempt_FAILED,
attempt.Status, "expected payment to fail")
// Assert that we get a temporary channel
// failure which has a channel update.
require.NotNil(t.t, attempt.Failure)
require.NotNil(t.t, attempt.Failure.ChannelUpdate)
require.Equal(t.t,
lnrpc.Failure_TEMPORARY_CHANNEL_FAILURE,
attempt.Failure.Code)
// For settle and resume we make sure the payment is successful.
case routerrpc.ResolveHoldForwardAction_SETTLE:
fallthrough