routerrpc: expose SetChannel* methods from Router backend

Allow router RPC requests to call into the ChanStatusManager to
manually update channel state.
This commit is contained in:
Elliott Jin 2021-02-12 23:29:13 -08:00
parent 4e4f4bc194
commit db76b970ac
2 changed files with 18 additions and 1 deletions

@ -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.

@ -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 {