Skip to content

Commit

Permalink
Merge pull request ElementsProject#153 from nepet/own-config-file
Browse files Browse the repository at this point in the history
cln plugin config file
  • Loading branch information
grubles committed Apr 28, 2023
2 parents a88063f + a15616c commit 6efdb8c
Show file tree
Hide file tree
Showing 19 changed files with 1,488 additions and 610 deletions.
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ INTEGRATION_TEST_ENV= \
INTEGRATION_TEST_OPTS= \
-tags dev \
-tags fast_test \
-timeout=30m -v
-timeout=30m -v \
-failfast

BINS= \
${OUTDIR}/peerswapd \
Expand Down Expand Up @@ -130,7 +131,12 @@ test-misc-integration: test-bins
'Test_GrpcReconnectStream|'\
'Test_GrpcRetryRequest|'\
'Test_RestoreFromPassedCSV|'\
'Test_Wumbo)'\
'Test_Wumbo|'\
'Test_ClnConfig|'\
'Test_ClnPluginConfigFile|'\
'Test_ClnPluginConfigFile_DoesNotExist|'\
'Test_ClnPluginConfig_ElementsAuthCookie|'\
'Test_ClnPluginConfig_DisableLiquid)'\
./test
.PHONY: test-misc-integration

Expand Down
26 changes: 25 additions & 1 deletion clightning/clightning.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ var methods = []peerswaprpcMethod{
&LiquidGetBalance{},
&ReloadPolicyFile{},
&GetRequestedSwaps{},
&ListConfig{},
}

var devmethods = []peerswaprpcMethod{}
Expand Down Expand Up @@ -92,6 +93,8 @@ type ClightningClient struct {
ctx context.Context

isReady bool

peerswapConfig PeerswapClightningConfig
}

func (cl *ClightningClient) SetReady() {
Expand Down Expand Up @@ -180,7 +183,7 @@ func (cl *ClightningClient) CanSpend(amtMsat uint64) error {
return nil
}

// Implementation returns the name of the lightning network client
// Implementation returns the name of the lightning network client
// implementation.
func (cl *ClightningClient) Implementation() string {
return "CLN"
Expand Down Expand Up @@ -246,6 +249,27 @@ func (cl *ClightningClient) SetupClients(liquidWallet *wallet.ElementsRpcWallet,
}
}

// SetPeerswapConfig injects the peerswap config that is used during runtime.
// This config is just used for a console print.
func (cl *ClightningClient) SetPeerswapConfig(config *Config) {
cl.peerswapConfig = PeerswapClightningConfig{
BitcoinRpcUser: config.Bitcoin.RpcUser,
BitcoinRpcPassword: config.Bitcoin.RpcPassword,
BitcoinRpcPasswordFile: config.Bitcoin.RpcPasswordFile,
BitcoinRpcHost: config.Bitcoin.RpcHost,
BitcoinRpcPort: config.Bitcoin.RpcPort,
BitcoinCookieFilePath: config.Bitcoin.RpcPasswordFile,
LiquidRpcUser: config.Liquid.RpcUser,
LiquidRpcPassword: config.Liquid.RpcPassword,
LiquidRpcPasswordFile: config.Liquid.RpcPasswordFile,
LiquidRpcHost: config.Liquid.RpcHost,
LiquidRpcPort: config.Liquid.RpcPort,
LiquidRpcWallet: config.Liquid.RpcWallet,
LiquidDisabled: config.Liquid.Disabled,
PeerswapDir: config.PeerswapDir,
}
}

func (cl *ClightningClient) GetLightningRpc() *glightning.Lightning {
return cl.glightning
}
Expand Down
36 changes: 36 additions & 0 deletions clightning/clightning_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,42 @@ func (c RemoveSuspiciousPeer) LongDescription() string {
`with this node`
}

type ListConfig struct {
cl *ClightningClient
}

func (c *ListConfig) Name() string {
return "peerswap-listconfig"
}

func (c *ListConfig) New() interface{} {
return &ListConfig{
cl: c.cl,
}
}

func (c *ListConfig) Call() (jrpc2.Result, error) {
if !c.cl.isReady {
return nil, ErrWaitingForReady
}

return c.cl.peerswapConfig, nil
}

func (c *ListConfig) Get(client *ClightningClient) jrpc2.ServerMethod {
return &ListConfig{
cl: client,
}
}

func (c ListConfig) Description() string {
return "Show the peerswap config"
}

func (c ListConfig) LongDescription() string {
return c.Description()
}

type PeerSwapPeerChannel struct {
ChannelId string `json:"short_channel_id"`
LocalBalance uint64 `json:"local_balance"`
Expand Down
236 changes: 0 additions & 236 deletions clightning/clightning_config.go

This file was deleted.

0 comments on commit 6efdb8c

Please sign in to comment.