mirror of
https://github.com/getAlby/hub.git
synced 2026-08-13 12:33:39 +02:00
* feat: just in time channels with lsps2 * fix: clarify JIT receive channel fee * fix: fees * fix: fees 2 * fix: don't show low inbound when LSPS2 is active * fix: remove the receive limit below the input if LSPS2 is being used * fix: simplify * fix: bring back fee % for outgoing * fix: remove unneeded changes * fix: typo * fix: unneeded * fix: don't show open first channel is LSPS2 * feat: clearer JIT channel fee copy on receive screen * fix: add LSPS2 var info * fix: don't duplicate JIT fee hint on create invoice form * fix: make paymentDone a standard boolean * fix: update to golang:1.26 in Dockerfile * feat: read LSPS2 sources from channel suggestions, set minimum receive amount, update guide link * docs: update LDK_LSPS2_ADDRESSES to be used as an override * fix: only show minimum jit receive amount on validation error * fix: add more detail to receive error when receiving low amounts with jit * fix: do not use JIT when user has public channels * feat: add option to disable JIT * fix: isTrusted check, add jit property to event * fix: do not require node restart for toggling JIT * chore: simplify JIT alert * chore: add guide link on node settings JIT description * feat: fetch the lsp2info to have access to params like minimum/maximum payment size * refactor: share single learn-more link across JIT fee hint branches * fix: remove variable amount invoice support * fix: use lsps2info for min payment size and remove channelPeerSuggestion usage of minimumChannelSize * fix: only do amount validation according to lsps2Info values if jit is enabled in settings * feat: add jit first payment fee alert on receive via lightning address * fix: remove unnecessary conditional * fix: ensure at least one sat is left over when opening JIT channel * chore: remove hardcoded suggestions * chore: rename JIT enabled config variable * fix: ui checks when JIT is disabled * fix: amount input validation message * fix: formatting --------- Co-authored-by: anon <anon@anon.com> Co-authored-by: saunter <68239231+stackingsaunter@users.noreply.github.com> Co-authored-by: fmar <fmar@fmar> Co-authored-by: René Aaron <rene@twentyuno.net> Co-authored-by: Roland Bewick <roland.bewick@gmail.com>
70 lines
2.3 KiB
Go
70 lines
2.3 KiB
Go
package controllers
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/getAlby/go-nostr"
|
|
"github.com/getAlby/hub/logger"
|
|
"github.com/getAlby/hub/nip47/models"
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
type makeInvoiceParams struct {
|
|
Amount uint64 `json:"amount"` // msats (NIP-47)
|
|
Description string `json:"description"`
|
|
DescriptionHash string `json:"description_hash"`
|
|
Expiry uint64 `json:"expiry"`
|
|
Metadata map[string]interface{} `json:"metadata,omitempty"`
|
|
}
|
|
type makeInvoiceResponse struct {
|
|
models.Transaction
|
|
}
|
|
|
|
func (controller *nip47Controller) HandleMakeInvoiceEvent(ctx context.Context, nip47Request *models.Request, requestEventId uint, appId uint, publishResponse publishFunc) {
|
|
|
|
makeInvoiceParams := &makeInvoiceParams{}
|
|
resp := decodeRequest(nip47Request, makeInvoiceParams)
|
|
if resp != nil {
|
|
publishResponse(resp, nostr.Tags{})
|
|
return
|
|
}
|
|
|
|
logger.Logger.WithFields(logrus.Fields{
|
|
"app_id": appId,
|
|
"request_event_id": requestEventId,
|
|
"amount": makeInvoiceParams.Amount,
|
|
"description": makeInvoiceParams.Description,
|
|
"description_hash": makeInvoiceParams.DescriptionHash,
|
|
"expiry": makeInvoiceParams.Expiry,
|
|
"metadata": makeInvoiceParams.Metadata,
|
|
}).Debug("Handling make_invoice request")
|
|
|
|
expiry := makeInvoiceParams.Expiry
|
|
|
|
transaction, err := controller.transactionsService.MakeInvoice(ctx, makeInvoiceParams.Amount, makeInvoiceParams.Description, makeInvoiceParams.DescriptionHash, expiry, makeInvoiceParams.Metadata, controller.lnClient, &appId, &requestEventId, nil)
|
|
if err != nil {
|
|
logger.Logger.WithFields(logrus.Fields{
|
|
"request_event_id": requestEventId,
|
|
"amount": makeInvoiceParams.Amount,
|
|
"description": makeInvoiceParams.Description,
|
|
"descriptionHash": makeInvoiceParams.DescriptionHash,
|
|
"expiry": makeInvoiceParams.Expiry,
|
|
}).Infof("Failed to make invoice: %v", err)
|
|
|
|
publishResponse(&models.Response{
|
|
ResultType: nip47Request.Method,
|
|
Error: mapNip47Error(err),
|
|
}, nostr.Tags{})
|
|
return
|
|
}
|
|
|
|
nip47Transaction := models.ToNip47Transaction(transaction)
|
|
responsePayload := &makeInvoiceResponse{
|
|
Transaction: *nip47Transaction,
|
|
}
|
|
|
|
publishResponse(&models.Response{
|
|
ResultType: nip47Request.Method,
|
|
Result: responsePayload,
|
|
}, nostr.Tags{})
|
|
}
|