Compare commits

...

5 Commits

Author SHA1 Message Date
Elliot Lee
4a0d675726 Release 1.0.0-beta.0 2018-05-10 15:56:23 -07:00
Elliot Lee
b2b6715ac0 Add request(), hasNextPage(), and requestNextPage() (#887)
* Add support for all rippled APIs, including subscriptions.
* Add support for arbitrary stream message types.
* Note that rippled APIs take amounts in drops.
* request() will be available in ripple-lib version 1.0.0+
2018-05-10 15:43:56 -07:00
Elliot Lee
823d93b86c Add checksums for 0.22.0 2018-05-10 15:26:43 -07:00
Elliot Lee
7a42db99c9 Bump version to 0.22.0 2018-05-10 00:33:20 -07:00
Elliot Lee
f28ec27614 getOrderbook - return raw order data (#886)
Fix #799
2018-05-08 15:05:41 -07:00
31 changed files with 1779 additions and 94 deletions

View File

@@ -1,5 +1,34 @@
# ripple-lib Release History
## 1.0.0-beta.0 (2018-05-10)
+ [Add `request`, `hasNextPage`, and
`requestNextPage`](https://github.com/ripple/ripple-lib/pull/887).
+ This provides support for all rippled APIs, including subscriptions.
+ Note that rippled APIs take XRP amounts in drops (1 drop = 0.000001 XRP).
The SHA-256 checksums for the browser version of this release can be found
below.
```
% shasum -a 256 *
ab2094979a3d6b320c7bc22bc5946c50fa5e29af0976d352e7689b0a4d840c55 ripple-1.0.0-beta.0-debug.js
0e7f7d740606c2866ebf63776b13b41a555848e1a1419e2c8058d2e6c562d7fd ripple-1.0.0-beta.0-min.js
bd05e8806832ca4192aea7ba2d0362baa9f44605f8e8e6676acd25eb0b94b778 ripple-1.0.0-beta.0.js
```
## 0.22.0 (2018-05-10)
+ [`getOrderbook` - return raw order data](https://github.com/ripple/ripple-lib/pull/886). The full `BookOffer` data is now provided under `data`.
The SHA-256 checksums for the browser version of this release can be found
below.
```
% shasum -a 256 *
33f71b55c4adec4452826e44fe7809377364df04222b60f0fce01e7de2daff33 ripple-0.22.0-debug.js
63232888a4ea77065e8e8eb8fdaa8ebfe3a785428fe935e2667c1ea54c837f29 ripple-0.22.0-min.js
ab98026fabe296bd938297c48cb58e01dfdbe90f3c66c9617d6a3e1efd4c6b93 ripple-0.22.0.js
```
## 0.21.0 (2018-04-11)
+ [Upgrade https-proxy-agent](https://github.com/ripple/ripple-lib/pull/883)
@@ -8,7 +37,7 @@
The SHA-256 checksums for the browser version of this release can be found
below.
```
% shasum -a 256 *
% shasum -a 256 *
3ab52209ad4a80393c8c08ef3f4aa9cfb47bc76c0ede2ee9fa7f5ca180ba4d67 ripple-0.21.0-debug.js
3b1efccded347bed5f64757098a1ea6a513bb8932d922d00af47cd24e001dc14 ripple-0.21.0-min.js
db08e5a3eab1f659b4c803543374398004d950ba720adc4b9a7658817cb5c94b ripple-0.21.0.js

View File

@@ -33,6 +33,11 @@
- [Payment Channel Create](#payment-channel-create)
- [Payment Channel Fund](#payment-channel-fund)
- [Payment Channel Claim](#payment-channel-claim)
- [rippled APIs](#rippled-apis)
- [Listening to streams](#listening-to-streams)
- [request](#request)
- [hasNextPage](#hasnextpage)
- [requestNextPage](#requestnextpage)
- [API Methods](#api-methods)
- [connect](#connect)
- [disconnect](#disconnect)
@@ -84,7 +89,7 @@
# Introduction
RippleAPI is the official client library to the XRP Ledger. Currently, RippleAPI is only available in JavaScript.
RippleAPI (ripple-lib) is the official client library to the XRP Ledger. Currently, RippleAPI is only available in JavaScript.
Using RippleAPI, you can:
* [Query transactions from the XRP Ledger history](#gettransaction)
@@ -93,8 +98,6 @@ Using RippleAPI, you can:
* [Generate a new XRP Ledger Address](#generateaddress)
* ... and [much more](#api-methods).
RippleAPI only provides access to *validated*, *immutable* transaction data.
## Boilerplate
Use the following [boilerplate code](https://en.wikipedia.org/wiki/Boilerplate_code) to wrap your custom code using RippleAPI.
@@ -750,6 +753,185 @@ signature | string | *Optional* Signed claim authorizing withdrawal of XRP from
```
# rippled APIs
ripple-lib relies on [rippled APIs](https://ripple.com/build/rippled-apis/) for all online functionality. With ripple-lib version 1.0.0 and higher, you can easily access rippled APIs through ripple-lib. Use the `request()`, `hasNextPage()`, and `requestNextPage()` methods:
* Use `request()` to issue any `rippled` command, including `account_currencies`, `subscribe`, and `unsubscribe`. [Full list of API Methods](https://ripple.com/build/rippled-apis/#api-methods).
* Use `hasNextPage()` to determine whether a response has more pages. This is true when the response includes a [`marker` field](https://ripple.com/build/rippled-apis/#markers-and-pagination).
* Use `requestNextPage()` to request the next page of data.
When using rippled APIs, [specify XRP amounts in drops](https://ripple.com/build/rippled-apis/#specifying-currency-amounts). 1 XRP = 1000000 drops.
## Listening to streams
The `rippled` server can push updates to your client when various events happen. Refer to [Subscriptions in the `rippled` API docs](https://ripple.com/build/rippled-apis/#subscriptions) for details.
Note that the `streams` parameter for generic streams takes an array. For example, to subscribe to the `validations` stream, use `{ streams: [ 'validations' ] }`.
The string names of some generic streams to subscribe to are in the table below. (Refer to `rippled` for an up-to-date list of streams.)
Type | Description
---- | -----------
`server` | Sends a message whenever the status of the `rippled` server (for example, network connectivity) changes.
`ledger` | Sends a message whenever the consensus process declares a new validated ledger.
`transactions` | Sends a message whenever a transaction is included in a closed ledger.
`transactions_proposed` | Sends a message whenever a transaction is included in a closed ledger, as well as some transactions that have not yet been included in a validated ledger and may never be. Not all proposed transactions appear before validation. Even some transactions that don't succeed are included in validated ledgers because they take the anti-spam transaction fee.
`validations` | Sends a message whenever the server receives a validation message, also called a validation vote, regardless of whether the server trusts the validator.
`manifests` | Sends a message whenever the server receives a manifest.
`peer_status` | (Admin-only) Information about connected peer `rippled` servers, especially with regards to the consensus process.
When you subscribe to a stream, you must also listen to the relevant message type(s). Some of the available message types are in the table below. (Refer to `rippled` for an up-to-date list of message types.)
Type | Description
---- | -----------
`ledgerClosed` | Sent by the `ledger` stream when the consensus process declares a new fully validated ledger. The message identifies the ledger and provides some information about its contents.
`validationReceived` | Sent by the `validations` stream when the server receives a validation message, also called a validation vote, regardless of whether the server trusts the validator.
`manifestReceived` | Sent by the `manifests` stream when the server receives a manifest.
`transaction` | Sent by many subscriptions including `transactions`, `transactions_proposed`, `accounts`, `accounts_proposed`, and `book` (Order Book). See [Transaction Streams](https://ripple.com/build/rippled-apis/#transaction-streams) for details.
`peerStatusChange` | (Admin-only) Reports a large amount of information on the activities of other `rippled` servers to which the server is connected.
To register your listener function, use `connection.on(type, handler)`.
Here is an example of listening for transactions on given account(s):
```
const account = 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn' // Replace with the account you want notifications for
api.connect().then(() => { // Omit this if you are already connected
// 'transaction' can be replaced with the relevant `type` from the table above
api.connection.on('transaction', (event) => {
// Do something useful with `event`
console.log(JSON.stringify(event, null, 2))
})
api.request('subscribe', {
accounts: [ account ]
}).then(response => {
if (response.status === 'success') {
console.log('Successfully subscribed')
}
}).catch(error => {
// Handle `error`
})
})
```
The subscription ends when you unsubscribe or the WebSocket connection is closed.
For full details, see [rippled Subscriptions](https://ripple.com/build/rippled-apis/#subscriptions).
## request
`request(command: string, options: object): Promise<object>`
Returns the response from invoking the specified command, with the specified options, on the connected rippled server.
Refer to [rippled APIs](https://ripple.com/build/rippled-apis/) for commands and options. All XRP amounts must be specified in drops. One drop is equal to 0.000001 XRP. See [Specifying Currency Amounts](https://ripple.com/build/rippled-apis/#specifying-currency-amounts).
Most commands return data for the `current` (in-progress, open) ledger by default. Do not rely on this. Always specify a ledger version in your request. In the example below, the 'validated' ledger is requested, which is the most recent ledger that has been validated by the whole network. See [Specifying Ledgers](https://ripple.com/build/rippled-apis/#specifying-ledgers).
### Return Value
This method returns a promise that resolves with the response from rippled.
### Example
```javascript
// Replace 'ledger' with your desired rippled command
return api.request('ledger', {
ledger_index: 'validated'
}).then(response => {
/* Do something useful with response */
console.log(JSON.stringify(response, null, 2))
}).catch(console.error);
```
```json
{
"ledger": {
"accepted": true,
"account_hash": "F9E9653EA76EA0AEA58AC98A8E19EDCEC8299C2940519A190674FFAED3639A1F",
"close_flags": 0,
"close_time": 577999430,
"close_time_human": "2018-Apr-25 19:23:50",
"close_time_resolution": 10,
"closed": true,
"hash": "450E5CB0A39495839DA9CD9A0FED74BD71CBB929423A907ADC00F14FC7E7F920",
"ledger_hash": "450E5CB0A39495839DA9CD9A0FED74BD71CBB929423A907ADC00F14FC7E7F920",
"ledger_index": "38217406",
"parent_close_time": 577999422,
"parent_hash": "B8B364C63EB9E13FDB89CB729FEF833089B8438CBEB8FC41744CB667209221B3",
"seqNum": "38217406",
"totalCoins": "99992286058637091",
"total_coins": "99992286058637091",
"transaction_hash": "5BDD3D2780C28FB2C91C3404BD8ED04786B764B1E18CF319888EDE2C09834726"
},
"ledger_hash": "450E5CB0A39495839DA9CD9A0FED74BD71CBB929423A907ADC00F14FC7E7F920",
"ledger_index": 38217406,
"validated": true
}
```
## hasNextPage
`hasNextPage(currentResponse): boolean`
Returns `true` when there are more pages available.
When there are more results than contained in the response, the response includes a `marker` field. You can use this convenience method, or check for `marker` yourself.
See [Markers and Pagination](https://ripple.com/build/rippled-apis/#markers-and-pagination).
### Return Value
This method returns `true` if `currentResponse` includes a `marker`.
### Example
```javascript
return api.request('ledger_data', {
ledger_index: 'validated'
}).then(response => {
/* Do something useful with response */
if (api.hasNextPage(response)) {
/* There are more pages available */
}
}).catch(console.error);
```
## requestNextPage
`requestNextPage(command: string, params: object = {}, currentResponse: object): Promise<object>`
Requests the next page of data.
You can use this convenience method, or include `currentResponse.marker` in `params` yourself, when using `request`.
See [Markers and Pagination](https://ripple.com/build/rippled-apis/#markers-and-pagination).
### Return Value
This method returns a promise that resolves with the next page of data from rippled.
If the response does not have a next page, the promise will reject with `new errors.NotFoundError('response does not have a next page')`.
### Example
```javascript
const command = 'ledger_data'
const params = {
ledger_index: 'validated'
}
return api.request(command, params).then(response => {
return api.requestNextPage(command, params, response)
}).then(response_page_2 => {
/* Do something useful with second page of response */
}).catch(console.error);
```
# API Methods
## connect
@@ -2272,6 +2454,7 @@ bids[] | object | An order in the order book.
*bids[].properties.* maker | [address](#address) | The address of the account that submitted the order.
*bids[].properties.* sequence | [sequence](#account-sequence-number) | The account sequence number of the transaction that created this order.
*bids[].properties.* makerExchangeRate | [value](#value) | The exchange rate from the point of view of the account that submitted the order (also known as "quality").
*bids[].data.* \* | object |
*bids[].* state | object | *Optional* The state of the order.
*bids[].state.* fundedAmount | [amount](#amount) | How much of the amount the maker would have to pay that the maker currently holds.
*bids[].state.* priceOfFundedAmount | [amount](#amount) | How much the `fundedAmount` would convert to through the exchange rate of this order.
@@ -2282,10 +2465,17 @@ asks[] | object | An order in the order book.
*asks[].properties.* maker | [address](#address) | The address of the account that submitted the order.
*asks[].properties.* sequence | [sequence](#account-sequence-number) | The account sequence number of the transaction that created this order.
*asks[].properties.* makerExchangeRate | [value](#value) | The exchange rate from the point of view of the account that submitted the order (also known as "quality").
*asks[].data.* \* | object |
*asks[].* state | object | *Optional* The state of the order.
*asks[].state.* fundedAmount | [amount](#amount) | How much of the amount the maker would have to pay that the maker currently holds.
*asks[].state.* priceOfFundedAmount | [amount](#amount) | How much the `fundedAmount` would convert to through the exchange rate of this order.
### New in ripple-lib 0.22.0 and higher
The response includes a `data` property containing the raw order data. This may include `owner_funds`, `Flags`, and other fields.
For details, see the rippled method [book_offers](https://ripple.com/build/rippled-apis/#book-offers).
### Example
```javascript
@@ -2326,6 +2516,30 @@ return api.getOrderbook(address, orderbook)
"maker": "rwBYyfufTzk77zUSKEu4MvixfarC35av1J",
"sequence": 386940,
"makerExchangeRate": "326.5003614141928"
},
"data": {
"Account": "rwBYyfufTzk77zUSKEu4MvixfarC35av1J",
"BookDirectory": "6EAB7C172DEFA430DBFAD120FDC373B5F5AF8B191649EC98570B9980E49C7DE8",
"BookNode": "0000000000000000",
"Flags": 0,
"LedgerEntryType": "Offer",
"OwnerNode": "0000000000000008",
"PreviousTxnID": "92DBA0BE18B331AC61FB277211477A255D3B5EA9C5FE689171DE689FB45FE18A",
"PreviousTxnLgrSeq": 10714030,
"Sequence": 386940,
"TakerGets": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0.2849323720855092"
},
"TakerPays": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "93.030522464522"
},
"index": "8092033091034D94219BC1131AF7A6B469D790D81831CB479AB6F67A32BE4E13",
"owner_funds": "31.77682120227525",
"quality": "326.5003614141928"
}
},
{
@@ -2346,6 +2560,30 @@ return api.getOrderbook(address, orderbook)
"maker": "rwjsRktX1eguUr1pHTffyHnC4uyrvX58V1",
"sequence": 207855,
"makerExchangeRate": "330.6364334177034"
},
"data": {
"Account": "rwjsRktX1eguUr1pHTffyHnC4uyrvX58V1",
"BookDirectory": "6EAB7C172DEFA430DBFAD120FDC373B5F5AF8B191649EC98570BBF1EEFA2FB0A",
"BookNode": "0000000000000000",
"Flags": 0,
"LedgerEntryType": "Offer",
"OwnerNode": "0000000000000000",
"PreviousTxnID": "C6BDA152363E3CFE18688A6830B49F3DB2B05976110B5908EA4EB66D93DEEB1F",
"PreviousTxnLgrSeq": 10714031,
"Sequence": 207855,
"TakerGets": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0.00302447007930511"
},
"TakerPays": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "1"
},
"index": "8DB3520FF9CB16A0EA955056C49115F8CFB03A587D0A4AFC844F1D220EFCE0B9",
"owner_funds": "0.0670537912615556",
"quality": "330.6364334177034"
}
},
{
@@ -2367,6 +2605,31 @@ return api.getOrderbook(address, orderbook)
"maker": "raudnGKfTK23YKfnS7ixejHrqGERTYNFXk",
"sequence": 110103,
"makerExchangeRate": "331.1338298016111"
},
"data": {
"Account": "raudnGKfTK23YKfnS7ixejHrqGERTYNFXk",
"BookDirectory": "6EAB7C172DEFA430DBFAD120FDC373B5F5AF8B191649EC98570BC3A506FC016F",
"BookNode": "0000000000000000",
"Expiration": 472785283,
"Flags": 131072,
"LedgerEntryType": "Offer",
"OwnerNode": "00000000000008F0",
"PreviousTxnID": "77E763F1D02F58965CD1AD94F557B37A582FAC7760B71F391B856959836C2F7B",
"PreviousTxnLgrSeq": 10713576,
"Sequence": 110103,
"TakerGets": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0.3"
},
"TakerPays": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "99.34014894048333"
},
"index": "9ECDFD31B28643FD3A54658398C5715D6DAD574F83F04529CB24765770F9084D",
"owner_funds": "4.021116654525635",
"quality": "331.1338298016111"
}
},
{
@@ -2399,6 +2662,40 @@ return api.getOrderbook(address, orderbook)
"value": "268.2219496064341",
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
}
},
"data": {
"Account": "rPyYxUGK8L4dgEvjPs3aRc1B1jEiLr3Hx5",
"BookDirectory": "6EAB7C172DEFA430DBFAD120FDC373B5F5AF8B191649EC98570BCB85BCA78000",
"BookNode": "0000000000000000",
"Flags": 131072,
"LedgerEntryType": "Offer",
"OwnerNode": "0000000000000000",
"PreviousTxnID": "D22993C68C94ACE3F2FCE4A334EBEA98CC46DCA92886C12B5E5B4780B5E17D4E",
"PreviousTxnLgrSeq": 10711938,
"Sequence": 392,
"TakerGets": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0.8095"
},
"TakerPays": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "268.754"
},
"index": "18B136E08EF50F0DEE8521EA22D16A950CD8B6DDF5F6E07C35F7FDDBBB09718D",
"owner_funds": "0.8095132334507441",
"quality": "332",
"taker_gets_funded": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0.8078974385735969"
},
"taker_pays_funded": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "268.2219496064341"
}
}
},
{
@@ -2420,6 +2717,30 @@ return api.getOrderbook(address, orderbook)
"maker": "raudnGKfTK23YKfnS7ixejHrqGERTYNFXk",
"sequence": 110105,
"makerExchangeRate": "337.7996295968016"
},
"data": {
"Account": "raudnGKfTK23YKfnS7ixejHrqGERTYNFXk",
"BookDirectory": "6EAB7C172DEFA430DBFAD120FDC373B5F5AF8B191649EC98570C00450D461510",
"BookNode": "0000000000000000",
"Expiration": 472785284,
"Flags": 131072,
"LedgerEntryType": "Offer",
"OwnerNode": "00000000000008F0",
"PreviousTxnID": "1F4D9D859D9AABA888C0708A572B38919A3AEF2C8C1F5A13F58F44C92E5FF3FB",
"PreviousTxnLgrSeq": 10713576,
"Sequence": 110105,
"TakerGets": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0.4499999999999999"
},
"TakerPays": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "152.0098333185607"
},
"index": "9F380E0B39E2AF8AA9608C3E39A5A8628E6D0F44385C6D12BE06F4FEC8D83351",
"quality": "337.7996295968016"
}
},
{
@@ -2440,6 +2761,30 @@ return api.getOrderbook(address, orderbook)
"maker": "rDbsCJr5m8gHDCNEHCZtFxcXHsD4S9jH83",
"sequence": 110061,
"makerExchangeRate": "347.2306949944844"
},
"data": {
"Account": "rDbsCJr5m8gHDCNEHCZtFxcXHsD4S9jH83",
"BookDirectory": "6EAB7C172DEFA430DBFAD120FDC373B5F5AF8B191649EC98570C560B764D760C",
"BookNode": "0000000000000000",
"Flags": 131072,
"LedgerEntryType": "Offer",
"OwnerNode": "0000000000000001",
"PreviousTxnID": "9A0B6B76F0D86614F965A2FFCC8859D8607F4E424351D4CFE2FBE24510F93F25",
"PreviousTxnLgrSeq": 10708382,
"Sequence": 110061,
"TakerGets": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0.003768001830745216"
},
"TakerPays": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "1.308365894430151"
},
"index": "B971769686CE1B9139502770158A4E7C011CFF8E865E5AAE5428E23AAA0E146D",
"owner_funds": "0.2229210189326514",
"quality": "347.2306949944844"
}
},
{
@@ -2461,6 +2806,31 @@ return api.getOrderbook(address, orderbook)
"maker": "rDVBvAQScXrGRGnzrxRrcJPeNLeLeUTAqE",
"sequence": 35788,
"makerExchangeRate": "352.7092203179974"
},
"data": {
"Account": "rDVBvAQScXrGRGnzrxRrcJPeNLeLeUTAqE",
"BookDirectory": "6EAB7C172DEFA430DBFAD120FDC373B5F5AF8B191649EC98570C87DF25DC4FC6",
"BookNode": "0000000000000000",
"Expiration": 472783298,
"Flags": 131072,
"LedgerEntryType": "Offer",
"OwnerNode": "00000000000003D2",
"PreviousTxnID": "E5F9A10F29A4BB3634D5A84FC96931E17267B58E0D2D5ADE24FFB751E52ADB9E",
"PreviousTxnLgrSeq": 10713533,
"Sequence": 35788,
"TakerGets": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0.5"
},
"TakerPays": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "176.3546101589987"
},
"index": "D2CB71038AD0ECAF4B5FF0A953AD1257225D0071E6F3AF9ADE67F05590B45C6E",
"owner_funds": "6.617688680663627",
"quality": "352.7092203179974"
}
},
{
@@ -2493,6 +2863,40 @@ return api.getOrderbook(address, orderbook)
"value": "179.1217564870259",
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
}
},
"data": {
"Account": "rN6jbxx4H6NxcnmkzBxQnbCWLECNKrgSSf",
"BookDirectory": "6EAB7C172DEFA430DBFAD120FDC373B5F5AF8B191649EC98570CC0B8E0E2C000",
"BookNode": "0000000000000000",
"Flags": 131072,
"LedgerEntryType": "Offer",
"OwnerNode": "0000000000000000",
"PreviousTxnID": "2E16ACFEAC2306E3B3483D445787F3496FACF9504F7A5E909620C1A73E2EDE54",
"PreviousTxnLgrSeq": 10558020,
"Sequence": 491,
"TakerGets": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0.5"
},
"TakerPays": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "179.48"
},
"index": "DA853913C8013C9471957349EDAEE4DF4846833B8CCB92008E2A8994E37BEF0D",
"owner_funds": "0.5",
"quality": "358.96",
"taker_gets_funded": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0.499001996007984"
},
"taker_pays_funded": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "179.1217564870259"
}
}
},
{
@@ -2514,6 +2918,30 @@ return api.getOrderbook(address, orderbook)
"maker": "rDVBvAQScXrGRGnzrxRrcJPeNLeLeUTAqE",
"sequence": 35789,
"makerExchangeRate": "360.9637829743709"
},
"data": {
"Account": "rDVBvAQScXrGRGnzrxRrcJPeNLeLeUTAqE",
"BookDirectory": "6EAB7C172DEFA430DBFAD120FDC373B5F5AF8B191649EC98570CD2F24C9C145D",
"BookNode": "0000000000000000",
"Expiration": 472783299,
"Flags": 131072,
"LedgerEntryType": "Offer",
"OwnerNode": "00000000000003D2",
"PreviousTxnID": "B1B12E47043B4260223A2C4240D19E93526B55B1DB38DEED335DACE7C04FEB23",
"PreviousTxnLgrSeq": 10713534,
"Sequence": 35789,
"TakerGets": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0.8"
},
"TakerPays": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "288.7710263794967"
},
"index": "B89AD580E908F7337CCBB47A0BAAC6417EF13AC3465E34E8B7DD3BED016EA833",
"quality": "360.9637829743709"
}
},
{
@@ -2546,6 +2974,40 @@ return api.getOrderbook(address, orderbook)
"value": "82.50309772176658",
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
}
},
"data": {
"Account": "rUeCeioKJkbYhv4mRGuAbZpPcqkMCoYq6N",
"BookDirectory": "6EAB7C172DEFA430DBFAD120FDC373B5F5AF8B191649EC98570D0069F50EA028",
"BookNode": "0000000000000000",
"Flags": 0,
"LedgerEntryType": "Offer",
"OwnerNode": "0000000000000012",
"PreviousTxnID": "F0E8ABF07F83DF0B5EF5B417E8E29A45A5503BA8F26FBC86447CC6B1FAD6A1C4",
"PreviousTxnLgrSeq": 10447672,
"Sequence": 5255,
"TakerGets": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0.5"
},
"TakerPays": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "182.9814890090516"
},
"index": "D652DCE4B19C6CB43912651D3A975371D3B2A16A034EDF07BC11BF721AEF94A4",
"owner_funds": "0.225891986027944",
"quality": "365.9629780181032",
"taker_gets_funded": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0.2254411038203033"
},
"taker_pays_funded": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "82.50309772176658"
}
}
}
],
@@ -2568,6 +3030,30 @@ return api.getOrderbook(address, orderbook)
"maker": "r49y2xKuKVG2dPkNHgWQAV61cjxk8gryjQ",
"sequence": 434,
"makerExchangeRate": "0.003120027456241615"
},
"data": {
"Account": "r49y2xKuKVG2dPkNHgWQAV61cjxk8gryjQ",
"BookDirectory": "20294C923E80A51B487EB9547B3835FD483748B170D2D0A4520B15A60037FFCF",
"BookNode": "0000000000000000",
"Flags": 0,
"LedgerEntryType": "Offer",
"OwnerNode": "0000000000000000",
"PreviousTxnID": "544932DC56D72E845AF2B738821FE07865E32EC196270678AB0D947F54E9F49F",
"PreviousTxnLgrSeq": 10679000,
"Sequence": 434,
"TakerGets": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "3205.1"
},
"TakerPays": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "10"
},
"index": "CE457115A4ADCC8CB351B3E35A0851E48DE16605C23E305017A9B697B156DE5A",
"owner_funds": "41952.95917199965",
"quality": "0.003120027456241615"
}
},
{
@@ -2588,6 +3074,30 @@ return api.getOrderbook(address, orderbook)
"maker": "rDYCRhpahKEhCFV25xScg67Bwf4W9sTYAm",
"sequence": 233,
"makerExchangeRate": "0.003125"
},
"data": {
"Account": "rDYCRhpahKEhCFV25xScg67Bwf4W9sTYAm",
"BookDirectory": "20294C923E80A51B487EB9547B3835FD483748B170D2D0A4520B1A2BC2EC5000",
"BookNode": "0000000000000000",
"Flags": 0,
"LedgerEntryType": "Offer",
"OwnerNode": "0000000000000000",
"PreviousTxnID": "F68F9658AB3D462FEB027E6C380F054BC6D2514B43EC3C6AD46EE19C59BF1CC3",
"PreviousTxnLgrSeq": 10704238,
"Sequence": 233,
"TakerGets": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "1599.063669386278"
},
"TakerPays": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "4.99707396683212"
},
"index": "BF14FBB305159DBCAEA91B7E848408F5B559A91B160EBCB6D244958A6A16EA6B",
"owner_funds": "3169.910902910102",
"quality": "0.003125"
}
},
{
@@ -2621,6 +3131,41 @@ return api.getOrderbook(address, orderbook)
"value": "0",
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
}
},
"data": {
"Account": "raudnGKfTK23YKfnS7ixejHrqGERTYNFXk",
"BookDirectory": "20294C923E80A51B487EB9547B3835FD483748B170D2D0A4520B2BF1C2F4D4C9",
"BookNode": "0000000000000000",
"Expiration": 472785284,
"Flags": 0,
"LedgerEntryType": "Offer",
"OwnerNode": "00000000000008F0",
"PreviousTxnID": "446410E1CD718AC01929DD16B558FCF6B3A7B8BF208C420E67A280C089C5C59B",
"PreviousTxnLgrSeq": 10713576,
"Sequence": 110104,
"TakerGets": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "143.1050962074379"
},
"TakerPays": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0.4499999999999999"
},
"index": "67924B0EAA15784CC00CCD5FDD655EE2D6D2AE40341776B5F14E52341E7FC73E",
"owner_funds": "0",
"quality": "0.003144542101755081",
"taker_gets_funded": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0"
},
"taker_pays_funded": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0"
}
}
},
{
@@ -2654,6 +3199,41 @@ return api.getOrderbook(address, orderbook)
"value": "0",
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
}
},
"data": {
"Account": "rDVBvAQScXrGRGnzrxRrcJPeNLeLeUTAqE",
"BookDirectory": "20294C923E80A51B487EB9547B3835FD483748B170D2D0A4520B2CD7A2BFBB75",
"BookNode": "0000000000000000",
"Expiration": 472772651,
"Flags": 0,
"LedgerEntryType": "Offer",
"OwnerNode": "00000000000003CD",
"PreviousTxnID": "D49164AB68DDA3AEC9DFCC69A35685C4F532B5C231D3C1D25FEA7D5D0224FB84",
"PreviousTxnLgrSeq": 10711128,
"Sequence": 35625,
"TakerGets": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "254.329207354604"
},
"TakerPays": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0.8"
},
"index": "567BF2825173E3FB28FC94E436B6EB30D9A415FC2335E6D25CDE1BE47B25D120",
"owner_funds": "0",
"quality": "0.003145529403882357",
"taker_gets_funded": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0"
},
"taker_pays_funded": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0"
}
}
},
{
@@ -2674,6 +3254,30 @@ return api.getOrderbook(address, orderbook)
"maker": "rwBYyfufTzk77zUSKEu4MvixfarC35av1J",
"sequence": 387756,
"makerExchangeRate": "0.003155743848271834"
},
"data": {
"Account": "rwBYyfufTzk77zUSKEu4MvixfarC35av1J",
"BookDirectory": "20294C923E80A51B487EB9547B3835FD483748B170D2D0A4520B3621DF140FDA",
"BookNode": "0000000000000000",
"Flags": 0,
"LedgerEntryType": "Offer",
"OwnerNode": "0000000000000008",
"PreviousTxnID": "2E371E2B287C8A9FBB3424E4204B17AD9FA1BAA9F3B33C7D2261E3B038AFF083",
"PreviousTxnLgrSeq": 10716291,
"Sequence": 387756,
"TakerGets": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "390.4979"
},
"TakerPays": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "1.23231134568807"
},
"index": "8CA23E55BF9F46AC7E803D3DB40FD03225EFCA66650D4CF0CBDD28A7CCDC8400",
"owner_funds": "5704.824764087842",
"quality": "0.003155743848271834"
}
},
{
@@ -2694,6 +3298,30 @@ return api.getOrderbook(address, orderbook)
"maker": "rwjsRktX1eguUr1pHTffyHnC4uyrvX58V1",
"sequence": 208927,
"makerExchangeRate": "0.003160328237957649"
},
"data": {
"Account": "rwjsRktX1eguUr1pHTffyHnC4uyrvX58V1",
"BookDirectory": "20294C923E80A51B487EB9547B3835FD483748B170D2D0A4520B3A4D41FF4211",
"BookNode": "0000000000000000",
"Flags": 0,
"LedgerEntryType": "Offer",
"OwnerNode": "0000000000000000",
"PreviousTxnID": "91763FA7089C63CC4D5D14CBA6A5A5BF7ECE949B0D34F00FD35E733AF9F05AF1",
"PreviousTxnLgrSeq": 10716292,
"Sequence": 208927,
"TakerGets": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "1"
},
"TakerPays": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0.003160328237957649"
},
"index": "7206866E39D9843623EE79E570242753DEE3C597F3856AEFB4631DD5AD8B0557",
"owner_funds": "45.55665106096075",
"quality": "0.003160328237957649"
}
},
{
@@ -2714,6 +3342,29 @@ return api.getOrderbook(address, orderbook)
"maker": "r49y2xKuKVG2dPkNHgWQAV61cjxk8gryjQ",
"sequence": 429,
"makerExchangeRate": "0.003174603174603175"
},
"data": {
"Account": "r49y2xKuKVG2dPkNHgWQAV61cjxk8gryjQ",
"BookDirectory": "20294C923E80A51B487EB9547B3835FD483748B170D2D0A4520B4748E68669A7",
"BookNode": "0000000000000000",
"Flags": 0,
"LedgerEntryType": "Offer",
"OwnerNode": "0000000000000000",
"PreviousTxnID": "3B3CF6FF1A336335E78513CF77AFD3A784ACDD7B1B4D3F1F16E22957A060BFAE",
"PreviousTxnLgrSeq": 10639969,
"Sequence": 429,
"TakerGets": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "4725"
},
"TakerPays": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "15"
},
"index": "42894809370C7E6B23498EF8E22AD4B05F02B94F08E6983357A51EA96A95FF7F",
"quality": "0.003174603174603175"
}
},
{
@@ -2734,6 +3385,30 @@ return api.getOrderbook(address, orderbook)
"maker": "rDbsCJr5m8gHDCNEHCZtFxcXHsD4S9jH83",
"sequence": 110099,
"makerExchangeRate": "0.003193013959408667"
},
"data": {
"Account": "rDbsCJr5m8gHDCNEHCZtFxcXHsD4S9jH83",
"BookDirectory": "20294C923E80A51B487EB9547B3835FD483748B170D2D0A4520B58077ED03C1B",
"BookNode": "0000000000000000",
"Flags": 131072,
"LedgerEntryType": "Offer",
"OwnerNode": "0000000000000001",
"PreviousTxnID": "98F3F2D02D3BB0AEAC09EECCF2F24BBE5E1AB2C71C40D7BD0A5199E12541B6E2",
"PreviousTxnLgrSeq": 10715839,
"Sequence": 110099,
"TakerGets": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "1.24252537879871"
},
"TakerPays": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0.003967400879423823"
},
"index": "F4404D6547149419D3607F81D7080979FBB3AFE2661F9A933E2F6C07AC1D1F6D",
"owner_funds": "73.52163803897041",
"quality": "0.003193013959408667"
}
},
{
@@ -2767,6 +3442,40 @@ return api.getOrderbook(address, orderbook)
"value": "0",
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
}
},
"data": {
"Account": "rDVBvAQScXrGRGnzrxRrcJPeNLeLeUTAqE",
"BookDirectory": "20294C923E80A51B487EB9547B3835FD483748B170D2D0A4520B72A555B981A3",
"BookNode": "0000000000000000",
"Expiration": 472772652,
"Flags": 0,
"LedgerEntryType": "Offer",
"OwnerNode": "00000000000003CD",
"PreviousTxnID": "146C8DBB047BAAFAE5B8C8DECCCDACD9DFCD7A464E5AB273230FF975E9B83CF7",
"PreviousTxnLgrSeq": 10711128,
"Sequence": 35627,
"TakerGets": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "496.5429474010489"
},
"TakerPays": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "1.6"
},
"index": "50CAA04E81D0009115B61C132FC9887FA9E5336E0CB8A2E7D3280ADBF6ABC043",
"quality": "0.003222279177208227",
"taker_gets_funded": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0"
},
"taker_pays_funded": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0"
}
}
},
{
@@ -2787,6 +3496,29 @@ return api.getOrderbook(address, orderbook)
"maker": "r49y2xKuKVG2dPkNHgWQAV61cjxk8gryjQ",
"sequence": 431,
"makerExchangeRate": "0.003222687721559781"
},
"data": {
"Account": "r49y2xKuKVG2dPkNHgWQAV61cjxk8gryjQ",
"BookDirectory": "20294C923E80A51B487EB9547B3835FD483748B170D2D0A4520B730474DD96E5",
"BookNode": "0000000000000000",
"Flags": 0,
"LedgerEntryType": "Offer",
"OwnerNode": "0000000000000000",
"PreviousTxnID": "624F9ADA85EC3BE845EAC075B47E01E4F89288EAF27823C715777B3DFFB21F24",
"PreviousTxnLgrSeq": 10639989,
"Sequence": 431,
"TakerGets": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "3103"
},
"TakerPays": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "10"
},
"index": "8A319A496288228AD9CAD74375E32FA81805C56A9AD84798A26756A8B3F9EE23",
"quality": "0.003222687721559781"
}
}
]

View File

@@ -14,6 +14,12 @@ This method returns a promise that resolves with an object with the following st
<%- renderSchema('output/get-orderbook.json') %>
### New in ripple-lib 0.22.0 and higher
The response includes a `data` property containing the raw order data. This may include `owner_funds`, `Flags`, and other fields.
For details, see the rippled method [book_offers](https://ripple.com/build/rippled-apis/#book-offers).
### Example
```javascript

View File

@@ -0,0 +1,27 @@
## hasNextPage
`hasNextPage(currentResponse): boolean`
Returns `true` when there are more pages available.
When there are more results than contained in the response, the response includes a `marker` field. You can use this convenience method, or check for `marker` yourself.
See [Markers and Pagination](https://ripple.com/build/rippled-apis/#markers-and-pagination).
### Return Value
This method returns `true` if `currentResponse` includes a `marker`.
### Example
```javascript
return api.request('ledger_data', {
ledger_index: 'validated'
}).then(response => {
/* Do something useful with response */
if (api.hasNextPage(response)) {
/* There are more pages available */
}
}).catch(console.error);
```

View File

@@ -4,6 +4,10 @@
<% include basictypes.md.ejs %>
<% include transactions.md.ejs %>
<% include specifications.md.ejs %>
<% include rippledAPIs.md.ejs %>
<% include request.md.ejs %>
<% include hasNextPage.md.ejs %>
<% include requestNextPage.md.ejs %>
<% include methods.md.ejs %>
<% include connect.md.ejs %>
<% include disconnect.md.ejs %>

View File

@@ -1,6 +1,6 @@
# Introduction
RippleAPI is the official client library to the XRP Ledger. Currently, RippleAPI is only available in JavaScript.
RippleAPI (ripple-lib) is the official client library to the XRP Ledger. Currently, RippleAPI is only available in JavaScript.
Using RippleAPI, you can:
* [Query transactions from the XRP Ledger history](#gettransaction)
@@ -8,5 +8,3 @@ Using RippleAPI, you can:
* [Submit](#submit) transactions to the XRP Ledger, including [Payments](#payment), [Orders](#order), [Settings changes](#settings), and [other types](#transaction-types)
* [Generate a new XRP Ledger Address](#generateaddress)
* ... and [much more](#api-methods).
RippleAPI only provides access to *validated*, *immutable* transaction data.

27
docs/src/request.md.ejs Normal file
View File

@@ -0,0 +1,27 @@
## request
`request(command: string, options: object): Promise<object>`
Returns the response from invoking the specified command, with the specified options, on the connected rippled server.
Refer to [rippled APIs](https://ripple.com/build/rippled-apis/) for commands and options. All XRP amounts must be specified in drops. One drop is equal to 0.000001 XRP. See [Specifying Currency Amounts](https://ripple.com/build/rippled-apis/#specifying-currency-amounts).
Most commands return data for the `current` (in-progress, open) ledger by default. Do not rely on this. Always specify a ledger version in your request. In the example below, the 'validated' ledger is requested, which is the most recent ledger that has been validated by the whole network. See [Specifying Ledgers](https://ripple.com/build/rippled-apis/#specifying-ledgers).
### Return Value
This method returns a promise that resolves with the response from rippled.
### Example
```javascript
// Replace 'ledger' with your desired rippled command
return api.request('ledger', {
ledger_index: 'validated'
}).then(response => {
/* Do something useful with response */
console.log(JSON.stringify(response, null, 2))
}).catch(console.error);
```
<%- renderFixture('responses/ledger.json') %>

View File

@@ -0,0 +1,29 @@
## requestNextPage
`requestNextPage(command: string, params: object = {}, currentResponse: object): Promise<object>`
Requests the next page of data.
You can use this convenience method, or include `currentResponse.marker` in `params` yourself, when using `request`.
See [Markers and Pagination](https://ripple.com/build/rippled-apis/#markers-and-pagination).
### Return Value
This method returns a promise that resolves with the next page of data from rippled.
If the response does not have a next page, the promise will reject with `new errors.NotFoundError('response does not have a next page')`.
### Example
```javascript
const command = 'ledger_data'
const params = {
ledger_index: 'validated'
}
return api.request(command, params).then(response => {
return api.requestNextPage(command, params, response)
}).then(response_page_2 => {
/* Do something useful with second page of response */
}).catch(console.error);
```

View File

@@ -0,0 +1,66 @@
# rippled APIs
ripple-lib relies on [rippled APIs](https://ripple.com/build/rippled-apis/) for all online functionality. With ripple-lib version 1.0.0 and higher, you can easily access rippled APIs through ripple-lib. Use the `request()`, `hasNextPage()`, and `requestNextPage()` methods:
* Use `request()` to issue any `rippled` command, including `account_currencies`, `subscribe`, and `unsubscribe`. [Full list of API Methods](https://ripple.com/build/rippled-apis/#api-methods).
* Use `hasNextPage()` to determine whether a response has more pages. This is true when the response includes a [`marker` field](https://ripple.com/build/rippled-apis/#markers-and-pagination).
* Use `requestNextPage()` to request the next page of data.
When using rippled APIs, [specify XRP amounts in drops](https://ripple.com/build/rippled-apis/#specifying-currency-amounts). 1 XRP = 1000000 drops.
## Listening to streams
The `rippled` server can push updates to your client when various events happen. Refer to [Subscriptions in the `rippled` API docs](https://ripple.com/build/rippled-apis/#subscriptions) for details.
Note that the `streams` parameter for generic streams takes an array. For example, to subscribe to the `validations` stream, use `{ streams: [ 'validations' ] }`.
The string names of some generic streams to subscribe to are in the table below. (Refer to `rippled` for an up-to-date list of streams.)
Type | Description
---- | -----------
`server` | Sends a message whenever the status of the `rippled` server (for example, network connectivity) changes.
`ledger` | Sends a message whenever the consensus process declares a new validated ledger.
`transactions` | Sends a message whenever a transaction is included in a closed ledger.
`transactions_proposed` | Sends a message whenever a transaction is included in a closed ledger, as well as some transactions that have not yet been included in a validated ledger and may never be. Not all proposed transactions appear before validation. Even some transactions that don't succeed are included in validated ledgers because they take the anti-spam transaction fee.
`validations` | Sends a message whenever the server receives a validation message, also called a validation vote, regardless of whether the server trusts the validator.
`manifests` | Sends a message whenever the server receives a manifest.
`peer_status` | (Admin-only) Information about connected peer `rippled` servers, especially with regards to the consensus process.
When you subscribe to a stream, you must also listen to the relevant message type(s). Some of the available message types are in the table below. (Refer to `rippled` for an up-to-date list of message types.)
Type | Description
---- | -----------
`ledgerClosed` | Sent by the `ledger` stream when the consensus process declares a new fully validated ledger. The message identifies the ledger and provides some information about its contents.
`validationReceived` | Sent by the `validations` stream when the server receives a validation message, also called a validation vote, regardless of whether the server trusts the validator.
`manifestReceived` | Sent by the `manifests` stream when the server receives a manifest.
`transaction` | Sent by many subscriptions including `transactions`, `transactions_proposed`, `accounts`, `accounts_proposed`, and `book` (Order Book). See [Transaction Streams](https://ripple.com/build/rippled-apis/#transaction-streams) for details.
`peerStatusChange` | (Admin-only) Reports a large amount of information on the activities of other `rippled` servers to which the server is connected.
To register your listener function, use `connection.on(type, handler)`.
Here is an example of listening for transactions on given account(s):
```
const account = 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn' // Replace with the account you want notifications for
api.connect().then(() => { // Omit this if you are already connected
// 'transaction' can be replaced with the relevant `type` from the table above
api.connection.on('transaction', (event) => {
// Do something useful with `event`
console.log(JSON.stringify(event, null, 2))
})
api.request('subscribe', {
accounts: [ account ]
}).then(response => {
if (response.status === 'success') {
console.log('Successfully subscribed')
}
}).catch(error => {
// Handle `error`
})
})
```
The subscription ends when you unsubscribe or the WebSocket connection is closed.
For full details, see [rippled Subscriptions](https://ripple.com/build/rippled-apis/#subscriptions).

View File

@@ -1,6 +1,6 @@
{
"name": "ripple-lib",
"version": "0.21.0",
"version": "1.0.0-beta.0",
"license": "ISC",
"description": "A JavaScript API for interacting with Ripple in Node.js and the browser",
"files": [

View File

@@ -1,4 +1,3 @@
import * as _ from 'lodash'
import {EventEmitter} from 'events'
import {Connection, errors, validate} from './common'
import {
@@ -87,25 +86,12 @@ function getCollectKeyFromCommand(command: string): string|undefined {
}
}
// prevent access to non-validated ledger versions
export class RestrictedConnection extends Connection {
request(request: any, timeout?: number) {
const ledger_index = request.ledger_index
if (ledger_index !== undefined && ledger_index !== 'validated') {
if (!_.isNumber(ledger_index) || ledger_index > this._ledgerVersion) {
return Promise.reject(new errors.LedgerVersionError(
`ledgerVersion ${ledger_index} is greater than server\'s ` +
`most recent validated ledger: ${this._ledgerVersion}`))
}
}
return super.request(request, timeout)
}
}
class RippleAPI extends EventEmitter {
_feeCushion: number
connection: RestrictedConnection
// New in > 0.21.0
// non-validated ledger versions are allowed, and passed to rippled as-is.
connection: Connection
// these are exposed only for use by unit tests; they are not part of the API.
static _PRIVATE = {
@@ -121,7 +107,7 @@ class RippleAPI extends EventEmitter {
this._feeCushion = options.feeCushion || 1.2
const serverURL = options.server
if (serverURL !== undefined) {
this.connection = new RestrictedConnection(serverURL, options)
this.connection = new Connection(serverURL, options)
this.connection.on('ledgerClosed', message => {
this.emit('ledger', formatLedgerClose(message))
})
@@ -137,14 +123,14 @@ class RippleAPI extends EventEmitter {
} else {
// use null object pattern to provide better error message if user
// tries to call a method that requires a connection
this.connection = new RestrictedConnection(null, options)
this.connection = new Connection(null, options)
}
}
async _request(command: 'account_info', params: AccountInfoRequest):
async request(command: 'account_info', params: AccountInfoRequest):
Promise<AccountInfoResponse>
async _request(command: 'account_lines', params: AccountLinesRequest):
async request(command: 'account_lines', params: AccountLinesRequest):
Promise<AccountLinesResponse>
/**
@@ -152,33 +138,62 @@ class RippleAPI extends EventEmitter {
* For an account's trust lines and balances,
* see `getTrustlines` and `getBalances`.
*/
async _request(command: 'account_objects', params: AccountObjectsRequest):
async request(command: 'account_objects', params: AccountObjectsRequest):
Promise<AccountObjectsResponse>
async _request(command: 'account_offers', params: AccountOffersRequest):
async request(command: 'account_offers', params: AccountOffersRequest):
Promise<AccountOffersResponse>
async _request(command: 'book_offers', params: BookOffersRequest):
async request(command: 'book_offers', params: BookOffersRequest):
Promise<BookOffersResponse>
async _request(command: 'gateway_balances', params: GatewayBalancesRequest):
async request(command: 'gateway_balances', params: GatewayBalancesRequest):
Promise<GatewayBalancesResponse>
async _request(command: 'ledger', params: LedgerRequest):
async request(command: 'ledger', params: LedgerRequest):
Promise<LedgerResponse>
async _request(command: 'ledger_entry', params: LedgerEntryRequest):
async request(command: 'ledger_entry', params: LedgerEntryRequest):
Promise<LedgerEntryResponse>
async request(command: string, params: object):
Promise<object>
/**
* Makes a request to the API with the given command and
* additional request body parameters.
*
* NOTE: This command is under development.
*/
async _request(command: string, params: object = {}) {
async request(command: string, params: object = {}): Promise<object> {
return this.connection.request({
...params,
command
})
}
/**
* Returns true if there are more pages of data.
*
* When there are more results than contained in the response, the response
* includes a `marker` field.
*
* See https://ripple.com/build/rippled-apis/#markers-and-pagination
*/
hasNextPage<T extends {marker?: string}>(currentResponse: T): boolean {
return !!currentResponse.marker
}
async requestNextPage<T extends {marker?: string}>(
command: string,
params: object = {},
currentResponse: T
): Promise<object> {
if (!currentResponse.marker) {
return Promise.reject(
new errors.NotFoundError('response does not have a next page')
)
}
const nextPageParams = Object.assign({}, params, {
marker: currentResponse.marker
})
return this.request(command, nextPageParams)
}
/**
* Makes multiple paged requests to the API to return a given number of
* resources. _requestAll() will make multiple requests until the `limit`
@@ -188,8 +203,9 @@ class RippleAPI extends EventEmitter {
* If the command is unknown, an additional `collect` property is required to
* know which response key contains the array of resources.
*
* NOTE: This command is under development and should not yet be relied
* on by external consumers.
* NOTE: This command is used by existing methods and is not recommended for
* general use. Instead, use rippled's built-in pagination and make multiple
* requests as needed.
*/
async _requestAll(command: 'account_offers', params: AccountOffersRequest):
Promise<AccountOffersResponse[]>
@@ -222,12 +238,9 @@ class RippleAPI extends EventEmitter {
limit: countRemaining,
marker
}
// NOTE: We have to generalize the `this._request()` function signature
// here until we add support for unknown commands (since command is some
// unknown string).
const singleResult = await (<Function>this._request)(command, repeatProps)
const singleResult = await this.request(command, repeatProps)
const collectedData = singleResult[collectKey]
marker = singleResult.marker
marker = singleResult['marker']
results.push(singleResult)
// Make sure we handle when no data (not even an empty array) is returned.
const isExpectedFormat = Array.isArray(collectedData)

View File

@@ -7,12 +7,6 @@ import {RippledError, DisconnectedError, NotConnectedError,
TimeoutError, ResponseFormatError, ConnectionError,
RippledNotInitializedError} from './errors'
function isStreamMessageType(type) {
return type === 'ledgerClosed' ||
type === 'transaction' ||
type === 'path_find'
}
export interface ConnectionOptions {
trace?: boolean,
proxy?: string
@@ -93,16 +87,17 @@ class Connection extends EventEmitter {
throw new ResponseFormatError('valid id not found in response')
}
return [data.id.toString(), data]
} else if (isStreamMessageType(data.type)) {
if (data.type === 'ledgerClosed') {
this._updateLedgerVersions(data)
this._updateFees(data)
}
return [data.type, data]
} else if (data.type === undefined && data.error) {
return ['error', data.error, data.error_message, data] // e.g. slowDown
}
throw new ResponseFormatError('unrecognized message type: ' + data.type)
// Possible `data.type` values include 'ledgerClosed',
// 'transaction', 'path_find', and many others.
if (data.type === 'ledgerClosed') {
this._updateLedgerVersions(data)
this._updateFees(data)
}
return [data.type, data]
}
_onMessage(message) {
@@ -427,7 +422,7 @@ class Connection extends EventEmitter {
function onDisconnect() {
clearTimeout(timer)
self.removeAllListeners(eventName)
reject(new DisconnectedError())
reject(new DisconnectedError('websocket was closed'))
}
function cleanup() {

View File

@@ -45,9 +45,14 @@
},
"required": ["fundedAmount", "priceOfFundedAmount"],
"additionalProperties": false
},
"data": {
"description": "The raw order data. This may include `owner_funds`, `Flags`, and other fields.",
"type": "object",
"additionalProperties": true
}
},
"required": ["specification", "properties"],
"required": ["specification", "properties", "data"],
"additionalProperties": false
}
}

View File

@@ -35,7 +35,7 @@ export default async function getAccountInfo(
// 1. Validate
validate.getAccountInfo({address, options})
// 2. Make Request
const response = await this._request('account_info', {
const response = await this.request('account_info', {
account: address,
ledger_index: options.ledgerVersion || 'validated'
})

View File

@@ -14,7 +14,7 @@ export default async function getAccountObjects(
// through to rippled. rippled validates requests.
// Make Request
const response = await this._request('account_objects', removeUndefined({
const response = await this.request('account_objects', removeUndefined({
account: address,
type: options.type,
ledger_hash: options.ledgerHash,

View File

@@ -54,7 +54,7 @@ async function getBalanceSheet(
validate.getBalanceSheet({address, options})
options = await ensureLedgerVersion.call(this, options)
// 2. Make Request
const response = await this._request('gateway_balances', {
const response = await this.request('gateway_balances', {
account: address,
strict: true,
hotwallet: options.excludeAddresses,

View File

@@ -15,7 +15,7 @@ async function getLedger(
// 1. Validate
validate.getLedger({options})
// 2. Make Request
const response = await this._request('ledger', {
const response = await this.request('ledger', {
ledger_index: options.ledgerVersion || 'validated',
expand: options.includeAllData,
transactions: options.includeTransactions,

View File

@@ -73,7 +73,7 @@ async function makeRequest(
ledger_index: options.ledgerVersion || 'validated',
limit: options.limit,
taker
})
})
}

View File

@@ -17,15 +17,16 @@ export type FormattedOrderbookOrder = {
state?: {
fundedAmount: Amount,
priceOfFundedAmount: Amount
}
},
data: BookOffer
}
export function parseOrderbookOrder(
order: BookOffer
data: BookOffer
): FormattedOrderbookOrder {
const direction = (order.Flags & orderFlags.Sell) === 0 ? 'buy' : 'sell'
const takerGetsAmount = parseAmount(order.TakerGets)
const takerPaysAmount = parseAmount(order.TakerPays)
const direction = (data.Flags & orderFlags.Sell) === 0 ? 'buy' : 'sell'
const takerGetsAmount = parseAmount(data.TakerGets)
const takerPaysAmount = parseAmount(data.TakerPays)
const quantity = (direction === 'buy') ? takerPaysAmount : takerGetsAmount
const totalPrice = (direction === 'buy') ? takerGetsAmount : takerPaysAmount
@@ -35,25 +36,25 @@ export function parseOrderbookOrder(
direction: direction,
quantity: quantity,
totalPrice: totalPrice,
passive: ((order.Flags & orderFlags.Passive) !== 0) || undefined,
expirationTime: parseTimestamp(order.Expiration)
passive: ((data.Flags & orderFlags.Passive) !== 0) || undefined,
expirationTime: parseTimestamp(data.Expiration)
})
const properties = {
maker: order.Account,
sequence: order.Sequence,
makerExchangeRate: adjustQualityForXRP(order.quality,
maker: data.Account,
sequence: data.Sequence,
makerExchangeRate: adjustQualityForXRP(data.quality,
takerGetsAmount.currency, takerPaysAmount.currency)
}
const takerGetsFunded = order.taker_gets_funded ?
parseAmount(order.taker_gets_funded) : undefined
const takerPaysFunded = order.taker_pays_funded ?
parseAmount(order.taker_pays_funded) : undefined
const takerGetsFunded = data.taker_gets_funded ?
parseAmount(data.taker_gets_funded) : undefined
const takerPaysFunded = data.taker_pays_funded ?
parseAmount(data.taker_pays_funded) : undefined
const available = removeUndefined({
fundedAmount: takerGetsFunded,
priceOfFundedAmount: takerPaysFunded
})
const state = _.isEmpty(available) ? undefined : available
return removeUndefined({specification, properties, state})
return removeUndefined({specification, properties, state, data})
}

View File

@@ -23,7 +23,7 @@ async function getPaymentChannel(
// 1. Validate
validate.getPaymentChannel({id})
// 2. Make Request
const response = await this._request('ledger_entry', {
const response = await this.request('ledger_entry', {
index: id,
binary: false,
ledger_index: 'validated'

View File

@@ -33,7 +33,7 @@ async function getSettings(
// 1. Validate
validate.getSettings({address, options})
// 2. Make Request
const response = await this._request('account_info', {
const response = await this.request('account_info', {
account: address,
ledger_index: options.ledgerVersion || 'validated',
signer_lists: true

View File

@@ -51,6 +51,55 @@ describe('RippleAPI', function () {
assert.strictEqual(error.inspect(), '[RippleError(mess, { data: 1 })]');
});
describe('pagination', function () {
describe('hasNextPage', function () {
it('returns true when there is another page', function () {
return this.api.request('ledger_data').then(response => {
assert(this.api.hasNextPage(response));
}
);
});
it('returns false when there are no more pages', function () {
return this.api.request('ledger_data').then(response => {
return this.api.requestNextPage('ledger_data', {}, response);
}).then(response => {
assert(!this.api.hasNextPage(response));
});
});
});
describe('requestNextPage', function () {
it('requests the next page', function () {
return this.api.request('ledger_data').then(response => {
return this.api.requestNextPage('ledger_data', {}, response);
}).then(response => {
assert.equal(response.state[0].index, '000B714B790C3C79FEE00D17C4DEB436B375466F29679447BA64F265FD63D731')
});
});
it('rejects when there are no more pages', function () {
return this.api.request('ledger_data').then(response => {
return this.api.requestNextPage('ledger_data', {}, response);
}).then(response => {
assert(!this.api.hasNextPage(response))
return this.api.requestNextPage('ledger_data', {}, response);
}).then(() => {
assert(false, 'Should reject');
}).catch(error => {
assert(error instanceof Error);
assert.equal(error.message, 'response does not have a next page')
});
});
});
});
describe('preparePayment', function () {
it('normal', function () {
@@ -1213,7 +1262,7 @@ describe('RippleAPI', function () {
});
it('request account_objects', function () {
return this.api._request('account_objects', {
return this.api.request('account_objects', {
account: address
}).then(response =>
checkResult(responses.getAccountObjects, 'AccountObjectsResponse', response));
@@ -1221,7 +1270,7 @@ describe('RippleAPI', function () {
it('request account_objects - invalid options', function () {
// Intentionally no local validation of these options
return this.api._request('account_objects', {
return this.api.request('account_objects', {
account: address,
invalid: 'options'
}).then(response =>
@@ -1528,12 +1577,12 @@ describe('RippleAPI', function () {
_.partial(checkResult, responses.getLedger.header, 'getLedger'));
});
// New in > 0.21.0
// future ledger versions are allowed, and passed to rippled as-is.
it('getLedger - future ledger version', function () {
return this.api.getLedger({ ledgerVersion: 14661789 }).then(() => {
assert(false, 'Should throw LedgerVersionError');
}).catch(error => {
assert(error instanceof this.api.errors.LedgerVersionError);
});
return this.api.getLedger({ ledgerVersion: 14661789 }).then(response => {
assert(response)
})
});
it('getLedger - with state as hashes', function () {

View File

@@ -394,10 +394,10 @@ describe('Connection', function() {
});
it('unrecognized message type', function(done) {
this.api.on('error', (errorCode, errorMessage, message) => {
assert.strictEqual(errorCode, 'badMessage');
assert.strictEqual(errorMessage, 'unrecognized message type: unknown');
assert.strictEqual(message, '{"type":"unknown"}');
// This enables us to automatically support any
// new messages added by rippled in the future.
this.api.connection.on('unknown', (event) => {
assert.deepEqual(event, {type: 'unknown'})
done();
});

View File

@@ -17,6 +17,26 @@
"maker": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
"sequence": 5,
"makerExchangeRate": "3.970260734451929e-8"
},
"data": {
"Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
"BookDirectory": "A118405CF7C2C89AB0CC084417187B86870DC14325C861A0470E1AEE5CBE20D9",
"BookNode": "0000000000000000",
"Flags": 0,
"LedgerEntryType": "Offer",
"OwnerNode": "0000000000000000",
"PreviousTxnID": "9DD36CC7338FEB9E501A33EAAA4C00DBE4ED3A692704C62DDBD1848EE1F6E762",
"PreviousTxnLgrSeq": 11,
"Sequence": 5,
"TakerGets": "254391353000000",
"TakerPays": {
"currency": "USD",
"issuer": "rp8rJYTpodf8qbSCHVTNacf8nSW8mRakFw",
"value": "10.1"
},
"index": "BF656DABDD84E6128A45039F8D557C9477D4DA31F5B00868F2191F0A11FE3798",
"owner_funds": "99999998959999928",
"quality": "3970260734451929e-29"
}
}
],
@@ -38,6 +58,25 @@
"maker": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
"sequence": 6,
"makerExchangeRate": "0.0000780093458738806"
},
"data": {
"Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
"BookDirectory": "A118405CF7C2C89AB0CC084417187B86870DC14325C861A0561BB6E89EFF509C",
"BookNode": "0000000000000000",
"Flags": 131072,
"LedgerEntryType": "Offer",
"OwnerNode": "0000000000000000",
"PreviousTxnID": "CFB5786459E568DFC504E7319C515658DED657A7F4EFB5957B33E5E3BD9A1353",
"PreviousTxnLgrSeq": 13,
"Sequence": 6,
"TakerPays": "134000000",
"TakerGets": {
"currency": "USD",
"issuer": "rp8rJYTpodf8qbSCHVTNacf8nSW8mRakFw",
"value": "10453252347.1"
},
"index": "C72CDC1BA4DA529B062871F22C6D175A4D97D4F1160D0D7E646E60699278B5B5",
"quality": "78.0093458738806"
}
}
]

View File

@@ -18,6 +18,30 @@
"maker": "rwBYyfufTzk77zUSKEu4MvixfarC35av1J",
"sequence": 386940,
"makerExchangeRate": "326.5003614141928"
},
"data": {
"Account": "rwBYyfufTzk77zUSKEu4MvixfarC35av1J",
"BookDirectory": "6EAB7C172DEFA430DBFAD120FDC373B5F5AF8B191649EC98570B9980E49C7DE8",
"BookNode": "0000000000000000",
"Flags": 0,
"LedgerEntryType": "Offer",
"OwnerNode": "0000000000000008",
"PreviousTxnID": "92DBA0BE18B331AC61FB277211477A255D3B5EA9C5FE689171DE689FB45FE18A",
"PreviousTxnLgrSeq": 10714030,
"Sequence": 386940,
"TakerGets": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0.2849323720855092"
},
"TakerPays": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "93.030522464522"
},
"index": "8092033091034D94219BC1131AF7A6B469D790D81831CB479AB6F67A32BE4E13",
"owner_funds": "31.77682120227525",
"quality": "326.5003614141928"
}
},
{
@@ -38,6 +62,30 @@
"maker": "rwjsRktX1eguUr1pHTffyHnC4uyrvX58V1",
"sequence": 207855,
"makerExchangeRate": "330.6364334177034"
},
"data": {
"Account": "rwjsRktX1eguUr1pHTffyHnC4uyrvX58V1",
"BookDirectory": "6EAB7C172DEFA430DBFAD120FDC373B5F5AF8B191649EC98570BBF1EEFA2FB0A",
"BookNode": "0000000000000000",
"Flags": 0,
"LedgerEntryType": "Offer",
"OwnerNode": "0000000000000000",
"PreviousTxnID": "C6BDA152363E3CFE18688A6830B49F3DB2B05976110B5908EA4EB66D93DEEB1F",
"PreviousTxnLgrSeq": 10714031,
"Sequence": 207855,
"TakerGets": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0.00302447007930511"
},
"TakerPays": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "1"
},
"index": "8DB3520FF9CB16A0EA955056C49115F8CFB03A587D0A4AFC844F1D220EFCE0B9",
"owner_funds": "0.0670537912615556",
"quality": "330.6364334177034"
}
},
{
@@ -59,6 +107,31 @@
"maker": "raudnGKfTK23YKfnS7ixejHrqGERTYNFXk",
"sequence": 110103,
"makerExchangeRate": "331.1338298016111"
},
"data": {
"Account": "raudnGKfTK23YKfnS7ixejHrqGERTYNFXk",
"BookDirectory": "6EAB7C172DEFA430DBFAD120FDC373B5F5AF8B191649EC98570BC3A506FC016F",
"BookNode": "0000000000000000",
"Expiration": 472785283,
"Flags": 131072,
"LedgerEntryType": "Offer",
"OwnerNode": "00000000000008F0",
"PreviousTxnID": "77E763F1D02F58965CD1AD94F557B37A582FAC7760B71F391B856959836C2F7B",
"PreviousTxnLgrSeq": 10713576,
"Sequence": 110103,
"TakerGets": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0.3"
},
"TakerPays": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "99.34014894048333"
},
"index": "9ECDFD31B28643FD3A54658398C5715D6DAD574F83F04529CB24765770F9084D",
"owner_funds": "4.021116654525635",
"quality": "331.1338298016111"
}
},
{
@@ -91,6 +164,40 @@
"value": "268.2219496064341",
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
}
},
"data": {
"Account": "rPyYxUGK8L4dgEvjPs3aRc1B1jEiLr3Hx5",
"BookDirectory": "6EAB7C172DEFA430DBFAD120FDC373B5F5AF8B191649EC98570BCB85BCA78000",
"BookNode": "0000000000000000",
"Flags": 131072,
"LedgerEntryType": "Offer",
"OwnerNode": "0000000000000000",
"PreviousTxnID": "D22993C68C94ACE3F2FCE4A334EBEA98CC46DCA92886C12B5E5B4780B5E17D4E",
"PreviousTxnLgrSeq": 10711938,
"Sequence": 392,
"TakerGets": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0.8095"
},
"TakerPays": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "268.754"
},
"index": "18B136E08EF50F0DEE8521EA22D16A950CD8B6DDF5F6E07C35F7FDDBBB09718D",
"owner_funds": "0.8095132334507441",
"quality": "332",
"taker_gets_funded": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0.8078974385735969"
},
"taker_pays_funded": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "268.2219496064341"
}
}
},
{
@@ -112,6 +219,30 @@
"maker": "raudnGKfTK23YKfnS7ixejHrqGERTYNFXk",
"sequence": 110105,
"makerExchangeRate": "337.7996295968016"
},
"data": {
"Account": "raudnGKfTK23YKfnS7ixejHrqGERTYNFXk",
"BookDirectory": "6EAB7C172DEFA430DBFAD120FDC373B5F5AF8B191649EC98570C00450D461510",
"BookNode": "0000000000000000",
"Expiration": 472785284,
"Flags": 131072,
"LedgerEntryType": "Offer",
"OwnerNode": "00000000000008F0",
"PreviousTxnID": "1F4D9D859D9AABA888C0708A572B38919A3AEF2C8C1F5A13F58F44C92E5FF3FB",
"PreviousTxnLgrSeq": 10713576,
"Sequence": 110105,
"TakerGets": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0.4499999999999999"
},
"TakerPays": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "152.0098333185607"
},
"index": "9F380E0B39E2AF8AA9608C3E39A5A8628E6D0F44385C6D12BE06F4FEC8D83351",
"quality": "337.7996295968016"
}
},
{
@@ -132,6 +263,30 @@
"maker": "rDbsCJr5m8gHDCNEHCZtFxcXHsD4S9jH83",
"sequence": 110061,
"makerExchangeRate": "347.2306949944844"
},
"data": {
"Account": "rDbsCJr5m8gHDCNEHCZtFxcXHsD4S9jH83",
"BookDirectory": "6EAB7C172DEFA430DBFAD120FDC373B5F5AF8B191649EC98570C560B764D760C",
"BookNode": "0000000000000000",
"Flags": 131072,
"LedgerEntryType": "Offer",
"OwnerNode": "0000000000000001",
"PreviousTxnID": "9A0B6B76F0D86614F965A2FFCC8859D8607F4E424351D4CFE2FBE24510F93F25",
"PreviousTxnLgrSeq": 10708382,
"Sequence": 110061,
"TakerGets": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0.003768001830745216"
},
"TakerPays": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "1.308365894430151"
},
"index": "B971769686CE1B9139502770158A4E7C011CFF8E865E5AAE5428E23AAA0E146D",
"owner_funds": "0.2229210189326514",
"quality": "347.2306949944844"
}
},
{
@@ -153,6 +308,31 @@
"maker": "rDVBvAQScXrGRGnzrxRrcJPeNLeLeUTAqE",
"sequence": 35788,
"makerExchangeRate": "352.7092203179974"
},
"data": {
"Account": "rDVBvAQScXrGRGnzrxRrcJPeNLeLeUTAqE",
"BookDirectory": "6EAB7C172DEFA430DBFAD120FDC373B5F5AF8B191649EC98570C87DF25DC4FC6",
"BookNode": "0000000000000000",
"Expiration": 472783298,
"Flags": 131072,
"LedgerEntryType": "Offer",
"OwnerNode": "00000000000003D2",
"PreviousTxnID": "E5F9A10F29A4BB3634D5A84FC96931E17267B58E0D2D5ADE24FFB751E52ADB9E",
"PreviousTxnLgrSeq": 10713533,
"Sequence": 35788,
"TakerGets": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0.5"
},
"TakerPays": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "176.3546101589987"
},
"index": "D2CB71038AD0ECAF4B5FF0A953AD1257225D0071E6F3AF9ADE67F05590B45C6E",
"owner_funds": "6.617688680663627",
"quality": "352.7092203179974"
}
},
{
@@ -185,6 +365,40 @@
"value": "179.1217564870259",
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
}
},
"data": {
"Account": "rN6jbxx4H6NxcnmkzBxQnbCWLECNKrgSSf",
"BookDirectory": "6EAB7C172DEFA430DBFAD120FDC373B5F5AF8B191649EC98570CC0B8E0E2C000",
"BookNode": "0000000000000000",
"Flags": 131072,
"LedgerEntryType": "Offer",
"OwnerNode": "0000000000000000",
"PreviousTxnID": "2E16ACFEAC2306E3B3483D445787F3496FACF9504F7A5E909620C1A73E2EDE54",
"PreviousTxnLgrSeq": 10558020,
"Sequence": 491,
"TakerGets": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0.5"
},
"TakerPays": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "179.48"
},
"index": "DA853913C8013C9471957349EDAEE4DF4846833B8CCB92008E2A8994E37BEF0D",
"owner_funds": "0.5",
"quality": "358.96",
"taker_gets_funded": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0.499001996007984"
},
"taker_pays_funded": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "179.1217564870259"
}
}
},
{
@@ -206,6 +420,30 @@
"maker": "rDVBvAQScXrGRGnzrxRrcJPeNLeLeUTAqE",
"sequence": 35789,
"makerExchangeRate": "360.9637829743709"
},
"data": {
"Account": "rDVBvAQScXrGRGnzrxRrcJPeNLeLeUTAqE",
"BookDirectory": "6EAB7C172DEFA430DBFAD120FDC373B5F5AF8B191649EC98570CD2F24C9C145D",
"BookNode": "0000000000000000",
"Expiration": 472783299,
"Flags": 131072,
"LedgerEntryType": "Offer",
"OwnerNode": "00000000000003D2",
"PreviousTxnID": "B1B12E47043B4260223A2C4240D19E93526B55B1DB38DEED335DACE7C04FEB23",
"PreviousTxnLgrSeq": 10713534,
"Sequence": 35789,
"TakerGets": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0.8"
},
"TakerPays": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "288.7710263794967"
},
"index": "B89AD580E908F7337CCBB47A0BAAC6417EF13AC3465E34E8B7DD3BED016EA833",
"quality": "360.9637829743709"
}
},
{
@@ -238,6 +476,40 @@
"value": "82.50309772176658",
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
}
},
"data": {
"Account": "rUeCeioKJkbYhv4mRGuAbZpPcqkMCoYq6N",
"BookDirectory": "6EAB7C172DEFA430DBFAD120FDC373B5F5AF8B191649EC98570D0069F50EA028",
"BookNode": "0000000000000000",
"Flags": 0,
"LedgerEntryType": "Offer",
"OwnerNode": "0000000000000012",
"PreviousTxnID": "F0E8ABF07F83DF0B5EF5B417E8E29A45A5503BA8F26FBC86447CC6B1FAD6A1C4",
"PreviousTxnLgrSeq": 10447672,
"Sequence": 5255,
"TakerGets": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0.5"
},
"TakerPays": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "182.9814890090516"
},
"index": "D652DCE4B19C6CB43912651D3A975371D3B2A16A034EDF07BC11BF721AEF94A4",
"owner_funds": "0.225891986027944",
"quality": "365.9629780181032",
"taker_gets_funded": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0.2254411038203033"
},
"taker_pays_funded": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "82.50309772176658"
}
}
}
],
@@ -260,6 +532,30 @@
"maker": "r49y2xKuKVG2dPkNHgWQAV61cjxk8gryjQ",
"sequence": 434,
"makerExchangeRate": "0.003120027456241615"
},
"data": {
"Account": "r49y2xKuKVG2dPkNHgWQAV61cjxk8gryjQ",
"BookDirectory": "20294C923E80A51B487EB9547B3835FD483748B170D2D0A4520B15A60037FFCF",
"BookNode": "0000000000000000",
"Flags": 0,
"LedgerEntryType": "Offer",
"OwnerNode": "0000000000000000",
"PreviousTxnID": "544932DC56D72E845AF2B738821FE07865E32EC196270678AB0D947F54E9F49F",
"PreviousTxnLgrSeq": 10679000,
"Sequence": 434,
"TakerGets": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "3205.1"
},
"TakerPays": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "10"
},
"index": "CE457115A4ADCC8CB351B3E35A0851E48DE16605C23E305017A9B697B156DE5A",
"owner_funds": "41952.95917199965",
"quality": "0.003120027456241615"
}
},
{
@@ -280,6 +576,30 @@
"maker": "rDYCRhpahKEhCFV25xScg67Bwf4W9sTYAm",
"sequence": 233,
"makerExchangeRate": "0.003125"
},
"data": {
"Account": "rDYCRhpahKEhCFV25xScg67Bwf4W9sTYAm",
"BookDirectory": "20294C923E80A51B487EB9547B3835FD483748B170D2D0A4520B1A2BC2EC5000",
"BookNode": "0000000000000000",
"Flags": 0,
"LedgerEntryType": "Offer",
"OwnerNode": "0000000000000000",
"PreviousTxnID": "F68F9658AB3D462FEB027E6C380F054BC6D2514B43EC3C6AD46EE19C59BF1CC3",
"PreviousTxnLgrSeq": 10704238,
"Sequence": 233,
"TakerGets": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "1599.063669386278"
},
"TakerPays": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "4.99707396683212"
},
"index": "BF14FBB305159DBCAEA91B7E848408F5B559A91B160EBCB6D244958A6A16EA6B",
"owner_funds": "3169.910902910102",
"quality": "0.003125"
}
},
{
@@ -313,6 +633,41 @@
"value": "0",
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
}
},
"data": {
"Account": "raudnGKfTK23YKfnS7ixejHrqGERTYNFXk",
"BookDirectory": "20294C923E80A51B487EB9547B3835FD483748B170D2D0A4520B2BF1C2F4D4C9",
"BookNode": "0000000000000000",
"Expiration": 472785284,
"Flags": 0,
"LedgerEntryType": "Offer",
"OwnerNode": "00000000000008F0",
"PreviousTxnID": "446410E1CD718AC01929DD16B558FCF6B3A7B8BF208C420E67A280C089C5C59B",
"PreviousTxnLgrSeq": 10713576,
"Sequence": 110104,
"TakerGets": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "143.1050962074379"
},
"TakerPays": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0.4499999999999999"
},
"index": "67924B0EAA15784CC00CCD5FDD655EE2D6D2AE40341776B5F14E52341E7FC73E",
"owner_funds": "0",
"quality": "0.003144542101755081",
"taker_gets_funded": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0"
},
"taker_pays_funded": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0"
}
}
},
{
@@ -346,6 +701,41 @@
"value": "0",
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
}
},
"data": {
"Account": "rDVBvAQScXrGRGnzrxRrcJPeNLeLeUTAqE",
"BookDirectory": "20294C923E80A51B487EB9547B3835FD483748B170D2D0A4520B2CD7A2BFBB75",
"BookNode": "0000000000000000",
"Expiration": 472772651,
"Flags": 0,
"LedgerEntryType": "Offer",
"OwnerNode": "00000000000003CD",
"PreviousTxnID": "D49164AB68DDA3AEC9DFCC69A35685C4F532B5C231D3C1D25FEA7D5D0224FB84",
"PreviousTxnLgrSeq": 10711128,
"Sequence": 35625,
"TakerGets": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "254.329207354604"
},
"TakerPays": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0.8"
},
"index": "567BF2825173E3FB28FC94E436B6EB30D9A415FC2335E6D25CDE1BE47B25D120",
"owner_funds": "0",
"quality": "0.003145529403882357",
"taker_gets_funded": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0"
},
"taker_pays_funded": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0"
}
}
},
{
@@ -366,6 +756,30 @@
"maker": "rwBYyfufTzk77zUSKEu4MvixfarC35av1J",
"sequence": 387756,
"makerExchangeRate": "0.003155743848271834"
},
"data": {
"Account": "rwBYyfufTzk77zUSKEu4MvixfarC35av1J",
"BookDirectory": "20294C923E80A51B487EB9547B3835FD483748B170D2D0A4520B3621DF140FDA",
"BookNode": "0000000000000000",
"Flags": 0,
"LedgerEntryType": "Offer",
"OwnerNode": "0000000000000008",
"PreviousTxnID": "2E371E2B287C8A9FBB3424E4204B17AD9FA1BAA9F3B33C7D2261E3B038AFF083",
"PreviousTxnLgrSeq": 10716291,
"Sequence": 387756,
"TakerGets": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "390.4979"
},
"TakerPays": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "1.23231134568807"
},
"index": "8CA23E55BF9F46AC7E803D3DB40FD03225EFCA66650D4CF0CBDD28A7CCDC8400",
"owner_funds": "5704.824764087842",
"quality": "0.003155743848271834"
}
},
{
@@ -386,6 +800,30 @@
"maker": "rwjsRktX1eguUr1pHTffyHnC4uyrvX58V1",
"sequence": 208927,
"makerExchangeRate": "0.003160328237957649"
},
"data": {
"Account": "rwjsRktX1eguUr1pHTffyHnC4uyrvX58V1",
"BookDirectory": "20294C923E80A51B487EB9547B3835FD483748B170D2D0A4520B3A4D41FF4211",
"BookNode": "0000000000000000",
"Flags": 0,
"LedgerEntryType": "Offer",
"OwnerNode": "0000000000000000",
"PreviousTxnID": "91763FA7089C63CC4D5D14CBA6A5A5BF7ECE949B0D34F00FD35E733AF9F05AF1",
"PreviousTxnLgrSeq": 10716292,
"Sequence": 208927,
"TakerGets": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "1"
},
"TakerPays": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0.003160328237957649"
},
"index": "7206866E39D9843623EE79E570242753DEE3C597F3856AEFB4631DD5AD8B0557",
"owner_funds": "45.55665106096075",
"quality": "0.003160328237957649"
}
},
{
@@ -406,6 +844,29 @@
"maker": "r49y2xKuKVG2dPkNHgWQAV61cjxk8gryjQ",
"sequence": 429,
"makerExchangeRate": "0.003174603174603175"
},
"data": {
"Account": "r49y2xKuKVG2dPkNHgWQAV61cjxk8gryjQ",
"BookDirectory": "20294C923E80A51B487EB9547B3835FD483748B170D2D0A4520B4748E68669A7",
"BookNode": "0000000000000000",
"Flags": 0,
"LedgerEntryType": "Offer",
"OwnerNode": "0000000000000000",
"PreviousTxnID": "3B3CF6FF1A336335E78513CF77AFD3A784ACDD7B1B4D3F1F16E22957A060BFAE",
"PreviousTxnLgrSeq": 10639969,
"Sequence": 429,
"TakerGets": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "4725"
},
"TakerPays": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "15"
},
"index": "42894809370C7E6B23498EF8E22AD4B05F02B94F08E6983357A51EA96A95FF7F",
"quality": "0.003174603174603175"
}
},
{
@@ -426,6 +887,30 @@
"maker": "rDbsCJr5m8gHDCNEHCZtFxcXHsD4S9jH83",
"sequence": 110099,
"makerExchangeRate": "0.003193013959408667"
},
"data": {
"Account": "rDbsCJr5m8gHDCNEHCZtFxcXHsD4S9jH83",
"BookDirectory": "20294C923E80A51B487EB9547B3835FD483748B170D2D0A4520B58077ED03C1B",
"BookNode": "0000000000000000",
"Flags": 131072,
"LedgerEntryType": "Offer",
"OwnerNode": "0000000000000001",
"PreviousTxnID": "98F3F2D02D3BB0AEAC09EECCF2F24BBE5E1AB2C71C40D7BD0A5199E12541B6E2",
"PreviousTxnLgrSeq": 10715839,
"Sequence": 110099,
"TakerGets": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "1.24252537879871"
},
"TakerPays": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0.003967400879423823"
},
"index": "F4404D6547149419D3607F81D7080979FBB3AFE2661F9A933E2F6C07AC1D1F6D",
"owner_funds": "73.52163803897041",
"quality": "0.003193013959408667"
}
},
{
@@ -459,6 +944,40 @@
"value": "0",
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
}
},
"data": {
"Account": "rDVBvAQScXrGRGnzrxRrcJPeNLeLeUTAqE",
"BookDirectory": "20294C923E80A51B487EB9547B3835FD483748B170D2D0A4520B72A555B981A3",
"BookNode": "0000000000000000",
"Expiration": 472772652,
"Flags": 0,
"LedgerEntryType": "Offer",
"OwnerNode": "00000000000003CD",
"PreviousTxnID": "146C8DBB047BAAFAE5B8C8DECCCDACD9DFCD7A464E5AB273230FF975E9B83CF7",
"PreviousTxnLgrSeq": 10711128,
"Sequence": 35627,
"TakerGets": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "496.5429474010489"
},
"TakerPays": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "1.6"
},
"index": "50CAA04E81D0009115B61C132FC9887FA9E5336E0CB8A2E7D3280ADBF6ABC043",
"quality": "0.003222279177208227",
"taker_gets_funded": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0"
},
"taker_pays_funded": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0"
}
}
},
{
@@ -479,6 +998,29 @@
"maker": "r49y2xKuKVG2dPkNHgWQAV61cjxk8gryjQ",
"sequence": 431,
"makerExchangeRate": "0.003222687721559781"
},
"data": {
"Account": "r49y2xKuKVG2dPkNHgWQAV61cjxk8gryjQ",
"BookDirectory": "20294C923E80A51B487EB9547B3835FD483748B170D2D0A4520B730474DD96E5",
"BookNode": "0000000000000000",
"Flags": 0,
"LedgerEntryType": "Offer",
"OwnerNode": "0000000000000000",
"PreviousTxnID": "624F9ADA85EC3BE845EAC075B47E01E4F89288EAF27823C715777B3DFFB21F24",
"PreviousTxnLgrSeq": 10639989,
"Sequence": 431,
"TakerGets": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "3103"
},
"TakerPays": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "10"
},
"index": "8A319A496288228AD9CAD74375E32FA81805C56A9AD84798A26756A8B3F9EE23",
"quality": "0.003222687721559781"
}
}
]

23
test/fixtures/responses/ledger.json vendored Normal file
View File

@@ -0,0 +1,23 @@
{
"ledger": {
"accepted": true,
"account_hash": "F9E9653EA76EA0AEA58AC98A8E19EDCEC8299C2940519A190674FFAED3639A1F",
"close_flags": 0,
"close_time": 577999430,
"close_time_human": "2018-Apr-25 19:23:50",
"close_time_resolution": 10,
"closed": true,
"hash": "450E5CB0A39495839DA9CD9A0FED74BD71CBB929423A907ADC00F14FC7E7F920",
"ledger_hash": "450E5CB0A39495839DA9CD9A0FED74BD71CBB929423A907ADC00F14FC7E7F920",
"ledger_index": "38217406",
"parent_close_time": 577999422,
"parent_hash": "B8B364C63EB9E13FDB89CB729FEF833089B8438CBEB8FC41744CB667209221B3",
"seqNum": "38217406",
"totalCoins": "99992286058637091",
"total_coins": "99992286058637091",
"transaction_hash": "5BDD3D2780C28FB2C91C3404BD8ED04786B764B1E18CF319888EDE2C09834726"
},
"ledger_hash": "450E5CB0A39495839DA9CD9A0FED74BD71CBB929423A907ADC00F14FC7E7F920",
"ledger_index": 38217406,
"validated": true
}

View File

@@ -37,6 +37,10 @@ module.exports = {
usd_xrp: require('./book-offers-usd-xrp'),
xrp_usd: require('./book-offers-xrp-usd')
},
ledger_data: {
first_page: require('./ledger-data-first-page'),
last_page: require('./ledger-data-last-page')
},
ledger_entry: {
error: require('./ledger-entry-error')
},

View File

@@ -0,0 +1,40 @@
{
"id": 0,
"status": "success",
"type": "response",
"result": {
"ledger_hash":
"102A6E70FFB18C18E97BB56E3047B0E45EA1BCC90BFCCB8CBB0D07BF0E2AB449",
"ledger_index": 38202000,
"marker":
"000B714B790C3C79FEE00D17C4DEB436B375466F29679447BA64F265FD63D730",
"state": [
{
"Flags": 0,
"Indexes": [
"B32769DB3BE790E959A96CF37A62414479E3EB20A5AEC7156B2BF8FD816DBFF8"
],
"LedgerEntryType": "DirectoryNode",
"Owner": "rwt5iiE1mRbBgNhH6spU4nKgHcE7xK9joN",
"RootIndex":
"0005C961C890079D3C4CC8317F9735D388C3CE3D9BCDC152D3C9A7C08F508D1B",
"index":
"0005C961C890079D3C4CC8317F9735D388C3CE3D9BCDC152D3C9A7C08F508D1B"
},
{
"Account": "rpzpyUjdWKmz7yyMvirk3abcaNvSPmDpJn",
"Balance": "91508000",
"Flags": 0,
"LedgerEntryType": "AccountRoot",
"OwnerCount": 0,
"PreviousTxnID":
"F62A5A5EC92DE4E52663B9C7B44A2B76DAB1371737C83A5A81127CBDA84DFE9E",
"PreviousTxnLgrSeq": 35672898,
"Sequence": 1,
"index":
"000B6A1287DB6174F61B1BF987E630CF41DA2A2131CFEB6C5C8143A8F539E9D1"
}
],
"validated": true
}
}

View File

@@ -0,0 +1,47 @@
{
"id": 0,
"status": "success",
"type": "response",
"result": {
"ledger_hash":
"102A6E70FFB18C18E97BB56E3047B0E45EA1BCC90BFCCB8CBB0D07BF0E2AB449",
"ledger_index": 38202000,
"state": [
{
"Account": "rN3rdDNhQidDuzTFU1ArXWr89B4JG9xZ99",
"Balance": "249222644",
"Flags": 0,
"LedgerEntryType": "AccountRoot",
"OwnerCount": 0,
"PreviousTxnID":
"9A6EEBB6055E2C768BCA3B89B458A5D14A931449443053D9A1A9256F79D590DC",
"PreviousTxnLgrSeq": 35891744,
"Sequence": 1,
"index":
"000B714B790C3C79FEE00D17C4DEB436B375466F29679447BA64F265FD63D731"
},
{
"Account": "rLNNqGs2jJKQcg2CuoACuwkJ1ssga9LTYT",
"BookDirectory":
"6FA9AF02AF19345DC187747EF07CDABECA37CB6DCFFB045E5A08D0CF885B163B",
"BookNode": "0000000000000000",
"Flags": 0,
"LedgerEntryType": "Offer",
"OwnerNode": "0000000000000000",
"PreviousTxnID":
"5D3E557E7C08FA90EF9EE144165855B3823BD24319F28BDD81E23C3573398C44",
"PreviousTxnLgrSeq": 38040457,
"Sequence": 9,
"TakerGets": {
"currency": "CNY",
"issuer": "rPT74sUcTBTQhkHVD54WGncoqXEAMYbmH7",
"value": "322.4"
},
"TakerPays": "80000000",
"index":
"0011C33FA959278D478E7A3811D7DBB9E43E1768E12538CD54B028E5E7DA96E5"
}
],
"validated": true
}
}

View File

@@ -237,6 +237,15 @@ module.exports = function createMockRippled(port) {
}
});
mock.on('request_ledger_data', function (request, conn) {
assert.strictEqual(request.command, 'ledger_data');
if (request.marker) {
conn.send(createResponse(request, fixtures.ledger_data.last_page));
} else {
conn.send(createResponse(request, fixtures.ledger_data.first_page));
}
});
mock.on('request_ledger_entry', function (request, conn) {
assert.strictEqual(request.command, 'ledger_entry');
if (request.index ===