package main import ( "context" "fmt" "github.com/lightningnetwork/lnd/lnrpc/routerrpc" "github.com/urfave/cli" ) var interceptForwardCommand = cli.Command{ Name: "interceptforward", Category: "Payments", Usage: "Intercept forward packets.", Action: actionDecorator(interceptForward), } func interceptForward(ctx *cli.Context) error { conn := getClientConn(ctx, false) defer conn.Close() client := routerrpc.NewRouterClient(conn) rpcCtx := context.Background() interceptor, err := client.HtlcInterceptor(rpcCtx) if err != nil { return err } for { request, err := interceptor.Recv() if err != nil { return err } printRespJSON(request) if request.AmountMSat < 200000 { fmt.Println("Fail packet with amount less than 200 Sats") interceptor.Send(&routerrpc.ForwardHtlcInterceptResponse{ CircuitKey: request.CircuitKey, Action: routerrpc.ResolveHoldForwardAction_RESUME, }) } else { fmt.Println("Resuming packet with amount more than 200 Sats") interceptor.Send(&routerrpc.ForwardHtlcInterceptResponse{ CircuitKey: request.CircuitKey, Action: routerrpc.ResolveHoldForwardAction_FAIL, }) } } return nil }