diff --git a/controllers/addinvoice.ctrl.go b/controllers/addinvoice.ctrl.go index 52017aa..7969a88 100644 --- a/controllers/addinvoice.ctrl.go +++ b/controllers/addinvoice.ctrl.go @@ -30,18 +30,6 @@ type AddInvoiceResponseBody struct { PayReq string `json:"pay_req"` } -// AddInvoice godoc -// @Summary Generate a new invoice -// @Description Returns a new bolt11 invoice -// @Accept json -// @Produce json -// @Tags Invoice -// @Param invoice body AddInvoiceRequestBody True "Add Invoice" -// @Success 200 {object} AddInvoiceResponseBody -// @Failure 400 {object} responses.ErrorResponse -// @Failure 500 {object} responses.ErrorResponse -// @Router /addinvoice [post] -// @Security OAuth2Password func (controller *AddInvoiceController) AddInvoice(c echo.Context) error { userID := c.Get("UserID").(int64) return AddInvoice(c, controller.svc, userID) diff --git a/controllers/balance.ctrl.go b/controllers/balance.ctrl.go index 3fa813f..96ee652 100644 --- a/controllers/balance.ctrl.go +++ b/controllers/balance.ctrl.go @@ -22,17 +22,6 @@ type BalanceResponse struct { } } -// Balance godoc -// @Summary Retrieve balance -// @Description Current user's balance in satoshi -// @Accept json -// @Produce json -// @Tags Account -// @Success 200 {object} BalanceResponse -// @Failure 400 {object} responses.ErrorResponse -// @Failure 500 {object} responses.ErrorResponse -// @Router /balance [get] -// @Security OAuth2Password func (controller *BalanceController) Balance(c echo.Context) error { userId := c.Get("UserID").(int64) balance, err := controller.svc.CurrentUserBalance(c.Request().Context(), userId) diff --git a/controllers/checkpayment.ctrl.go b/controllers/checkpayment.ctrl.go index 64b3974..41f91c2 100644 --- a/controllers/checkpayment.ctrl.go +++ b/controllers/checkpayment.ctrl.go @@ -21,18 +21,6 @@ func NewCheckPaymentController(svc *service.LndhubService) *CheckPaymentControll return &CheckPaymentController{svc: svc} } -// CheckPayment godoc -// @Summary Check if an invoice is paid -// @Description Checks if an invoice is paid, can be incoming our outgoing -// @Accept json -// @Produce json -// @Tags Invoice -// @Param payment_hash path string true "Payment hash" -// @Success 200 {object} CheckPaymentResponseBody -// @Failure 400 {object} responses.ErrorResponse -// @Failure 500 {object} responses.ErrorResponse -// @Router /checkpayment/{payment_hash} [get] -// @Security OAuth2Password func (controller *CheckPaymentController) CheckPayment(c echo.Context) error { userID := c.Get("UserID").(int64) rHash := c.Param("payment_hash") diff --git a/controllers/create.ctrl.go b/controllers/create.ctrl.go index f2cc0fd..f87d861 100644 --- a/controllers/create.ctrl.go +++ b/controllers/create.ctrl.go @@ -28,17 +28,6 @@ type CreateUserRequestBody struct { AccountType string `json:"accounttype"` } -// CreateUser godoc -// @Summary Create an account -// @Description Create a new account with a login and password -// @Accept json -// @Produce json -// @Tags Account -// @Param account body CreateUserRequestBody false "Create User" -// @Success 200 {object} CreateUserResponseBody -// @Failure 400 {object} responses.ErrorResponse -// @Failure 500 {object} responses.ErrorResponse -// @Router /create [post] func (controller *CreateUserController) CreateUser(c echo.Context) error { var body CreateUserRequestBody diff --git a/controllers/getinfo.ctrl.go b/controllers/getinfo.ctrl.go index a030ce0..1f16a3a 100644 --- a/controllers/getinfo.ctrl.go +++ b/controllers/getinfo.ctrl.go @@ -73,17 +73,6 @@ func NewGetInfoController(svc *service.LndhubService) *GetInfoController { return &GetInfoController{svc: svc} } -// GetInfo godoc -// @Summary Get info about the Lightning node -// @Description Returns info about the backend node powering this LNDhub instance -// @Accept json -// @Produce json -// @Tags Info -// @Success 200 {object} GetInfoResponse -// @Failure 400 {object} responses.ErrorResponse -// @Failure 500 {object} responses.ErrorResponse -// @Router /getinfo [get] -// @Security OAuth2Password func (controller *GetInfoController) GetInfo(c echo.Context) error { info, err := controller.svc.GetInfo(c.Request().Context()) @@ -96,6 +85,6 @@ func (controller *GetInfoController) GetInfo(c echo.Context) error { // BlueWallet right now requires a `identity_pubkey` in the response // https://github.com/BlueWallet/BlueWallet/blob/a28a2b96bce0bff6d1a24a951b59dc972369e490/class/wallets/lightning-custodian-wallet.js#L578 - c.Response().Header().Set(echo.HeaderCacheControl, "public, max-age=300, stale-if-error=21600") // cache for 5 minutes or if error for 6 hours max + c.Response().Header().Set(echo.HeaderCacheControl, "public, max-age=300, stale-if-error=21600") // cache for 5 minutes or if error for 6 hours max return c.JSON(http.StatusOK, info) } diff --git a/controllers/gettxs.ctrl.go b/controllers/gettxs.ctrl.go index fb08c4e..42bb203 100644 --- a/controllers/gettxs.ctrl.go +++ b/controllers/gettxs.ctrl.go @@ -46,17 +46,6 @@ type IncomingInvoice struct { CustomRecords map[uint64][]byte `json:"custom_records"` } -// GetTXS godoc -// @Summary Retrieve outgoing payments -// @Description Returns a list of outgoing payments for a user -// @Accept json -// @Produce json -// @Tags Account -// @Success 200 {object} []OutgoingInvoice -// @Failure 400 {object} responses.ErrorResponse -// @Failure 500 {object} responses.ErrorResponse -// @Router /gettxs [get] -// @Security OAuth2Password func (controller *GetTXSController) GetTXS(c echo.Context) error { userId := c.Get("UserID").(int64) @@ -84,17 +73,6 @@ func (controller *GetTXSController) GetTXS(c echo.Context) error { return c.JSON(http.StatusOK, &response) } -// GetUserInvoices godoc -// @Summary Retrieve incoming invoices -// @Description Returns a list of incoming invoices for a user -// @Accept json -// @Produce json -// @Tags Account -// @Success 200 {object} []IncomingInvoice -// @Failure 400 {object} responses.ErrorResponse -// @Failure 500 {object} responses.ErrorResponse -// @Router /getuserinvoices [get] -// @Security OAuth2Password func (controller *GetTXSController) GetUserInvoices(c echo.Context) error { userId := c.Get("UserID").(int64) diff --git a/controllers/invoice.ctrl.go b/controllers/invoice.ctrl.go index 90333dd..3621924 100644 --- a/controllers/invoice.ctrl.go +++ b/controllers/invoice.ctrl.go @@ -17,18 +17,6 @@ func NewInvoiceController(svc *service.LndhubService) *InvoiceController { return &InvoiceController{svc: svc} } -// Invoice godoc -// @Summary Generate a new invoice -// @Description Returns a new bolt11 invoice for a user with given login, without an Authorization Header -// @Accept json -// @Produce json -// @Tags Invoice -// @Param user_login path string true "User Login" -// @Param invoice body AddInvoiceRequestBody True "Add Invoice" -// @Success 200 {object} AddInvoiceResponseBody -// @Failure 400 {object} responses.ErrorResponse -// @Failure 500 {object} responses.ErrorResponse -// @Router /invoice/{user_login} [post] func (controller *InvoiceController) Invoice(c echo.Context) error { user, err := controller.svc.FindUserByLogin(c.Request().Context(), c.Param("user_login")) if err != nil { diff --git a/controllers/invoicestream.ctrl.go b/controllers/invoicestream.ctrl.go index e65e5e8..77656c7 100644 --- a/controllers/invoicestream.ctrl.go +++ b/controllers/invoicestream.ctrl.go @@ -27,20 +27,6 @@ func NewInvoiceStreamController(svc *service.LndhubService) *InvoiceStreamContro return &InvoiceStreamController{svc: svc} } -// StreamInvoices godoc -// @Summary Websocket for incoming payments -// @Description Websocket: won't work with Swagger web UI. Returns a stream of settled incoming payments. -// @Description A keep-alive message is sent on startup and every 30s. -// @Accept json -// @Produce json -// @Tags Invoice -// @Param token query string true "Auth token, retrieved from /auth endpoint" -// @Param since_payment_hash query string false "Payment hash of earliest invoice. If specified, missing updates starting from this payment will be sent." -// @Success 200 {object} []InvoiceEventWrapper -// @Failure 400 {object} responses.ErrorResponse -// @Failure 500 {object} responses.ErrorResponse -// @Router /invoices/stream [get] -// @Security OAuth2Password func (controller *InvoiceStreamController) StreamInvoices(c echo.Context) error { userId, err := tokens.ParseToken(controller.svc.Config.JWTSecret, (c.QueryParam("token")), false) if err != nil { diff --git a/controllers/keysend.ctrl.go b/controllers/keysend.ctrl.go index c136078..b35e65e 100644 --- a/controllers/keysend.ctrl.go +++ b/controllers/keysend.ctrl.go @@ -41,18 +41,6 @@ type KeySendResponseBody struct { PaymentRoute *service.Route `json:"payment_route,omitempty"` } -//// KeySend godoc -// @Summary Make a keysend payment -// @Description Pay a node without an invoice using it's public key -// @Accept json -// @Produce json -// @Tags Payment -// @Param KeySendRequestBody body KeySendRequestBody True "Invoice to pay" -// @Success 200 {object} KeySendResponseBody -// @Failure 400 {object} responses.ErrorResponse -// @Failure 500 {object} responses.ErrorResponse -// @Router /keysend [post] -// @Security OAuth2Password func (controller *KeySendController) KeySend(c echo.Context) error { userID := c.Get("UserID").(int64) reqBody := KeySendRequestBody{} diff --git a/controllers/payinvoice.ctrl.go b/controllers/payinvoice.ctrl.go index 614b1ca..3916f61 100644 --- a/controllers/payinvoice.ctrl.go +++ b/controllers/payinvoice.ctrl.go @@ -39,18 +39,6 @@ type PayInvoiceResponseBody struct { PaymentRoute *service.Route `json:"payment_route,omitempty"` } -// PayInvoice godoc -// @Summary Pay an invoice -// @Description Pay a bolt11 invoice -// @Accept json -// @Produce json -// @Tags Payment -// @Param PayInvoiceRequest body PayInvoiceRequestBody True "Invoice to pay" -// @Success 200 {object} PayInvoiceResponseBody -// @Failure 400 {object} responses.ErrorResponse -// @Failure 500 {object} responses.ErrorResponse -// @Router /payinvoice [post] -// @Security OAuth2Password func (controller *PayInvoiceController) PayInvoice(c echo.Context) error { userID := c.Get("UserID").(int64) reqBody := PayInvoiceRequestBody{} diff --git a/controllers_v2/balance.ctrl.go b/controllers_v2/balance.ctrl.go index e637fbc..bcd8b3a 100644 --- a/controllers_v2/balance.ctrl.go +++ b/controllers_v2/balance.ctrl.go @@ -17,9 +17,9 @@ func NewBalanceController(svc *service.LndhubService) *BalanceController { } type BalanceResponse struct { - BTC struct { - AvailableBalance int64 - } + Balance int64 `json:"balance"` + Currency string `json:"currency"` + Unit string `json:"unit"` } // Balance godoc @@ -31,7 +31,7 @@ type BalanceResponse struct { // @Success 200 {object} BalanceResponse // @Failure 400 {object} responses.ErrorResponse // @Failure 500 {object} responses.ErrorResponse -// @Router /balance [get] +// @Router /v2/balance [get] // @Security OAuth2Password func (controller *BalanceController) Balance(c echo.Context) error { userId := c.Get("UserID").(int64) @@ -40,8 +40,8 @@ func (controller *BalanceController) Balance(c echo.Context) error { return err } return c.JSON(http.StatusOK, &BalanceResponse{ - BTC: struct{ AvailableBalance int64 }{ - AvailableBalance: balance, - }, + Balance: balance, + Currency: "BTC", + Unit: "sat", }) } diff --git a/controllers_v2/invoice.ctrl.go b/controllers_v2/invoice.ctrl.go index bbfbb28..43f320f 100644 --- a/controllers_v2/invoice.ctrl.go +++ b/controllers_v2/invoice.ctrl.go @@ -2,9 +2,9 @@ package v2controllers import ( "net/http" + "time" "github.com/getAlby/lndhub.go/common" - "github.com/getAlby/lndhub.go/lib" "github.com/getAlby/lndhub.go/lib/responses" "github.com/getAlby/lndhub.go/lib/service" "github.com/getsentry/sentry-go" @@ -20,44 +20,35 @@ func NewInvoiceController(svc *service.LndhubService) *InvoiceController { return &InvoiceController{svc: svc} } -type OutgoingInvoice struct { - RHash interface{} `json:"r_hash,omitempty"` - PaymentHash interface{} `json:"payment_hash"` - PaymentPreimage string `json:"payment_preimage"` - Value int64 `json:"value"` - Type string `json:"type"` +type Invoice struct { + PaymentHash string `json:"payment_hash"` + PaymentRequest string `json:"payment_request"` + Description string `json:"description"` + DescriptionHash string `json:"description_hash"` + PaymentPreimage string `json:"payment_preimage,omitempty"` + Destination string `json:"destination"` + Amount int64 `json:"amount"` Fee int64 `json:"fee"` - Timestamp int64 `json:"timestamp"` - Memo string `json:"memo"` + Status string `json:"status"` + Type string `json:"type"` + ErrorMessage string `json:"error_message,omitempty"` + SettledAt time.Time `json:"settled_at"` + ExpiresAt time.Time `json:"expires_at"` + IsPaid bool `json:"is_paid"` Keysend bool `json:"keysend"` CustomRecords map[uint64][]byte `json:"custom_records"` } -type IncomingInvoice struct { - RHash interface{} `json:"r_hash,omitempty"` - PaymentHash interface{} `json:"payment_hash"` - PaymentRequest string `json:"payment_request"` - Description string `json:"description"` - PayReq string `json:"pay_req"` - Timestamp int64 `json:"timestamp"` - Type string `json:"type"` - ExpireTime int64 `json:"expire_time"` - Amount int64 `json:"amt"` - IsPaid bool `json:"ispaid"` - Keysend bool `json:"keysend"` - CustomRecords map[uint64][]byte `json:"custom_records"` -} - -// GetTXS godoc +// GetOutgoingInvoices godoc // @Summary Retrieve outgoing payments // @Description Returns a list of outgoing payments for a user // @Accept json // @Produce json // @Tags Account -// @Success 200 {object} []OutgoingInvoice +// @Success 200 {object} []Invoice // @Failure 400 {object} responses.ErrorResponse // @Failure 500 {object} responses.ErrorResponse -// @Router /gettxs [get] +// @Router /v2/invoices/outgoing [get] // @Security OAuth2Password func (controller *InvoiceController) GetOutgoingInvoices(c echo.Context) error { userId := c.Get("UserID").(int64) @@ -67,18 +58,23 @@ func (controller *InvoiceController) GetOutgoingInvoices(c echo.Context) error { return err } - response := make([]OutgoingInvoice, len(invoices)) + response := make([]Invoice, len(invoices)) for i, invoice := range invoices { - rhash, _ := lib.ToJavaScriptBuffer(invoice.RHash) - response[i] = OutgoingInvoice{ - RHash: rhash, - PaymentHash: rhash, + response[i] = Invoice{ + PaymentHash: invoice.RHash, + PaymentRequest: invoice.PaymentRequest, + Description: invoice.Memo, + DescriptionHash: invoice.DescriptionHash, PaymentPreimage: invoice.Preimage, - Value: invoice.Amount, - Type: common.InvoiceTypePaid, + Destination: invoice.DestinationPubkeyHex, + Amount: invoice.Amount, Fee: invoice.Fee, - Timestamp: invoice.CreatedAt.Unix(), - Memo: invoice.Memo, + Status: invoice.State, + Type: common.InvoiceTypePaid, + ErrorMessage: invoice.ErrorMessage, + SettledAt: invoice.SettledAt.Time, + ExpiresAt: invoice.ExpiresAt.Time, + IsPaid: invoice.State == common.InvoiceStateSettled, Keysend: invoice.Keysend, CustomRecords: invoice.DestinationCustomRecords, } @@ -86,16 +82,16 @@ func (controller *InvoiceController) GetOutgoingInvoices(c echo.Context) error { return c.JSON(http.StatusOK, &response) } -// GetUserInvoices godoc +// GetIncomingInvoices godoc // @Summary Retrieve incoming invoices // @Description Returns a list of incoming invoices for a user // @Accept json // @Produce json // @Tags Account -// @Success 200 {object} []IncomingInvoice +// @Success 200 {object} []Invoice // @Failure 400 {object} responses.ErrorResponse // @Failure 500 {object} responses.ErrorResponse -// @Router /getuserinvoices [get] +// @Router /v2/invoices/incoming [get] // @Security OAuth2Password func (controller *InvoiceController) GetIncomingInvoices(c echo.Context) error { userId := c.Get("UserID").(int64) @@ -105,37 +101,40 @@ func (controller *InvoiceController) GetIncomingInvoices(c echo.Context) error { return err } - response := make([]IncomingInvoice, len(invoices)) + response := make([]Invoice, len(invoices)) for i, invoice := range invoices { - rhash, _ := lib.ToJavaScriptBuffer(invoice.RHash) - response[i] = IncomingInvoice{ - RHash: rhash, - PaymentHash: invoice.RHash, - PaymentRequest: invoice.PaymentRequest, - Description: invoice.Memo, - PayReq: invoice.PaymentRequest, - Timestamp: invoice.CreatedAt.Unix(), - Type: common.InvoiceTypeUser, - ExpireTime: 3600 * 24, - Amount: invoice.Amount, - IsPaid: invoice.State == common.InvoiceStateSettled, - Keysend: invoice.Keysend, - CustomRecords: invoice.DestinationCustomRecords, + response[i] = Invoice{ + PaymentHash: invoice.RHash, + PaymentRequest: invoice.PaymentRequest, + Description: invoice.Memo, + DescriptionHash: invoice.DescriptionHash, + PaymentPreimage: invoice.Preimage, + Destination: invoice.DestinationPubkeyHex, + Amount: invoice.Amount, + Fee: invoice.Fee, + Status: invoice.State, + Type: common.InvoiceTypeUser, + ErrorMessage: invoice.ErrorMessage, + SettledAt: invoice.SettledAt.Time, + ExpiresAt: invoice.ExpiresAt.Time, + IsPaid: invoice.State == common.InvoiceStateSettled, + Keysend: invoice.Keysend, + CustomRecords: invoice.DestinationCustomRecords, } } return c.JSON(http.StatusOK, &response) } type AddInvoiceRequestBody struct { - Amount interface{} `json:"amt"` // amount in Satoshi - Memo string `json:"memo"` - DescriptionHash string `json:"description_hash" validate:"omitempty,hexadecimal,len=64"` + Amount int64 `json:"amount" validate:"required,gt=0"` + Description string `json:"description"` + DescriptionHash string `json:"description_hash" validate:"omitempty,hexadecimal,len=64"` } type AddInvoiceResponseBody struct { - RHash string `json:"r_hash"` - PaymentRequest string `json:"payment_request"` - PayReq string `json:"pay_req"` + PaymentHash string `json:"payment_hash"` + PaymentRequest string `json:"payment_request"` + ExpiresAt time.Time `json:"expires_at"` } // AddInvoice godoc @@ -148,7 +147,7 @@ type AddInvoiceResponseBody struct { // @Success 200 {object} AddInvoiceResponseBody // @Failure 400 {object} responses.ErrorResponse // @Failure 500 {object} responses.ErrorResponse -// @Router /addinvoice [post] +// @Router /v2/invoices [post] // @Security OAuth2Password func (controller *InvoiceController) AddInvoice(c echo.Context) error { userID := c.Get("UserID").(int64) @@ -168,18 +167,19 @@ func (controller *InvoiceController) AddInvoice(c echo.Context) error { if err != nil || amount < 0 { return c.JSON(http.StatusBadRequest, responses.BadArgumentsError) } - c.Logger().Infof("Adding invoice: user_id:%v memo:%s value:%v description_hash:%s", userID, body.Memo, amount, body.DescriptionHash) + c.Logger().Infof("Adding invoice: user_id:%v memo:%s value:%v description_hash:%s", userID, body.Description, amount, body.DescriptionHash) - invoice, err := controller.svc.AddIncomingInvoice(c.Request().Context(), userID, amount, body.Memo, body.DescriptionHash) + invoice, err := controller.svc.AddIncomingInvoice(c.Request().Context(), userID, amount, body.Description, body.DescriptionHash) if err != nil { c.Logger().Errorf("Error creating invoice: user_id:%v error: %v", userID, err) sentry.CaptureException(err) return c.JSON(http.StatusBadRequest, responses.BadArgumentsError) } - responseBody := AddInvoiceResponseBody{} - responseBody.RHash = invoice.RHash - responseBody.PaymentRequest = invoice.PaymentRequest - responseBody.PayReq = invoice.PaymentRequest + responseBody := AddInvoiceResponseBody{ + PaymentHash: invoice.RHash, + PaymentRequest: invoice.PaymentRequest, + ExpiresAt: invoice.ExpiresAt.Time, + } return c.JSON(http.StatusOK, &responseBody) } diff --git a/controllers_v2/keysend.ctrl.go b/controllers_v2/keysend.ctrl.go index 35c18eb..6708511 100644 --- a/controllers_v2/keysend.ctrl.go +++ b/controllers_v2/keysend.ctrl.go @@ -1,11 +1,9 @@ package v2controllers import ( - "fmt" "net/http" "strconv" - "github.com/getAlby/lndhub.go/lib" "github.com/getAlby/lndhub.go/lib/responses" "github.com/getAlby/lndhub.go/lib/service" "github.com/getAlby/lndhub.go/lnd" @@ -31,14 +29,14 @@ type KeySendRequestBody struct { } type KeySendResponseBody struct { - RHash *lib.JavaScriptBuffer `json:"payment_hash,omitempty"` - Amount int64 `json:"num_satoshis,omitempty"` - Description string `json:"description,omitempty"` - Destination string `json:"destination,omitempty"` - DescriptionHashStr string `json:"description_hash,omitempty"` - PaymentError string `json:"payment_error,omitempty"` - PaymentPreimage *lib.JavaScriptBuffer `json:"payment_preimage,omitempty"` - PaymentRoute *service.Route `json:"payment_route,omitempty"` + Amount int64 `json:"amount,omitempty"` + Fee int64 `json:"fee,omitempty"` + Description string `json:"description,omitempty"` + DescriptionHash string `json:"description_hash,omitempty"` + Destination string `json:"destination,omitempty"` + PaymentError string `json:"payment_error,omitempty"` + PaymentPreimage string `json:"payment_preimage,omitempty"` + PaymentHash string `json:"payment_hash,omitempty"` } //// KeySend godoc @@ -51,7 +49,7 @@ type KeySendResponseBody struct { // @Success 200 {object} KeySendResponseBody // @Failure 400 {object} responses.ErrorResponse // @Failure 500 {object} responses.ErrorResponse -// @Router /keysend [post] +// @Router /v2/payments/keysend [post] // @Security OAuth2Password func (controller *KeySendController) KeySend(c echo.Context) error { userID := c.Get("UserID").(int64) @@ -109,19 +107,20 @@ func (controller *KeySendController) KeySend(c echo.Context) error { return c.JSON(http.StatusBadRequest, echo.Map{ "error": true, "code": 10, - "message": fmt.Sprintf("Payment failed. Does the receiver have enough inbound capacity? (%v)", err), + "message": err.Error(), }) } - responseBody := &KeySendResponseBody{} - responseBody.RHash = &lib.JavaScriptBuffer{Data: sendPaymentResponse.PaymentHash} - responseBody.Amount = invoice.Amount - responseBody.Destination = invoice.DestinationPubkeyHex - responseBody.Description = invoice.Memo - responseBody.DescriptionHashStr = invoice.DescriptionHash - responseBody.PaymentError = sendPaymentResponse.PaymentError - responseBody.PaymentPreimage = &lib.JavaScriptBuffer{Data: sendPaymentResponse.PaymentPreimage} - responseBody.PaymentRoute = sendPaymentResponse.PaymentRoute + responseBody := &KeySendResponseBody{ + Amount: sendPaymentResponse.Invoice.Amount, + Fee: sendPaymentResponse.Invoice.Fee, + Description: sendPaymentResponse.Invoice.Memo, + DescriptionHash: sendPaymentResponse.Invoice.DescriptionHash, + Destination: sendPaymentResponse.Invoice.DestinationPubkeyHex, + PaymentError: sendPaymentResponse.PaymentError, + PaymentPreimage: sendPaymentResponse.PaymentPreimageStr, + PaymentHash: sendPaymentResponse.PaymentHashStr, + } return c.JSON(http.StatusOK, responseBody) } diff --git a/controllers_v2/payinvoice.ctrl.go b/controllers_v2/payinvoice.ctrl.go index 441583a..157d8e6 100644 --- a/controllers_v2/payinvoice.ctrl.go +++ b/controllers_v2/payinvoice.ctrl.go @@ -1,11 +1,9 @@ package v2controllers import ( - "fmt" "net/http" "strings" - "github.com/getAlby/lndhub.go/lib" "github.com/getAlby/lndhub.go/lib/responses" "github.com/getAlby/lndhub.go/lib/service" "github.com/getAlby/lndhub.go/lnd" @@ -24,19 +22,19 @@ func NewPayInvoiceController(svc *service.LndhubService) *PayInvoiceController { } type PayInvoiceRequestBody struct { - Invoice string `json:"invoice" validate:"required"` - Amount interface{} `json:"amount" validate:"omitempty"` + Invoice string `json:"invoice" validate:"required"` + Amount int64 `json:"amount" validate:"omitempty,gte=0"` } type PayInvoiceResponseBody struct { - RHash *lib.JavaScriptBuffer `json:"payment_hash,omitempty"` - PaymentRequest string `json:"payment_request,omitempty"` - PayReq string `json:"pay_req,omitempty"` - Amount int64 `json:"num_satoshis,omitempty"` - Description string `json:"description,omitempty"` - DescriptionHashStr string `json:"description_hash,omitempty"` - PaymentError string `json:"payment_error,omitempty"` - PaymentPreimage *lib.JavaScriptBuffer `json:"payment_preimage,omitempty"` - PaymentRoute *service.Route `json:"payment_route,omitempty"` + PaymentRequest string `json:"payment_request,omitempty"` + Amount int64 `json:"amount,omitempty"` + Fee int64 `json:"fee,omitempty"` + Description string `json:"description,omitempty"` + DescriptionHash string `json:"description_hash,omitempty"` + Destination string `json:"destination,omitempty"` + PaymentError string `json:"payment_error,omitempty"` + PaymentPreimage string `json:"payment_preimage,omitempty"` + PaymentHash string `json:"payment_hash,omitempty"` } // PayInvoice godoc @@ -49,7 +47,7 @@ type PayInvoiceResponseBody struct { // @Success 200 {object} PayInvoiceResponseBody // @Failure 400 {object} responses.ErrorResponse // @Failure 500 {object} responses.ErrorResponse -// @Router /payinvoice [post] +// @Router /v2/payments/bolt11 [post] // @Security OAuth2Password func (controller *PayInvoiceController) PayInvoice(c echo.Context) error { userID := c.Get("UserID").(int64) @@ -115,22 +113,22 @@ func (controller *PayInvoiceController) PayInvoice(c echo.Context) error { hub.CaptureException(err) }) } - return c.JSON(http.StatusBadRequest, echo.Map{ + return c.JSON(http.StatusInternalServerError, echo.Map{ "error": true, "code": 10, - "message": fmt.Sprintf("Payment failed. Does the receiver have enough inbound capacity? (%v)", err), + "message": err.Error(), }) } - responseBody := &PayInvoiceResponseBody{} - responseBody.RHash = &lib.JavaScriptBuffer{Data: sendPaymentResponse.PaymentHash} - responseBody.PaymentRequest = paymentRequest - responseBody.PayReq = paymentRequest - responseBody.Amount = invoice.Amount - responseBody.Description = invoice.Memo - responseBody.DescriptionHashStr = invoice.DescriptionHash - responseBody.PaymentError = sendPaymentResponse.PaymentError - responseBody.PaymentPreimage = &lib.JavaScriptBuffer{Data: sendPaymentResponse.PaymentPreimage} - responseBody.PaymentRoute = sendPaymentResponse.PaymentRoute + responseBody := &PayInvoiceResponseBody{ + Amount: sendPaymentResponse.Invoice.Amount, + Fee: sendPaymentResponse.Invoice.Fee, + Description: sendPaymentResponse.Invoice.Memo, + DescriptionHash: sendPaymentResponse.Invoice.DescriptionHash, + Destination: sendPaymentResponse.Invoice.DestinationPubkeyHex, + PaymentError: sendPaymentResponse.PaymentError, + PaymentPreimage: sendPaymentResponse.PaymentPreimageStr, + PaymentHash: sendPaymentResponse.PaymentHashStr, + } return c.JSON(http.StatusOK, responseBody) } diff --git a/docs/docs.go b/docs/docs.go index 72ce1aa..df51af4 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -24,57 +24,6 @@ const docTemplate = `{ "host": "{{.Host}}", "basePath": "{{.BasePath}}", "paths": { - "/addinvoice": { - "post": { - "security": [ - { - "OAuth2Password": [] - } - ], - "description": "Returns a new bolt11 invoice", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Invoice" - ], - "summary": "Generate a new invoice", - "parameters": [ - { - "description": "Add Invoice", - "name": "invoice", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/controllers.AddInvoiceRequestBody" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.AddInvoiceResponseBody" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/responses.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/responses.ErrorResponse" - } - } - } - } - }, "/auth": { "post": { "description": "Exchanges a login + password for a token", @@ -120,7 +69,7 @@ const docTemplate = `{ } } }, - "/balance": { + "/v2/balance": { "get": { "security": [ { @@ -142,7 +91,7 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/controllers.BalanceResponse" + "$ref": "#/definitions/v2controllers.BalanceResponse" } }, "400": { @@ -160,14 +109,14 @@ const docTemplate = `{ } } }, - "/checkpayment/{payment_hash}": { - "get": { + "/v2/invoices": { + "post": { "security": [ { "OAuth2Password": [] } ], - "description": "Checks if an invoice is paid, can be incoming our outgoing", + "description": "Returns a new bolt11 invoice", "consumes": [ "application/json" ], @@ -177,58 +126,15 @@ const docTemplate = `{ "tags": [ "Invoice" ], - "summary": "Check if an invoice is paid", + "summary": "Generate a new invoice", "parameters": [ { - "type": "string", - "description": "Payment hash", - "name": "payment_hash", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.CheckPaymentResponseBody" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/responses.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/responses.ErrorResponse" - } - } - } - } - }, - "/create": { - "post": { - "description": "Create a new account with a login and password", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Account" - ], - "summary": "Create an account", - "parameters": [ - { - "description": "Create User", - "name": "account", + "description": "Add Invoice", + "name": "invoice", "in": "body", + "required": true, "schema": { - "$ref": "#/definitions/controllers.CreateUserRequestBody" + "$ref": "#/definitions/v2controllers.AddInvoiceRequestBody" } } ], @@ -236,7 +142,7 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/controllers.CreateUserResponseBody" + "$ref": "#/definitions/v2controllers.AddInvoiceResponseBody" } }, "400": { @@ -254,90 +160,7 @@ const docTemplate = `{ } } }, - "/getinfo": { - "get": { - "security": [ - { - "OAuth2Password": [] - } - ], - "description": "Returns info about the backend node powering this LNDhub instance", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Info" - ], - "summary": "Get info about the Lightning node", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.GetInfoResponse" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/responses.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/responses.ErrorResponse" - } - } - } - } - }, - "/gettxs": { - "get": { - "security": [ - { - "OAuth2Password": [] - } - ], - "description": "Returns a list of outgoing payments for a user", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Account" - ], - "summary": "Retrieve outgoing payments", - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/controllers.OutgoingInvoice" - } - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/responses.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/responses.ErrorResponse" - } - } - } - } - }, - "/getuserinvoices": { + "/v2/invoices/incoming": { "get": { "security": [ { @@ -361,7 +184,7 @@ const docTemplate = `{ "schema": { "type": "array", "items": { - "$ref": "#/definitions/controllers.IncomingInvoice" + "$ref": "#/definitions/v2controllers.Invoice" } } }, @@ -380,67 +203,14 @@ const docTemplate = `{ } } }, - "/invoice/{user_login}": { - "post": { - "description": "Returns a new bolt11 invoice for a user with given login, without an Authorization Header", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Invoice" - ], - "summary": "Generate a new invoice", - "parameters": [ - { - "type": "string", - "description": "User Login", - "name": "user_login", - "in": "path", - "required": true - }, - { - "description": "Add Invoice", - "name": "invoice", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/controllers.AddInvoiceRequestBody" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.AddInvoiceResponseBody" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/responses.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/responses.ErrorResponse" - } - } - } - } - }, - "/invoices/stream": { + "/v2/invoices/outgoing": { "get": { "security": [ { "OAuth2Password": [] } ], - "description": "Websocket: won't work with Swagger web UI. Returns a stream of settled incoming payments.\nA keep-alive message is sent on startup and every 30s.", + "description": "Returns a list of outgoing payments for a user", "consumes": [ "application/json" ], @@ -448,31 +218,16 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Invoice" - ], - "summary": "Websocket for incoming payments", - "parameters": [ - { - "type": "string", - "description": "Auth token, retrieved from /auth endpoint", - "name": "token", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "Payment hash of earliest invoice. If specified, missing updates starting from this payment will be sent.", - "name": "since_payment_hash", - "in": "query" - } + "Account" ], + "summary": "Retrieve outgoing payments", "responses": { "200": { "description": "OK", "schema": { "type": "array", "items": { - "$ref": "#/definitions/controllers.InvoiceEventWrapper" + "$ref": "#/definitions/v2controllers.Invoice" } } }, @@ -491,58 +246,7 @@ const docTemplate = `{ } } }, - "/keysend": { - "post": { - "security": [ - { - "OAuth2Password": [] - } - ], - "description": "Pay a node without an invoice using it's public key", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Payment" - ], - "summary": "Make a keysend payment", - "parameters": [ - { - "description": "Invoice to pay", - "name": "KeySendRequestBody", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/controllers.KeySendRequestBody" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.KeySendResponseBody" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/responses.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/responses.ErrorResponse" - } - } - } - } - }, - "/payinvoice": { + "/v2/payments/bolt11": { "post": { "security": [ { @@ -567,7 +271,7 @@ const docTemplate = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/controllers.PayInvoiceRequestBody" + "$ref": "#/definitions/v2controllers.PayInvoiceRequestBody" } } ], @@ -575,7 +279,103 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/controllers.PayInvoiceResponseBody" + "$ref": "#/definitions/v2controllers.PayInvoiceResponseBody" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/responses.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/responses.ErrorResponse" + } + } + } + } + }, + "/v2/payments/keysend": { + "post": { + "security": [ + { + "OAuth2Password": [] + } + ], + "description": "Pay a node without an invoice using it's public key", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Payment" + ], + "summary": "Make a keysend payment", + "parameters": [ + { + "description": "Invoice to pay", + "name": "KeySendRequestBody", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v2controllers.KeySendRequestBody" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v2controllers.KeySendResponseBody" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/responses.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/responses.ErrorResponse" + } + } + } + } + }, + "/v2/users": { + "post": { + "description": "Create a new account with a username and password", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Account" + ], + "summary": "Create an account", + "parameters": [ + { + "description": "Create User", + "name": "account", + "in": "body", + "schema": { + "$ref": "#/definitions/v2controllers.CreateUserRequestBody" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v2controllers.CreateUserResponseBody" } }, "400": { @@ -595,34 +395,6 @@ const docTemplate = `{ } }, "definitions": { - "controllers.AddInvoiceRequestBody": { - "type": "object", - "properties": { - "amt": { - "description": "amount in Satoshi" - }, - "description_hash": { - "type": "string" - }, - "memo": { - "type": "string" - } - } - }, - "controllers.AddInvoiceResponseBody": { - "type": "object", - "properties": { - "pay_req": { - "type": "string" - }, - "payment_request": { - "type": "string" - }, - "r_hash": { - "type": "string" - } - } - }, "controllers.AuthRequestBody": { "type": "object", "properties": { @@ -648,172 +420,91 @@ const docTemplate = `{ } } }, - "controllers.BalanceResponse": { + "responses.ErrorResponse": { "type": "object", "properties": { - "btc": { - "type": "object", - "properties": { - "availableBalance": { - "type": "integer" - } - } - } - } - }, - "controllers.Chain": { - "type": "object", - "properties": { - "chain": { - "description": "The blockchain the node is on (eg bitcoin, litecoin)", - "type": "string" + "code": { + "type": "integer" }, - "network": { - "description": "The network the node is on (eg regtest, testnet, mainnet)", - "type": "string" - } - } - }, - "controllers.CheckPaymentResponseBody": { - "type": "object", - "properties": { - "paid": { + "error": { "type": "boolean" + }, + "message": { + "type": "string" } } }, - "controllers.CreateUserRequestBody": { + "v2controllers.AddInvoiceRequestBody": { + "type": "object", + "required": [ + "amount" + ], + "properties": { + "amount": { + "type": "integer" + }, + "description": { + "type": "string" + }, + "description_hash": { + "type": "string" + } + } + }, + "v2controllers.AddInvoiceResponseBody": { "type": "object", "properties": { - "accounttype": { + "expires_at": { "type": "string" }, - "login": { + "payment_hash": { "type": "string" }, - "partnerid": { + "payment_request": { + "type": "string" + } + } + }, + "v2controllers.BalanceResponse": { + "type": "object", + "properties": { + "balance": { + "type": "integer" + }, + "currency": { "type": "string" }, + "unit": { + "type": "string" + } + } + }, + "v2controllers.CreateUserRequestBody": { + "type": "object", + "properties": { "password": { "type": "string" + }, + "username": { + "type": "string" } } }, - "controllers.CreateUserResponseBody": { + "v2controllers.CreateUserResponseBody": { "type": "object", "properties": { - "login": { - "type": "string" - }, "password": { "type": "string" - } - } - }, - "controllers.Feature": { - "type": "object", - "properties": { - "is_known": { - "type": "boolean" }, - "is_required": { - "type": "boolean" - }, - "name": { + "username": { "type": "string" } } }, - "controllers.GetInfoResponse": { + "v2controllers.Invoice": { "type": "object", "properties": { - "alias": { - "description": "If applicable, the alias of the current node, e.g. \"bob\"", - "type": "string" - }, - "best_header_timestamp": { - "description": "Timestamp of the block best known to the wallet", - "type": "integer" - }, - "block_hash": { - "description": "The node's current view of the hash of the best block", - "type": "string" - }, - "block_height": { - "description": "The node's current view of the height of the best block", - "type": "integer" - }, - "chains": { - "description": "A list of active chains the node is connected to", - "type": "array", - "items": { - "$ref": "#/definitions/controllers.Chain" - } - }, - "color": { - "description": "The color of the current node in hex code format", - "type": "string" - }, - "commit_hash": { - "description": "The SHA1 commit hash that the daemon is compiled with.", - "type": "string" - }, - "features": { - "description": "Features that our node has advertised in our init message, node\nannouncements and invoices.", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/controllers.Feature" - } - }, - "identity_pubkey": { - "description": "The identity pubkey of the current node.", - "type": "string" - }, - "num_active_channels": { - "description": "Number of active channels", - "type": "integer" - }, - "num_inactive_channels": { - "description": "Number of inactive channels", - "type": "integer" - }, - "num_peers": { - "description": "Number of peers", - "type": "integer" - }, - "num_pending_channels": { - "description": "Number of pending channels", - "type": "integer" - }, - "synced_to_chain": { - "description": "Whether the wallet's view is synced to the main chain", - "type": "boolean" - }, - "synced_to_graph": { - "description": "Whether we consider ourselves synced with the public channel graph.", - "type": "boolean" - }, - "testnet": { - "description": "Whether the current node is connected to testnet. This field is\ndeprecated and the network field should be used instead\n\nDeprecated: Do not use.", - "type": "boolean" - }, - "uris": { - "description": "The URIs of the current node.", - "type": "array", - "items": { - "type": "string" - } - }, - "version": { - "description": "The version of the LND software that the node is running.", - "type": "string" - } - } - }, - "controllers.IncomingInvoice": { - "type": "object", - "properties": { - "amt": { + "amount": { "type": "integer" }, "custom_records": { @@ -828,43 +519,48 @@ const docTemplate = `{ "description": { "type": "string" }, - "expire_time": { + "description_hash": { + "type": "string" + }, + "destination": { + "type": "string" + }, + "error_message": { + "type": "string" + }, + "expires_at": { + "type": "string" + }, + "fee": { "type": "integer" }, - "ispaid": { + "is_paid": { "type": "boolean" }, "keysend": { "type": "boolean" }, - "pay_req": { + "payment_hash": { + "type": "string" + }, + "payment_preimage": { "type": "string" }, - "payment_hash": {}, "payment_request": { "type": "string" }, - "r_hash": {}, - "timestamp": { - "type": "integer" + "settled_at": { + "type": "string" + }, + "status": { + "type": "string" }, "type": { "type": "string" } } }, - "controllers.InvoiceEventWrapper": { - "type": "object", - "properties": { - "invoice": { - "$ref": "#/definitions/controllers.IncomingInvoice" - }, - "type": { - "type": "string" - } - } - }, - "controllers.KeySendRequestBody": { + "v2controllers.KeySendRequestBody": { "type": "object", "required": [ "amount", @@ -888,9 +584,12 @@ const docTemplate = `{ } } }, - "controllers.KeySendResponseBody": { + "v2controllers.KeySendResponseBody": { "type": "object", "properties": { + "amount": { + "type": "integer" + }, "description": { "type": "string" }, @@ -900,137 +599,64 @@ const docTemplate = `{ "destination": { "type": "string" }, - "num_satoshis": { + "fee": { "type": "integer" }, "payment_error": { "type": "string" }, "payment_hash": { - "$ref": "#/definitions/lib.JavaScriptBuffer" + "type": "string" }, "payment_preimage": { - "$ref": "#/definitions/lib.JavaScriptBuffer" - }, - "payment_route": { - "$ref": "#/definitions/service.Route" + "type": "string" } } }, - "controllers.OutgoingInvoice": { - "type": "object", - "properties": { - "custom_records": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "integer" - } - } - }, - "fee": { - "type": "integer" - }, - "keysend": { - "type": "boolean" - }, - "memo": { - "type": "string" - }, - "payment_hash": {}, - "payment_preimage": { - "type": "string" - }, - "r_hash": {}, - "timestamp": { - "type": "integer" - }, - "type": { - "type": "string" - }, - "value": { - "type": "integer" - } - } - }, - "controllers.PayInvoiceRequestBody": { + "v2controllers.PayInvoiceRequestBody": { "type": "object", "required": [ "invoice" ], "properties": { - "amount": {}, + "amount": { + "type": "integer", + "minimum": 0 + }, "invoice": { "type": "string" } } }, - "controllers.PayInvoiceResponseBody": { + "v2controllers.PayInvoiceResponseBody": { "type": "object", "properties": { + "amount": { + "type": "integer" + }, "description": { "type": "string" }, "description_hash": { "type": "string" }, - "num_satoshis": { - "type": "integer" - }, - "pay_req": { + "destination": { "type": "string" }, + "fee": { + "type": "integer" + }, "payment_error": { "type": "string" }, "payment_hash": { - "$ref": "#/definitions/lib.JavaScriptBuffer" + "type": "string" }, "payment_preimage": { - "$ref": "#/definitions/lib.JavaScriptBuffer" + "type": "string" }, "payment_request": { "type": "string" - }, - "payment_route": { - "$ref": "#/definitions/service.Route" - } - } - }, - "lib.JavaScriptBuffer": { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "type": "integer" - } - } - } - }, - "responses.ErrorResponse": { - "type": "object", - "properties": { - "code": { - "type": "integer" - }, - "error": { - "type": "boolean" - }, - "message": { - "type": "string" - } - } - }, - "service.Route": { - "type": "object", - "properties": { - "total_amt": { - "type": "integer" - }, - "total_fees": { - "type": "integer" } } } diff --git a/docs/swagger.json b/docs/swagger.json index 49c2eb9..394e889 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -20,57 +20,6 @@ }, "basePath": "/", "paths": { - "/addinvoice": { - "post": { - "security": [ - { - "OAuth2Password": [] - } - ], - "description": "Returns a new bolt11 invoice", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Invoice" - ], - "summary": "Generate a new invoice", - "parameters": [ - { - "description": "Add Invoice", - "name": "invoice", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/controllers.AddInvoiceRequestBody" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.AddInvoiceResponseBody" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/responses.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/responses.ErrorResponse" - } - } - } - } - }, "/auth": { "post": { "description": "Exchanges a login + password for a token", @@ -116,7 +65,7 @@ } } }, - "/balance": { + "/v2/balance": { "get": { "security": [ { @@ -138,7 +87,7 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/controllers.BalanceResponse" + "$ref": "#/definitions/v2controllers.BalanceResponse" } }, "400": { @@ -156,14 +105,14 @@ } } }, - "/checkpayment/{payment_hash}": { - "get": { + "/v2/invoices": { + "post": { "security": [ { "OAuth2Password": [] } ], - "description": "Checks if an invoice is paid, can be incoming our outgoing", + "description": "Returns a new bolt11 invoice", "consumes": [ "application/json" ], @@ -173,58 +122,15 @@ "tags": [ "Invoice" ], - "summary": "Check if an invoice is paid", + "summary": "Generate a new invoice", "parameters": [ { - "type": "string", - "description": "Payment hash", - "name": "payment_hash", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.CheckPaymentResponseBody" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/responses.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/responses.ErrorResponse" - } - } - } - } - }, - "/create": { - "post": { - "description": "Create a new account with a login and password", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Account" - ], - "summary": "Create an account", - "parameters": [ - { - "description": "Create User", - "name": "account", + "description": "Add Invoice", + "name": "invoice", "in": "body", + "required": true, "schema": { - "$ref": "#/definitions/controllers.CreateUserRequestBody" + "$ref": "#/definitions/v2controllers.AddInvoiceRequestBody" } } ], @@ -232,7 +138,7 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/controllers.CreateUserResponseBody" + "$ref": "#/definitions/v2controllers.AddInvoiceResponseBody" } }, "400": { @@ -250,90 +156,7 @@ } } }, - "/getinfo": { - "get": { - "security": [ - { - "OAuth2Password": [] - } - ], - "description": "Returns info about the backend node powering this LNDhub instance", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Info" - ], - "summary": "Get info about the Lightning node", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.GetInfoResponse" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/responses.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/responses.ErrorResponse" - } - } - } - } - }, - "/gettxs": { - "get": { - "security": [ - { - "OAuth2Password": [] - } - ], - "description": "Returns a list of outgoing payments for a user", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Account" - ], - "summary": "Retrieve outgoing payments", - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/controllers.OutgoingInvoice" - } - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/responses.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/responses.ErrorResponse" - } - } - } - } - }, - "/getuserinvoices": { + "/v2/invoices/incoming": { "get": { "security": [ { @@ -357,7 +180,7 @@ "schema": { "type": "array", "items": { - "$ref": "#/definitions/controllers.IncomingInvoice" + "$ref": "#/definitions/v2controllers.Invoice" } } }, @@ -376,67 +199,14 @@ } } }, - "/invoice/{user_login}": { - "post": { - "description": "Returns a new bolt11 invoice for a user with given login, without an Authorization Header", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Invoice" - ], - "summary": "Generate a new invoice", - "parameters": [ - { - "type": "string", - "description": "User Login", - "name": "user_login", - "in": "path", - "required": true - }, - { - "description": "Add Invoice", - "name": "invoice", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/controllers.AddInvoiceRequestBody" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.AddInvoiceResponseBody" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/responses.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/responses.ErrorResponse" - } - } - } - } - }, - "/invoices/stream": { + "/v2/invoices/outgoing": { "get": { "security": [ { "OAuth2Password": [] } ], - "description": "Websocket: won't work with Swagger web UI. Returns a stream of settled incoming payments.\nA keep-alive message is sent on startup and every 30s.", + "description": "Returns a list of outgoing payments for a user", "consumes": [ "application/json" ], @@ -444,31 +214,16 @@ "application/json" ], "tags": [ - "Invoice" - ], - "summary": "Websocket for incoming payments", - "parameters": [ - { - "type": "string", - "description": "Auth token, retrieved from /auth endpoint", - "name": "token", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "Payment hash of earliest invoice. If specified, missing updates starting from this payment will be sent.", - "name": "since_payment_hash", - "in": "query" - } + "Account" ], + "summary": "Retrieve outgoing payments", "responses": { "200": { "description": "OK", "schema": { "type": "array", "items": { - "$ref": "#/definitions/controllers.InvoiceEventWrapper" + "$ref": "#/definitions/v2controllers.Invoice" } } }, @@ -487,58 +242,7 @@ } } }, - "/keysend": { - "post": { - "security": [ - { - "OAuth2Password": [] - } - ], - "description": "Pay a node without an invoice using it's public key", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Payment" - ], - "summary": "Make a keysend payment", - "parameters": [ - { - "description": "Invoice to pay", - "name": "KeySendRequestBody", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/controllers.KeySendRequestBody" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.KeySendResponseBody" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/responses.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/responses.ErrorResponse" - } - } - } - } - }, - "/payinvoice": { + "/v2/payments/bolt11": { "post": { "security": [ { @@ -563,7 +267,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/controllers.PayInvoiceRequestBody" + "$ref": "#/definitions/v2controllers.PayInvoiceRequestBody" } } ], @@ -571,7 +275,103 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/controllers.PayInvoiceResponseBody" + "$ref": "#/definitions/v2controllers.PayInvoiceResponseBody" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/responses.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/responses.ErrorResponse" + } + } + } + } + }, + "/v2/payments/keysend": { + "post": { + "security": [ + { + "OAuth2Password": [] + } + ], + "description": "Pay a node without an invoice using it's public key", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Payment" + ], + "summary": "Make a keysend payment", + "parameters": [ + { + "description": "Invoice to pay", + "name": "KeySendRequestBody", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v2controllers.KeySendRequestBody" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v2controllers.KeySendResponseBody" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/responses.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/responses.ErrorResponse" + } + } + } + } + }, + "/v2/users": { + "post": { + "description": "Create a new account with a username and password", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Account" + ], + "summary": "Create an account", + "parameters": [ + { + "description": "Create User", + "name": "account", + "in": "body", + "schema": { + "$ref": "#/definitions/v2controllers.CreateUserRequestBody" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v2controllers.CreateUserResponseBody" } }, "400": { @@ -591,34 +391,6 @@ } }, "definitions": { - "controllers.AddInvoiceRequestBody": { - "type": "object", - "properties": { - "amt": { - "description": "amount in Satoshi" - }, - "description_hash": { - "type": "string" - }, - "memo": { - "type": "string" - } - } - }, - "controllers.AddInvoiceResponseBody": { - "type": "object", - "properties": { - "pay_req": { - "type": "string" - }, - "payment_request": { - "type": "string" - }, - "r_hash": { - "type": "string" - } - } - }, "controllers.AuthRequestBody": { "type": "object", "properties": { @@ -644,172 +416,91 @@ } } }, - "controllers.BalanceResponse": { + "responses.ErrorResponse": { "type": "object", "properties": { - "btc": { - "type": "object", - "properties": { - "availableBalance": { - "type": "integer" - } - } - } - } - }, - "controllers.Chain": { - "type": "object", - "properties": { - "chain": { - "description": "The blockchain the node is on (eg bitcoin, litecoin)", - "type": "string" + "code": { + "type": "integer" }, - "network": { - "description": "The network the node is on (eg regtest, testnet, mainnet)", - "type": "string" - } - } - }, - "controllers.CheckPaymentResponseBody": { - "type": "object", - "properties": { - "paid": { + "error": { "type": "boolean" + }, + "message": { + "type": "string" } } }, - "controllers.CreateUserRequestBody": { + "v2controllers.AddInvoiceRequestBody": { + "type": "object", + "required": [ + "amount" + ], + "properties": { + "amount": { + "type": "integer" + }, + "description": { + "type": "string" + }, + "description_hash": { + "type": "string" + } + } + }, + "v2controllers.AddInvoiceResponseBody": { "type": "object", "properties": { - "accounttype": { + "expires_at": { "type": "string" }, - "login": { + "payment_hash": { "type": "string" }, - "partnerid": { + "payment_request": { + "type": "string" + } + } + }, + "v2controllers.BalanceResponse": { + "type": "object", + "properties": { + "balance": { + "type": "integer" + }, + "currency": { "type": "string" }, + "unit": { + "type": "string" + } + } + }, + "v2controllers.CreateUserRequestBody": { + "type": "object", + "properties": { "password": { "type": "string" + }, + "username": { + "type": "string" } } }, - "controllers.CreateUserResponseBody": { + "v2controllers.CreateUserResponseBody": { "type": "object", "properties": { - "login": { - "type": "string" - }, "password": { "type": "string" - } - } - }, - "controllers.Feature": { - "type": "object", - "properties": { - "is_known": { - "type": "boolean" }, - "is_required": { - "type": "boolean" - }, - "name": { + "username": { "type": "string" } } }, - "controllers.GetInfoResponse": { + "v2controllers.Invoice": { "type": "object", "properties": { - "alias": { - "description": "If applicable, the alias of the current node, e.g. \"bob\"", - "type": "string" - }, - "best_header_timestamp": { - "description": "Timestamp of the block best known to the wallet", - "type": "integer" - }, - "block_hash": { - "description": "The node's current view of the hash of the best block", - "type": "string" - }, - "block_height": { - "description": "The node's current view of the height of the best block", - "type": "integer" - }, - "chains": { - "description": "A list of active chains the node is connected to", - "type": "array", - "items": { - "$ref": "#/definitions/controllers.Chain" - } - }, - "color": { - "description": "The color of the current node in hex code format", - "type": "string" - }, - "commit_hash": { - "description": "The SHA1 commit hash that the daemon is compiled with.", - "type": "string" - }, - "features": { - "description": "Features that our node has advertised in our init message, node\nannouncements and invoices.", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/controllers.Feature" - } - }, - "identity_pubkey": { - "description": "The identity pubkey of the current node.", - "type": "string" - }, - "num_active_channels": { - "description": "Number of active channels", - "type": "integer" - }, - "num_inactive_channels": { - "description": "Number of inactive channels", - "type": "integer" - }, - "num_peers": { - "description": "Number of peers", - "type": "integer" - }, - "num_pending_channels": { - "description": "Number of pending channels", - "type": "integer" - }, - "synced_to_chain": { - "description": "Whether the wallet's view is synced to the main chain", - "type": "boolean" - }, - "synced_to_graph": { - "description": "Whether we consider ourselves synced with the public channel graph.", - "type": "boolean" - }, - "testnet": { - "description": "Whether the current node is connected to testnet. This field is\ndeprecated and the network field should be used instead\n\nDeprecated: Do not use.", - "type": "boolean" - }, - "uris": { - "description": "The URIs of the current node.", - "type": "array", - "items": { - "type": "string" - } - }, - "version": { - "description": "The version of the LND software that the node is running.", - "type": "string" - } - } - }, - "controllers.IncomingInvoice": { - "type": "object", - "properties": { - "amt": { + "amount": { "type": "integer" }, "custom_records": { @@ -824,43 +515,48 @@ "description": { "type": "string" }, - "expire_time": { + "description_hash": { + "type": "string" + }, + "destination": { + "type": "string" + }, + "error_message": { + "type": "string" + }, + "expires_at": { + "type": "string" + }, + "fee": { "type": "integer" }, - "ispaid": { + "is_paid": { "type": "boolean" }, "keysend": { "type": "boolean" }, - "pay_req": { + "payment_hash": { + "type": "string" + }, + "payment_preimage": { "type": "string" }, - "payment_hash": {}, "payment_request": { "type": "string" }, - "r_hash": {}, - "timestamp": { - "type": "integer" + "settled_at": { + "type": "string" + }, + "status": { + "type": "string" }, "type": { "type": "string" } } }, - "controllers.InvoiceEventWrapper": { - "type": "object", - "properties": { - "invoice": { - "$ref": "#/definitions/controllers.IncomingInvoice" - }, - "type": { - "type": "string" - } - } - }, - "controllers.KeySendRequestBody": { + "v2controllers.KeySendRequestBody": { "type": "object", "required": [ "amount", @@ -884,9 +580,12 @@ } } }, - "controllers.KeySendResponseBody": { + "v2controllers.KeySendResponseBody": { "type": "object", "properties": { + "amount": { + "type": "integer" + }, "description": { "type": "string" }, @@ -896,137 +595,64 @@ "destination": { "type": "string" }, - "num_satoshis": { + "fee": { "type": "integer" }, "payment_error": { "type": "string" }, "payment_hash": { - "$ref": "#/definitions/lib.JavaScriptBuffer" + "type": "string" }, "payment_preimage": { - "$ref": "#/definitions/lib.JavaScriptBuffer" - }, - "payment_route": { - "$ref": "#/definitions/service.Route" + "type": "string" } } }, - "controllers.OutgoingInvoice": { - "type": "object", - "properties": { - "custom_records": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "integer" - } - } - }, - "fee": { - "type": "integer" - }, - "keysend": { - "type": "boolean" - }, - "memo": { - "type": "string" - }, - "payment_hash": {}, - "payment_preimage": { - "type": "string" - }, - "r_hash": {}, - "timestamp": { - "type": "integer" - }, - "type": { - "type": "string" - }, - "value": { - "type": "integer" - } - } - }, - "controllers.PayInvoiceRequestBody": { + "v2controllers.PayInvoiceRequestBody": { "type": "object", "required": [ "invoice" ], "properties": { - "amount": {}, + "amount": { + "type": "integer", + "minimum": 0 + }, "invoice": { "type": "string" } } }, - "controllers.PayInvoiceResponseBody": { + "v2controllers.PayInvoiceResponseBody": { "type": "object", "properties": { + "amount": { + "type": "integer" + }, "description": { "type": "string" }, "description_hash": { "type": "string" }, - "num_satoshis": { - "type": "integer" - }, - "pay_req": { + "destination": { "type": "string" }, + "fee": { + "type": "integer" + }, "payment_error": { "type": "string" }, "payment_hash": { - "$ref": "#/definitions/lib.JavaScriptBuffer" + "type": "string" }, "payment_preimage": { - "$ref": "#/definitions/lib.JavaScriptBuffer" + "type": "string" }, "payment_request": { "type": "string" - }, - "payment_route": { - "$ref": "#/definitions/service.Route" - } - } - }, - "lib.JavaScriptBuffer": { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "type": "integer" - } - } - } - }, - "responses.ErrorResponse": { - "type": "object", - "properties": { - "code": { - "type": "integer" - }, - "error": { - "type": "boolean" - }, - "message": { - "type": "string" - } - } - }, - "service.Route": { - "type": "object", - "properties": { - "total_amt": { - "type": "integer" - }, - "total_fees": { - "type": "integer" } } } diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 2264d19..1cc9159 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -1,23 +1,5 @@ basePath: / definitions: - controllers.AddInvoiceRequestBody: - properties: - amt: - description: amount in Satoshi - description_hash: - type: string - memo: - type: string - type: object - controllers.AddInvoiceResponseBody: - properties: - pay_req: - type: string - payment_request: - type: string - r_hash: - type: string - type: object controllers.AuthRequestBody: properties: login: @@ -34,128 +16,61 @@ definitions: refresh_token: type: string type: object - controllers.BalanceResponse: + responses.ErrorResponse: properties: - btc: - properties: - availableBalance: - type: integer - type: object - type: object - controllers.Chain: - properties: - chain: - description: The blockchain the node is on (eg bitcoin, litecoin) - type: string - network: - description: The network the node is on (eg regtest, testnet, mainnet) - type: string - type: object - controllers.CheckPaymentResponseBody: - properties: - paid: + code: + type: integer + error: type: boolean + message: + type: string type: object - controllers.CreateUserRequestBody: + v2controllers.AddInvoiceRequestBody: properties: - accounttype: + amount: + type: integer + description: type: string - login: + description_hash: type: string - partnerid: + required: + - amount + type: object + v2controllers.AddInvoiceResponseBody: + properties: + expires_at: type: string + payment_hash: + type: string + payment_request: + type: string + type: object + v2controllers.BalanceResponse: + properties: + balance: + type: integer + currency: + type: string + unit: + type: string + type: object + v2controllers.CreateUserRequestBody: + properties: password: type: string - type: object - controllers.CreateUserResponseBody: - properties: - login: + username: type: string + type: object + v2controllers.CreateUserResponseBody: + properties: password: type: string - type: object - controllers.Feature: - properties: - is_known: - type: boolean - is_required: - type: boolean - name: + username: type: string type: object - controllers.GetInfoResponse: + v2controllers.Invoice: properties: - alias: - description: If applicable, the alias of the current node, e.g. "bob" - type: string - best_header_timestamp: - description: Timestamp of the block best known to the wallet - type: integer - block_hash: - description: The node's current view of the hash of the best block - type: string - block_height: - description: The node's current view of the height of the best block - type: integer - chains: - description: A list of active chains the node is connected to - items: - $ref: '#/definitions/controllers.Chain' - type: array - color: - description: The color of the current node in hex code format - type: string - commit_hash: - description: The SHA1 commit hash that the daemon is compiled with. - type: string - features: - additionalProperties: - $ref: '#/definitions/controllers.Feature' - description: |- - Features that our node has advertised in our init message, node - announcements and invoices. - type: object - identity_pubkey: - description: The identity pubkey of the current node. - type: string - num_active_channels: - description: Number of active channels - type: integer - num_inactive_channels: - description: Number of inactive channels - type: integer - num_peers: - description: Number of peers - type: integer - num_pending_channels: - description: Number of pending channels - type: integer - synced_to_chain: - description: Whether the wallet's view is synced to the main chain - type: boolean - synced_to_graph: - description: Whether we consider ourselves synced with the public channel - graph. - type: boolean - testnet: - description: |- - Whether the current node is connected to testnet. This field is - deprecated and the network field should be used instead - - Deprecated: Do not use. - type: boolean - uris: - description: The URIs of the current node. - items: - type: string - type: array - version: - description: The version of the LND software that the node is running. - type: string - type: object - controllers.IncomingInvoice: - properties: - amt: + amount: type: integer custom_records: additionalProperties: @@ -165,31 +80,34 @@ definitions: type: object description: type: string - expire_time: + description_hash: + type: string + destination: + type: string + error_message: + type: string + expires_at: + type: string + fee: type: integer - ispaid: + is_paid: type: boolean keysend: type: boolean - pay_req: + payment_hash: + type: string + payment_preimage: type: string - payment_hash: {} payment_request: type: string - r_hash: {} - timestamp: - type: integer + settled_at: + type: string + status: + type: string type: type: string type: object - controllers.InvoiceEventWrapper: - properties: - invoice: - $ref: '#/definitions/controllers.IncomingInvoice' - type: - type: string - type: object - controllers.KeySendRequestBody: + v2controllers.KeySendRequestBody: properties: amount: type: integer @@ -205,101 +123,55 @@ definitions: - amount - destination type: object - controllers.KeySendResponseBody: + v2controllers.KeySendResponseBody: properties: + amount: + type: integer description: type: string description_hash: type: string destination: type: string - num_satoshis: + fee: type: integer payment_error: type: string payment_hash: - $ref: '#/definitions/lib.JavaScriptBuffer' - payment_preimage: - $ref: '#/definitions/lib.JavaScriptBuffer' - payment_route: - $ref: '#/definitions/service.Route' - type: object - controllers.OutgoingInvoice: - properties: - custom_records: - additionalProperties: - items: - type: integer - type: array - type: object - fee: - type: integer - keysend: - type: boolean - memo: type: string - payment_hash: {} payment_preimage: type: string - r_hash: {} - timestamp: - type: integer - type: - type: string - value: - type: integer type: object - controllers.PayInvoiceRequestBody: + v2controllers.PayInvoiceRequestBody: properties: - amount: {} + amount: + minimum: 0 + type: integer invoice: type: string required: - invoice type: object - controllers.PayInvoiceResponseBody: + v2controllers.PayInvoiceResponseBody: properties: + amount: + type: integer description: type: string description_hash: type: string - num_satoshis: - type: integer - pay_req: + destination: type: string + fee: + type: integer payment_error: type: string payment_hash: - $ref: '#/definitions/lib.JavaScriptBuffer' + type: string payment_preimage: - $ref: '#/definitions/lib.JavaScriptBuffer' + type: string payment_request: type: string - payment_route: - $ref: '#/definitions/service.Route' - type: object - lib.JavaScriptBuffer: - properties: - data: - items: - type: integer - type: array - type: object - responses.ErrorResponse: - properties: - code: - type: integer - error: - type: boolean - message: - type: string - type: object - service.Route: - properties: - total_amt: - type: integer - total_fees: - type: integer type: object info: contact: @@ -314,38 +186,6 @@ info: title: LNDhub.go version: 0.6.1 paths: - /addinvoice: - post: - consumes: - - application/json - description: Returns a new bolt11 invoice - parameters: - - description: Add Invoice - in: body - name: invoice - required: true - schema: - $ref: '#/definitions/controllers.AddInvoiceRequestBody' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/controllers.AddInvoiceResponseBody' - "400": - description: Bad Request - schema: - $ref: '#/definitions/responses.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/responses.ErrorResponse' - security: - - OAuth2Password: [] - summary: Generate a new invoice - tags: - - Invoice /auth: post: consumes: @@ -375,7 +215,7 @@ paths: summary: Authenticate tags: - Account - /balance: + /v2/balance: get: consumes: - application/json @@ -386,7 +226,7 @@ paths: "200": description: OK schema: - $ref: '#/definitions/controllers.BalanceResponse' + $ref: '#/definitions/v2controllers.BalanceResponse' "400": description: Bad Request schema: @@ -400,78 +240,25 @@ paths: summary: Retrieve balance tags: - Account - /checkpayment/{payment_hash}: - get: - consumes: - - application/json - description: Checks if an invoice is paid, can be incoming our outgoing - parameters: - - description: Payment hash - in: path - name: payment_hash - required: true - type: string - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/controllers.CheckPaymentResponseBody' - "400": - description: Bad Request - schema: - $ref: '#/definitions/responses.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/responses.ErrorResponse' - security: - - OAuth2Password: [] - summary: Check if an invoice is paid - tags: - - Invoice - /create: + /v2/invoices: post: consumes: - application/json - description: Create a new account with a login and password + description: Returns a new bolt11 invoice parameters: - - description: Create User + - description: Add Invoice in: body - name: account + name: invoice + required: true schema: - $ref: '#/definitions/controllers.CreateUserRequestBody' + $ref: '#/definitions/v2controllers.AddInvoiceRequestBody' produces: - application/json responses: "200": description: OK schema: - $ref: '#/definitions/controllers.CreateUserResponseBody' - "400": - description: Bad Request - schema: - $ref: '#/definitions/responses.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/responses.ErrorResponse' - summary: Create an account - tags: - - Account - /getinfo: - get: - consumes: - - application/json - description: Returns info about the backend node powering this LNDhub instance - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/controllers.GetInfoResponse' + $ref: '#/definitions/v2controllers.AddInvoiceResponseBody' "400": description: Bad Request schema: @@ -482,37 +269,10 @@ paths: $ref: '#/definitions/responses.ErrorResponse' security: - OAuth2Password: [] - summary: Get info about the Lightning node + summary: Generate a new invoice tags: - - Info - /gettxs: - get: - consumes: - - application/json - description: Returns a list of outgoing payments for a user - produces: - - application/json - responses: - "200": - description: OK - schema: - items: - $ref: '#/definitions/controllers.OutgoingInvoice' - type: array - "400": - description: Bad Request - schema: - $ref: '#/definitions/responses.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/responses.ErrorResponse' - security: - - OAuth2Password: [] - summary: Retrieve outgoing payments - tags: - - Account - /getuserinvoices: + - Invoice + /v2/invoices/incoming: get: consumes: - application/json @@ -524,7 +284,7 @@ paths: description: OK schema: items: - $ref: '#/definitions/controllers.IncomingInvoice' + $ref: '#/definitions/v2controllers.Invoice' type: array "400": description: Bad Request @@ -539,60 +299,11 @@ paths: summary: Retrieve incoming invoices tags: - Account - /invoice/{user_login}: - post: - consumes: - - application/json - description: Returns a new bolt11 invoice for a user with given login, without - an Authorization Header - parameters: - - description: User Login - in: path - name: user_login - required: true - type: string - - description: Add Invoice - in: body - name: invoice - required: true - schema: - $ref: '#/definitions/controllers.AddInvoiceRequestBody' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/controllers.AddInvoiceResponseBody' - "400": - description: Bad Request - schema: - $ref: '#/definitions/responses.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/responses.ErrorResponse' - summary: Generate a new invoice - tags: - - Invoice - /invoices/stream: + /v2/invoices/outgoing: get: consumes: - application/json - description: |- - Websocket: won't work with Swagger web UI. Returns a stream of settled incoming payments. - A keep-alive message is sent on startup and every 30s. - parameters: - - description: Auth token, retrieved from /auth endpoint - in: query - name: token - required: true - type: string - - description: Payment hash of earliest invoice. If specified, missing updates - starting from this payment will be sent. - in: query - name: since_payment_hash - type: string + description: Returns a list of outgoing payments for a user produces: - application/json responses: @@ -600,7 +311,7 @@ paths: description: OK schema: items: - $ref: '#/definitions/controllers.InvoiceEventWrapper' + $ref: '#/definitions/v2controllers.Invoice' type: array "400": description: Bad Request @@ -612,42 +323,10 @@ paths: $ref: '#/definitions/responses.ErrorResponse' security: - OAuth2Password: [] - summary: Websocket for incoming payments + summary: Retrieve outgoing payments tags: - - Invoice - /keysend: - post: - consumes: - - application/json - description: Pay a node without an invoice using it's public key - parameters: - - description: Invoice to pay - in: body - name: KeySendRequestBody - required: true - schema: - $ref: '#/definitions/controllers.KeySendRequestBody' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/controllers.KeySendResponseBody' - "400": - description: Bad Request - schema: - $ref: '#/definitions/responses.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/responses.ErrorResponse' - security: - - OAuth2Password: [] - summary: Make a keysend payment - tags: - - Payment - /payinvoice: + - Account + /v2/payments/bolt11: post: consumes: - application/json @@ -658,14 +337,14 @@ paths: name: PayInvoiceRequest required: true schema: - $ref: '#/definitions/controllers.PayInvoiceRequestBody' + $ref: '#/definitions/v2controllers.PayInvoiceRequestBody' produces: - application/json responses: "200": description: OK schema: - $ref: '#/definitions/controllers.PayInvoiceResponseBody' + $ref: '#/definitions/v2controllers.PayInvoiceResponseBody' "400": description: Bad Request schema: @@ -679,6 +358,67 @@ paths: summary: Pay an invoice tags: - Payment + /v2/payments/keysend: + post: + consumes: + - application/json + description: Pay a node without an invoice using it's public key + parameters: + - description: Invoice to pay + in: body + name: KeySendRequestBody + required: true + schema: + $ref: '#/definitions/v2controllers.KeySendRequestBody' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/v2controllers.KeySendResponseBody' + "400": + description: Bad Request + schema: + $ref: '#/definitions/responses.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/responses.ErrorResponse' + security: + - OAuth2Password: [] + summary: Make a keysend payment + tags: + - Payment + /v2/users: + post: + consumes: + - application/json + description: Create a new account with a username and password + parameters: + - description: Create User + in: body + name: account + schema: + $ref: '#/definitions/v2controllers.CreateUserRequestBody' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/v2controllers.CreateUserResponseBody' + "400": + description: Bad Request + schema: + $ref: '#/definitions/responses.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/responses.ErrorResponse' + summary: Create an account + tags: + - Account schemes: - https - http