Skip to content

Commit 9bafcb2

Browse files
authored
Merge pull request #8160 from carlaKC/7298-2-forwardblindedroutes
[2/3]: Support Forwarding of Blinded Payments
2 parents b117551 + 2188dd9 commit 9bafcb2

23 files changed

+1538
-447
lines changed

config.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -626,8 +626,9 @@ func DefaultConfig() Config {
626626
RejectCacheSize: channeldb.DefaultRejectCacheSize,
627627
ChannelCacheSize: channeldb.DefaultChannelCacheSize,
628628
},
629-
Prometheus: lncfg.DefaultPrometheus(),
630-
Watchtower: lncfg.DefaultWatchtowerCfg(defaultTowerDir),
629+
Prometheus: lncfg.DefaultPrometheus(),
630+
Watchtower: lncfg.DefaultWatchtowerCfg(defaultTowerDir),
631+
ProtocolOptions: lncfg.DefaultProtocol(),
631632
HealthChecks: &lncfg.HealthCheckConfig{
632633
ChainCheck: &lncfg.CheckConfig{
633634
Interval: defaultChainInterval,

contractcourt/htlc_incoming_contest_resolver.go

+6-11
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"fmt"
88
"io"
99

10-
"github.com/btcsuite/btcd/btcec/v2"
1110
"github.com/btcsuite/btcd/btcutil"
1211
"github.com/btcsuite/btcd/txscript"
1312
"github.com/lightningnetwork/lnd/channeldb"
@@ -18,7 +17,6 @@ import (
1817
"github.com/lightningnetwork/lnd/lnwallet"
1918
"github.com/lightningnetwork/lnd/lnwire"
2019
"github.com/lightningnetwork/lnd/queue"
21-
"github.com/lightningnetwork/lnd/tlv"
2220
)
2321

2422
// htlcIncomingContestResolver is a ContractResolver that's able to resolve an
@@ -522,18 +520,15 @@ func (h *htlcIncomingContestResolver) Supplement(htlc channeldb.HTLC) {
522520
func (h *htlcIncomingContestResolver) decodePayload() (*hop.Payload,
523521
[]byte, error) {
524522

525-
var blindingPoint *btcec.PublicKey
526-
h.htlc.BlindingPoint.WhenSome(
527-
func(b tlv.RecordT[lnwire.BlindingPointTlvType,
528-
*btcec.PublicKey]) {
529-
530-
blindingPoint = b.Val
531-
},
532-
)
523+
blindingInfo := hop.ReconstructBlindingInfo{
524+
IncomingAmt: h.htlc.Amt,
525+
IncomingExpiry: h.htlc.RefundTimeout,
526+
BlindingKey: h.htlc.BlindingPoint,
527+
}
533528

534529
onionReader := bytes.NewReader(h.htlc.OnionBlob[:])
535530
iterator, err := h.OnionProcessor.ReconstructHopIterator(
536-
onionReader, h.htlc.RHash[:], blindingPoint,
531+
onionReader, h.htlc.RHash[:], blindingInfo,
537532
)
538533
if err != nil {
539534
return nil, nil, err

contractcourt/htlc_incoming_contest_resolver_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"io/ioutil"
77
"testing"
88

9-
"github.com/btcsuite/btcd/btcec/v2"
109
sphinx "github.com/lightningnetwork/lightning-onion"
1110
"github.com/lightningnetwork/lnd/chainntnfs"
1211
"github.com/lightningnetwork/lnd/channeldb"
@@ -290,7 +289,7 @@ type mockOnionProcessor struct {
290289
}
291290

292291
func (o *mockOnionProcessor) ReconstructHopIterator(r io.Reader, rHash []byte,
293-
blindingPoint *btcec.PublicKey) (hop.Iterator, error) {
292+
_ hop.ReconstructBlindingInfo) (hop.Iterator, error) {
294293

295294
data, err := ioutil.ReadAll(r)
296295
if err != nil {

contractcourt/interfaces.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"io"
66

7-
"github.com/btcsuite/btcd/btcec/v2"
87
"github.com/btcsuite/btcd/wire"
98
"github.com/lightningnetwork/lnd/channeldb"
109
"github.com/lightningnetwork/lnd/channeldb/models"
@@ -42,7 +41,7 @@ type OnionProcessor interface {
4241
// ReconstructHopIterator attempts to decode a valid sphinx packet from
4342
// the passed io.Reader instance.
4443
ReconstructHopIterator(r io.Reader, rHash []byte,
45-
blindingKey *btcec.PublicKey) (hop.Iterator, error)
44+
blindingInfo hop.ReconstructBlindingInfo) (hop.Iterator, error)
4645
}
4746

4847
// UtxoSweeper defines the sweep functions that contract court requires.

docs/release-notes/release-notes-0.18.0.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,9 @@ call where arguments were swapped.
187187
bitcoin peers' feefilter values into account](https://github.com/lightningnetwork/lnd/pull/8418).
188188

189189
* [Preparatory work](https://github.com/lightningnetwork/lnd/pull/8159) for
190-
forwarding of blinded routes was added.
190+
forwarding of blinded routes was added, along with [support](https://github.com/lightningnetwork/lnd/pull/8160)
191+
for forwarding blinded payments. Forwarding of blinded payments is disabled
192+
by default, and the feature is not yet advertised to the network.
191193

192194
## RPC Additions
193195

htlcswitch/hop/forwarding_info.go

+5
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,9 @@ type ForwardingInfo struct {
2222
// OutgoingCTLV is the specified value of the CTLV timelock to be used
2323
// in the outgoing HTLC.
2424
OutgoingCTLV uint32
25+
26+
// NextBlinding is an optional blinding point to be passed to the next
27+
// node in UpdateAddHtlc. This field is set if the htlc is part of a
28+
// blinded route.
29+
NextBlinding lnwire.BlindingPointRecord
2530
}

htlcswitch/hop/fuzz_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func fuzzPayload(f *testing.F, finalPayload bool) {
117117

118118
r := bytes.NewReader(data)
119119

120-
payload1, err := NewPayloadFromReader(r, finalPayload)
120+
payload1, _, err := NewPayloadFromReader(r, finalPayload)
121121
if err != nil {
122122
return
123123
}
@@ -146,7 +146,7 @@ func fuzzPayload(f *testing.F, finalPayload bool) {
146146
require.NoError(t, err)
147147
}
148148

149-
payload2, err := NewPayloadFromReader(&b, finalPayload)
149+
payload2, _, err := NewPayloadFromReader(&b, finalPayload)
150150
require.NoError(t, err)
151151

152152
require.Equal(t, payload1, payload2)

0 commit comments

Comments
 (0)