From cf3c45d6aef9b3777abdd2a9141f450cea4ee2cc Mon Sep 17 00:00:00 2001 From: Michael Bumann Date: Tue, 30 Jan 2024 10:55:24 +0100 Subject: [PATCH 1/4] Use argon2 as more memory efficient key derivation algorithm scrypt uses too much memory especially with that config that we had used --- aesgcm.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/aesgcm.go b/aesgcm.go index 5f7002d7..67001c48 100644 --- a/aesgcm.go +++ b/aesgcm.go @@ -7,7 +7,7 @@ import ( "encoding/hex" "strings" - "golang.org/x/crypto/scrypt" + "golang.org/x/crypto/argon2" ) func DeriveKey(password string, salt []byte) ([]byte, []byte, error) { @@ -18,10 +18,7 @@ func DeriveKey(password string, salt []byte) ([]byte, []byte, error) { } } - key, err := scrypt.Key([]byte(password), salt, 131072, 8, 1, 32) - if err != nil { - return nil, nil, err - } + key := argon2.Key([]byte(password), salt, 3, 32*1024, 1, 32) return key, salt, nil } From d3bf0df93bbe11168c6fd8bcf06b10473b395120 Mon Sep 17 00:00:00 2001 From: Michael Bumann Date: Tue, 30 Jan 2024 10:55:43 +0100 Subject: [PATCH 2/4] store the nwc db in the data directory this makes it easier to backup and use a volume --- config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.go b/config.go index 76f8d956..3f1eb60f 100644 --- a/config.go +++ b/config.go @@ -23,7 +23,7 @@ type AppConfig struct { LNDMacaroonFile string `envconfig:"LND_MACAROON_FILE"` Workdir string `envconfig:"WORK_DIR" default:".data"` Port string `envconfig:"PORT" default:"8080"` - DatabaseUri string `envconfig:"DATABASE_URI" default:"nostr-wallet-connect.db"` + DatabaseUri string `envconfig:"DATABASE_URI" default:".data/nwc.db"` CookieSecret string `envconfig:"COOKIE_SECRET"` } From 3ca6b8d83b5e50692f90b103795968663b0c801a Mon Sep 17 00:00:00 2001 From: Michael Bumann Date: Tue, 30 Jan 2024 15:00:49 +0100 Subject: [PATCH 3/4] load only first 100 transctions otherwise the NWC payload is too big we need to add pagination later --- breez.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/breez.go b/breez.go index 4f942ceb..7a0c9790 100644 --- a/breez.go +++ b/breez.go @@ -187,7 +187,8 @@ func (bs *BreezService) ListTransactions(ctx context.Context, senderPubkey strin } transactions = []Nip47Transaction{} - for _, payment := range payments { + paymentList := payments[0:100] + for _, payment := range paymentList { if payment.PaymentType != breez_sdk.PaymentTypeReceived && payment.PaymentType != breez_sdk.PaymentTypeSent { // skip other types of payments for now continue From 88b121d648fc71091ede0779fa454b50c0a912b6 Mon Sep 17 00:00:00 2001 From: Roland Bewick Date: Thu, 1 Feb 2024 14:36:25 +0700 Subject: [PATCH 4/4] fix: breez limit --- breez.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/breez.go b/breez.go index 2f798e08..10d42bcb 100644 --- a/breez.go +++ b/breez.go @@ -187,6 +187,10 @@ func (bs *BreezService) LookupInvoice(ctx context.Context, senderPubkey string, func (bs *BreezService) ListTransactions(ctx context.Context, senderPubkey string, from, until, limit, offset uint64, unpaid bool, invoiceType string) (transactions []Nip47Transaction, err error) { request := breez_sdk.ListPaymentsRequest{} + if limit == 0 { + // make sure a sensible limit is passed + limit = 100 + } if limit > 0 { limit32 := uint32(limit) request.Limit = &limit32 @@ -210,8 +214,7 @@ func (bs *BreezService) ListTransactions(ctx context.Context, senderPubkey strin } transactions = []Nip47Transaction{} - paymentList := payments[0:100] - for _, payment := range paymentList { + for _, payment := range payments { if payment.PaymentType != breez_sdk.PaymentTypeReceived && payment.PaymentType != breez_sdk.PaymentTypeSent { // skip other types of payments for now continue