Skip to content

Commit fd45a21

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 fd28327 commit fd45a21

File tree

6 files changed

+3723
-3622
lines changed

6 files changed

+3723
-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: 3661 additions & 3609 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
@@ -6477,7 +6477,7 @@
64776477
}
64786478
}
64796479
},
6480-
"lnrpcOnionMessage": {
6480+
"lnrpcOnionMessageUpdate": {
64816481
"type": "object",
64826482
"properties": {
64836483
"peer": {
@@ -6494,6 +6494,23 @@
64946494
"type": "string",
64956495
"format": "byte",
64966496
"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."
6497+
},
6498+
"reply_path": {
6499+
"$ref": "#/definitions/lnrpcBlindedPath",
6500+
"description": "reply_path is the blinded path that should be used when replying to a\nreceived message."
6501+
},
6502+
"encrypted_recipient_data": {
6503+
"type": "string",
6504+
"format": "byte",
6505+
"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."
6506+
},
6507+
"custom_records": {
6508+
"type": "object",
6509+
"additionalProperties": {
6510+
"type": "string",
6511+
"format": "byte"
6512+
},
6513+
"description": "Custom onion message tlv records. These are customized fields that are\nnot defined by LND and cannot be extracted."
64976514
}
64986515
}
64996516
},

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
@@ -9361,10 +9361,28 @@ func (r *rpcServer) SubscribeOnionMessages(
93619361
"failed type assertion: %T", update)
93629362
}
93639363

9364-
err := server.Send(&lnrpc.OnionMessage{
9365-
Peer: oMsg.Peer[:],
9366-
BlindingPoint: oMsg.BlindingPoint,
9367-
Onion: oMsg.OnionBlob,
9364+
bp := &lnrpc.BlindedPath{}
9365+
9366+
if oMsg.ReplyPath != nil {
9367+
bp.IntroductionNode = oMsg.ReplyPath.FirstNodeID.SerializeCompressed()
9368+
bp.BlindingPoint = oMsg.ReplyPath.BlindingPoint.SerializeCompressed()
9369+
9370+
for _, hop := range oMsg.ReplyPath.Hops {
9371+
rpcHop := &lnrpc.BlindedHop{
9372+
BlindedNode: hop.BlindedNodeID.SerializeCompressed(),
9373+
EncryptedData: hop.EncryptedData,
9374+
}
9375+
bp.BlindedHops = append(bp.BlindedHops, rpcHop)
9376+
}
9377+
}
9378+
9379+
err := server.Send(&lnrpc.OnionMessageUpdate{
9380+
Peer: oMsg.Peer[:],
9381+
BlindingPoint: oMsg.BlindingPoint,
9382+
Onion: oMsg.OnionBlob,
9383+
ReplyPath: bp,
9384+
EncryptedRecipientData: oMsg.EncryptedRecipientData,
9385+
CustomRecords: oMsg.CustomRecords,
93689386
})
93699387
if err != nil {
93709388
return err

0 commit comments

Comments
 (0)