From c5f5ab12b99cb89a2ab8e1ee25bb9ca8e5bc25b2 Mon Sep 17 00:00:00 2001 From: kiwiidb Date: Wed, 8 Jun 2022 14:46:32 +0200 Subject: [PATCH 1/2] remove memo --- lib/service/invoicesubscription.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/service/invoicesubscription.go b/lib/service/invoicesubscription.go index 4aa79c47..6a2ccfca 100644 --- a/lib/service/invoicesubscription.go +++ b/lib/service/invoicesubscription.go @@ -36,7 +36,7 @@ func (svc *LndhubService) HandleInternalKeysendPayment(ctx context.Context, invo UserID: user.ID, Amount: invoice.Amount, Internal: true, - Memo: "Keysend payment", + Memo: "", State: common.InvoiceStateInitialized, ExpiresAt: bun.NullTime{Time: time.Now().Add(expiry)}, Keysend: true, @@ -200,7 +200,7 @@ func (svc *LndhubService) createKeysendInvoice(ctx context.Context, rawInvoice * Type: common.InvoiceTypeIncoming, UserID: user.ID, Amount: rawInvoice.AmtPaidSat, - Memo: "Keysend payment", //TODO: also extract this from the custom records? + Memo: "", State: common.InvoiceStateInitialized, ExpiresAt: bun.NullTime{Time: time.Now().Add(expiry)}, Keysend: true, From aaa7911b4fcbfd48a945c9e1290e3edd6594a287 Mon Sep 17 00:00:00 2001 From: kiwiidb Date: Wed, 8 Jun 2022 15:34:08 +0200 Subject: [PATCH 2/2] always update invoice with hash --- lib/service/invoices.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/service/invoices.go b/lib/service/invoices.go index fedc70c8..39179e6b 100644 --- a/lib/service/invoices.go +++ b/lib/service/invoices.go @@ -81,7 +81,7 @@ func (svc *LndhubService) SendInternalPayment(ctx context.Context, invoice *mode InvoiceID: incomingInvoice.ID, CreditAccountID: recipientCreditAccount.ID, DebitAccountID: recipientDebitAccount.ID, - Amount: invoice.Amount, + Amount: incomingInvoice.Amount, } _, err = svc.DB.NewInsert().Model(&recipientEntry).Exec(ctx) if err != nil { @@ -93,11 +93,11 @@ func (svc *LndhubService) SendInternalPayment(ctx context.Context, invoice *mode preimage, _ := hex.DecodeString(incomingInvoice.Preimage) sendPaymentResponse.PaymentPreimageStr = incomingInvoice.Preimage sendPaymentResponse.PaymentPreimage = preimage - sendPaymentResponse.Invoice = invoice - paymentHash, _ := hex.DecodeString(invoice.RHash) - sendPaymentResponse.PaymentHashStr = invoice.RHash + sendPaymentResponse.Invoice = &incomingInvoice + paymentHash, _ := hex.DecodeString(incomingInvoice.RHash) + sendPaymentResponse.PaymentHashStr = incomingInvoice.RHash sendPaymentResponse.PaymentHash = paymentHash - sendPaymentResponse.PaymentRoute = &Route{TotalAmt: invoice.Amount, TotalFees: 0} + sendPaymentResponse.PaymentRoute = &Route{TotalAmt: incomingInvoice.Amount, TotalFees: 0} incomingInvoice.Internal = true // mark incoming invoice as internal, just for documentation/debugging incomingInvoice.State = common.InvoiceStateSettled @@ -244,6 +244,7 @@ func (svc *LndhubService) PayInvoice(ctx context.Context, invoice *models.Invoic // These changes to the invoice are persisted in the `HandleSuccessfulPayment` function invoice.Preimage = paymentResponse.PaymentPreimageStr invoice.Fee = paymentResponse.PaymentRoute.TotalFees + invoice.RHash = paymentResponse.PaymentHashStr err = svc.HandleSuccessfulPayment(context.Background(), invoice, entry) return &paymentResponse, err }