Merge pull request #891 from shocknet/assets_liabilities

assets and liabilities
This commit is contained in:
Justin (shocknet) 2026-02-27 00:42:29 -05:00 committed by GitHub
commit f0418fb389
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 843 additions and 11 deletions

View file

@ -80,6 +80,7 @@ type Client struct {
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)
@ -842,6 +843,35 @@ func NewClient(params ClientParams) *Client {
}
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 {

View file

@ -79,6 +79,13 @@ const (
USAGE_METRIC SingleMetricType = "USAGE_METRIC"
)
type TrackedOperationType string
const (
ROOT TrackedOperationType = "ROOT"
USER TrackedOperationType = "USER"
)
type UserOperationType string
const (
@ -163,6 +170,21 @@ type AppsMetricsRequest struct {
Include_operations bool `json:"include_operations"`
To_unix int64 `json:"to_unix"`
}
type AssetOperation struct {
Amount int64 `json:"amount"`
Tracked *TrackedOperation `json:"tracked"`
Ts int64 `json:"ts"`
}
type AssetsAndLiabilities struct {
Liquidity_providers []LiquidityAssetProvider `json:"liquidity_providers"`
Lnds []LndAssetProvider `json:"lnds"`
Users_balance int64 `json:"users_balance"`
}
type AssetsAndLiabilitiesReq struct {
Limit_invoices int64 `json:"limit_invoices"`
Limit_payments int64 `json:"limit_payments"`
Limit_providers int64 `json:"limit_providers"`
}
type AuthApp struct {
App *Application `json:"app"`
Auth_token string `json:"auth_token"`
@ -398,6 +420,10 @@ type LatestUsageMetricReq struct {
type LinkNPubThroughTokenRequest struct {
Token string `json:"token"`
}
type LiquidityAssetProvider struct {
Pubkey string `json:"pubkey"`
Tracked *TrackedLiquidityProvider `json:"tracked"`
}
type LiveDebitRequest struct {
Debit *LiveDebitRequest_debit `json:"debit"`
Npub string `json:"npub"`
@ -411,6 +437,10 @@ type LiveUserOperation struct {
Latest_balance int64 `json:"latest_balance"`
Operation *UserOperation `json:"operation"`
}
type LndAssetProvider struct {
Pubkey string `json:"pubkey"`
Tracked *TrackedLndProvider `json:"tracked"`
}
type LndChannels struct {
Open_channels []OpenChannel `json:"open_channels"`
}
@ -715,6 +745,25 @@ type SingleMetricReq struct {
Page int64 `json:"page"`
Request_id int64 `json:"request_id"`
}
type TrackedLiquidityProvider struct {
Balance int64 `json:"balance"`
Invoices []AssetOperation `json:"invoices"`
Payments []AssetOperation `json:"payments"`
}
type TrackedLndProvider struct {
Channels_balance int64 `json:"channels_balance"`
Confirmed_balance int64 `json:"confirmed_balance"`
Incoming_tx []AssetOperation `json:"incoming_tx"`
Invoices []AssetOperation `json:"invoices"`
Outgoing_tx []AssetOperation `json:"outgoing_tx"`
Payments []AssetOperation `json:"payments"`
Unconfirmed_balance int64 `json:"unconfirmed_balance"`
}
type TrackedOperation struct {
Amount int64 `json:"amount"`
Ts int64 `json:"ts"`
Type TrackedOperationType `json:"type"`
}
type TransactionSwapQuote struct {
Chain_fee_sats int64 `json:"chain_fee_sats"`
Completed_at_unix int64 `json:"completed_at_unix"`