lnrpc: send custom message

This commit is contained in:
Joost Jager
2021-05-31 10:03:47 +02:00
parent 5d7e814ea8
commit ae959b16ae
14 changed files with 4451 additions and 3825 deletions

53
cmd/lncli/cmd_custom.go Normal file
View File

@@ -0,0 +1,53 @@
package main
import (
"encoding/hex"
"github.com/lightningnetwork/lnd/lnrpc"
"github.com/urfave/cli"
)
var sendCustomCommand = cli.Command{
Name: "sendcustom",
Flags: []cli.Flag{
cli.StringFlag{
Name: "peer",
},
cli.Uint64Flag{
Name: "type",
},
cli.StringFlag{
Name: "data",
},
},
Action: actionDecorator(sendCustom),
}
func sendCustom(ctx *cli.Context) error {
ctxc := getContext()
client, cleanUp := getClient(ctx)
defer cleanUp()
peer, err := hex.DecodeString(ctx.String("peer"))
if err != nil {
return err
}
msgType := ctx.Uint64("type")
data, err := hex.DecodeString(ctx.String("data"))
if err != nil {
return err
}
_, err = client.SendCustomMessage(
ctxc,
&lnrpc.SendCustomMessageRequest{
Peer: peer,
Type: uint32(msgType),
Data: data,
},
)
return err
}

View File

@@ -384,6 +384,7 @@ func main() {
profileSubCommand,
getStateCommand,
deletePaymentsCommand,
sendCustomCommand,
}
// Add any extra commands determined by build flags.