lnrpc: receive custom message
This commit is contained in:
16 files changed
+4406
-3836
No files matched your search
@@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
|
||||
"github.com/lightningnetwork/lnd/lnrpc"
|
||||
"github.com/urfave/cli"
|
||||
@@ -51,3 +52,32 @@ func sendCustom(ctx *cli.Context) error {
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
var subscribeCustomCommand = cli.Command{
|
||||
Name: "subscribecustom",
|
||||
Action: actionDecorator(subscribeCustom),
|
||||
}
|
||||
|
||||
func subscribeCustom(ctx *cli.Context) error {
|
||||
ctxc := getContext()
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
stream, err := client.SubscribeCustomMessages(
|
||||
ctxc,
|
||||
&lnrpc.SubscribeCustomMessagesRequest{},
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for {
|
||||
msg, err := stream.Recv()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Printf("Received from peer %x: type=%d, data=%x\n",
|
||||
msg.Peer, msg.Type, msg.Data)
|
||||
}
|
||||
}
|
||||
@@ -385,6 +385,7 @@ func main() {
|
||||
getStateCommand,
|
||||
deletePaymentsCommand,
|
||||
sendCustomCommand,
|
||||
subscribeCustomCommand,
|
||||
}
|
||||
|
||||
// Add any extra commands determined by build flags.
|
||||
|
||||
Reference in new issue
Block a user