swagger: add all endpoints

This commit is contained in:
kiwiidb
2022-04-26 13:48:05 +02:00
parent 0818abdd2c
commit 2793303ad3
14 changed files with 2451 additions and 21 deletions

View File

@@ -30,7 +30,18 @@ type AddInvoiceResponseBody struct {
PayReq string `json:"pay_req"`
}
// AddInvoice : Add invoice Controller
// 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)

View File

@@ -29,7 +29,17 @@ type AuthResponseBody struct {
AccessToken string `json:"access_token"`
}
// Auth : Auth Controller
// Auth godoc
// @Summary Authenticate
// @Description Exchanges a login + password for a token
// @Accept json
// @Produce json
// @Tags Account
// @Param AuthRequestBody body AuthRequestBody false "Login and password"
// @Success 200 {object} AuthResponseBody
// @Failure 400 {object} responses.ErrorResponse
// @Failure 500 {object} responses.ErrorResponse
// @Router /auth [post]
func (controller *AuthController) Auth(c echo.Context) error {
var body AuthRequestBody

View File

@@ -21,7 +21,18 @@ func NewCheckPaymentController(svc *service.LndhubService) *CheckPaymentControll
return &CheckPaymentController{svc: svc}
}
// CheckPayment : Check Payment Controller
// 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")

View File

