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:
Elle Mouton
2024-05-02 14:22:34 +02:00
parent 925b68c1ed
commit ad0905f10e
6 changed files with 71 additions and 28 deletions

View File

@@ -101,7 +101,7 @@ func TestBlindedDataEncoding(t *testing.T) {
}
}
encodedData := NewBlindedRouteData(
encodedData := NewNonFinalBlindedRouteData(
channelID, pubkey(t), info, constraints,
testCase.features,
)
@@ -134,7 +134,7 @@ func TestBlindingSpecTestVectors(t *testing.T) {
}{
{
encoded: "011a0000000000000000000000000000000000000000000000000000020800000000000006c10a0800240000009627100c06000b69e505dc0e00fd023103123456",
expectedPaymentData: NewBlindedRouteData(
expectedPaymentData: NewNonFinalBlindedRouteData(
lnwire.ShortChannelID{
BlockHeight: 0,
TxIndex: 0,
@@ -158,7 +158,7 @@ func TestBlindingSpecTestVectors(t *testing.T) {
},
{
encoded: "020800000000000004510821031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f0a0800300000006401f40c06000b69c105dc0e00",
expectedPaymentData: NewBlindedRouteData(
expectedPaymentData: NewNonFinalBlindedRouteData(
lnwire.ShortChannelID{
TxPosition: 1105,
},