mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-08 14:57:38 +02:00
lnrpc: send custom message
This commit is contained in:
53
cmd/lncli/cmd_custom.go
Normal file
53
cmd/lncli/cmd_custom.go
Normal 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
|
||||
}
|
@@ -384,6 +384,7 @@ func main() {
|
||||
profileSubCommand,
|
||||
getStateCommand,
|
||||
deletePaymentsCommand,
|
||||
sendCustomCommand,
|
||||
}
|
||||
|
||||
// Add any extra commands determined by build flags.
|
||||
|
Reference in New Issue
Block a user