Skip to content

Commit

Permalink
fix: make invoice description field
Browse files Browse the repository at this point in the history
  • Loading branch information
rolznz committed Aug 9, 2023
1 parent af895e5 commit ed71d07
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
4 changes: 3 additions & 1 deletion alby.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (svc *AlbyOAuthService) MakeInvoice(ctx context.Context, senderPubkey strin
body := bytes.NewBuffer([]byte{})
payload := &MakeInvoiceRequest{
Amount: amount,
Memo: description,
Description: description,
DescriptionHash: descriptionHash,
// TODO: support expiry
}
Expand Down Expand Up @@ -155,6 +155,8 @@ func (svc *AlbyOAuthService) MakeInvoice(ctx context.Context, senderPubkey strin
"expiry": expiry,
"appId": app.ID,
"userId": app.User.ID,
"paymentRequest": responsePayload.PaymentRequest,
"paymentHash": responsePayload.PaymentHash,
}).Info("Make invoice successful")
return responsePayload.PaymentRequest, responsePayload.PaymentHash, nil
} else {
Expand Down
20 changes: 14 additions & 6 deletions handle_make_invoice_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,25 @@ func (svc *Service) HandleMakeInvoiceEvent(ctx context.Context, request *Nip47Re
}

svc.Logger.WithFields(logrus.Fields{
"eventId": event.ID,
"eventKind": event.Kind,
"appId": app.ID,
"eventId": event.ID,
"eventKind": event.Kind,
"appId": app.ID,
"amount": makeInvoiceParams.Amount,
"description": makeInvoiceParams.Description,
"descriptionHash": makeInvoiceParams.DescriptionHash,
"expiry": makeInvoiceParams.Expiry,
}).Info("Making invoice")

invoice, paymentHash, err := svc.lnClient.MakeInvoice(ctx, event.PubKey, makeInvoiceParams.Amount, makeInvoiceParams.Description, makeInvoiceParams.DescriptionHash, makeInvoiceParams.Expiry)
if err != nil {
svc.Logger.WithFields(logrus.Fields{
"eventId": event.ID,
"eventKind": event.Kind,
"appId": app.ID,
"eventId": event.ID,
"eventKind": event.Kind,
"appId": app.ID,
"amount": makeInvoiceParams.Amount,
"description": makeInvoiceParams.Description,
"descriptionHash": makeInvoiceParams.DescriptionHash,
"expiry": makeInvoiceParams.Expiry,
}).Infof("Failed to make invoice: %v", err)
nostrEvent.State = "error"
svc.db.Save(&nostrEvent)
Expand Down
3 changes: 2 additions & 1 deletion models.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const (
var nip47MethodDescriptions = map[string]string{
NIP_47_GET_BALANCE_METHOD: "Read your balance.",
NIP_47_PAY_INVOICE_METHOD: "Send payments from your wallet.",
NIP_47_MAKE_INVOICE_METHOD: "Create invoices on your behalf.",
}

type AlbyMe struct {
Expand Down Expand Up @@ -115,7 +116,7 @@ type PayResponse struct {

type MakeInvoiceRequest struct {
Amount int64 `json:"amount"`
Memo string `json:"memo"`
Description string `json:"description"`
DescriptionHash string `json:"description_hash"`
}

Expand Down

0 comments on commit ed71d07

Please sign in to comment.