From a085b59814a797bc9aa93d511d351cd4fe7ccf76 Mon Sep 17 00:00:00 2001 From: Keagan McClelland Date: Tue, 12 Mar 2024 12:16:01 -0700 Subject: [PATCH] lnd: implement new Quiesce RPC with link operation stub --- lnrpc/devrpc/config_active.go | 2 ++ lnrpc/devrpc/dev_server.go | 26 ++++++++++++++++++++++++++ subrpcserver_config.go | 4 ++++ 3 files changed, 32 insertions(+) diff --git a/lnrpc/devrpc/config_active.go b/lnrpc/devrpc/config_active.go index 6fc274f2e..da5cd5be9 100644 --- a/lnrpc/devrpc/config_active.go +++ b/lnrpc/devrpc/config_active.go @@ -6,6 +6,7 @@ package devrpc import ( "github.com/btcsuite/btcd/chaincfg" "github.com/lightningnetwork/lnd/channeldb" + "github.com/lightningnetwork/lnd/htlcswitch" ) // Config is the primary configuration struct for the DEV RPC server. It @@ -16,4 +17,5 @@ import ( type Config struct { ActiveNetParams *chaincfg.Params GraphDB *channeldb.ChannelGraph + Switch *htlcswitch.Switch } diff --git a/lnrpc/devrpc/dev_server.go b/lnrpc/devrpc/dev_server.go index 662c0d08d..4b7ebcd1e 100644 --- a/lnrpc/devrpc/dev_server.go +++ b/lnrpc/devrpc/dev_server.go @@ -40,6 +40,10 @@ var ( Entity: "offchain", Action: "write", }}, + "/devrpc.Dev/Quiesce": {{ + Entity: "offchain", + Action: "write", + }}, } ) @@ -342,3 +346,25 @@ func (s *Server) ImportGraph(ctx context.Context, return &ImportGraphResponse{}, nil } + +// Quiesce initiates the quiescence process for the channel with the given +// channel ID. This method will block until the channel is fully quiesced. +func (s *Server) Quiesce(_ context.Context, in *QuiescenceRequest) ( + *QuiescenceResponse, error) { + + txid, err := lnrpc.GetChanPointFundingTxid(in.ChanId) + if err != nil { + return nil, err + } + + op := wire.NewOutPoint(txid, in.ChanId.OutputIndex) + cid := lnwire.NewChanIDFromOutPoint(*op) + _, err = s.cfg.Switch.GetLink(cid) + if err != nil { + return nil, err + } + + // TODO(proofofkeags): Add Link operation for initiating quiescence and + // implement the rest of this in those terms + return nil, fmt.Errorf("TODO(proofofkeags): Implement") +} diff --git a/subrpcserver_config.go b/subrpcserver_config.go index a4ee6d1a1..9e9295931 100644 --- a/subrpcserver_config.go +++ b/subrpcserver_config.go @@ -346,6 +346,10 @@ func (s *subRPCServerConfigs) PopulateDependencies(cfg *Config, reflect.ValueOf(graphDB), ) + subCfgValue.FieldByName("Switch").Set( + reflect.ValueOf(htlcSwitch), + ) + case *peersrpc.Config: subCfgValue := extractReflectValue(subCfg)