From 728311f0c16dfd9865382356d4e206b42648e086 Mon Sep 17 00:00:00 2001 From: Abdullahi Yunus Date: Mon, 9 Feb 2026 12:41:21 +0100 Subject: [PATCH 1/3] lnrpc: change command name In this commit we update `sendonion` to `sendonionmessage`. This clarifies the intent of the command is to send onion messages, not `sendonion` for payments which we have in `switchrpc`. --- lnrpc/lightning.proto | 4 ++-- lnrpc/lightning.swagger.json | 4 ++-- lnrpc/lightning_grpc.pb.go | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lnrpc/lightning.proto b/lnrpc/lightning.proto index dd52dd106f1..18d14baef82 100644 --- a/lnrpc/lightning.proto +++ b/lnrpc/lightning.proto @@ -597,13 +597,13 @@ service Lightning { rpc SubscribeCustomMessages (SubscribeCustomMessagesRequest) returns (stream CustomMessage); - /* lncli: `sendonion` + /* lncli: `sendonionmessage` SendOnionMessage sends an onion message to a peer. */ rpc SendOnionMessage (SendOnionMessageRequest) returns (SendOnionMessageResponse); - /* lncli: `subscribeonion` + /* lncli: `subscribeonionmessage` SubscribeOnionMessages subscribes to a stream of incoming onion messages. */ rpc SubscribeOnionMessages (SubscribeOnionMessagesRequest) diff --git a/lnrpc/lightning.swagger.json b/lnrpc/lightning.swagger.json index 23c86dcc5fe..6a0f43d6c55 100644 --- a/lnrpc/lightning.swagger.json +++ b/lnrpc/lightning.swagger.json @@ -2266,7 +2266,7 @@ }, "/v1/onionmessage": { "post": { - "summary": "lncli: `sendonion`\nSendOnionMessage sends an onion message to a peer.", + "summary": "lncli: `sendonionmessage`\nSendOnionMessage sends an onion message to a peer.", "operationId": "Lightning_SendOnionMessage", "responses": { "200": { @@ -2299,7 +2299,7 @@ }, "/v1/onionmessage/subscribe": { "get": { - "summary": "lncli: `subscribeonion`\nSubscribeOnionMessages subscribes to a stream of incoming onion messages.", + "summary": "lncli: `subscribeonionmessage`\nSubscribeOnionMessages subscribes to a stream of incoming onion messages.", "operationId": "Lightning_SubscribeOnionMessages", "responses": { "200": { diff --git a/lnrpc/lightning_grpc.pb.go b/lnrpc/lightning_grpc.pb.go index 19e0165fd78..07bef2242d7 100644 --- a/lnrpc/lightning_grpc.pb.go +++ b/lnrpc/lightning_grpc.pb.go @@ -417,10 +417,10 @@ type LightningClient interface { // needs to be compiled with the `dev` build tag, and the message type to // override should be specified in lnd's experimental protocol configuration. SubscribeCustomMessages(ctx context.Context, in *SubscribeCustomMessagesRequest, opts ...grpc.CallOption) (Lightning_SubscribeCustomMessagesClient, error) - // lncli: `sendonion` + // lncli: `sendonionmessage` // SendOnionMessage sends an onion message to a peer. SendOnionMessage(ctx context.Context, in *SendOnionMessageRequest, opts ...grpc.CallOption) (*SendOnionMessageResponse, error) - // lncli: `subscribeonion` + // lncli: `subscribeonionmessage` // SubscribeOnionMessages subscribes to a stream of incoming onion messages. SubscribeOnionMessages(ctx context.Context, in *SubscribeOnionMessagesRequest, opts ...grpc.CallOption) (Lightning_SubscribeOnionMessagesClient, error) // lncli: `listaliases` @@ -1806,10 +1806,10 @@ type LightningServer interface { // needs to be compiled with the `dev` build tag, and the message type to // override should be specified in lnd's experimental protocol configuration. SubscribeCustomMessages(*SubscribeCustomMessagesRequest, Lightning_SubscribeCustomMessagesServer) error - // lncli: `sendonion` + // lncli: `sendonionmessage` // SendOnionMessage sends an onion message to a peer. SendOnionMessage(context.Context, *SendOnionMessageRequest) (*SendOnionMessageResponse, error) - // lncli: `subscribeonion` + // lncli: `subscribeonionmessage` // SubscribeOnionMessages subscribes to a stream of incoming onion messages. SubscribeOnionMessages(*SubscribeOnionMessagesRequest, Lightning_SubscribeOnionMessagesServer) error // lncli: `listaliases` From 43748f72eac79deb0fee97f2f2b6f7ea6cebeadd Mon Sep 17 00:00:00 2001 From: Abdullahi Yunus Date: Mon, 9 Feb 2026 12:58:07 +0100 Subject: [PATCH 2/3] commands: add cli commands Add CLI commands for the SendOnionMessage and SubscribeOnionMessages RPCs, allowing users to send and receive onion messages via lncli. --- cmd/commands/cmd_onion_message.go | 95 +++++++++++++++++++++++++++++++ cmd/commands/main.go | 2 + 2 files changed, 97 insertions(+) create mode 100644 cmd/commands/cmd_onion_message.go diff --git a/cmd/commands/cmd_onion_message.go b/cmd/commands/cmd_onion_message.go new file mode 100644 index 00000000000..3246e7de3d3 --- /dev/null +++ b/cmd/commands/cmd_onion_message.go @@ -0,0 +1,95 @@ +package commands + +import ( + "encoding/hex" + "fmt" + + "github.com/lightningnetwork/lnd/lnrpc" + "github.com/urfave/cli" +) + +var sendOnionMessageCommand = cli.Command{ + Name: "sendonionmessage", + Category: "Peers", + Usage: "Send an onion message to a peer", + Flags: []cli.Flag{ + cli.StringFlag{ + Name: "peer", + }, + cli.StringFlag{ + Name: "path_key", + }, + cli.StringFlag{ + Name: "onion", + }, + }, + Action: actionDecorator(sendOnionMessage), +} + +// sendOnionMessage sends an onion message to a peer. +func sendOnionMessage(ctx *cli.Context) error { + ctxc := getContext() + client, cleanUp := getClient(ctx) + defer cleanUp() + + peer, err := hex.DecodeString(ctx.String("peer")) + if err != nil { + return fmt.Errorf("invalid peer hex: %w", err) + } + + pathKey, err := hex.DecodeString(ctx.String("path_key")) + if err != nil { + return fmt.Errorf("invalid path_key hex: %w", err) + } + + onion, err := hex.DecodeString(ctx.String("onion")) + if err != nil { + return fmt.Errorf("invalid onion hex: %w", err) + } + + resp, err := client.SendOnionMessage( + ctxc, &lnrpc.SendOnionMessageRequest{ + Peer: peer, + PathKey: pathKey, + Onion: onion, + }, + ) + + if err != nil { + return err + } + + printRespJSON(resp) + + return nil +} + +var subscribeOnionMessageCommand = cli.Command{ + Name: "subscribeonionmessage", + Category: "Peers", + Usage: "Subscribe to incoming onion messages", + Action: actionDecorator(subscribeOnionMessage), +} + +// subscribeOnionMessage subscribes to incoming onion messages. +func subscribeOnionMessage(ctx *cli.Context) error { + ctxc := getContext() + client, cleanUp := getClient(ctx) + defer cleanUp() + + stream, err := client.SubscribeOnionMessages( + ctxc, &lnrpc.SubscribeOnionMessagesRequest{}, + ) + if err != nil { + return err + } + + for { + msg, err := stream.Recv() + if err != nil { + return err + } + + printRespJSON(msg) + } +} diff --git a/cmd/commands/main.go b/cmd/commands/main.go index a11b63b9d33..71bf70dfcb6 100644 --- a/cmd/commands/main.go +++ b/cmd/commands/main.go @@ -513,6 +513,8 @@ func Main() { deletePaymentsCommand, sendCustomCommand, subscribeCustomCommand, + sendOnionMessageCommand, + subscribeOnionMessageCommand, fishCompletionCommand, listAliasesCommand, estimateRouteFeeCommand, From 414e98d8cba65cd38447080b83c23c2a435bbd73 Mon Sep 17 00:00:00 2001 From: Abdullahi Yunus Date: Mon, 9 Feb 2026 13:20:53 +0100 Subject: [PATCH 3/3] docs: add releasenote --- docs/release-notes/release-notes-0.21.0.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/release-notes/release-notes-0.21.0.md b/docs/release-notes/release-notes-0.21.0.md index ee39431a603..9169913ee3f 100644 --- a/docs/release-notes/release-notes-0.21.0.md +++ b/docs/release-notes/release-notes-0.21.0.md @@ -98,6 +98,9 @@ * The `estimatefee` command now supports the `--utxos` flag to specify explicit inputs for fee estimation. +* [`SendOnionMessage` and `SubscribeOnionMessages`](https://github.com/lightningnetwork/lnd/pull/10560) + RPCs now have corresponding `lncli` commands. + # Improvements ## Functional Updates @@ -177,6 +180,7 @@ # Contributors (Alphabetical Order) +* Abdulkbk * Boris Nagaev * Elle Mouton * Erick Cestari