Skip to content

Commit 392d4c8

Browse files
authored
Merge pull request #10089 from gijswijs/onion-messaging-1
Onion message forwarding
2 parents 6ea4791 + 061b89a commit 392d4c8

40 files changed

+7233
-3792
lines changed

.golangci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ linters:
160160
- github.com/gogo/protobuf
161161
- google.golang.org/protobuf
162162
- github.com/lightningnetwork/lnd/sqldb
163+
- github.com/lightningnetwork/lightning-onion
163164
replace-local: true
164165

165166
gosec:

docs/release-notes/release-notes-0.21.0.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,11 @@
7777

7878
# New Features
7979

80-
- Basic Support for [onion messaging forwarding](https://github.com/lightningnetwork/lnd/pull/9868)
81-
consisting of a new message type, `OnionMessage`. This includes the message's
82-
definition, comprising a path key and an onion blob, along with the necessary
83-
serialization and deserialization logic for peer-to-peer communication.
80+
- [Basic Support](https://github.com/lightningnetwork/lnd/pull/9868) for onion
81+
[messaging forwarding](https://github.com/lightningnetwork/lnd/pull/10089).
82+
This adds a new message type, `OnionMessage`, comprising a path key and an
83+
onion blob. It includes the necessary serialization and deserialization logic
84+
for peer-to-peer communication.
8485

8586
## Functional Enhancements
8687

feature/default_sets.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,8 @@ var defaultSetDesc = setDesc{
111111
SetInit: {}, // I
112112
SetNodeAnn: {}, // N
113113
},
114+
lnwire.OnionMessagesOptional: {
115+
SetInit: {}, // I
116+
SetNodeAnn: {}, // N
117+
},
114118
}

feature/manager.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ type Config struct {
7777
// coop close.
7878
NoRbfCoopClose bool
7979

80+
// NoOnionMessages unsets any bits that signal support for onion
81+
// messaging.
82+
NoOnionMessages bool
83+
8084
// CustomFeatures is a set of custom features to advertise in each
8185
// set.
8286
CustomFeatures map[Set][]lnwire.FeatureBit
@@ -221,6 +225,10 @@ func newManager(cfg Config, desc setDesc) (*Manager, error) {
221225
raw.Unset(lnwire.RbfCoopCloseOptionalStaging)
222226
raw.Unset(lnwire.RbfCoopCloseOptional)
223227
}
228+
if cfg.NoOnionMessages {
229+
raw.Unset(lnwire.OnionMessagesOptional)
230+
raw.Unset(lnwire.OnionMessagesRequired)
231+
}
224232

225233
for _, custom := range cfg.CustomFeatures[set] {
226234
if custom > set.Maximum() {

go.mod

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ require (
3232
github.com/kkdai/bstream v1.0.0
3333
github.com/lightninglabs/neutrino v0.16.1
3434
github.com/lightninglabs/neutrino/cache v1.1.2
35-
github.com/lightningnetwork/lightning-onion v1.2.1-0.20240815225420-8b40adf04ab9
35+
github.com/lightningnetwork/lightning-onion v1.3.0
36+
github.com/lightningnetwork/lnd/actor v0.0.3
3637
github.com/lightningnetwork/lnd/cert v1.2.2
3738
github.com/lightningnetwork/lnd/clock v1.1.1
3839
github.com/lightningnetwork/lnd/fn/v2 v2.0.9
@@ -82,7 +83,7 @@ require (
8283
github.com/containerd/continuity v0.3.0 // indirect
8384
github.com/coreos/go-semver v0.3.0 // indirect
8485
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
85-
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
86+
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
8687
github.com/decred/dcrd/crypto/blake256 v1.0.1 // indirect
8788
github.com/decred/dcrd/lru v1.1.2 // indirect
8889
github.com/docker/cli v28.1.1+incompatible // indirect
@@ -148,8 +149,7 @@ require (
148149
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
149150
github.com/rivo/uniseg v0.2.0 // indirect
150151
github.com/rogpeppe/fastuuid v1.2.0 // indirect
151-
github.com/russross/blackfriday/v2 v2.0.1 // indirect
152-
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
152+
github.com/russross/blackfriday/v2 v2.1.0 // indirect
153153
github.com/sirupsen/logrus v1.9.2 // indirect
154154
github.com/soheilhy/cmux v0.1.5 // indirect
155155
github.com/spf13/pflag v1.0.6 // indirect
@@ -202,6 +202,9 @@ require (
202202
sigs.k8s.io/yaml v1.2.0 // indirect
203203
)
204204

205+
// TODO(gijs): remove once new actor package is released.
206+
replace github.com/lightningnetwork/lnd/actor => ./actor
207+
205208
// TODO(elle): remove once the gossip V2 sqldb changes have been made.
206209
replace github.com/lightningnetwork/lnd/sqldb => ./sqldb
207210

go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7
111111
github.com/coreos/go-systemd/v22 v22.3.2 h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzAJc1DzSI=
112112
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
113113
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
114-
github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM=
115-
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
114+
github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4=
115+
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
116116
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
117117
github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY=
118118
github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
@@ -368,8 +368,8 @@ github.com/lightninglabs/neutrino/cache v1.1.2 h1:C9DY/DAPaPxbFC+xNNEI/z1SJY9GS3
368368
github.com/lightninglabs/neutrino/cache v1.1.2/go.mod h1:XJNcgdOw1LQnanGjw8Vj44CvguYA25IMKjWFZczwZuo=
369369
github.com/lightninglabs/protobuf-go-hex-display v1.33.0-hex-display h1:Y2WiPkBS/00EiEg0qp0FhehxnQfk3vv8U6Xt3nN+rTY=
370370
github.com/lightninglabs/protobuf-go-hex-display v1.33.0-hex-display/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
371-
github.com/lightningnetwork/lightning-onion v1.2.1-0.20240815225420-8b40adf04ab9 h1:6D3LrdagJweLLdFm1JNodZsBk6iU4TTsBBFLQ4yiXfI=
372-
github.com/lightningnetwork/lightning-onion v1.2.1-0.20240815225420-8b40adf04ab9/go.mod h1:EDqJ3MuZIbMq0QI1czTIKDJ/GS8S14RXPwapHw8cw6w=
371+
github.com/lightningnetwork/lightning-onion v1.3.0 h1:FqILgHjD6euc/Muo1VOzZ4+XDPuFnw6EYROBq0rR/5c=
372+
github.com/lightningnetwork/lightning-onion v1.3.0/go.mod h1:nP85zMHG7c0si/eHBbSQpuDCtnIXfSvFrK3tW6YWzmU=
373373
github.com/lightningnetwork/lnd/cert v1.2.2 h1:71YK6hogeJtxSxw2teq3eGeuy4rHGKcFf0d0Uy4qBjI=
374374
github.com/lightningnetwork/lnd/cert v1.2.2/go.mod h1:jQmFn/Ez4zhDgq2hnYSw8r35bqGVxViXhX6Cd7HXM6U=
375375
github.com/lightningnetwork/lnd/clock v1.1.1 h1:OfR3/zcJd2RhH0RU+zX/77c0ZiOnIMsDIBjgjWdZgA0=
@@ -485,13 +485,13 @@ github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWN
485485
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
486486
github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU=
487487
github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc=
488-
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
489488
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
489+
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
490+
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
490491
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
491492
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
492493
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
493494
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
494-
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
495495
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
496496
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
497497
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=

htlcswitch/hop/fuzz_test.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,25 @@ func FuzzHopData(f *testing.F) {
3939

4040
func FuzzHopPayload(f *testing.F) {
4141
f.Fuzz(func(t *testing.T, data []byte) {
42-
if len(data) > sphinx.MaxPayloadSize {
42+
if len(data) > sphinx.MaxRoutingPayloadSize {
4343
return
4444
}
4545

4646
r := bytes.NewReader(data)
4747

48-
var hopPayload1, hopPayload2 sphinx.HopPayload
48+
var hopPayload1, hopPayload2 *sphinx.HopPayload
49+
tlvGuaranteed := false
4950

50-
if err := hopPayload1.Decode(r); err != nil {
51+
hopPayload1, err := sphinx.DecodeHopPayload(r, tlvGuaranteed)
52+
if err != nil {
5153
return
5254
}
5355

5456
var b bytes.Buffer
5557
require.NoError(t, hopPayload1.Encode(&b))
56-
require.NoError(t, hopPayload2.Decode(&b))
58+
59+
hopPayload2, err = sphinx.DecodeHopPayload(&b, tlvGuaranteed)
60+
require.NoError(t, err)
5761

5862
require.Equal(t, hopPayload1, hopPayload2)
5963
})
@@ -129,7 +133,7 @@ func FuzzPayloadIntermediateNoBlinding(f *testing.F) {
129133

130134
func fuzzPayload(f *testing.F, finalPayload, updateAddBlinded bool) {
131135
f.Fuzz(func(t *testing.T, data []byte) {
132-
if len(data) > sphinx.MaxPayloadSize {
136+
if len(data) > sphinx.MaxRoutingPayloadSize {
133137
return
134138
}
135139

itest/list_on_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,10 @@ var allTestCases = []*lntest.TestCase{
543543
Name: "onion message",
544544
TestFunc: testOnionMessage,
545545
},
546+
{
547+
Name: "onion message forwarding",
548+
TestFunc: testOnionMessageForwarding,
549+
},
546550
{
547551
Name: "sign verify message with addr",
548552
TestFunc: testSignVerifyMessageWithAddr,

0 commit comments

Comments
 (0)