mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-19 11:15:49 +00:00
[DOC] rippled gateway_balances method
This commit is contained in:
@@ -427,6 +427,7 @@ API methods for the Websocket and JSON-RPC APIs are defined by command names, an
|
||||
* [`account_offers` - Get info about an account's currency exchange offers](#account-offers)
|
||||
* [`account_tx` - Get info about an account's transactions](#account-tx)
|
||||
* [`book_offers` - Get info about offers to exchange two currencies](#book-offers)
|
||||
* [`gateway_balances` - Calculate total amounts issued by an account](#gateway-balances)
|
||||
* [`ledger` - Get info about a ledger version](#ledger)
|
||||
* [`ledger_closed` - Get the latest closed ledger version](#ledger-closed)
|
||||
* [`ledger_current` - Get the current working ledger version](#ledger-current)
|
||||
@@ -2659,6 +2660,225 @@ The response follows the [standard format](#response-formatting), with a success
|
||||
* `lgrNotFound` - The ledger specified by the `ledger_hash` or `ledger_index` does not exist, or it does exist but the server does not have it.
|
||||
|
||||
|
||||
## gateway_balances ##
|
||||
[[Source]<br>](https://github.com/ripple/rippled/blob/9111ad1a9dc37d49d085aa317712625e635197c0/src/ripple/rpc/handlers/GatewayBalances.cpp "Source")
|
||||
|
||||
The `gateway_balances` command calculates the total balances issued by a given account, optionally excluding amounts held by specific "hot wallet" addresses. _(New in [version 0.28.2](https://github.com/ripple/rippled/releases/tag/0.28.2).)_
|
||||
|
||||
#### Request Format ####
|
||||
An example of the request format:
|
||||
|
||||
<div class='multicode'>
|
||||
|
||||
*WebSocket*
|
||||
|
||||
```
|
||||
{
|
||||
"id": "example_gateway_balances_1",
|
||||
"command": "gateway_balances",
|
||||
"account": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
|
||||
"strict": true,
|
||||
"hotwallet": ["rKm4uWpg9tfwbVSeATv4KxDe6mpE9yPkgJ","ra7JkEzrgeKHdzKgo4EUUVBnxggY4z37kt"],
|
||||
"ledger_index": "validated"
|
||||
}
|
||||
```
|
||||
|
||||
*JSON-RPC*
|
||||
|
||||
```
|
||||
{
|
||||
"method": "gateway_balances",
|
||||
"params": [
|
||||
{
|
||||
"account": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
|
||||
"hotwallet": [
|
||||
"rKm4uWpg9tfwbVSeATv4KxDe6mpE9yPkgJ",
|
||||
"ra7JkEzrgeKHdzKgo4EUUVBnxggY4z37kt"
|
||||
],
|
||||
"ledger_index": "validated",
|
||||
"strict": true
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
The request includes the following parameters:
|
||||
|
||||
| Field | Type | Description |
|
||||
|-----------|---------|-------------|
|
||||
| account | String | The address of the account to use |
|
||||
| strict | Boolean | (Optional) If true, only accept an address or public key for the account parameter. Defaults to false. |
|
||||
| hotwallet | String or Array | The address of a hot wallet account to exclude from the balances issued, or an array of such addresses. |
|
||||
| ledger\_hash | String | (Optional) A 20-byte hex string for the ledger version to use. (See [Specifying a Ledger](#specifying-a-ledger-instance)) |
|
||||
| ledger\_index | String or Unsigned Integer| (Optional) The sequence number of the ledger version to use, or a shortcut string to choose a ledger automatically. (See [Specifying a Ledger](#specifying-a-ledger-instance))|
|
||||
|
||||
#### Response Format ####
|
||||
|
||||
An example of a successful response:
|
||||
|
||||
<div class='multicode'>
|
||||
|
||||
*WebSocket*
|
||||
|
||||
```
|
||||
{
|
||||
"id": 3,
|
||||
"status": "success",
|
||||
"type": "response",
|
||||
"result": {
|
||||
"account": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
|
||||
"assets": {
|
||||
"r9F6wk8HkXrgYWoJ7fsv4VrUBVoqDVtzkH": [
|
||||
{
|
||||
"currency": "BTC",
|
||||
"value": "5444166510000000e-26"
|
||||
}
|
||||
],
|
||||
"rPFLkxQk6xUGdGYEykqe7PR25Gr7mLHDc8": [
|
||||
{
|
||||
"currency": "EUR",
|
||||
"value": "4000000000000000e-27"
|
||||
}
|
||||
],
|
||||
"rPU6VbckqCLW4kb51CWqZdxvYyQrQVsnSj": [
|
||||
{
|
||||
"currency": "BTC",
|
||||
"value": "1029900000000000e-26"
|
||||
}
|
||||
],
|
||||
"rpR95n1iFkTqpoy1e878f4Z1pVHVtWKMNQ": [
|
||||
{
|
||||
"currency": "BTC",
|
||||
"value": "4000000000000000e-30"
|
||||
}
|
||||
],
|
||||
"rwmUaXsWtXU4Z843xSYwgt1is97bgY8yj6": [
|
||||
{
|
||||
"currency": "BTC",
|
||||
"value": "8700000000000000e-30"
|
||||
}
|
||||
]
|
||||
},
|
||||
"balances": {
|
||||
"rKm4uWpg9tfwbVSeATv4KxDe6mpE9yPkgJ": [
|
||||
{
|
||||
"currency": "EUR",
|
||||
"value": "29826.1965999999"
|
||||
}
|
||||
],
|
||||
"ra7JkEzrgeKHdzKgo4EUUVBnxggY4z37kt": [
|
||||
{
|
||||
"currency": "USD",
|
||||
"value": "13857.70416"
|
||||
}
|
||||
]
|
||||
},
|
||||
"ledger_hash": "61DDBF304AF6E8101576BF161D447CA8E4F0170DDFBEAFFD993DC9383D443388",
|
||||
"ledger_index": 14483195,
|
||||
"obligations": {
|
||||
"BTC": "5908.324927635318",
|
||||
"EUR": "992471.7419793958",
|
||||
"GBP": "4991.38706013193",
|
||||
"USD": "1997134.20229482"
|
||||
},
|
||||
"validated": true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
*JSON-RPC*
|
||||
|
||||
```
|
||||
200 OK
|
||||
{
|
||||
"result": {
|
||||
"account": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
|
||||
"assets": {
|
||||
"r9F6wk8HkXrgYWoJ7fsv4VrUBVoqDVtzkH": [
|
||||
{
|
||||
"currency": "BTC",
|
||||
"value": "5444166510000000e-26"
|
||||
}
|
||||
],
|
||||
"rPFLkxQk6xUGdGYEykqe7PR25Gr7mLHDc8": [
|
||||
{
|
||||
"currency": "EUR",
|
||||
"value": "4000000000000000e-27"
|
||||
}
|
||||
],
|
||||
"rPU6VbckqCLW4kb51CWqZdxvYyQrQVsnSj": [
|
||||
{
|
||||
"currency": "BTC",
|
||||
"value": "1029900000000000e-26"
|
||||
}
|
||||
],
|
||||
"rpR95n1iFkTqpoy1e878f4Z1pVHVtWKMNQ": [
|
||||
{
|
||||
"currency": "BTC",
|
||||
"value": "4000000000000000e-30"
|
||||
}
|
||||
],
|
||||
"rwmUaXsWtXU4Z843xSYwgt1is97bgY8yj6": [
|
||||
{
|
||||
"currency": "BTC",
|
||||
"value": "8700000000000000e-30"
|
||||
}
|
||||
]
|
||||
},
|
||||
"balances": {
|
||||
"rKm4uWpg9tfwbVSeATv4KxDe6mpE9yPkgJ": [
|
||||
{
|
||||
"currency": "EUR",
|
||||
"value": "29826.1965999999"
|
||||
}
|
||||
],
|
||||
"ra7JkEzrgeKHdzKgo4EUUVBnxggY4z37kt": [
|
||||
{
|
||||
"currency": "USD",
|
||||
"value": "13857.70416"
|
||||
}
|
||||
]
|
||||
},
|
||||
"ledger_hash": "980FECF48CA4BFDEC896692C31A50D484BDFE865EC101B00259C413AA3DBD672",
|
||||
"ledger_index": 14483212,
|
||||
"obligations": {
|
||||
"BTC": "5908.324927635318",
|
||||
"EUR": "992471.7419793958",
|
||||
"GBP": "4991.38706013193",
|
||||
"USD": "1997134.20229482"
|
||||
},
|
||||
"status": "success",
|
||||
"validated": true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
**Note:** There is no command-line syntax for this method. Use the [`json` command](#json) to access this from the command line.
|
||||
|
||||
The response follows the [standard format](#response-formatting), with a successful result containing the following fields:
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| obligations | Object | (Omitted if empty) Total amounts issued to accounts that are not hot wallets, as a map of currencies to the total value issued. |
|
||||
| balances | Object | (Omitted if empty) Amounts issued to the `hotwallet` accounts from the request. The keys are hot wallet addresses and the values are arrays of currency amounts they hold. The issuer (omitted from the currency amounts) is the account from the request. |
|
||||
| assets | Object | (Omitted if empty) Total amounts held that are issued by others. For the recommended gateway configuration, there should be none. |
|
||||
| ledger\_hash | String | (May be omitted) The identifying hash of the ledger that was used to generate this response. |
|
||||
| ledger\_index | Number | (May be omitted) The sequence number of the ledger version that was used to generate this response. |
|
||||
| ledger\_current\_index | Number | (May be omitted) The sequence number of the current in-progress ledger version that was used to generate this response. |
|
||||
|
||||
#### Possible Errors ####
|
||||
|
||||
* Any of the [universal error types](#universal-errors).
|
||||
* `invalidParams` - One or more fields are specified incorrectly, or one or more required fields are missing.
|
||||
* `invalidHotWallet` - One or more of the addresses specified in the `hotwallet` field is not the address of an account holding currency issued by the account from the request.
|
||||
* `actNotFound` - The address specified in the `account` field of the request does not correspond to an account in the ledger.
|
||||
* `lgrNotFound` - The ledger specified by the `ledger_hash` or `ledger_index` does not exist, or it does exist but the server does not have it.
|
||||
|
||||
|
||||
|
||||
## wallet_propose ##
|
||||
[[Source]<br>](https://github.com/ripple/rippled/blob/master/src/ripple/rpc/handlers/WalletPropose.cpp "Source")
|
||||
|
||||
Reference in New Issue
Block a user