From 5128839d975e74b0659df970c26e40c684295529 Mon Sep 17 00:00:00 2001 From: bruwbird Date: Sat, 24 Feb 2024 17:38:49 +0900 Subject: [PATCH] glightning: update dependencies for glightning Add RpcPasswordFile field to configuration for Bitcoin RPC connection. If no user name or passphrase is set, obtained from a cookie. If bitcoind or elementsd had restarted then their respective cookies would have changed. Since it is not possible to label the cln wallet, set the label only on the cln elementd only. --- clightning/clightning_wallet.go | 5 ++++- cmd/peerswap-plugin/main.go | 4 +++- cmd/peerswaplnd/peerswapd/main.go | 3 ++- elements/client.go | 4 ++-- go.mod | 4 +--- go.sum | 2 ++ 6 files changed, 14 insertions(+), 8 deletions(-) diff --git a/clightning/clightning_wallet.go b/clightning/clightning_wallet.go index 7e77cd76..af9347c8 100644 --- a/clightning/clightning_wallet.go +++ b/clightning/clightning_wallet.go @@ -200,7 +200,10 @@ func (cl *ClightningClient) CreateCoopSpendingTransaction(swapParams *swap.Openi } func (cl *ClightningClient) SetLabel(txID, address, label string) error { - return cl.gbitcoin.SetLabel(address, label) + // todo implement + // This function assigns an identifiable label to the target transaction based on the txid. + // Currently no such functionality is available, so it has not been implemented. + return nil } func (cl *ClightningClient) NewAddress() (string, error) { diff --git a/cmd/peerswap-plugin/main.go b/cmd/peerswap-plugin/main.go index dde274ce..470d50bf 100644 --- a/cmd/peerswap-plugin/main.go +++ b/cmd/peerswap-plugin/main.go @@ -182,6 +182,7 @@ func run(ctx context.Context, lightningPlugin *clightning.ClightningClient) erro config.Liquid.RpcUser, config.Liquid.RpcPassword, config.Liquid.RpcHost, + config.Liquid.RpcPasswordFile, config.Liquid.RpcPort, ) if err != nil { @@ -436,8 +437,9 @@ func getBitcoinClient(li *glightning.Lightning, pluginConfig *clightning.Config) rpcPassword := pluginConfig.Bitcoin.RpcPassword rpcHost := pluginConfig.Bitcoin.RpcHost rpcPort := pluginConfig.Bitcoin.RpcPort + ppcCookie := pluginConfig.Bitcoin.RpcPasswordFile - bitcoin := gbitcoin.NewBitcoin(rpcUser, rpcPassword) + bitcoin := gbitcoin.NewBitcoin(rpcUser, rpcPassword, ppcCookie) bitcoin.SetTimeout(10) err := bitcoin.StartUp(rpcHost, "", uint(rpcPort)) if err != nil { diff --git a/cmd/peerswaplnd/peerswapd/main.go b/cmd/peerswaplnd/peerswapd/main.go index c5650410..4c822614 100644 --- a/cmd/peerswaplnd/peerswapd/main.go +++ b/cmd/peerswaplnd/peerswapd/main.go @@ -205,6 +205,7 @@ func run() error { liquidConfig.RpcUser, liquidConfig.RpcPassword, liquidConfig.RpcHost, + liquidConfig.RpcPasswordFile, liquidConfig.RpcPort, ) if err != nil { @@ -441,7 +442,7 @@ func getBitcoinChain(ctx context.Context, li lnrpc.LightningClient) (*chaincfg.P } func getBitcoinClient(cfg *peerswaplnd.OnchainConfig) (*gbitcoin.Bitcoin, error) { - bitcoin := gbitcoin.NewBitcoin(cfg.RpcUser, cfg.RpcPassword) + bitcoin := gbitcoin.NewBitcoin(cfg.RpcUser, cfg.RpcPassword, cfg.RpcCookieFilePath) err := bitcoin.StartUp(cfg.RpcHost, "", cfg.RpcPort) if err != nil { return nil, err diff --git a/elements/client.go b/elements/client.go index 503837cf..635d921b 100644 --- a/elements/client.go +++ b/elements/client.go @@ -11,8 +11,8 @@ import ( type ElementsClientBuilder struct { } -func NewClient(rpcUser, rpcPassword, rpcHost string, rpcPort uint) (*gelements.Elements, error) { - c := gelements.NewElements(rpcUser, rpcPassword) +func NewClient(rpcUser, rpcPassword, rpcHost, RpcPasswordFile string, rpcPort uint) (*gelements.Elements, error) { + c := gelements.NewElements(rpcUser, rpcPassword, RpcPasswordFile) var backoff int64 = 1 for { diff --git a/go.mod b/go.mod index fb47192b..bb096b64 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/btcsuite/btcd/btcutil v1.1.2 github.com/btcsuite/btcd/btcutil/psbt v1.1.5 github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 - github.com/elementsproject/glightning v0.0.0-20231126051537-e32b4dae6cbb + github.com/elementsproject/glightning v0.0.0-20240224063423-55240d61b52a github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3 github.com/jessevdk/go-flags v1.5.0 @@ -151,5 +151,3 @@ require ( // This fork contains some options we need to reconnect to lnd. replace github.com/grpc-ecosystem/go-grpc-middleware => github.com/nepet/go-grpc-middleware v1.3.1-0.20220824133300-340e95267339 - -replace github.com/elementsproject/glightning => github.com/yusukeshimizu/glightning v0.0.0-20240214001938-06d9e0562297 diff --git a/go.sum b/go.sum index bf227568..3cea8da6 100644 --- a/go.sum +++ b/go.sum @@ -186,6 +186,8 @@ github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4 github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dvyukov/go-fuzz v0.0.0-20220726122315-1d375ef9f9f6 h1:sE4tvxWw01v7K3MAHwKF2UF3xQbgy23PRURntuV1CkU= github.com/dvyukov/go-fuzz v0.0.0-20220726122315-1d375ef9f9f6/go.mod h1:11Gm+ccJnvAhCNLlf5+cS9KjtbaD5I5zaZpFMsTHWTw= +github.com/elementsproject/glightning v0.0.0-20240224063423-55240d61b52a h1:xnVQmVqGmSs3m8zPQF4iYEYiUAmJx8MlT9vJ3lAaOjc= +github.com/elementsproject/glightning v0.0.0-20240224063423-55240d61b52a/go.mod h1:YAdIeSyx8VEhDCtEaGOJLmWNpPaQ3x4vYSAj9Vrppdo= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=