mulit: don't set customData on the lnrpc route level
We now make sure we only set the custom channel data in the lnrpc.Route only if it contains relevant data.
This commit is contained in:
1 parent
f35c295bd8
commit
cbfc0e0dc2
4 files changed
+26
-17
No files matched your search
@@ -1,7 +1,6 @@
|
||||
package itest
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strings"
|
||||
@@ -15,7 +14,6 @@ import (
|
||||
"github.com/lightningnetwork/lnd/lntest/node"
|
||||
"github.com/lightningnetwork/lnd/lntest/wait"
|
||||
"github.com/lightningnetwork/lnd/lntypes"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/lightningnetwork/lnd/routing/route"
|
||||
"github.com/stretchr/testify/require"
|
||||
"google.golang.org/grpc/codes"
|
||||
@@ -477,17 +475,9 @@ func testForwardInterceptorRestart(ht *lntest.HarnessTest) {
|
||||
rt.FirstHopAmountMsat)
|
||||
}
|
||||
|
||||
cr := lnwire.CustomRecords(p.FirstHopCustomRecords)
|
||||
recordData, err := cr.Serialize()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if !bytes.Equal(rt.CustomChannelData, recordData) {
|
||||
return fmt.Errorf("expected custom records to "+
|
||||
"be equal, got %x expected %x",
|
||||
rt.CustomChannelData, recordData)
|
||||
}
|
||||
// Make sure the custom channel data is nil because
|
||||
// this is not a custom channel payment.
|
||||
require.Nil(ht, rt.CustomChannelData)
|
||||
|
||||
return nil
|
||||
},
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package routerrpc
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
@@ -622,10 +623,26 @@ func (r *RouterBackend) MarshallRoute(route *route.Route) (*lnrpc.Route, error)
|
||||
// Allow the aux data parser to parse the custom records into
|
||||
// a human-readable JSON (if available).
|
||||
if r.ParseCustomChannelData != nil {
|
||||
// Store the original custom data to check if parsing
|
||||
// changed it.
|
||||
originalCustomData := make([]byte, len(customData))
|
||||
copy(originalCustomData, customData)
|
||||
|
||||
err := r.ParseCustomChannelData(resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// We make sure we only set this field if the parser
|
||||
// changed the data otherwise we might mistakenly
|
||||
// show other tlv custom wire data as custom channel
|
||||
// data.
|
||||
if bytes.Equal(
|
||||
originalCustomData, resp.CustomChannelData,
|
||||
) {
|
||||
|
||||
resp.CustomChannelData = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +90,8 @@ type PaymentCreationInfo struct {
|
||||
|
||||
// FirstHopCustomRecords are the TLV records that are to be sent to the
|
||||
// first hop of this payment. These records will be transmitted via the
|
||||
// wire message only and therefore do not affect the onion payload size.
|
||||
// wire message (UpdateAddHTLC) only and therefore do not affect the
|
||||
// onion payload size.
|
||||
FirstHopCustomRecords lnwire.CustomRecords
|
||||
}
|
||||
|
||||
|
||||
@@ -524,9 +524,10 @@ type Route struct {
|
||||
]
|
||||
|
||||
// FirstHopWireCustomRecords is a set of custom records that should be
|
||||
// included in the wire message sent to the first hop. This is only set
|
||||
// on custom channels and is used to include additional information
|
||||
// about the actual value of the payment.
|
||||
// included in the wire message sent to the first hop. This is for
|
||||
// example used in custom channels. Besides custom channels we use it
|
||||
// also for the endorsement bit. This data will be sent to the first
|
||||
// hop in the UpdateAddHTLC message.
|
||||
//
|
||||
// NOTE: Since these records already represent TLV records, and we
|
||||
// enforce them to be in the custom range (e.g. >= 65536), we don't use
|
||||
|
||||
Reference in new issue
Block a user