From abb4f175480b772de0f1ebb665ade06000de7332 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Aaron?= Date: Wed, 9 Oct 2024 11:19:09 +0200 Subject: [PATCH 1/2] fix: increase metadata limit --- constants/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/constants/constants.go b/constants/constants.go index 48293630..f2566fca 100644 --- a/constants/constants.go +++ b/constants/constants.go @@ -34,7 +34,7 @@ const ( // given a relay limit of 512000 bytes and ideally being able to list 50 transactions, // each transaction would have to have a maximum size of 10240 // accounting for encryption and other metadata in the response, this is set to 2048 characters -const INVOICE_METADATA_MAX_LENGTH = 2048 +const INVOICE_METADATA_MAX_LENGTH = 4096 // errors used by NIP-47 and the transaction service const ( From a09d7fe14388cd20502f1fe8598e8e1213b0f49f Mon Sep 17 00:00:00 2001 From: im-adithya Date: Wed, 9 Oct 2024 15:19:31 +0530 Subject: [PATCH 2/2] fix: metadata tests and change comment --- constants/constants.go | 6 +++--- transactions/make_invoice_test.go | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/constants/constants.go b/constants/constants.go index f2566fca..98a8afee 100644 --- a/constants/constants.go +++ b/constants/constants.go @@ -31,9 +31,9 @@ const ( ) // limit encoded metadata length, otherwise relays may have trouble listing multiple transactions -// given a relay limit of 512000 bytes and ideally being able to list 50 transactions, -// each transaction would have to have a maximum size of 10240 -// accounting for encryption and other metadata in the response, this is set to 2048 characters +// given a relay limit of 512000 bytes and ideally being able to list 25 transactions, +// each transaction would have to have a maximum size of 20480 +// accounting for encryption and other metadata in the response, this is set to 4096 characters const INVOICE_METADATA_MAX_LENGTH = 4096 // errors used by NIP-47 and the transaction service diff --git a/transactions/make_invoice_test.go b/transactions/make_invoice_test.go index 74b74c03..c421bd92 100644 --- a/transactions/make_invoice_test.go +++ b/transactions/make_invoice_test.go @@ -3,6 +3,7 @@ package transactions import ( "context" "encoding/json" + "fmt" "strings" "testing" @@ -50,7 +51,7 @@ func TestMakeInvoice_MetadataTooLarge(t *testing.T) { transaction, err := transactionsService.MakeInvoice(ctx, 1234, "Hello world", "", 0, metadata, svc.LNClient, nil, nil) assert.Error(t, err) - assert.Equal(t, "encoded invoice metadata provided is too large. Limit: 2048 Received: 2049", err.Error()) + assert.Equal(t, fmt.Sprintf("encoded invoice metadata provided is too large. Limit: %d Received: %d", constants.INVOICE_METADATA_MAX_LENGTH, constants.INVOICE_METADATA_MAX_LENGTH+1), err.Error()) assert.Nil(t, transaction) }