admin swaps
This commit is contained in:
parent
a596e186fe
commit
d120ad7f99
22 changed files with 1258 additions and 226 deletions
|
|
@ -74,6 +74,7 @@ type Client struct {
|
|||
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)
|
||||
|
|
@ -114,16 +115,18 @@ type Client struct {
|
|||
HandleLnurlWithdraw func(query HandleLnurlWithdraw_Query) error
|
||||
Health func() error
|
||||
LinkNPubThroughToken func(req LinkNPubThroughTokenRequest) error
|
||||
ListAdminSwaps func() (*SwapsList, error)
|
||||
ListAdminInvoiceSwaps func() (*InvoiceSwapsList, error)
|
||||
ListAdminTxSwaps func() (*TxSwapsList, error)
|
||||
ListChannels func() (*LndChannels, error)
|
||||
ListSwaps func() (*SwapsList, 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)
|
||||
PayAdminTransactionSwap func(req PayAdminTransactionSwapRequest) (*AdminSwapResponse, 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
|
||||
|
|
@ -667,6 +670,35 @@ func NewClient(params ClientParams) *Client {
|
|||
}
|
||||
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 {
|
||||
|
|
@ -1324,7 +1356,7 @@ func NewClient(params ClientParams) *Client {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
finalRoute := "/api/user/swap/quote"
|
||||
finalRoute := "/api/user/swap/transaction/quote"
|
||||
body, err := json.Marshal(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
@ -1643,12 +1675,12 @@ func NewClient(params ClientParams) *Client {
|
|||
}
|
||||
return nil
|
||||
},
|
||||
ListAdminSwaps: func() (*SwapsList, error) {
|
||||
ListAdminInvoiceSwaps: func() (*InvoiceSwapsList, error) {
|
||||
auth, err := params.RetrieveAdminAuth()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
finalRoute := "/api/admin/swap/list"
|
||||
finalRoute := "/api/admin/swap/invoice/list"
|
||||
body := []byte{}
|
||||
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
||||
if err != nil {
|
||||
|
|
@ -1662,7 +1694,33 @@ func NewClient(params ClientParams) *Client {
|
|||
if result.Status == "ERROR" {
|
||||
return nil, fmt.Errorf(result.Reason)
|
||||
}
|
||||
res := SwapsList{}
|
||||
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
|
||||
|
|
@ -1691,12 +1749,12 @@ func NewClient(params ClientParams) *Client {
|
|||
}
|
||||
return &res, nil
|
||||
},
|
||||
ListSwaps: func() (*SwapsList, error) {
|
||||
ListTxSwaps: func() (*TxSwapsList, error) {
|
||||
auth, err := params.RetrieveUserAuth()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
finalRoute := "/api/user/swap/list"
|
||||
finalRoute := "/api/user/swap/transaction/list"
|
||||
body := []byte{}
|
||||
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
||||
if err != nil {
|
||||
|
|
@ -1710,7 +1768,7 @@ func NewClient(params ClientParams) *Client {
|
|||
if result.Status == "ERROR" {
|
||||
return nil, fmt.Errorf(result.Reason)
|
||||
}
|
||||
res := SwapsList{}
|
||||
res := TxSwapsList{}
|
||||
err = json.Unmarshal(resBody, &res)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
@ -1892,7 +1950,36 @@ func NewClient(params ClientParams) *Client {
|
|||
}
|
||||
return &res, nil
|
||||
},
|
||||
PayAdminTransactionSwap: func(req PayAdminTransactionSwapRequest) (*AdminSwapResponse, error) {
|
||||
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
|
||||
|
|
@ -1914,7 +2001,7 @@ func NewClient(params ClientParams) *Client {
|
|||
if result.Status == "ERROR" {
|
||||
return nil, fmt.Errorf(result.Reason)
|
||||
}
|
||||
res := AdminSwapResponse{}
|
||||
res := AdminTxSwapResponse{}
|
||||
err = json.Unmarshal(resBody, &res)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
|
|
@ -123,7 +123,10 @@ type AddProductRequest struct {
|
|||
Name string `json:"name"`
|
||||
Price_sats int64 `json:"price_sats"`
|
||||
}
|
||||
type AdminSwapResponse struct {
|
||||
type AdminInvoiceSwapResponse struct {
|
||||
Tx_id string `json:"tx_id"`
|
||||
}
|
||||
type AdminTxSwapResponse struct {
|
||||
Network_fee int64 `json:"network_fee"`
|
||||
Tx_id string `json:"tx_id"`
|
||||
}
|
||||
|
|
@ -356,6 +359,35 @@ type HttpCreds struct {
|
|||
Token string `json:"token"`
|
||||
Url string `json:"url"`
|
||||
}
|
||||
type InvoiceSwapOperation struct {
|
||||
Failure_reason string `json:"failure_reason"`
|
||||
Invoice_paid string `json:"invoice_paid"`
|
||||
Operation_payment *UserOperation `json:"operation_payment"`
|
||||
Swap_operation_id string `json:"swap_operation_id"`
|
||||
Tx_id string `json:"tx_id"`
|
||||
}
|
||||
type InvoiceSwapQuote struct {
|
||||
Address string `json:"address"`
|
||||
Chain_fee_sats int64 `json:"chain_fee_sats"`
|
||||
Invoice string `json:"invoice"`
|
||||
Invoice_amount_sats int64 `json:"invoice_amount_sats"`
|
||||
Service_fee_sats int64 `json:"service_fee_sats"`
|
||||
Service_url string `json:"service_url"`
|
||||
Swap_fee_sats int64 `json:"swap_fee_sats"`
|
||||
Swap_operation_id string `json:"swap_operation_id"`
|
||||
Transaction_amount_sats int64 `json:"transaction_amount_sats"`
|
||||
Tx_id string `json:"tx_id"`
|
||||
}
|
||||
type InvoiceSwapQuoteList struct {
|
||||
Quotes []InvoiceSwapQuote `json:"quotes"`
|
||||
}
|
||||
type InvoiceSwapRequest struct {
|
||||
Invoice string `json:"invoice"`
|
||||
}
|
||||
type InvoiceSwapsList struct {
|
||||
Quotes []InvoiceSwapQuote `json:"quotes"`
|
||||
Swaps []InvoiceSwapOperation `json:"swaps"`
|
||||
}
|
||||
type LatestBundleMetricReq struct {
|
||||
Limit int64 `json:"limit"`
|
||||
}
|
||||
|
|
@ -559,6 +591,10 @@ type PayAddressResponse struct {
|
|||
Service_fee int64 `json:"service_fee"`
|
||||
Txid string `json:"txId"`
|
||||
}
|
||||
type PayAdminInvoiceSwapRequest struct {
|
||||
Sat_per_v_byte int64 `json:"sat_per_v_byte"`
|
||||
Swap_operation_id string `json:"swap_operation_id"`
|
||||
}
|
||||
type PayAdminTransactionSwapRequest struct {
|
||||
Address string `json:"address"`
|
||||
Swap_operation_id string `json:"swap_operation_id"`
|
||||
|
|
@ -665,16 +701,6 @@ type SingleMetricReq struct {
|
|||
Page int64 `json:"page"`
|
||||
Request_id int64 `json:"request_id"`
|
||||
}
|
||||
type SwapOperation struct {
|
||||
Address_paid string `json:"address_paid"`
|
||||
Failure_reason string `json:"failure_reason"`
|
||||
Operation_payment *UserOperation `json:"operation_payment"`
|
||||
Swap_operation_id string `json:"swap_operation_id"`
|
||||
}
|
||||
type SwapsList struct {
|
||||
Quotes []TransactionSwapQuote `json:"quotes"`
|
||||
Swaps []SwapOperation `json:"swaps"`
|
||||
}
|
||||
type TransactionSwapQuote struct {
|
||||
Chain_fee_sats int64 `json:"chain_fee_sats"`
|
||||
Invoice_amount_sats int64 `json:"invoice_amount_sats"`
|
||||
|
|
@ -690,6 +716,16 @@ type TransactionSwapQuoteList struct {
|
|||
type TransactionSwapRequest struct {
|
||||
Transaction_amount_sats int64 `json:"transaction_amount_sats"`
|
||||
}
|
||||
type TxSwapOperation struct {
|
||||
Address_paid string `json:"address_paid"`
|
||||
Failure_reason string `json:"failure_reason"`
|
||||
Operation_payment *UserOperation `json:"operation_payment"`
|
||||
Swap_operation_id string `json:"swap_operation_id"`
|
||||
}
|
||||
type TxSwapsList struct {
|
||||
Quotes []TransactionSwapQuote `json:"quotes"`
|
||||
Swaps []TxSwapOperation `json:"swaps"`
|
||||
}
|
||||
type UpdateChannelPolicyRequest struct {
|
||||
Policy *ChannelPolicy `json:"policy"`
|
||||
Update *UpdateChannelPolicyRequest_update `json:"update"`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue