Merge pull request #5230 from carlaKC/5059-interceptorchanupdate
multi: send channel update for failed interceptor packets
This commit is contained in:
commit
9ef00d98a7
@ -139,7 +139,16 @@ func (f *interceptedForward) Resume() error {
|
|||||||
|
|
||||||
// Fail forward a failed packet to the switch.
|
// Fail forward a failed packet to the switch.
|
||||||
func (f *interceptedForward) Fail() error {
|
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 {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to encrypt failure reason %v", err)
|
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,
|
require.Equal(t.t, lnrpc.HTLCAttempt_FAILED,
|
||||||
attempt.Status, "expected payment to fail")
|
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.
|
// For settle and resume we make sure the payment is successful.
|
||||||
case routerrpc.ResolveHoldForwardAction_SETTLE:
|
case routerrpc.ResolveHoldForwardAction_SETTLE:
|
||||||
fallthrough
|
fallthrough
|
||||||
|
Loading…
Reference in New Issue
Block a user