Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2/3]: Support Forwarding of Blinded Payments #8160

Merged
merged 16 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -626,8 +626,9 @@ func DefaultConfig() Config {
RejectCacheSize: channeldb.DefaultRejectCacheSize,
ChannelCacheSize: channeldb.DefaultChannelCacheSize,
},
Prometheus: lncfg.DefaultPrometheus(),
Watchtower: lncfg.DefaultWatchtowerCfg(defaultTowerDir),
Prometheus: lncfg.DefaultPrometheus(),
Watchtower: lncfg.DefaultWatchtowerCfg(defaultTowerDir),
ProtocolOptions: lncfg.DefaultProtocol(),
HealthChecks: &lncfg.HealthCheckConfig{
ChainCheck: &lncfg.CheckConfig{
Interval: defaultChainInterval,
Expand Down
17 changes: 6 additions & 11 deletions contractcourt/htlc_incoming_contest_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"fmt"
"io"

"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/txscript"
"github.com/lightningnetwork/lnd/channeldb"
Expand All @@ -18,7 +17,6 @@ import (
"github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/queue"
"github.com/lightningnetwork/lnd/tlv"
)

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

var blindingPoint *btcec.PublicKey
h.htlc.BlindingPoint.WhenSome(
func(b tlv.RecordT[lnwire.BlindingPointTlvType,
*btcec.PublicKey]) {

blindingPoint = b.Val
},
)
blindingInfo := hop.ReconstructBlindingInfo{
IncomingAmt: h.htlc.Amt,
IncomingExpiry: h.htlc.RefundTimeout,
BlindingKey: h.htlc.BlindingPoint,
}

onionReader := bytes.NewReader(h.htlc.OnionBlob[:])
iterator, err := h.OnionProcessor.ReconstructHopIterator(
onionReader, h.htlc.RHash[:], blindingPoint,
onionReader, h.htlc.RHash[:], blindingInfo,
)
if err != nil {
return nil, nil, err
Expand Down
3 changes: 1 addition & 2 deletions contractcourt/htlc_incoming_contest_resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"io/ioutil"
"testing"

"github.com/btcsuite/btcd/btcec/v2"
sphinx "github.com/lightningnetwork/lightning-onion"
"github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb"
Expand Down Expand Up @@ -290,7 +289,7 @@ type mockOnionProcessor struct {
}

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

data, err := ioutil.ReadAll(r)
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions contractcourt/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"io"

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

// UtxoSweeper defines the sweep functions that contract court requires.
Expand Down
4 changes: 3 additions & 1 deletion docs/release-notes/release-notes-0.18.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ call where arguments were swapped.
bitcoin peers' feefilter values into account](https://github.com/lightningnetwork/lnd/pull/8418).

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

## RPC Additions

Expand Down
5 changes: 5 additions & 0 deletions htlcswitch/hop/forwarding_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ type ForwardingInfo struct {
// OutgoingCTLV is the specified value of the CTLV timelock to be used
// in the outgoing HTLC.
OutgoingCTLV uint32

// NextBlinding is an optional blinding point to be passed to the next
// node in UpdateAddHtlc. This field is set if the htlc is part of a
// blinded route.
NextBlinding lnwire.BlindingPointRecord
}
4 changes: 2 additions & 2 deletions htlcswitch/hop/fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func fuzzPayload(f *testing.F, finalPayload bool) {

r := bytes.NewReader(data)

payload1, err := NewPayloadFromReader(r, finalPayload)
payload1, _, err := NewPayloadFromReader(r, finalPayload)
if err != nil {
return
}
Expand Down Expand Up @@ -146,7 +146,7 @@ func fuzzPayload(f *testing.F, finalPayload bool) {
require.NoError(t, err)
}

payload2, err := NewPayloadFromReader(&b, finalPayload)
payload2, _, err := NewPayloadFromReader(&b, finalPayload)
require.NoError(t, err)

require.Equal(t, payload1, payload2)
Expand Down