From 58790b6f45f2547da2d3e601075b1cabf06eb00f Mon Sep 17 00:00:00 2001 From: Jesse de Wit Date: Thu, 21 Sep 2023 14:09:48 +0200 Subject: [PATCH] cln_client: return 'not enough funds' error --- cln/cln_client.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cln/cln_client.go b/cln/cln_client.go index 2909806..5c5f53e 100644 --- a/cln/cln_client.go +++ b/cln/cln_client.go @@ -12,6 +12,7 @@ import ( "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/wire" "github.com/elementsproject/glightning/glightning" + "github.com/elementsproject/glightning/jrpc2" "golang.org/x/exp/slices" ) @@ -126,6 +127,10 @@ func (c *ClnClient) OpenChannel(req *lightning.OpenChannelRequest) (*wire.OutPoi if err != nil { log.Printf("CLN: client.FundChannelExt(%v, %v) error: %v", pubkey, req.CapacitySat, err) + rpcError, ok := err.(*jrpc2.RpcError) + if ok && rpcError.Code == 301 { + return nil, fmt.Errorf("not enough funds: %w", err) + } return nil, err }