@@ -7,6 +7,63 @@ import (
"github.com/labstack/echo/v4"
)
//Copy over struct for swagger purposes
type GetInfoResponse struct {
// The version of the LND software that the node is running.
Version string `protobuf:"bytes,14,opt,name=version,proto3" json:"version,omitempty"`
// The SHA1 commit hash that the daemon is compiled with.
CommitHash string `protobuf:"bytes,20,opt,name=commit_hash,json=commitHash,proto3" json:"commit_hash,omitempty"`
// The identity pubkey of the current node.
IdentityPubkey string `protobuf:"bytes,1,opt,name=identity_pubkey,json=identityPubkey,proto3" json:"identity_pubkey,omitempty"`
// If applicable, the alias of the current node, e.g. "bob"
Alias string `protobuf:"bytes,2,opt,name=alias,proto3" json:"alias,omitempty"`
// The color of the current node in hex code format
Color string `protobuf:"bytes,17,opt,name=color,proto3" json:"color,omitempty"`
// Number of pending channels
NumPendingChannels uint32 `protobuf:"varint,3,opt,name=num_pending_channels,json=numPendingChannels,proto3" json:"num_pending_channels,omitempty"`
// Number of active channels
NumActiveChannels uint32 `protobuf:"varint,4,opt,name=num_active_channels,json=numActiveChannels,proto3" json:"num_active_channels,omitempty"`
// Number of inactive channels
NumInactiveChannels uint32 `protobuf:"varint,15,opt,name=num_inactive_channels,json=numInactiveChannels,proto3" json:"num_inactive_channels,omitempty"`
// Number of peers
NumPeers uint32 `protobuf:"varint,5,opt,name=num_peers,json=numPeers,proto3" json:"num_peers,omitempty"`
// The node's current view of the height of the best block
BlockHeight uint32 `protobuf:"varint,6,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"`
// The node's current view of the hash of the best block
BlockHash string `protobuf:"bytes,8,opt,name=block_hash,json=blockHash,proto3" json:"block_hash,omitempty"`
// Timestamp of the block best known to the wallet
BestHeaderTimestamp int64 `protobuf:"varint,13,opt,name=best_header_timestamp,json=bestHeaderTimestamp,proto3" json:"best_header_timestamp,omitempty"`
// Whether the wallet's view is synced to the main chain
SyncedToChain bool `protobuf:"varint,9,opt,name=synced_to_chain,json=syncedToChain,proto3" json:"synced_to_chain,omitempty"`
// Whether we consider ourselves synced with the public channel graph.
SyncedToGraph bool `protobuf:"varint,18,opt,name=synced_to_graph,json=syncedToGraph,proto3" json:"synced_to_graph,omitempty"`
//
//Whether the current node is connected to testnet. This field is
//deprecated and the network field should be used instead
//
// Deprecated: Do not use.
Testnet bool `protobuf:"varint,10,opt,name=testnet,proto3" json:"testnet,omitempty"`
// A list of active chains the node is connected to
Chains []*Chain `protobuf:"bytes,16,rep,name=chains,proto3" json:"chains,omitempty"`
// The URIs of the current node.
Uris []string `protobuf:"bytes,12,rep,name=uris,proto3" json:"uris,omitempty"`
//
//Features that our node has advertised in our init message, node
//announcements and invoices.
Features map[uint32]*Feature `protobuf:"bytes,19,rep,name=features,proto3" json:"features,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
}
type Chain struct {
// The blockchain the node is on (eg bitcoin, litecoin)
Chain string `protobuf:"bytes,1,opt,name=chain,proto3" json:"chain,omitempty"`
// The network the node is on (eg regtest, testnet, mainnet)
Network string `protobuf:"bytes,2,opt,name=network,proto3" json:"network,omitempty"`
}
type Feature struct {
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
IsRequired bool `protobuf:"varint,3,opt,name=is_required,json=isRequired,proto3" json:"is_required,omitempty"`
IsKnown bool `protobuf:"varint,4,opt,name=is_known,json=isKnown,proto3" json:"is_known,omitempty"`
}
// GetInfoController : GetInfoController struct
type GetInfoController struct {
svc *service.LndhubService
@@ -16,10 +73,19 @@ func NewGetInfoController(svc *service.LndhubService) *GetInfoController {
return &GetInfoController{svc: svc}
}
// GetInfo : GetInfo handler
// 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 {
// TODO: add some caching for this GetInfo call. No need to always hit the node
info, err := controller.svc.GetInfo(c.Request().Context())
if err != nil {
return err

View File

@@ -42,7 +42,17 @@ type IncomingInvoice struct {
IsPaid bool `json:"ispaid"`
}
// GetTXS : Get TXS Controller
// 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)
@@ -68,6 +78,17 @@ 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)

View File

@@ -17,7 +17,18 @@ func NewInvoiceController(svc *service.LndhubService) *InvoiceController {
return &InvoiceController{svc: svc}
}
// Invoice : Invoice Controller
// 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 {

View File

@@ -26,7 +26,20 @@ func NewInvoiceStreamController(svc *service.LndhubService) *InvoiceStreamContro
return &InvoiceStreamController{svc: svc}
}
// Stream invoices streams incoming payments to the client
// 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 {

View File

@@ -41,7 +41,18 @@ type KeySendResponseBody struct {
PaymentRoute *service.Route `json:"payment_route,omitempty"`
}
// KeySend : Key send Controller
//// PayInvoice 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{}

View File

@@ -38,7 +38,18 @@ type PayInvoiceResponseBody struct {
PaymentRoute *service.Route `json:"payment_route,omitempty"`
}
// PayInvoice : Pay invoice Controller
// 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{}

View File

@@ -24,6 +24,102 @@ 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",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Account"
],
"summary": "Authenticate",
"parameters": [
{
"description": "Login and password",
"name": "AuthRequestBody",
"in": "body",
"schema": {
"$ref": "#/definitions/controllers.AuthRequestBody"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/controllers.AuthResponseBody"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/responses.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/responses.ErrorResponse"
}
}
}
}
},
"/balance": {
"get": {
"security": [
@@ -39,7 +135,7 @@ const docTemplate = `{
"application/json"
],
"tags": [
"account"
"Account"
],
"summary": "Retrieve balance",
"responses": {
@@ -64,6 +160,55 @@ const docTemplate = `{
}
}
},
"/checkpayment/{payment_hash}": {
"get": {
"security": [
{
"OAuth2Password": []
}
],
"description": "Checks if an invoice is paid, can be incoming our outgoing",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Invoice"
],
"summary": "Check if an invoice is paid",
"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",
@@ -73,6 +218,9 @@ const docTemplate = `{
"produces": [
"application/json"
],
"tags": [
"Account"
],
"summary": "Create an account",
"parameters": [
{
@@ -105,9 +253,401 @@ 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": {
"get": {
"security": [
{
"OAuth2Password": []
}
],
"description": "Returns a list of incoming invoices for a user",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Account"
],
"summary": "Retrieve incoming invoices",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/controllers.IncomingInvoice"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/responses.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/responses.ErrorResponse"
}
}
}
}
},
"/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": {
"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.",
"consumes": [
"application/json"
],
"produces": [
"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"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/controllers.InvoiceEventWrapper"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/responses.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/responses.ErrorResponse"
}
}
}
}
},
"/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": {
"post": {
"security": [
{
"OAuth2Password": []
}
],
"description": "Pay a bolt11 invoice",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Payment"
],
"summary": "Pay an invoice",
"parameters": [
{
"description": "Invoice to pay",
"name": "PayInvoiceRequest",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/controllers.PayInvoiceRequestBody"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/controllers.PayInvoiceResponseBody"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/responses.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/responses.ErrorResponse"
}
}
}
}
}
},
"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": {
"login": {
"type": "string"
},
"password": {
"type": "string"
},
"refresh_token": {
"type": "string"
}
}
},
"controllers.AuthResponseBody": {
"type": "object",
"properties": {
"access_token": {
"type": "string"
},
"refresh_token": {
"type": "string"
}
}
},
"controllers.BalanceResponse": {
"type": "object",
"properties": {
@@ -121,6 +661,27 @@ const docTemplate = `{
}
}
},
"controllers.Chain": {
"type": "object",
"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"
}
}
},
"controllers.CheckPaymentResponseBody": {
"type": "object",
"properties": {
"paid": {
"type": "boolean"
}
}
},
"controllers.CreateUserRequestBody": {
"type": "object",
"properties": {
@@ -149,6 +710,281 @@ const docTemplate = `{
}
}
},
"controllers.Feature": {
"type": "object",
"properties": {
"is_known": {
"type": "boolean"
},
"is_required": {
"type": "boolean"
},
"name": {
"type": "string"
}
}
},
"controllers.GetInfoResponse": {
"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": {
"type": "integer"
},
"description": {
"type": "string"
},
"expire_time": {
"type": "integer"
},
"ispaid": {
"type": "boolean"
},
"pay_req": {
"type": "string"
},
"payment_hash": {},
"payment_request": {
"type": "string"
},
"r_hash": {},
"timestamp": {
"type": "integer"
},
"type": {
"type": "string"
}
}
},
"controllers.InvoiceEventWrapper": {
"type": "object",
"properties": {
"invoice": {
"$ref": "#/definitions/controllers.IncomingInvoice"
},
"type": {
"type": "string"
}
}
},
"controllers.KeySendRequestBody": {
"type": "object",
"required": [
"amount",
"destination"
],
"properties": {
"amount": {
"type": "integer"
},
"customRecords": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"destination": {
"type": "string"
},
"memo": {
"type": "string"
}
}
},
"controllers.KeySendResponseBody": {
"type": "object",
"properties": {
"description": {
"type": "string"
},
"description_hash": {
"type": "string"
},
"destination": {
"type": "string"
},
"num_satoshis": {
"type": "integer"
},
"payment_error": {
"type": "string"
},
"payment_hash": {
"$ref": "#/definitions/lib.JavaScriptBuffer"
},
"payment_preimage": {
"$ref": "#/definitions/lib.JavaScriptBuffer"
},
"payment_route": {
"$ref": "#/definitions/service.Route"
}
}
},
"controllers.OutgoingInvoice": {
"type": "object",
"properties": {
"fee": {
"type": "integer"
},
"memo": {
"type": "string"
},
"payment_hash": {},
"payment_preimage": {
"type": "string"
},
"r_hash": {},
"timestamp": {
"type": "integer"
},
"type": {
"type": "string"
},
"value": {
"type": "integer"
}
}
},
"controllers.PayInvoiceRequestBody": {
"type": "object",
"required": [
"invoice"
],
"properties": {
"amount": {},
"invoice": {
"type": "string"
}
}
},
"controllers.PayInvoiceResponseBody": {
"type": "object",
"properties": {
"description": {
"type": "string"
},
"description_hash": {
"type": "string"
},
"num_satoshis": {
"type": "integer"
},
"pay_req": {
"type": "string"
},
"payment_error": {
"type": "string"
},
"payment_hash": {
"$ref": "#/definitions/lib.JavaScriptBuffer"
},
"payment_preimage": {
"$ref": "#/definitions/lib.JavaScriptBuffer"
},
"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": {
@@ -162,6 +998,17 @@ const docTemplate = `{
"type": "string"
}
}
},
"service.Route": {
"type": "object",
"properties": {
"total_amt": {
"type": "integer"
},
"total_fees": {
"type": "integer"
}
}
}
},
"securityDefinitions": {
@@ -178,7 +1025,7 @@ var SwaggerInfo = &swag.Spec{
Version: "0.6.1",
Host: "",
BasePath: "/",
Schemes: []string{},
Schemes: []string{"http", "https"},
Title: "LNDhub.go",
Description: "Accounting wrapper for the Lightning Network providing separate accounts for end-users.",
InfoInstanceName: "swagger",

View File

@@ -1,4 +1,8 @@
{
"schemes": [
"http",
"https"
],
"swagger": "2.0",
"info": {
"description": "Accounting wrapper for the Lightning Network providing separate accounts for end-users.",
@@ -16,6 +20,102 @@
},
"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",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Account"
],
"summary": "Authenticate",
"parameters": [
{
"description": "Login and password",
"name": "AuthRequestBody",
"in": "body",
"schema": {
"$ref": "#/definitions/controllers.AuthRequestBody"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/controllers.AuthResponseBody"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/responses.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/responses.ErrorResponse"
}
}
}
}
},
"/balance": {
"get": {
"security": [
@@ -31,7 +131,7 @@
"application/json"
],
"tags": [
"account"
"Account"
],
"summary": "Retrieve balance",
"responses": {
@@ -56,6 +156,55 @@
}
}
},
"/checkpayment/{payment_hash}": {
"get": {
"security": [
{
"OAuth2Password": []
}
],
"description": "Checks if an invoice is paid, can be incoming our outgoing",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Invoice"
],
"summary": "Check if an invoice is paid",
"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",
@@ -65,6 +214,9 @@
"produces": [
"application/json"
],
"tags": [
"Account"
],
"summary": "Create an account",
"parameters": [
{
@@ -97,9 +249,401 @@
}
}
}
},
"/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": {
"get": {
"security": [
{
"OAuth2Password": []
}
],
"description": "Returns a list of incoming invoices for a user",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Account"
],
"summary": "Retrieve incoming invoices",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/controllers.IncomingInvoice"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/responses.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/responses.ErrorResponse"
}
}
}
}
},
"/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": {
"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.",
"consumes": [
"application/json"
],
"produces": [
"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"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/controllers.InvoiceEventWrapper"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/responses.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/responses.ErrorResponse"
}
}
}
}
},
"/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": {
"post": {
"security": [
{
"OAuth2Password": []
}
],
"description": "Pay a bolt11 invoice",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Payment"
],
"summary": "Pay an invoice",
"parameters": [
{
"description": "Invoice to pay",
"name": "PayInvoiceRequest",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/controllers.PayInvoiceRequestBody"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/controllers.PayInvoiceResponseBody"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/responses.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/responses.ErrorResponse"
}
}
}
}
}
},
"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": {
"login": {
"type": "string"
},
"password": {
"type": "string"
},
"refresh_token": {
"type": "string"
}
}
},
"controllers.AuthResponseBody": {
"type": "object",
"properties": {
"access_token": {
"type": "string"
},
"refresh_token": {
"type": "string"
}
}
},
"controllers.BalanceResponse": {
"type": "object",
"properties": {
@@ -113,6 +657,27 @@
}
}
},
"controllers.Chain": {
"type": "object",
"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"
}
}
},
"controllers.CheckPaymentResponseBody": {
"type": "object",
"properties": {
"paid": {
"type": "boolean"
}
}
},
"controllers.CreateUserRequestBody": {
"type": "object",
"properties": {
@@ -141,6 +706,281 @@
}
}
},
"controllers.Feature": {
"type": "object",
"properties": {
"is_known": {
"type": "boolean"
},
"is_required": {
"type": "boolean"
},
"name": {
"type": "string"
}
}
},
"controllers.GetInfoResponse": {
"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": {
"type": "integer"
},
"description": {
"type": "string"
},
"expire_time": {
"type": "integer"
},
"ispaid": {
"type": "boolean"
},
"pay_req": {
"type": "string"
},
"payment_hash": {},
"payment_request": {
"type": "string"
},
"r_hash": {},
"timestamp": {
"type": "integer"
},
"type": {
"type": "string"
}
}
},
"controllers.InvoiceEventWrapper": {
"type": "object",
"properties": {
"invoice": {
"$ref": "#/definitions/controllers.IncomingInvoice"
},
"type": {
"type": "string"
}
}
},
"controllers.KeySendRequestBody": {
"type": "object",
"required": [
"amount",
"destination"
],
"properties": {
"amount": {
"type": "integer"
},
"customRecords": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"destination": {
"type": "string"
},
"memo": {
"type": "string"
}
}
},
"controllers.KeySendResponseBody": {
"type": "object",
"properties": {
"description": {
"type": "string"
},
"description_hash": {
"type": "string"
},
"destination": {
"type": "string"
},
"num_satoshis": {
"type": "integer"
},
"payment_error": {
"type": "string"
},
"payment_hash": {
"$ref": "#/definitions/lib.JavaScriptBuffer"
},
"payment_preimage": {
"$ref": "#/definitions/lib.JavaScriptBuffer"
},
"payment_route": {
"$ref": "#/definitions/service.Route"
}
}
},
"controllers.OutgoingInvoice": {
"type": "object",
"properties": {
"fee": {
"type": "integer"
},
"memo": {
"type": "string"
},
"payment_hash": {},
"payment_preimage": {
"type": "string"
},
"r_hash": {},
"timestamp": {
"type": "integer"
},
"type": {
"type": "string"
},
"value": {
"type": "integer"
}
}
},
"controllers.PayInvoiceRequestBody": {
"type": "object",
"required": [
"invoice"
],
"properties": {
"amount": {},
"invoice": {
"type": "string"
}
}
},
"controllers.PayInvoiceResponseBody": {
"type": "object",
"properties": {
"description": {
"type": "string"
},
"description_hash": {
"type": "string"
},
"num_satoshis": {
"type": "integer"
},
"pay_req": {
"type": "string"
},
"payment_error": {
"type": "string"
},
"payment_hash": {
"$ref": "#/definitions/lib.JavaScriptBuffer"
},
"payment_preimage": {
"$ref": "#/definitions/lib.JavaScriptBuffer"
},
"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": {
@@ -154,6 +994,17 @@
"type": "string"
}
}
},
"service.Route": {
"type": "object",
"properties": {
"total_amt": {
"type": "integer"
},
"total_fees": {
"type": "integer"
}
}
}
},
"securityDefinitions": {

View File

@@ -1,5 +1,39 @@
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:
type: string
password:
type: string
refresh_token:
type: string
type: object
controllers.AuthResponseBody:
properties:
access_token:
type: string
refresh_token:
type: string
type: object
controllers.BalanceResponse:
properties:
btc:
@@ -8,6 +42,20 @@ definitions:
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:
type: boolean
type: object
controllers.CreateUserRequestBody:
properties:
accounttype:
@@ -26,6 +74,201 @@ definitions:
password:
type: string
type: object
controllers.Feature:
properties:
is_known:
type: boolean
is_required:
type: boolean
name:
type: string
type: object
controllers.GetInfoResponse:
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:
type: integer
description:
type: string
expire_time:
type: integer
ispaid:
type: boolean
pay_req:
type: string
payment_hash: {}
payment_request:
type: string
r_hash: {}
timestamp:
type: integer
type:
type: string
type: object
controllers.InvoiceEventWrapper:
properties:
invoice:
$ref: '#/definitions/controllers.IncomingInvoice'
type:
type: string
type: object
controllers.KeySendRequestBody:
properties:
amount:
type: integer
customRecords:
additionalProperties:
type: string
type: object
destination:
type: string
memo:
type: string
required:
- amount
- destination
type: object
controllers.KeySendResponseBody:
properties:
description:
type: string
description_hash:
type: string
destination:
type: string
num_satoshis:
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:
fee:
type: integer
memo:
type: string
payment_hash: {}
payment_preimage:
type: string
r_hash: {}
timestamp:
type: integer
type:
type: string
value:
type: integer
type: object
controllers.PayInvoiceRequestBody:
properties:
amount: {}
invoice:
type: string
required:
- invoice
type: object
controllers.PayInvoiceResponseBody:
properties:
description:
type: string
description_hash:
type: string
num_satoshis:
type: integer
pay_req:
type: string
payment_error:
type: string
payment_hash:
$ref: '#/definitions/lib.JavaScriptBuffer'
payment_preimage:
$ref: '#/definitions/lib.JavaScriptBuffer'
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:
@@ -35,6 +278,13 @@ definitions:
message:
type: string
type: object
service.Route:
properties:
total_amt:
type: integer
total_fees:
type: integer
type: object
info:
contact:
email: hello@getalby.com
@@ -48,6 +298,67 @@ 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:
- application/json
description: Exchanges a login + password for a token
parameters:
- description: Login and password
in: body
name: AuthRequestBody
schema:
$ref: '#/definitions/controllers.AuthRequestBody'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/controllers.AuthResponseBody'
"400":
description: Bad Request
schema:
$ref: '#/definitions/responses.ErrorResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/responses.ErrorResponse'
summary: Authenticate
tags:
- Account
/balance:
get:
consumes:
@@ -72,7 +383,38 @@ paths:
- OAuth2Password: []
summary: Retrieve balance
tags:
- account
- 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:
post:
consumes:
@@ -100,6 +442,230 @@ paths:
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'
"400":
description: Bad Request
schema:
$ref: '#/definitions/responses.ErrorResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/responses.ErrorResponse'
security:
- OAuth2Password: []
summary: Get info about the Lightning node
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:
get:
consumes:
- application/json
description: Returns a list of incoming invoices for a user
produces:
- application/json
responses:
"200":
description: OK
schema:
items:
$ref: '#/definitions/controllers.IncomingInvoice'
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 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:
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
produces:
- application/json
responses:
"200":
description: OK
schema:
items:
$ref: '#/definitions/controllers.InvoiceEventWrapper'
type: array
"400":
description: Bad Request
schema:
$ref: '#/definitions/responses.ErrorResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/responses.ErrorResponse'
security:
- OAuth2Password: []
summary: Websocket for incoming 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:
post:
consumes:
- application/json
description: Pay a bolt11 invoice
parameters:
- description: Invoice to pay
in: body
name: PayInvoiceRequest
required: true
schema:
$ref: '#/definitions/controllers.PayInvoiceRequestBody'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/controllers.PayInvoiceResponseBody'
"400":
description: Bad Request
schema:
$ref: '#/definitions/responses.ErrorResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/responses.ErrorResponse'
security:
- OAuth2Password: []
summary: Pay an invoice
tags:
- Payment
schemes:
- http
- https
securityDefinitions:
OAuth2Password:
flow: password

View File

@@ -57,6 +57,7 @@ var staticContent embed.FS
// @securitydefinitions.oauth2.password OAuth2Password
// @tokenUrl /auth
// @schemes http https
func main() {
c := &service.Config{}