swaps wired
This commit is contained in:
parent
ec2d48664a
commit
f20d40e44f
21 changed files with 679 additions and 137 deletions
|
|
@ -101,6 +101,7 @@ type Client struct {
|
|||
GetSeed func() (*LndSeed, error)
|
||||
GetSingleBundleMetrics func(req SingleMetricReq) (*BundleData, error)
|
||||
GetSingleUsageMetrics func(req SingleMetricReq) (*UsageMetricTlv, error)
|
||||
GetTransactionSwapQuote func(req TransactionSwapRequest) (*TransactionSwapQuote, error)
|
||||
GetUsageMetrics func(req LatestUsageMetricReq) (*UsageMetrics, error)
|
||||
GetUserInfo func() (*UserInfo, error)
|
||||
GetUserOffer func(req OfferId) (*OfferConfig, error)
|
||||
|
|
@ -1285,6 +1286,35 @@ func NewClient(params ClientParams) *Client {
|
|||
}
|
||||
return &res, nil
|
||||
},
|
||||
GetTransactionSwapQuote: func(req TransactionSwapRequest) (*TransactionSwapQuote, error) {
|
||||
auth, err := params.RetrieveUserAuth()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
finalRoute := "/api/user/swap/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 := TransactionSwapQuote{}
|
||||
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 {
|
||||
|
|
|
|||
|
|
@ -532,9 +532,10 @@ type OperationsCursor struct {
|
|||
Ts int64 `json:"ts"`
|
||||
}
|
||||
type PayAddressRequest struct {
|
||||
Address string `json:"address"`
|
||||
Amoutsats int64 `json:"amoutSats"`
|
||||
Satspervbyte int64 `json:"satsPerVByte"`
|
||||
Address string `json:"address"`
|
||||
Amoutsats int64 `json:"amoutSats"`
|
||||
Satspervbyte int64 `json:"satsPerVByte"`
|
||||
Swap_operation_id string `json:"swap_operation_id"`
|
||||
}
|
||||
type PayAddressResponse struct {
|
||||
Network_fee int64 `json:"network_fee"`
|
||||
|
|
@ -639,6 +640,16 @@ type SingleMetricReq struct {
|
|||
Page int64 `json:"page"`
|
||||
Request_id int64 `json:"request_id"`
|
||||
}
|
||||
type TransactionSwapQuote struct {
|
||||
Chain_fee_sats int64 `json:"chain_fee_sats"`
|
||||
Invoice_amount_sats int64 `json:"invoice_amount_sats"`
|
||||
Swap_fee_sats int64 `json:"swap_fee_sats"`
|
||||
Swap_operation_id string `json:"swap_operation_id"`
|
||||
Transaction_amount_sats int64 `json:"transaction_amount_sats"`
|
||||
}
|
||||
type TransactionSwapRequest struct {
|
||||
Transaction_amount_sats int64 `json:"transaction_amount_sats"`
|
||||
}
|
||||
type UpdateChannelPolicyRequest struct {
|
||||
Policy *ChannelPolicy `json:"policy"`
|
||||
Update *UpdateChannelPolicyRequest_update `json:"update"`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue