2630 lines
69 KiB
Go
2630 lines
69 KiB
Go
// This file was autogenerated from a .proto file, DO NOT EDIT!
|
|
|
|
package lightning_pub
|
|
|
|
import (
|
|
"net/url"
|
|
"bytes"
|
|
"encoding/json"
|
|
"fmt"
|
|
"io"
|
|
"net/http"
|
|
"strings"
|
|
)
|
|
|
|
func doPostRequest(url string, body []byte, auth string) ([]byte, error) {
|
|
bodyReader := bytes.NewReader(body)
|
|
req, err := http.NewRequest(http.MethodPost, url, bodyReader)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req.Header.Set("authorization", auth)
|
|
return doRequest(req)
|
|
}
|
|
|
|
func doGetRequest(url string, auth string) ([]byte, error) {
|
|
req, err := http.NewRequest(http.MethodGet, url, nil)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req.Header.Set("authorization", auth)
|
|
return doRequest(req)
|
|
}
|
|
|
|
func doRequest(req *http.Request) ([]byte, error) {
|
|
res, err := http.DefaultClient.Do(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
resBody, err := io.ReadAll(res.Body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return resBody, nil
|
|
}
|
|
|
|
type ClientParams struct {
|
|
BaseURL string
|
|
RetrieveAdminAuth func() (string, error)
|
|
RetrieveAppAuth func() (string, error)
|
|
RetrieveGuestAuth func() (string, error)
|
|
RetrieveGuestWithPubAuth func() (string, error)
|
|
RetrieveMetricsAuth func() (string, error)
|
|
RetrieveUserAuth func() (string, error)
|
|
}
|
|
type Client struct {
|
|
AddApp func(req AddAppRequest) (*AuthApp, error)
|
|
AddAppInvoice func(req AddAppInvoiceRequest) (*NewInvoiceResponse, error)
|
|
AddAppUser func(req AddAppUserRequest) (*AppUser, error)
|
|
AddAppUserInvoice func(req AddAppUserInvoiceRequest) (*NewInvoiceResponse, error)
|
|
AddPeer func(req AddPeerRequest) error
|
|
AddProduct func(req AddProductRequest) (*Product, error)
|
|
AddUserOffer func(req OfferConfig) (*OfferId, error)
|
|
AuthApp func(req AuthAppRequest) (*AuthApp, error)
|
|
AuthorizeManage func(req ManageAuthorizationRequest) (*ManageAuthorization, error)
|
|
BanDebit func(req DebitOperation) error
|
|
BanUser func(req BanUserRequest) (*BanUserResponse, error)
|
|
// batching method: BatchUser not implemented
|
|
BumpTx func(req BumpTx) error
|
|
CloseChannel func(req CloseChannelRequest) (*CloseChannelResponse, error)
|
|
CreateOneTimeInviteLink func(req CreateOneTimeInviteLinkRequest) (*CreateOneTimeInviteLinkResponse, error)
|
|
DecodeInvoice func(req DecodeInvoiceRequest) (*DecodeInvoiceResponse, error)
|
|
DeleteUserOffer func(req OfferId) error
|
|
EditDebit func(req DebitAuthorizationRequest) error
|
|
EncryptionExchange func(req EncryptionExchangeRequest) error
|
|
EnrollAdminToken func(req EnrollAdminTokenRequest) error
|
|
EnrollMessagingToken func(req MessagingToken) error
|
|
GetAdminInvoiceSwapQuotes func(req InvoiceSwapRequest) (*InvoiceSwapQuoteList, error)
|
|
GetAdminTransactionSwapQuotes func(req TransactionSwapRequest) (*TransactionSwapQuoteList, error)
|
|
GetApp func() (*Application, error)
|
|
GetAppUser func(req GetAppUserRequest) (*AppUser, error)
|
|
GetAppUserLNURLInfo func(req GetAppUserLNURLInfoRequest) (*LnurlPayInfoResponse, error)
|
|
GetAppsMetrics func(req AppsMetricsRequest) (*AppsMetrics, error)
|
|
GetAssetsAndLiabilities func(req AssetsAndLiabilitiesReq) (*AssetsAndLiabilities, error)
|
|
GetBundleMetrics func(req LatestBundleMetricReq) (*BundleMetrics, error)
|
|
GetDebitAuthorizations func() (*DebitAuthorizations, error)
|
|
GetErrorStats func() (*ErrorStats, error)
|
|
GetHttpCreds func() (*HttpCreds, error)
|
|
GetInviteLinkState func(req GetInviteTokenStateRequest) (*GetInviteTokenStateResponse, error)
|
|
GetLNURLChannelLink func() (*LnurlLinkResponse, error)
|
|
GetLiveDebitRequests func() (*LiveDebitRequest, error)
|
|
GetLiveManageRequests func() (*LiveManageRequest, error)
|
|
GetLiveUserOperations func() (*LiveUserOperation, error)
|
|
GetLndForwardingMetrics func(req LndMetricsRequest) (*LndForwardingMetrics, error)
|
|
GetLndMetrics func(req LndMetricsRequest) (*LndMetrics, error)
|
|
GetLnurlPayInfo func(query GetLnurlPayInfo_Query) (*LnurlPayInfoResponse, error)
|
|
GetLnurlPayLink func() (*LnurlLinkResponse, error)
|
|
GetLnurlWithdrawInfo func(query GetLnurlWithdrawInfo_Query) (*LnurlWithdrawInfoResponse, error)
|
|
GetLnurlWithdrawLink func() (*LnurlLinkResponse, error)
|
|
GetManageAuthorizations func() (*ManageAuthorizations, error)
|
|
GetMigrationUpdate func() (*MigrationUpdate, error)
|
|
GetNPubLinkingState func(req GetNPubLinking) (*NPubLinking, error)
|
|
GetPaymentState func(req GetPaymentStateRequest) (*PaymentState, error)
|
|
GetProvidersDisruption func() (*ProvidersDisruption, error)
|
|
GetSeed func() (*LndSeed, error)
|
|
GetSingleBundleMetrics func(req SingleMetricReq) (*BundleData, error)
|
|
GetSingleUsageMetrics func(req SingleMetricReq) (*UsageMetricTlv, error)
|
|
GetTransactionSwapQuotes func(req TransactionSwapRequest) (*TransactionSwapQuoteList, error)
|
|
GetUsageMetrics func(req LatestUsageMetricReq) (*UsageMetrics, error)
|
|
GetUserInfo func() (*UserInfo, error)
|
|
GetUserOffer func(req OfferId) (*OfferConfig, error)
|
|
GetUserOfferInvoices func(req GetUserOfferInvoicesReq) (*OfferInvoices, error)
|
|
GetUserOffers func() (*UserOffers, error)
|
|
GetUserOperations func(req GetUserOperationsRequest) (*GetUserOperationsResponse, error)
|
|
HandleLnurlAddress func(routeParams HandleLnurlAddress_RouteParams) (*LnurlPayInfoResponse, error)
|
|
HandleLnurlPay func(query HandleLnurlPay_Query) (*HandleLnurlPayResponse, error)
|
|
HandleLnurlWithdraw func(query HandleLnurlWithdraw_Query) error
|
|
Health func() error
|
|
LinkNPubThroughToken func(req LinkNPubThroughTokenRequest) error
|
|
ListAdminInvoiceSwaps func() (*InvoiceSwapsList, error)
|
|
ListAdminTxSwaps func() (*TxSwapsList, error)
|
|
ListChannels func() (*LndChannels, error)
|
|
ListTxSwaps func() (*TxSwapsList, error)
|
|
LndGetInfo func(req LndGetInfoRequest) (*LndGetInfoResponse, error)
|
|
NewAddress func(req NewAddressRequest) (*NewAddressResponse, error)
|
|
NewInvoice func(req NewInvoiceRequest) (*NewInvoiceResponse, error)
|
|
NewProductInvoice func(query NewProductInvoice_Query) (*NewInvoiceResponse, error)
|
|
OpenChannel func(req OpenChannelRequest) (*OpenChannelResponse, error)
|
|
PayAddress func(req PayAddressRequest) (*PayAddressResponse, error)
|
|
PayAdminInvoiceSwap func(req PayAdminInvoiceSwapRequest) (*AdminInvoiceSwapResponse, error)
|
|
PayAdminTransactionSwap func(req PayAdminTransactionSwapRequest) (*AdminTxSwapResponse, error)
|
|
PayAppUserInvoice func(req PayAppUserInvoiceRequest) (*PayInvoiceResponse, error)
|
|
PayInvoice func(req PayInvoiceRequest) (*PayInvoiceResponse, error)
|
|
PingSubProcesses func() error
|
|
RefundAdminInvoiceSwap func(req RefundAdminInvoiceSwapRequest) (*AdminInvoiceSwapResponse, error)
|
|
RequestNPubLinkingToken func(req RequestNPubLinkingTokenRequest) (*RequestNPubLinkingTokenResponse, error)
|
|
ResetDebit func(req DebitOperation) error
|
|
ResetManage func(req ManageOperation) error
|
|
ResetMetricsStorages func() error
|
|
ResetNPubLinkingToken func(req RequestNPubLinkingTokenRequest) (*RequestNPubLinkingTokenResponse, error)
|
|
RespondToDebit func(req DebitResponse) error
|
|
SendAppUserToAppPayment func(req SendAppUserToAppPaymentRequest) error
|
|
SendAppUserToAppUserPayment func(req SendAppUserToAppUserPaymentRequest) error
|
|
SetMockAppBalance func(req SetMockAppBalanceRequest) error
|
|
SetMockAppUserBalance func(req SetMockAppUserBalanceRequest) error
|
|
SetMockInvoiceAsPaid func(req SetMockInvoiceAsPaidRequest) error
|
|
SubToWebRtcCandidates func() (*WebRtcCandidate, error)
|
|
SubmitWebRtcMessage func(req WebRtcMessage) (*WebRtcAnswer, error)
|
|
UpdateCallbackUrl func(req CallbackUrl) (*CallbackUrl, error)
|
|
UpdateChannelPolicy func(req UpdateChannelPolicyRequest) error
|
|
UpdateUserOffer func(req OfferConfig) error
|
|
UseInviteLink func(req UseInviteLinkRequest) error
|
|
UserHealth func() (*UserHealthState, error)
|
|
ZipMetricsStorages func() (*ZippedMetrics, error)
|
|
}
|
|
|
|
func NewClient(params ClientParams) *Client {
|
|
return &Client{
|
|
AddApp: func(req AddAppRequest) (*AuthApp, error) {
|
|
auth, err := params.RetrieveAdminAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/admin/app/add"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := AuthApp{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
AddAppInvoice: func(req AddAppInvoiceRequest) (*NewInvoiceResponse, error) {
|
|
auth, err := params.RetrieveAppAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/app/add/invoice"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := NewInvoiceResponse{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
AddAppUser: func(req AddAppUserRequest) (*AppUser, error) {
|
|
auth, err := params.RetrieveAppAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/app/user/add"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := AppUser{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
AddAppUserInvoice: func(req AddAppUserInvoiceRequest) (*NewInvoiceResponse, error) {
|
|
auth, err := params.RetrieveAppAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/app/user/add/invoice"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := NewInvoiceResponse{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
AddPeer: func(req AddPeerRequest) error {
|
|
auth, err := params.RetrieveAdminAuth()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
finalRoute := "/api/admin/peer"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return fmt.Errorf(result.Reason)
|
|
}
|
|
return nil
|
|
},
|
|
AddProduct: func(req AddProductRequest) (*Product, error) {
|
|
auth, err := params.RetrieveUserAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/user/product/add"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := Product{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
AddUserOffer: func(req OfferConfig) (*OfferId, error) {
|
|
auth, err := params.RetrieveUserAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/user/offer/add"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := OfferId{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
AuthApp: func(req AuthAppRequest) (*AuthApp, error) {
|
|
auth, err := params.RetrieveAdminAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/admin/app/auth"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := AuthApp{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
AuthorizeManage: func(req ManageAuthorizationRequest) (*ManageAuthorization, error) {
|
|
auth, err := params.RetrieveUserAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/user/manage/authorize"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := ManageAuthorization{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
BanDebit: func(req DebitOperation) error {
|
|
auth, err := params.RetrieveUserAuth()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
finalRoute := "/api/user/debit/ban"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return fmt.Errorf(result.Reason)
|
|
}
|
|
return nil
|
|
},
|
|
BanUser: func(req BanUserRequest) (*BanUserResponse, error) {
|
|
auth, err := params.RetrieveAdminAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/admin/user/ban"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := BanUserResponse{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
// batching method: BatchUser not implemented
|
|
BumpTx: func(req BumpTx) error {
|
|
auth, err := params.RetrieveAdminAuth()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
finalRoute := "/api/admin/tx/bump"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return fmt.Errorf(result.Reason)
|
|
}
|
|
return nil
|
|
},
|
|
CloseChannel: func(req CloseChannelRequest) (*CloseChannelResponse, error) {
|
|
auth, err := params.RetrieveAdminAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/admin/channel/close"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := CloseChannelResponse{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
CreateOneTimeInviteLink: func(req CreateOneTimeInviteLinkRequest) (*CreateOneTimeInviteLinkResponse, error) {
|
|
auth, err := params.RetrieveAdminAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/admin/app/invite/create"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := CreateOneTimeInviteLinkResponse{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
DecodeInvoice: func(req DecodeInvoiceRequest) (*DecodeInvoiceResponse, error) {
|
|
auth, err := params.RetrieveUserAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/user/invoice/decode"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := DecodeInvoiceResponse{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
DeleteUserOffer: func(req OfferId) error {
|
|
auth, err := params.RetrieveUserAuth()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
finalRoute := "/api/user/offer/delete"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return fmt.Errorf(result.Reason)
|
|
}
|
|
return nil
|
|
},
|
|
EditDebit: func(req DebitAuthorizationRequest) error {
|
|
auth, err := params.RetrieveUserAuth()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
finalRoute := "/api/user/debit/edit"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return fmt.Errorf(result.Reason)
|
|
}
|
|
return nil
|
|
},
|
|
EncryptionExchange: func(req EncryptionExchangeRequest) error {
|
|
auth, err := params.RetrieveGuestAuth()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
finalRoute := "/api/encryption/exchange"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return fmt.Errorf(result.Reason)
|
|
}
|
|
return nil
|
|
},
|
|
EnrollAdminToken: func(req EnrollAdminTokenRequest) error {
|
|
auth, err := params.RetrieveUserAuth()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
finalRoute := "/api/guest/npub/enroll/admin"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return fmt.Errorf(result.Reason)
|
|
}
|
|
return nil
|
|
},
|
|
EnrollMessagingToken: func(req MessagingToken) error {
|
|
auth, err := params.RetrieveUserAuth()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
finalRoute := "/api/user/messaging/enroll"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return fmt.Errorf(result.Reason)
|
|
}
|
|
return nil
|
|
},
|
|
GetAdminInvoiceSwapQuotes: func(req InvoiceSwapRequest) (*InvoiceSwapQuoteList, error) {
|
|
auth, err := params.RetrieveAdminAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/admin/swap/invoice/quote"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := InvoiceSwapQuoteList{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
GetAdminTransactionSwapQuotes: func(req TransactionSwapRequest) (*TransactionSwapQuoteList, error) {
|
|
auth, err := params.RetrieveAdminAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/admin/swap/transaction/quote"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := TransactionSwapQuoteList{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
GetApp: func() (*Application, error) {
|
|
auth, err := params.RetrieveAppAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/app/get"
|
|
body := []byte{}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := Application{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
GetAppUser: func(req GetAppUserRequest) (*AppUser, error) {
|
|
auth, err := params.RetrieveAppAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/app/user/get"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := AppUser{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
GetAppUserLNURLInfo: func(req GetAppUserLNURLInfoRequest) (*LnurlPayInfoResponse, error) {
|
|
auth, err := params.RetrieveAppAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/app/user/lnurl/pay/info"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := LnurlPayInfoResponse{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
GetAppsMetrics: func(req AppsMetricsRequest) (*AppsMetrics, error) {
|
|
auth, err := params.RetrieveMetricsAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/reports/apps"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := AppsMetrics{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
GetAssetsAndLiabilities: func(req AssetsAndLiabilitiesReq) (*AssetsAndLiabilities, error) {
|
|
auth, err := params.RetrieveAdminAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/admin/assets/liabilities"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := AssetsAndLiabilities{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
GetBundleMetrics: func(req LatestBundleMetricReq) (*BundleMetrics, error) {
|
|
auth, err := params.RetrieveMetricsAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/reports/bundle"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := BundleMetrics{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
GetDebitAuthorizations: func() (*DebitAuthorizations, error) {
|
|
auth, err := params.RetrieveUserAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/user/debit/get"
|
|
resBody, err := doGetRequest(params.BaseURL+finalRoute, auth)
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := DebitAuthorizations{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
GetErrorStats: func() (*ErrorStats, error) {
|
|
auth, err := params.RetrieveMetricsAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/reports/errors"
|
|
body := []byte{}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := ErrorStats{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
GetHttpCreds: func() (*HttpCreds, error) {
|
|
auth, err := params.RetrieveUserAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/user/http_creds"
|
|
body := []byte{}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := HttpCreds{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
GetInviteLinkState: func(req GetInviteTokenStateRequest) (*GetInviteTokenStateResponse, error) {
|
|
auth, err := params.RetrieveAdminAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/admin/app/invite/get"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := GetInviteTokenStateResponse{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
GetLNURLChannelLink: func() (*LnurlLinkResponse, error) {
|
|
auth, err := params.RetrieveUserAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/user/lnurl_channel/url"
|
|
body := []byte{}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := LnurlLinkResponse{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
// server streaming method: GetLiveDebitRequests not implemented
|
|
// server streaming method: GetLiveManageRequests not implemented
|
|
// server streaming method: GetLiveUserOperations not implemented
|
|
GetLndForwardingMetrics: func(req LndMetricsRequest) (*LndForwardingMetrics, error) {
|
|
auth, err := params.RetrieveMetricsAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/reports/lnd/forwarding"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := LndForwardingMetrics{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
GetLndMetrics: func(req LndMetricsRequest) (*LndMetrics, error) {
|
|
auth, err := params.RetrieveMetricsAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/reports/lnd"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := LndMetrics{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
GetLnurlPayInfo: func(query GetLnurlPayInfo_Query) (*LnurlPayInfoResponse, error) {
|
|
auth, err := params.RetrieveGuestAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/guest/lnurl_pay/info"
|
|
vals := url.Values{}
|
|
if query.K1 != nil {
|
|
vals.Set("k1", *query.K1)
|
|
}
|
|
q := vals.Encode()
|
|
if q != "" {
|
|
finalRoute = finalRoute + "?" + q
|
|
}
|
|
resBody, err := doGetRequest(params.BaseURL+finalRoute, auth)
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := LnurlPayInfoResponse{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
GetLnurlPayLink: func() (*LnurlLinkResponse, error) {
|
|
auth, err := params.RetrieveUserAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/user/lnurl_pay/link"
|
|
resBody, err := doGetRequest(params.BaseURL+finalRoute, auth)
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := LnurlLinkResponse{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
GetLnurlWithdrawInfo: func(query GetLnurlWithdrawInfo_Query) (*LnurlWithdrawInfoResponse, error) {
|
|
auth, err := params.RetrieveGuestAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/guest/lnurl_withdraw/info"
|
|
vals := url.Values{}
|
|
if query.K1 != nil {
|
|
vals.Set("k1", *query.K1)
|
|
}
|
|
q := vals.Encode()
|
|
if q != "" {
|
|
finalRoute = finalRoute + "?" + q
|
|
}
|
|
resBody, err := doGetRequest(params.BaseURL+finalRoute, auth)
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := LnurlWithdrawInfoResponse{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
GetLnurlWithdrawLink: func() (*LnurlLinkResponse, error) {
|
|
auth, err := params.RetrieveUserAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/user/lnurl_withdraw/link"
|
|
resBody, err := doGetRequest(params.BaseURL+finalRoute, auth)
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := LnurlLinkResponse{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
GetManageAuthorizations: func() (*ManageAuthorizations, error) {
|
|
auth, err := params.RetrieveUserAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/user/manage/get"
|
|
resBody, err := doGetRequest(params.BaseURL+finalRoute, auth)
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := ManageAuthorizations{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
// server streaming method: GetMigrationUpdate not implemented
|
|
GetNPubLinkingState: func(req GetNPubLinking) (*NPubLinking, error) {
|
|
auth, err := params.RetrieveAppAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/app/user/npub/state"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := NPubLinking{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
GetPaymentState: func(req GetPaymentStateRequest) (*PaymentState, error) {
|
|
auth, err := params.RetrieveUserAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/user/payment/state"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := PaymentState{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
GetProvidersDisruption: func() (*ProvidersDisruption, error) {
|
|
auth, err := params.RetrieveMetricsAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/metrics/providers/disruption"
|
|
body := []byte{}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := ProvidersDisruption{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
GetSeed: func() (*LndSeed, error) {
|
|
auth, err := params.RetrieveAdminAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/admin/seed"
|
|
resBody, err := doGetRequest(params.BaseURL+finalRoute, auth)
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := LndSeed{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
GetSingleBundleMetrics: func(req SingleMetricReq) (*BundleData, error) {
|
|
auth, err := params.RetrieveMetricsAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/reports/bundle/single"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := BundleData{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
GetSingleUsageMetrics: func(req SingleMetricReq) (*UsageMetricTlv, error) {
|
|
auth, err := params.RetrieveMetricsAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/reports/usage/single"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := UsageMetricTlv{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
GetTransactionSwapQuotes: func(req TransactionSwapRequest) (*TransactionSwapQuoteList, error) {
|
|
auth, err := params.RetrieveUserAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/user/swap/transaction/quote"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := TransactionSwapQuoteList{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
GetUsageMetrics: func(req LatestUsageMetricReq) (*UsageMetrics, error) {
|
|
auth, err := params.RetrieveMetricsAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/reports/usage"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := UsageMetrics{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
GetUserInfo: func() (*UserInfo, error) {
|
|
auth, err := params.RetrieveUserAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/user/info"
|
|
body := []byte{}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := UserInfo{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
GetUserOffer: func(req OfferId) (*OfferConfig, error) {
|
|
auth, err := params.RetrieveUserAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/user/offer/get"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := OfferConfig{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
GetUserOfferInvoices: func(req GetUserOfferInvoicesReq) (*OfferInvoices, error) {
|
|
auth, err := params.RetrieveUserAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/user/offer/get/invoices"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := OfferInvoices{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
GetUserOffers: func() (*UserOffers, error) {
|
|
auth, err := params.RetrieveUserAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/user/offers/get"
|
|
resBody, err := doGetRequest(params.BaseURL+finalRoute, auth)
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := UserOffers{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
GetUserOperations: func(req GetUserOperationsRequest) (*GetUserOperationsResponse, error) {
|
|
auth, err := params.RetrieveUserAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/user/operations"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := GetUserOperationsResponse{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
HandleLnurlAddress: func(routeParams HandleLnurlAddress_RouteParams) (*LnurlPayInfoResponse, error) {
|
|
auth, err := params.RetrieveGuestAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/.well-known/lnurlp/:address_name"
|
|
finalRoute = strings.Replace(finalRoute, ":address_name", routeParams.Address_name, 1)
|
|
resBody, err := doGetRequest(params.BaseURL+finalRoute, auth)
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := LnurlPayInfoResponse{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
HandleLnurlPay: func(query HandleLnurlPay_Query) (*HandleLnurlPayResponse, error) {
|
|
auth, err := params.RetrieveGuestAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/guest/lnurl_pay/handle"
|
|
vals := url.Values{}
|
|
if query.Amount != nil {
|
|
vals.Set("amount", *query.Amount)
|
|
}
|
|
if query.K1 != nil {
|
|
vals.Set("k1", *query.K1)
|
|
}
|
|
if query.Lnurl != nil {
|
|
vals.Set("lnurl", *query.Lnurl)
|
|
}
|
|
if query.Nostr != nil {
|
|
vals.Set("nostr", *query.Nostr)
|
|
}
|
|
q := vals.Encode()
|
|
if q != "" {
|
|
finalRoute = finalRoute + "?" + q
|
|
}
|
|
resBody, err := doGetRequest(params.BaseURL+finalRoute, auth)
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := HandleLnurlPayResponse{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
HandleLnurlWithdraw: func(query HandleLnurlWithdraw_Query) error {
|
|
auth, err := params.RetrieveGuestAuth()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
finalRoute := "/api/guest/lnurl_withdraw/handle"
|
|
vals := url.Values{}
|
|
if query.K1 != nil {
|
|
vals.Set("k1", *query.K1)
|
|
}
|
|
if query.Pr != nil {
|
|
vals.Set("pr", *query.Pr)
|
|
}
|
|
q := vals.Encode()
|
|
if q != "" {
|
|
finalRoute = finalRoute + "?" + q
|
|
}
|
|
resBody, err := doGetRequest(params.BaseURL+finalRoute, auth)
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return fmt.Errorf(result.Reason)
|
|
}
|
|
return nil
|
|
},
|
|
Health: func() error {
|
|
auth, err := params.RetrieveGuestAuth()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
finalRoute := "/api/health"
|
|
resBody, err := doGetRequest(params.BaseURL+finalRoute, auth)
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return fmt.Errorf(result.Reason)
|
|
}
|
|
return nil
|
|
},
|
|
LinkNPubThroughToken: func(req LinkNPubThroughTokenRequest) error {
|
|
auth, err := params.RetrieveGuestWithPubAuth()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
finalRoute := "/api/guest/npub/link"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return fmt.Errorf(result.Reason)
|
|
}
|
|
return nil
|
|
},
|
|
ListAdminInvoiceSwaps: func() (*InvoiceSwapsList, error) {
|
|
auth, err := params.RetrieveAdminAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/admin/swap/invoice/list"
|
|
body := []byte{}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := InvoiceSwapsList{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
ListAdminTxSwaps: func() (*TxSwapsList, error) {
|
|
auth, err := params.RetrieveAdminAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/admin/swap/transaction/list"
|
|
body := []byte{}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := TxSwapsList{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
ListChannels: func() (*LndChannels, error) {
|
|
auth, err := params.RetrieveAdminAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/admin/channels"
|
|
resBody, err := doGetRequest(params.BaseURL+finalRoute, auth)
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := LndChannels{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
ListTxSwaps: func() (*TxSwapsList, error) {
|
|
auth, err := params.RetrieveUserAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/user/swap/transaction/list"
|
|
body := []byte{}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := TxSwapsList{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
LndGetInfo: func(req LndGetInfoRequest) (*LndGetInfoResponse, error) {
|
|
auth, err := params.RetrieveAdminAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/admin/lnd/getinfo"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := LndGetInfoResponse{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
NewAddress: func(req NewAddressRequest) (*NewAddressResponse, error) {
|
|
auth, err := params.RetrieveUserAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/user/chain/new"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := NewAddressResponse{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
NewInvoice: func(req NewInvoiceRequest) (*NewInvoiceResponse, error) {
|
|
auth, err := params.RetrieveUserAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/user/invoice/new"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := NewInvoiceResponse{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
NewProductInvoice: func(query NewProductInvoice_Query) (*NewInvoiceResponse, error) {
|
|
auth, err := params.RetrieveUserAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/user/product/get/invoice"
|
|
vals := url.Values{}
|
|
if query.Id != nil {
|
|
vals.Set("id", *query.Id)
|
|
}
|
|
q := vals.Encode()
|
|
if q != "" {
|
|
finalRoute = finalRoute + "?" + q
|
|
}
|
|
resBody, err := doGetRequest(params.BaseURL+finalRoute, auth)
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := NewInvoiceResponse{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
OpenChannel: func(req OpenChannelRequest) (*OpenChannelResponse, error) {
|
|
auth, err := params.RetrieveAdminAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/admin/channel/open"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := OpenChannelResponse{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
PayAddress: func(req PayAddressRequest) (*PayAddressResponse, error) {
|
|
auth, err := params.RetrieveUserAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/user/chain/pay"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := PayAddressResponse{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
PayAdminInvoiceSwap: func(req PayAdminInvoiceSwapRequest) (*AdminInvoiceSwapResponse, error) {
|
|
auth, err := params.RetrieveAdminAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/admin/swap/invoice/pay"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := AdminInvoiceSwapResponse{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
PayAdminTransactionSwap: func(req PayAdminTransactionSwapRequest) (*AdminTxSwapResponse, error) {
|
|
auth, err := params.RetrieveAdminAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/admin/swap/transaction/pay"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := AdminTxSwapResponse{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
PayAppUserInvoice: func(req PayAppUserInvoiceRequest) (*PayInvoiceResponse, error) {
|
|
auth, err := params.RetrieveAppAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/app/invoice/pay"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := PayInvoiceResponse{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
PayInvoice: func(req PayInvoiceRequest) (*PayInvoiceResponse, error) {
|
|
auth, err := params.RetrieveUserAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/user/invoice/pay"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := PayInvoiceResponse{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
PingSubProcesses: func() error {
|
|
auth, err := params.RetrieveMetricsAuth()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
finalRoute := "/api/metrics/ping"
|
|
body := []byte{}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return fmt.Errorf(result.Reason)
|
|
}
|
|
return nil
|
|
},
|
|
RefundAdminInvoiceSwap: func(req RefundAdminInvoiceSwapRequest) (*AdminInvoiceSwapResponse, error) {
|
|
auth, err := params.RetrieveAdminAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/admin/swap/invoice/refund"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := AdminInvoiceSwapResponse{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
RequestNPubLinkingToken: func(req RequestNPubLinkingTokenRequest) (*RequestNPubLinkingTokenResponse, error) {
|
|
auth, err := params.RetrieveAppAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/app/user/npub/token"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := RequestNPubLinkingTokenResponse{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
ResetDebit: func(req DebitOperation) error {
|
|
auth, err := params.RetrieveUserAuth()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
finalRoute := "/api/user/debit/reset"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return fmt.Errorf(result.Reason)
|
|
}
|
|
return nil
|
|
},
|
|
ResetManage: func(req ManageOperation) error {
|
|
auth, err := params.RetrieveUserAuth()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
finalRoute := "/api/user/manage/reset"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return fmt.Errorf(result.Reason)
|
|
}
|
|
return nil
|
|
},
|
|
ResetMetricsStorages: func() error {
|
|
auth, err := params.RetrieveMetricsAuth()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
finalRoute := "/api/metrics/reset"
|
|
body := []byte{}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return fmt.Errorf(result.Reason)
|
|
}
|
|
return nil
|
|
},
|
|
ResetNPubLinkingToken: func(req RequestNPubLinkingTokenRequest) (*RequestNPubLinkingTokenResponse, error) {
|
|
auth, err := params.RetrieveAppAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/app/user/npub/token/reset"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := RequestNPubLinkingTokenResponse{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
RespondToDebit: func(req DebitResponse) error {
|
|
auth, err := params.RetrieveUserAuth()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
finalRoute := "/api/user/debit/finish"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return fmt.Errorf(result.Reason)
|
|
}
|
|
return nil
|
|
},
|
|
SendAppUserToAppPayment: func(req SendAppUserToAppPaymentRequest) error {
|
|
auth, err := params.RetrieveAppAuth()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
finalRoute := "/api/app/internal/pay"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return fmt.Errorf(result.Reason)
|
|
}
|
|
return nil
|
|
},
|
|
SendAppUserToAppUserPayment: func(req SendAppUserToAppUserPaymentRequest) error {
|
|
auth, err := params.RetrieveAppAuth()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
finalRoute := "/api/app/user/internal/pay"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return fmt.Errorf(result.Reason)
|
|
}
|
|
return nil
|
|
},
|
|
SetMockAppBalance: func(req SetMockAppBalanceRequest) error {
|
|
auth, err := params.RetrieveAppAuth()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
finalRoute := "/api/app/mock/blance/set"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return fmt.Errorf(result.Reason)
|
|
}
|
|
return nil
|
|
},
|
|
SetMockAppUserBalance: func(req SetMockAppUserBalanceRequest) error {
|
|
auth, err := params.RetrieveAppAuth()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
finalRoute := "/api/app/mock/user/blance/set"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return fmt.Errorf(result.Reason)
|
|
}
|
|
return nil
|
|
},
|
|
SetMockInvoiceAsPaid: func(req SetMockInvoiceAsPaidRequest) error {
|
|
auth, err := params.RetrieveGuestAuth()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
finalRoute := "/api/lnd/mock/invoice/paid"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return fmt.Errorf(result.Reason)
|
|
}
|
|
return nil
|
|
},
|
|
// server streaming method: SubToWebRtcCandidates not implemented
|
|
SubmitWebRtcMessage: func(req WebRtcMessage) (*WebRtcAnswer, error) {
|
|
auth, err := params.RetrieveMetricsAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/upgrade/wrtc"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := WebRtcAnswer{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
UpdateCallbackUrl: func(req CallbackUrl) (*CallbackUrl, error) {
|
|
auth, err := params.RetrieveUserAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/user/cb/update"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := CallbackUrl{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
UpdateChannelPolicy: func(req UpdateChannelPolicyRequest) error {
|
|
auth, err := params.RetrieveAdminAuth()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
finalRoute := "/api/admin/channel/policy/update"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return fmt.Errorf(result.Reason)
|
|
}
|
|
return nil
|
|
},
|
|
UpdateUserOffer: func(req OfferConfig) error {
|
|
auth, err := params.RetrieveUserAuth()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
finalRoute := "/api/user/offer/update"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return fmt.Errorf(result.Reason)
|
|
}
|
|
return nil
|
|
},
|
|
UseInviteLink: func(req UseInviteLinkRequest) error {
|
|
auth, err := params.RetrieveGuestWithPubAuth()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
finalRoute := "/api/guest/invite"
|
|
body, err := json.Marshal(req)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return fmt.Errorf(result.Reason)
|
|
}
|
|
return nil
|
|
},
|
|
UserHealth: func() (*UserHealthState, error) {
|
|
auth, err := params.RetrieveUserAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/user/health"
|
|
body := []byte{}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := UserHealthState{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
ZipMetricsStorages: func() (*ZippedMetrics, error) {
|
|
auth, err := params.RetrieveMetricsAuth()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
finalRoute := "/api/metrics/zip"
|
|
body := []byte{}
|
|
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := ResultError{}
|
|
err = json.Unmarshal(resBody, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.Status == "ERROR" {
|
|
return nil, fmt.Errorf(result.Reason)
|
|
}
|
|
res := ZippedMetrics{}
|
|
err = json.Unmarshal(resBody, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
},
|
|
}
|
|
}
|