Add default channel acceptor

- Implemented a default channel acceptor script for the channel acceptor in 'channel_acceptor.go'. If no accept script is provided, the default script is set to "continue".
- Updated 'cln_plugin.go' to include a new DefaultChannelAcceptorScript variable with an empty string default value.
- Updated the handleGetManifest function to include DefaultChannelAcceptorScript as a default for the 'channelAcceptScript' field.
This commit is contained in:
lndev
2023-07-12 09:06:51 +00:00
committed by Jesse de Wit
parent 70d6afcf85
commit c7eeaf1cbe
2 changed files with 10 additions and 1 deletions

View File

@@ -12,6 +12,13 @@ func channelAcceptor(acceptScript string, method string, openChannel json.RawMes
reject, _ := json.Marshal(struct { reject, _ := json.Marshal(struct {
Result string `json:"result"` Result string `json:"result"`
}{Result: "reject"}) }{Result: "reject"})
accept, _ := json.Marshal(struct {
Result string `json:"result"`
}{Result: "continue"})
if acceptScript == "" {
return accept, nil
}
sd := starlark.StringDict{ sd := starlark.StringDict{
"method": starlark.String(method), "method": starlark.String(method),

View File

@@ -24,6 +24,7 @@ const (
var ( var (
DefaultSubscriberTimeout = "1m" DefaultSubscriberTimeout = "1m"
DefaultChannelAcceptorScript = ""
) )
const ( const (
@@ -259,6 +260,7 @@ func (c *ClnPlugin) handleGetManifest(request *Request) {
Name: channelAcceptScript, Name: channelAcceptScript,
Type: "string", Type: "string",
Description: "starlark script for channel acceptor.", Description: "starlark script for channel acceptor.",
Default: &DefaultChannelAcceptorScript,
}, },
}, },
RpcMethods: []*RpcMethod{ RpcMethods: []*RpcMethod{