Skip to content

Commit 1a9544b

Browse files
committed
lndclient: rename payment request expiry field
DecodePayReq reports expiry as a duration from the invoice timestamp, while PaymentRequest exposes the computed absolute time. Rename Expiry to ExpiresAt to make that semantic explicit. This is a breaking API change: callers must update references from PaymentRequest.Expiry to PaymentRequest.ExpiresAt. The rename prevents existing callers from silently interpreting the changed value semantics.
1 parent f23e7c1 commit 1a9544b

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

lightning_client.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2908,8 +2908,8 @@ type PaymentRequest struct {
29082908
// Timestamp of the payment request.
29092909
Timestamp time.Time
29102910

2911-
// Expiry is the time at which the payment request expires.
2912-
Expiry time.Time
2911+
// ExpiresAt is the time at which the payment request expires.
2912+
ExpiresAt time.Time
29132913

29142914
// Description is a description attached to the payment request.
29152915
Description string
@@ -2963,7 +2963,7 @@ func (s *lightningClient) DecodePaymentRequest(ctx context.Context,
29632963
if resp.Expiry != 0 {
29642964
// LND reports expiry as a duration from the invoice timestamp.
29652965
invoiceTimestamp := time.Unix(resp.Timestamp, 0)
2966-
paymentReq.Expiry = invoiceTimestamp.Add(
2966+
paymentReq.ExpiresAt = invoiceTimestamp.Add(
29672967
time.Duration(resp.Expiry) * time.Second,
29682968
)
29692969
}

lightning_client_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ func (m *mockDecodePayReqRPCClient) DecodePayReq(_ context.Context,
3737
return m.response, nil
3838
}
3939

40-
// TestLightningClientDecodePaymentRequestExpiry ensures that the relative
40+
// TestLightningClientDecodePaymentRequestExpiresAt ensures that the relative
4141
// expiry returned by lnd is converted to an absolute expiration time.
42-
func TestLightningClientDecodePaymentRequestExpiry(t *testing.T) {
42+
func TestLightningClientDecodePaymentRequestExpiresAt(t *testing.T) {
4343
t.Parallel()
4444

4545
timestamp := time.Unix(1_700_000_000, 0)
@@ -65,7 +65,7 @@ func TestLightningClientDecodePaymentRequestExpiry(t *testing.T) {
6565
require.NoError(t, err)
6666
require.Equal(t, encoded, mock.request.PayReq)
6767
require.Equal(t, timestamp, request.Timestamp)
68-
require.Equal(t, timestamp.Add(expiry), request.Expiry)
68+
require.Equal(t, timestamp.Add(expiry), request.ExpiresAt)
6969
}
7070

7171
// mockRPCClient implements lnrpc.LightningClient with dynamic method

0 commit comments

Comments
 (0)