mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-26 21:46:37 +02:00
record+htlcswitch: convert BlindedRouteData fields to optional
For the final hop in a blinded route, the SCID and RelayInfo fields will _not_ be set. So these fields need to be converted to optional records. The existing BlindedRouteData constructor is also renamed to `NewNonFinalBlindedRouteData` in preparation for a `NewFinalBlindedRouteData` constructor which will be used to construct the blinded data for the final hop which will contain a much smaller set of data. The SCID and RelayInfo parameters of the constructor are left as non-pointers in order to force the caller to set them in the case that the constructor is called for non-final nodes. The other option would be to create a single constructor where all parameters are optional but I think this makes it easier for the caller to make a mistake.
This commit is contained in:
@@ -646,7 +646,7 @@ func TestValidateBlindedRouteData(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
name: "max cltv expired",
|
||||
data: record.NewBlindedRouteData(
|
||||
data: record.NewNonFinalBlindedRouteData(
|
||||
scid,
|
||||
nil,
|
||||
record.PaymentRelayInfo{},
|
||||
@@ -663,7 +663,7 @@ func TestValidateBlindedRouteData(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "zero max cltv",
|
||||
data: record.NewBlindedRouteData(
|
||||
data: record.NewNonFinalBlindedRouteData(
|
||||
scid,
|
||||
nil,
|
||||
record.PaymentRelayInfo{},
|
||||
@@ -682,7 +682,7 @@ func TestValidateBlindedRouteData(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "amount below minimum",
|
||||
data: record.NewBlindedRouteData(
|
||||
data: record.NewNonFinalBlindedRouteData(
|
||||
scid,
|
||||
nil,
|
||||
record.PaymentRelayInfo{},
|
||||
@@ -699,7 +699,7 @@ func TestValidateBlindedRouteData(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "valid, no features",
|
||||
data: record.NewBlindedRouteData(
|
||||
data: record.NewNonFinalBlindedRouteData(
|
||||
scid,
|
||||
nil,
|
||||
record.PaymentRelayInfo{},
|
||||
@@ -714,7 +714,7 @@ func TestValidateBlindedRouteData(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "unknown features",
|
||||
data: record.NewBlindedRouteData(
|
||||
data: record.NewNonFinalBlindedRouteData(
|
||||
scid,
|
||||
nil,
|
||||
record.PaymentRelayInfo{},
|
||||
@@ -738,7 +738,7 @@ func TestValidateBlindedRouteData(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "valid data",
|
||||
data: record.NewBlindedRouteData(
|
||||
data: record.NewNonFinalBlindedRouteData(
|
||||
scid,
|
||||
nil,
|
||||
record.PaymentRelayInfo{
|
||||
|
Reference in New Issue
Block a user