Skip to content

Commit 6aa7e89

Browse files
committed
lnrpc: Update SubscribeOnionMessages
With this Update we change the SubscribeOnionMessages RPC to return a stream of OnionMessageUpdate messages instead of OnionMessage. This way we also send back the decrypted payload if any, so we can inspect that in itests.
1 parent 233b9c4 commit 6aa7e89

File tree

6 files changed

+3725
-3622
lines changed

6 files changed

+3725
-3622
lines changed

itest/lnd_onion_message_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func testOnionMessage(ht *lntest.HarnessTest) {
2020
defer cancel()
2121

2222
// Create a channel to receive onion messages on.
23-
messages := make(chan *lnrpc.OnionMessage)
23+
messages := make(chan *lnrpc.OnionMessageUpdate)
2424
go func() {
2525
for {
2626
// If we fail to receive, just exit. The test should

lnrpc/lightning.pb.go

Lines changed: 3659 additions & 3607 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lnrpc/lightning.proto

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ service Lightning {
607607
SubscribeOnionMessages subscribes to a stream of incoming onion messages.
608608
*/
609609
rpc SubscribeOnionMessages (SubscribeOnionMessagesRequest)
610-
returns (stream OnionMessage);
610+
returns (stream OnionMessageUpdate);
611611

612612
/* lncli: `listaliases`
613613
ListAliases returns the set of all aliases that have ever existed with
@@ -676,7 +676,7 @@ message SendCustomMessageResponse {
676676
message SubscribeOnionMessagesRequest {
677677
}
678678

679-
message OnionMessage {
679+
message OnionMessageUpdate {
680680
// Peer from which this message originates. Represented as a byte-encoded
681681
// public key.
682682
bytes peer = 1;
@@ -694,6 +694,20 @@ message OnionMessage {
694694
// encrypted payloads and routing instructions used to forward this message
695695
// along its designated path.
696696
bytes onion = 3;
697+
698+
// reply_path is the blinded path that should be used when replying to a
699+
// received message.
700+
BlindedPath reply_path = 4;
701+
702+
// encrypted_recipient_data is the encrypted data that contains the
703+
// forwarding information for an onion message. It contains either
704+
// next_node_id or short_channel_id for each non-final node. It MAY contain
705+
// the path_id for the final node.
706+
bytes encrypted_recipient_data = 5;
707+
708+
// Custom onion message tlv records. These are customized fields that are
709+
// not defined by LND and cannot be extracted.
710+
map<uint64, bytes> custom_records = 6;
697711
}
698712

699713
message SendOnionMessageRequest {

lnrpc/lightning.swagger.json

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2308,13 +2308,13 @@
23082308
"type": "object",
23092309
"properties": {
23102310
"result": {
2311-
"$ref": "#/definitions/lnrpcOnionMessage"
2311+
"$ref": "#/definitions/lnrpcOnionMessageUpdate"
23122312
},
23132313
"error": {
23142314
"$ref": "#/definitions/rpcStatus"
23152315
}
23162316
},
2317-
"title": "Stream result of lnrpcOnionMessage"
2317+
"title": "Stream result of lnrpcOnionMessageUpdate"
23182318
}
23192319
},
23202320
"default": {
@@ -6542,7 +6542,7 @@
65426542
}
65436543
}
65446544
},
6545-
"lnrpcOnionMessage": {
6545+
"lnrpcOnionMessageUpdate": {
65466546
"type": "object",
65476547
"properties": {
65486548
"peer": {
@@ -6559,6 +6559,23 @@
65596559
"type": "string",
65606560
"format": "byte",
65616561
"description": "Serialized Sphinx onion packet (BOLT 4) containing the layered, per-hop\nencrypted payloads and routing instructions used to forward this message\nalong its designated path."
6562+
},
6563+
"reply_path": {
6564+
"$ref": "#/definitions/lnrpcBlindedPath",
6565+
"description": "reply_path is the blinded path that should be used when replying to a\nreceived message."
6566+
},
6567+
"encrypted_recipient_data": {
6568+
"type": "string",
6569+
"format": "byte",
6570+
"description": "encrypted_recipient_data is the encrypted data that contains the\nforwarding information for an onion message. It contains either\nnext_node_id or short_channel_id for each non-final node. It MAY contain\nthe path_id for the final node."
6571+
},
6572+
"custom_records": {
6573+
"type": "object",
6574+
"additionalProperties": {
6575+
"type": "string",
6576+
"format": "byte"
6577+
},
6578+
"description": "Custom onion message tlv records. These are customized fields that are\nnot defined by LND and cannot be extracted."
65626579
}
65636580
}
65646581
},

lnrpc/lightning_grpc.pb.go

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rpcserver.go

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9368,10 +9368,30 @@ func (r *rpcServer) SubscribeOnionMessages(
93689368
"failed type assertion: %T", update)
93699369
}
93709370

9371-
err := server.Send(&lnrpc.OnionMessage{
9372-
Peer: oMsg.Peer[:],
9373-
PathKey: oMsg.PathKey[:],
9374-
Onion: oMsg.OnionBlob,
9371+
bp := &lnrpc.BlindedPath{}
9372+
9373+
//nolint:ll
9374+
if oMsg.ReplyPath != nil {
9375+
bp.IntroductionNode = oMsg.ReplyPath.FirstNodeID.SerializeCompressed()
9376+
bp.BlindingPoint = oMsg.ReplyPath.BlindingPoint.SerializeCompressed()
9377+
9378+
for _, hop := range oMsg.ReplyPath.Hops {
9379+
rpcHop := &lnrpc.BlindedHop{
9380+
BlindedNode: hop.BlindedNodeID.SerializeCompressed(),
9381+
EncryptedData: hop.EncryptedData,
9382+
}
9383+
bp.BlindedHops = append(bp.BlindedHops, rpcHop)
9384+
}
9385+
}
9386+
9387+
//nolint:ll
9388+
err := server.Send(&lnrpc.OnionMessageUpdate{
9389+
Peer: oMsg.Peer[:],
9390+
PathKey: oMsg.PathKey[:],
9391+
Onion: oMsg.OnionBlob,
9392+
ReplyPath: bp,
9393+
EncryptedRecipientData: oMsg.EncryptedRecipientData,
9394+
CustomRecords: oMsg.CustomRecords,
93759395
})
93769396
if err != nil {
93779397
return err

0 commit comments

Comments
 (0)