From 0accfebddb65a76b64ad230ce7683a0b2577bcab Mon Sep 17 00:00:00 2001 From: im-adithya Date: Wed, 13 Dec 2023 15:21:17 +0530 Subject: [PATCH] chore: minor fixes --- alby.go | 10 +++++----- models.go | 3 ++- service_test.go | 2 -- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/alby.go b/alby.go index e3a4c949..21157fc3 100644 --- a/alby.go +++ b/alby.go @@ -453,7 +453,7 @@ func (svc *AlbyOAuthService) SendKeysend(ctx context.Context, senderPubkey strin "payeePubkey": destination, "appId": app.ID, "userId": app.User.ID, - }).Info("Processing payment request") + }).Info("Processing keysend request") tok, err := svc.FetchUserToken(ctx, app) if err != nil { return "", err @@ -464,11 +464,11 @@ func (svc *AlbyOAuthService) SendKeysend(ctx context.Context, senderPubkey strin for _, record := range custom_records { customRecordsMap[strconv.FormatUint(record.Type, 10)] = record.Value } - + body := bytes.NewBuffer([]byte{}) payload := &KeysendRequest{ - Amount: amount, - Destination: destination, + Amount: amount, + Destination: destination, CustomRecords: customRecordsMap, } err = json.NewEncoder(body).Encode(payload) @@ -506,7 +506,7 @@ func (svc *AlbyOAuthService) SendKeysend(ctx context.Context, senderPubkey strin "appId": app.ID, "userId": app.User.ID, "paymentHash": responsePayload.PaymentHash, - }).Info("Payment successful") + }).Info("Keysend payment successful") return responsePayload.Preimage, nil } diff --git a/models.go b/models.go index 2bb9827a..975be2c3 100644 --- a/models.go +++ b/models.go @@ -25,7 +25,7 @@ const ( NIP_47_ERROR_EXPIRED = "EXPIRED" NIP_47_ERROR_RESTRICTED = "RESTRICTED" NIP_47_OTHER = "OTHER" - NIP_47_CAPABILITIES = "pay_invoice,get_balance,get_info,make_invoice,lookup_invoice" + NIP_47_CAPABILITIES = "pay_invoice,pay_keysend,get_balance,get_info,make_invoice,lookup_invoice" ) const ( @@ -181,6 +181,7 @@ type Identity struct { Privkey string } +// TODO: move to models/Nip47 type Nip47Request struct { Method string `json:"method"` Params json.RawMessage `json:"params"` diff --git a/service_test.go b/service_test.go index f147e264..f8104482 100644 --- a/service_test.go +++ b/service_test.go @@ -572,12 +572,10 @@ type MockLn struct { } func (mln *MockLn) SendPaymentSync(ctx context.Context, senderPubkey string, payReq string) (preimage string, err error) { - //todo more advanced behaviour return "123preimage", nil } func (mln *MockLn) SendKeysend(ctx context.Context, senderPubkey string, amount int64, destination, preimage string, custom_records []TLVRecord) (preImage string, err error) { - //todo more advanced behaviour return "123preimage", nil }