Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: increase metadata limit #731

Merged
merged 2 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ 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
const INVOICE_METADATA_MAX_LENGTH = 2048
// 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
const (
Expand Down
3 changes: 2 additions & 1 deletion transactions/make_invoice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package transactions
import (
"context"
"encoding/json"
"fmt"
"strings"
"testing"

Expand Down Expand Up @@ -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)
}

Expand Down
Loading