Skip to content

Commit ce1a4c1

Browse files
lndclient: add FailureMessage and FailureCode to InterceptedHtlcResponse
The HTLC interception response type was missing fields for controlling how lnd encodes failure errors back to the sender. Without these fields, all interceptor failures are encoded as TemporaryChannelFailure and attributed to the intercepting node, which causes Mission Control to penalize the forwarding pair. This adds FailureMessage and FailureCode to InterceptedHtlcResponse and wires them through rpcInterceptorResponse. FailureMessage accepts a pre-encrypted onion error blob that lnd relays via IntermediateEncrypt, preserving the error attribution of the original encrypter. This is the path a virtual node behind the interceptor uses to produce errors attributed to itself rather than the intercepting node. FailureCode selects a specific failure code for errors attributed to the interceptor.
1 parent f483132 commit ce1a4c1

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

router_client.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,19 @@ type InterceptedHtlcResponse struct {
395395
// intercepted.
396396
Action InterceptorAction
397397

398+
// FailureMessage is a pre-encrypted onion error to return when the
399+
// action is fail. When set, lnd relays the bytes using
400+
// IntermediateEncrypt, preserving the error attribution of the
401+
// original encrypter.
402+
FailureMessage []byte
403+
404+
// FailureCode is the failure code to return when the action is
405+
// fail. When non-zero, lnd constructs an onion error attributed to
406+
// the intercepting node using EncryptFirstHop. When zero and
407+
// FailureMessage is also empty, lnd defaults to
408+
// TemporaryChannelFailure.
409+
FailureCode lnrpc.Failure_FailureCode
410+
398411
// IncomingAmount is the amount that should be used to validate the
399412
// incoming htlc. This might be different from the actual HTLC amount
400413
// for custom channels.
@@ -955,6 +968,22 @@ func rpcInterceptorResponse(request InterceptedHtlc,
955968
case InterceptorActionFail:
956969
rpcResp.Action = routerrpc.ResolveHoldForwardAction_FAIL
957970

971+
if len(response.FailureMessage) > 0 &&
972+
response.FailureCode != 0 {
973+
974+
return nil, errors.New(
975+
"failure_message and failure_code are " +
976+
"mutually exclusive",
977+
)
978+
}
979+
980+
if len(response.FailureMessage) > 0 {
981+
rpcResp.FailureMessage = response.FailureMessage
982+
}
983+
if response.FailureCode != 0 {
984+
rpcResp.FailureCode = response.FailureCode
985+
}
986+
958987
case InterceptorActionResume:
959988
rpcResp.Action = routerrpc.ResolveHoldForwardAction_RESUME
960989

0 commit comments

Comments
 (0)