From db76b970aca247257fb193f5442600cd8b0b4ba1 Mon Sep 17 00:00:00 2001 From: Elliott Jin Date: Fri, 12 Feb 2021 23:29:13 -0800 Subject: [PATCH] routerrpc: expose SetChannel* methods from Router backend Allow router RPC requests to call into the ChanStatusManager to manually update channel state. --- lnrpc/routerrpc/router_backend.go | 12 +++++++++++- rpcserver.go | 7 +++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lnrpc/routerrpc/router_backend.go b/lnrpc/routerrpc/router_backend.go index 7fab73548..6f06890f2 100644 --- a/lnrpc/routerrpc/router_backend.go +++ b/lnrpc/routerrpc/router_backend.go @@ -9,8 +9,8 @@ import ( "time" "github.com/btcsuite/btcd/btcec" - "github.com/btcsuite/btcd/chaincfg" + "github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcutil" "github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/htlcswitch" @@ -83,6 +83,16 @@ type RouterBackend struct { // InterceptableForwarder exposes the ability to intercept forward events // by letting the router register a ForwardInterceptor. InterceptableForwarder htlcswitch.InterceptableHtlcForwarder + + // SetChannelEnabled exposes the ability to manually enable a channel. + SetChannelEnabled func(wire.OutPoint) error + + // SetChannelDisabled exposes the ability to manually disable a channel + SetChannelDisabled func(wire.OutPoint) error + + // SetChannelAuto exposes the ability to restore automatic channel state + // management after manually setting channel status. + SetChannelAuto func(wire.OutPoint) error } // MissionControl defines the mission control dependencies of routerrpc. diff --git a/rpcserver.go b/rpcserver.go index d8883351a..ea3fc8a0b 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -602,6 +602,13 @@ func newRPCServer(cfg *Config, s *server, macService *macaroons.Service, DefaultFinalCltvDelta: uint16(cfg.Bitcoin.TimeLockDelta), SubscribeHtlcEvents: s.htlcNotifier.SubscribeHtlcEvents, InterceptableForwarder: s.interceptableSwitch, + SetChannelEnabled: func(outpoint wire.OutPoint) error { + return s.chanStatusMgr.RequestEnable(outpoint, true) + }, + SetChannelDisabled: func(outpoint wire.OutPoint) error { + return s.chanStatusMgr.RequestDisable(outpoint, true) + }, + SetChannelAuto: s.chanStatusMgr.RequestAuto, } genInvoiceFeatures := func() *lnwire.FeatureVector {