Skip to content

Commit d0dda6c

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 00763c5 commit d0dda6c

File tree

6 files changed

+3721
-3620
lines changed

6 files changed

+3721
-3620
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
@@ -675,7 +675,7 @@ message SendCustomMessageResponse {
675675
message SubscribeOnionMessagesRequest {
676676
}
677677

678-
message OnionMessage {
678+
message OnionMessageUpdate {
679679
// Peer from which the message originates
680680
bytes peer = 1;
681681

@@ -687,6 +687,20 @@ message OnionMessage {
687687
// encrypted routing information used to relay this message through the
688688
// network in a privacy-preserving manner.
689689
bytes onion = 3;
690+
691+
// reply_path is the blinded path that should be used when replying to a
692+
// received message.
693+
BlindedPath reply_path = 4;
694+
695+
// encrypted_recipient_data is the encrypted data that contains the
696+
// forwarding information for an onion message. It contains either
697+
// next_node_id or short_channel_id for each non-final node. It MAY contain
698+
// the path_id for the final node.
699+
bytes encrypted_recipient_data = 5;
700+
701+
// Custom onion message tlv records. These are customized fields that are
702+
// not defined by LND and cannot be extracted.
703+
map<uint64, bytes> custom_records = 6;
690704
}
691705

692706
message SendOnionMessageRequest {

lnrpc/lightning.swagger.json

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6467,7 +6467,7 @@
64676467
}
64686468
}
64696469
},
6470-
"lnrpcOnionMessage": {
6470+
"lnrpcOnionMessageUpdate": {
64716471
"type": "object",
64726472
"properties": {
64736473
"peer": {
@@ -6484,6 +6484,23 @@
64846484
"type": "string",
64856485
"format": "byte",
64866486
"description": "Onion is the raw serialized Sphinx onion packet containing the per-hop\nencrypted routing information used to relay this message through the\nnetwork in a privacy-preserving manner."
6487+
},
6488+
"reply_path": {
6489+
"$ref": "#/definitions/lnrpcBlindedPath",
6490+
"description": "reply_path is the blinded path that should be used when replying to a\nreceived message."
6491+
},
6492+
"encrypted_recipient_data": {
6493+
"type": "string",
6494+
"format": "byte",
6495+
"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."
6496+
},
6497+
"custom_records": {
6498+
"type": "object",
6499+
"additionalProperties": {
6500+
"type": "string",
6501+
"format": "byte"
6502+
},
6503+
"description": "Custom onion message tlv records. These are customized fields that are\nnot defined by LND and cannot be extracted."
64876504
}
64886505
}
64896506
},

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: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9316,10 +9316,28 @@ func (r *rpcServer) SubscribeOnionMessages(
93169316
"failed type assertion: %T", update)
93179317
}
93189318

9319-
err := server.Send(&lnrpc.OnionMessage{
9320-
Peer: oMsg.Peer[:],
9321-
BlindingPoint: oMsg.BlindingPoint,
9322-
Onion: oMsg.OnionBlob,
9319+
bp := &lnrpc.BlindedPath{}
9320+
9321+
if oMsg.ReplyPath != nil {
9322+
bp.IntroductionNode = oMsg.ReplyPath.FirstNodeID.SerializeCompressed()
9323+
bp.BlindingPoint = oMsg.ReplyPath.BlindingPoint.SerializeCompressed()
9324+
9325+
for _, hop := range oMsg.ReplyPath.Hops {
9326+
rpcHop := &lnrpc.BlindedHop{
9327+
BlindedNode: hop.BlindedNodeID.SerializeCompressed(),
9328+
EncryptedData: hop.EncryptedData,
9329+
}
9330+
bp.BlindedHops = append(bp.BlindedHops, rpcHop)
9331+
}
9332+
}
9333+
9334+
err := server.Send(&lnrpc.OnionMessageUpdate{
9335+
Peer: oMsg.Peer[:],
9336+
BlindingPoint: oMsg.BlindingPoint,
9337+
Onion: oMsg.OnionBlob,
9338+
ReplyPath: bp,
9339+
EncryptedRecipientData: oMsg.EncryptedRecipientData,
9340+
CustomRecords: oMsg.CustomRecords,
93239341
})
93249342
if err != nil {
93259343
return err

0 commit comments

Comments
 (0)