mirror of
https://github.com/aljazceru/lspd.git
synced 2025-12-18 22:34:22 +01:00
Retrieve the channel amount and the channel privacy from the environment
This commit is contained in:
13
server.go
13
server.go
@@ -9,6 +9,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
lspdrpc "github.com/breez/lspd/rpc"
|
lspdrpc "github.com/breez/lspd/rpc"
|
||||||
@@ -115,13 +116,21 @@ func (s *server) OpenChannel(ctx context.Context, in *lspdrpc.OpenChannelRequest
|
|||||||
var txidStr string
|
var txidStr string
|
||||||
var outputIndex uint32
|
var outputIndex uint32
|
||||||
if len(nodeChannels) == 0 && len(pendingChannels) == 0 {
|
if len(nodeChannels) == 0 && len(pendingChannels) == 0 {
|
||||||
|
channelAmount, err := strconv.ParseInt(os.Getenv("CHANNEL_AMOUNT"), 0, 64)
|
||||||
|
if err != nil || channelAmount <= 0 {
|
||||||
|
channelAmount = publicChannelAmount
|
||||||
|
}
|
||||||
|
isPrivate, err := strconv.ParseBool(os.Getenv("CHANNEL_PRIVATE"))
|
||||||
|
if err != nil {
|
||||||
|
isPrivate = false
|
||||||
|
}
|
||||||
response, err := client.OpenChannelSync(clientCtx, &lnrpc.OpenChannelRequest{
|
response, err := client.OpenChannelSync(clientCtx, &lnrpc.OpenChannelRequest{
|
||||||
LocalFundingAmount: publicChannelAmount,
|
LocalFundingAmount: channelAmount,
|
||||||
NodePubkeyString: in.Pubkey,
|
NodePubkeyString: in.Pubkey,
|
||||||
PushSat: 0,
|
PushSat: 0,
|
||||||
TargetConf: targetConf,
|
TargetConf: targetConf,
|
||||||
MinHtlcMsat: minHtlcMsat,
|
MinHtlcMsat: minHtlcMsat,
|
||||||
Private: false,
|
Private: isPrivate,
|
||||||
})
|
})
|
||||||
log.Printf("Response from OpenChannel: %#v (TX: %v)", response, hex.EncodeToString(response.GetFundingTxidBytes()))
|
log.Printf("Response from OpenChannel: %#v (TX: %v)", response, hex.EncodeToString(response.GetFundingTxidBytes()))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user