routing: only pack amount and cltv if populated

With the addition of blinded routes, we now need to account for the
possibility that intermediate nodes payloads will not have an amount
and expiry set because that information is provided by the recipient
encrypted data blob. This commit updates our payload packing to only
optionally include those fields.
This commit is contained in:
Carla Kirk-Cohen authored and Olaoluwa Osuntokun committed 2023-10-06 16:38:33 -07:00
1 parent fee0e05708
commit 940b491051
2 files changed
+40 -11

No files matched your search

+15
View File
@@ -8,6 +8,7 @@ import (
"github.com/btcsuite/btcd/btcec/v2"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/record"
"github.com/stretchr/testify/require"
)
var (
@@ -159,6 +160,20 @@ func TestAMPHop(t *testing.T) {
}
}
// TestNoForwardingParams tests packing of a hop payload without an amount or
// expiry height.
func TestNoForwardingParams(t *testing.T) {
t.Parallel()
hop := Hop{
EncryptedData: []byte{1, 2, 3},
}
var b bytes.Buffer
err := hop.PackHopPayload(&b, 2)
require.NoError(t, err)
}
// TestPayloadSize tests the payload size calculation that is provided by Hop
// structs.
func TestPayloadSize(t *testing.T) {