mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-10 07:45:49 +00:00
Compare commits
43 Commits
1.0.0-beta
...
1.0.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cfcbc9aab7 | ||
|
|
3ff4929a49 | ||
|
|
4bea69d647 | ||
|
|
09541dae86 | ||
|
|
bcbcc53c87 | ||
|
|
76f120bec9 | ||
|
|
f8bf28876d | ||
|
|
b03795df09 | ||
|
|
dbe20d6574 | ||
|
|
0550fab73e | ||
|
|
3f2d9d198e | ||
|
|
b9c953fce6 | ||
|
|
181cfd69de | ||
|
|
569766b8f8 | ||
|
|
53a232ebdc | ||
|
|
4c9a2ff538 | ||
|
|
dc623cd049 | ||
|
|
7cd517268b | ||
|
|
2438295e70 | ||
|
|
f5e1a4a588 | ||
|
|
9e9a0a7d9b | ||
|
|
1c68283d1e | ||
|
|
28796d37cb | ||
|
|
067bc48d4e | ||
|
|
b94698df0b | ||
|
|
4f40b5cb6d | ||
|
|
14704eee6b | ||
|
|
860f6a6cd8 | ||
|
|
7a928804ec | ||
|
|
14444bea3f | ||
|
|
47a139fdff | ||
|
|
4e30b9b2fa | ||
|
|
2112d4c0b3 | ||
|
|
1d1132b7fa | ||
|
|
e07fa11923 | ||
|
|
7c92adbf45 | ||
|
|
d55aa2339f | ||
|
|
95e39153da | ||
|
|
65d8260908 | ||
|
|
1aa9feda71 | ||
|
|
2e5b435b11 | ||
|
|
54f12862dc | ||
|
|
226ef862ae |
158
HISTORY.md
158
HISTORY.md
@@ -1,11 +1,167 @@
|
||||
# ripple-lib Release History
|
||||
|
||||
## 1.0.0 (2018-08-30)
|
||||
|
||||
We are pleased to announce the release of `ripple-lib` version 1.0.0.
|
||||
|
||||
This version features a range of changes and improvements that make the library
|
||||
more capable and flexible. It includes new methods for accessing rippled APIs,
|
||||
including subscriptions.
|
||||
|
||||
When using this version with `rippled` for online functionality, we recommend
|
||||
using `rippled` version 1.0.1 or later.
|
||||
|
||||
Here is a summary of the changes since `ripple-lib` version 0.22.0, which was
|
||||
the last non-beta version.
|
||||
|
||||
### New Features
|
||||
|
||||
+ [Add `request()`, `hasNextPage()`, and `requestNextPage()` for accessing `rippled`
|
||||
APIs](https://github.com/ripple/ripple-lib/blob/09541dae86bc859bf5928ac65b2645dfaaf7f8b1/docs/index.md#rippled-apis).
|
||||
+ Add `prepareTransaction()` for preparing raw `txJSON`.
|
||||
+ XRP amounts can be specified in drops. Also, `xrpToDrops()` and `dropsToXrp()`
|
||||
are available to make conversions.
|
||||
+ `getTransaction` responses can include a new `channelChanges` property that
|
||||
describes the details of a payment channel.
|
||||
|
||||
### Data Validation and Errors
|
||||
|
||||
+ [Amounts in drops and XRP are checked for
|
||||
validity](https://github.com/ripple/ripple-lib/blob/develop/HISTORY.md#100-beta1-2018-05-24).
|
||||
+ [A maximum fee is now
|
||||
imposed](https://github.com/ripple/ripple-lib/blob/develop/HISTORY.md#100-beta2-2018-06-08). Exceeding it causes a `ValidationError` to be
|
||||
thrown.
|
||||
+ Errors are improved and more data validation was added.
|
||||
+ Bug fix: `getPaths` now filters paths correctly and works correctly when the
|
||||
destination currency is XRP.
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
The following changes were introduced in 1.0.0.
|
||||
|
||||
+ `getTransaction()` and `getTransactions()`
|
||||
+ The `specification.destination.amount` field has been removed from the parsed transaction response.
|
||||
+ To determine the amount that a transaction delivered, use `outcome.deliveredAmount`.
|
||||
+ If you require the provisional requested `Amount` from the original transaction:
|
||||
+ Use `getTransaction`'s `includeRawTransaction` option, or
|
||||
+ Use `getTransactions`'s `includeRawTransactions` option, or
|
||||
+ Use the rippled APIs directly with `request`. For example, call the API methods `tx`, `account_tx`, etc.
|
||||
+ `getLedger()` response object
|
||||
+ The `rawTransactions` field has been removed (for consistency with `getTransaction()` and `getTransactions()`).
|
||||
+ Instead, within each `transaction`, use the new `rawTransaction` JSON string.
|
||||
+ The `metaData` field has been renamed to `meta` for consistency with rippled's `tx` method.
|
||||
+ `ledger_index` has been added to each raw transaction.
|
||||
|
||||
The SHA-256 checksums for the browser version of this release can be found
|
||||
below.
|
||||
```
|
||||
% shasum -a 256 *
|
||||
06e5efcb6846ad45dedfd85cfa2ef4bdeb608b15ccbfb60b872c995d97342426 ripple-1.0.0-debug.js
|
||||
cdb26b928a89ce228c727d1ff966df266eb46b2f76bd94f81cbeb0a9d75febf0 ripple-1.0.0-min.js
|
||||
f74ee804e8a945a994e4e3901a0a3eb52292fbdcbff61ed30cefb8ffbcba50c3 ripple-1.0.0.js
|
||||
```
|
||||
|
||||
## 1.0.0-beta.5 (2018-08-11)
|
||||
|
||||
+ [Fix a TypeScript error by importing the `Prepare` type](https://github.com/ripple/ripple-lib/commit/7cd517268bda5fe74b91dad02fedf8b51b7eae9b)
|
||||
|
||||
## 1.0.0-beta.4 (2018-08-10)
|
||||
|
||||
+ [Add `prepareTransaction()`](https://github.com/ripple/ripple-lib/pull/898)
|
||||
+ Internal improvements and cleanup
|
||||
|
||||
## 1.0.0-beta.3 (2018-07-17)
|
||||
|
||||
+ For payment channel transactions, `getTransaction` includes a new
|
||||
`channelChanges` property that describes the details of the payment channel.
|
||||
(#920)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
+ A bug caused calculated fees to use too many decimal places. This was fixed by
|
||||
rounding fees to 6 decimal places. (#912)
|
||||
+ When using the Settings transaction to set up a multi-signing list, the
|
||||
threshold and weights fields are required. (#909)
|
||||
+ Docs: Fix the MIMETYPE in examples with memos. (#914)
|
||||
|
||||
The SHA-256 checksums for the browser version of this release can be found
|
||||
below.
|
||||
```
|
||||
% shasum -a 256 *
|
||||
460dbb521e24c44cb53dabc1a74feeca33d031b44d889dd5b51103ca92d51de6 ripple-1.0.0-beta.3-debug.js
|
||||
cccfd24973c6b7990d9e933a589175dae26249825737fff4f2f73d8558a3f186 ripple-1.0.0-beta.3-min.js
|
||||
0dc456a58fb078347d9920310621595905085595d73c2b8fe96bea73bcf35450 ripple-1.0.0-beta.3.js
|
||||
```
|
||||
|
||||
## 1.0.0-beta.2 (2018-06-08)
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
+ During transaction preparation, there is now a maximum fee. Also, when a transaction is signed, its fee is checked and an error is thrown if the fee exceeds the maximum. The default `maxFeeXRP` is `'2'` (2 XRP). Override this value in the RippleAPI constructor.
|
||||
+ Attempting to prepare a transaction with an exact `fee` higher than `maxFeeXRP` causes a `ValidationError` to be thrown.
|
||||
+ Attempting to sign a transaction with a fee higher than `maxFeeXRP` causes a `ValidationError` to be thrown.
|
||||
+ The value returned by `getFee()` is capped at `maxFeeXRP`.
|
||||
|
||||
### Other Changes
|
||||
|
||||
+ In Transaction Instructions, the `maxFee` parameter is deprecated. Use the `maxFeeXRP` parameter in the RippleAPI constructor.
|
||||
|
||||
#### Overview of new fee limit
|
||||
|
||||
Most users of ripple-lib do not need to make any code changes to accommodate the new soft limit on fees. The limit is designed to protect against the most severe cases where an unintentionally high fee may be used.
|
||||
|
||||
+ When having ripple-lib provide the fee with a `prepare*` method, a maximum fee of `maxFeeXRP` (default 2 XRP) applies. You can prepare more economical transactions by setting a lower `maxFeeXRP`, or support high-priority transactions by setting a higher `maxFeeXRP` in the RippleAPI constructor.
|
||||
+ When using `sign` with a Fee higher than `maxFeeXRP`, a `ValidationError` is thrown.
|
||||
|
||||
If you have any questions or concerns, please open an issue on GitHub.
|
||||
|
||||
The SHA-256 checksums for the browser version of this release can be found
|
||||
below.
|
||||
```
|
||||
% shasum -a 256 *
|
||||
ef348a2805098e61395b689b410cbf4bfd35e4d72e38c89f4ab74ec5e19793f5 ripple-1.0.0-beta.2-debug.js
|
||||
ea33fd53df8c7176d5fbf52dae0b64aade7180860f26449062cdbefaf8bd4d9b ripple-1.0.0-beta.2-min.js
|
||||
fe5cc6e97c9b8a1470dacb34f16a64255cd639a25381abe9db1ba79e102456f2 ripple-1.0.0-beta.2.js
|
||||
```
|
||||
|
||||
## 1.0.0-beta.1 (2018-05-24)
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
+ Amounts in drops and XRP are checked for validity. Some
|
||||
methods may now throw a `BigNumber Error` or `ValidationError` if the amount
|
||||
is invalid. This may include methods that previously did not throw.
|
||||
+ Note that 1 drop is equivalent to 0.000001 XRP and 1 XRP is equivalent to 1,000,000 drops.
|
||||
+ Using drops is recommended. All rippled APIs require XRP amounts to be
|
||||
expressed in drops.
|
||||
|
||||
### Other Changes
|
||||
|
||||
+ Allow specifying amounts in drops for consistency with the `rippled`
|
||||
APIs.
|
||||
+ Export `xrpToDrops()` and `dropsToXrp()` functions.
|
||||
+ Potentially breaking change: Improve errors. For example, `RippledError` now includes the full response from
|
||||
the `rippled` server ([#687](https://github.com/ripple/ripple-lib/issues/687)). `NotConnectedError`
|
||||
may be thrown with a different message than before.
|
||||
|
||||
The SHA-256 checksums for the browser version of this release can be found
|
||||
below.
|
||||
```
|
||||
% shasum -a 256 *
|
||||
a80ebb39e186640246306eadb2879147458c8271fd3c6cb32e6ef78d0b4b01a5 ripple-1.0.0-beta.1-debug.js
|
||||
81bcc4b5fd6fd52220ed151242eaddd63eb29c4078845edc68f65b769557d126 ripple-1.0.0-beta.1-min.js
|
||||
738b4d65b58cf4e3542fa396f8d319a24cd7d0b7aff5ff629a900e244f735ff4 ripple-1.0.0-beta.1.js
|
||||
```
|
||||
|
||||
## 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).
|
||||
|
||||
When using rippled APIs, you must:
|
||||
+ For all XRP amounts, use drops (1 drop = 0.000001 XRP).
|
||||
+ Instead of `counterparty`, use `issuer`.
|
||||
|
||||
The SHA-256 checksums for the browser version of this release can be found
|
||||
below.
|
||||
|
||||
34
README.md
34
README.md
@@ -26,13 +26,41 @@ Install `ripple-lib`:
|
||||
$ yarn add ripple-lib
|
||||
```
|
||||
|
||||
Then see the [documentation](https://github.com/ripple/ripple-lib/blob/develop/docs/index.md) and [code samples](https://github.com/ripple/ripple-lib/tree/develop/docs/samples)
|
||||
Then see the [documentation](https://github.com/ripple/ripple-lib/blob/develop/docs/index.md) and [code samples](https://github.com/ripple/ripple-lib/tree/develop/docs/samples).
|
||||
|
||||
## Running tests
|
||||
### Mailing Lists
|
||||
|
||||
We have a low-traffic mailing list for announcements of new ripple-lib releases. (About 1 email per week)
|
||||
|
||||
+ [Subscribe to ripple-lib-announce](https://groups.google.com/forum/#!forum/ripple-lib-announce)
|
||||
|
||||
If you're using the XRP Ledger in production, you should run a [rippled server](https://github.com/ripple/rippled) and subscribe to the ripple-server mailing list as well.
|
||||
|
||||
+ [Subscribe to ripple-server](https://groups.google.com/forum/#!forum/ripple-server)
|
||||
|
||||
## Development
|
||||
|
||||
To build the library for Node.js:
|
||||
```
|
||||
$ yarn compile
|
||||
```
|
||||
|
||||
The TypeScript compiler will [output](./tsconfig.json#L7) the resulting JS files in `./dist/npm/`.
|
||||
|
||||
To build the library for the browser:
|
||||
```
|
||||
$ yarn build
|
||||
```
|
||||
|
||||
Gulp will [output](./Gulpfile.js) the resulting JS files in `./build/`.
|
||||
|
||||
For more details, see the `scripts` in `package.json`.
|
||||
|
||||
## Running Tests
|
||||
|
||||
1. Clone the repository
|
||||
2. `cd` into the repository and install dependencies with `yarn install`
|
||||
3. `yarn test` or `yarn test --coverage` (`istanbul` will create coverage reports in `coverage/lcov-report/`)
|
||||
3. `yarn test`
|
||||
|
||||
## Generating Documentation
|
||||
|
||||
|
||||
158
docs/index.md
158
docs/index.md
@@ -152,6 +152,7 @@ authorization | string | *Optional* Username and password for HTTP basic authent
|
||||
certificate | string | *Optional* A string containing the certificate key of the client in PEM format. (Can be an array of certificates).
|
||||
feeCushion | number | *Optional* Factor to multiply estimated fee by to provide a cushion in case the required fee rises during submission of a transaction. Defaults to `1.2`.
|
||||
key | string | *Optional* A string containing the private key of the client in PEM format. (Can be an array of keys).
|
||||
maxFeeXRP | string | *Optional* Maximum fee to use with transactions, in XRP. Must be a string-encoded number. Defaults to `'2'`.
|
||||
passphrase | string | *Optional* The passphrase for the private key of the client.
|
||||
proxy | uri string | *Optional* URI for HTTP/HTTPS proxy to use to connect to the rippled server.
|
||||
proxyAuthorization | string | *Optional* Username and password for HTTP basic authentication to the proxy in the format **username:password**.
|
||||
@@ -167,7 +168,7 @@ If you omit the `server` parameter, RippleAPI operates [offline](#offline-functi
|
||||
|
||||
1. Install [Node.js](https://nodejs.org) and [Yarn](https://yarnpkg.com/en/docs/install). Most Linux distros have a package for Node.js; check that it's the version you want.
|
||||
2. Use yarn to install RippleAPI:
|
||||
`yarn install ripple-lib`
|
||||
`yarn add ripple-lib`
|
||||
|
||||
After you have installed ripple-lib, you can create scripts using the [boilerplate](#boilerplate) and run them using the Node.js executable, typically named `node`:
|
||||
|
||||
@@ -221,14 +222,13 @@ Currencies are represented as either 3-character currency codes or 40-character
|
||||
## Value
|
||||
A *value* is a quantity of a currency represented as a decimal string. Be careful: JavaScript's native number format does not have sufficient precision to represent all values. XRP has different precision from other currencies.
|
||||
|
||||
**XRP** has 6 significant digits past the decimal point. In other words, XRP cannot be divided into positive values smaller than `0.000001` (1e-6). XRP has a maximum value of `100000000000` (1e11).
|
||||
**XRP** has 6 significant digits past the decimal point. In other words, XRP cannot be divided into positive values smaller than `0.000001` (1e-6). This smallest unit is called a "drop". XRP has a maximum value of `100000000000` (1e11). Some RippleAPI methods accept XRP in order to maintain compatibility with older versions of the API. For consistency with the `rippled` APIs, we recommend formally specifying XRP values in *drops* in all API requests, and converting them to XRP for display. This is similar to Bitcoin's *satoshis* and Ethereum's *wei*. 1 XRP = 1,000,000 drops.
|
||||
|
||||
**Non-XRP values** have 16 decimal digits of precision, with a maximum value of `9999999999999999e80`. The smallest positive non-XRP value is `1e-81`.
|
||||
|
||||
|
||||
## Amount
|
||||
|
||||
Example amount:
|
||||
Example 100.00 USD amount:
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -238,15 +238,16 @@ Example amount:
|
||||
}
|
||||
```
|
||||
|
||||
Example XRP amount:
|
||||
Example 3.0 XRP amount, in drops:
|
||||
```json
|
||||
{
|
||||
"currency": "XRP",
|
||||
"value": "2000"
|
||||
"currency": "drops",
|
||||
"value": "3000000"
|
||||
}
|
||||
```
|
||||
(Requires `ripple-lib` version 1.0.0 or higher.)
|
||||
|
||||
An *amount* is data structure representing a currency, a quantity of that currency, and the counterparty on the trustline that holds the value. For XRP, there is no counterparty.
|
||||
An *amount* is an object specifying a currency, a quantity of that currency, and the counterparty (issuer) on the trustline that holds the value. For XRP, there is no counterparty.
|
||||
|
||||
A *lax amount* allows the counterparty to be omitted for all currencies. If the counterparty is not specified in an amount within a transaction specification, then any counterparty may be used for that amount.
|
||||
|
||||
@@ -256,8 +257,8 @@ A *balance* is an amount than can have a negative value.
|
||||
|
||||
Name | Type | Description
|
||||
---- | ---- | -----------
|
||||
currency | [currency](#currency) | The three-character code or hexadecimal string used to denote currencies
|
||||
counterparty | [address](#address) | *Optional* The Ripple address of the account that owes or is owed the funds (omitted if `currency` is "XRP")
|
||||
currency | [currency](#currency) | The three-character code or hexadecimal string used to denote currencies, or "drops" for the smallest unit of XRP.
|
||||
counterparty | [address](#address) | *Optional* The Ripple address of the account that owes or is owed the funds (omitted if `currency` is "XRP" or "drops")
|
||||
value | [value](#value) | *Optional* The quantity of the currency, denoted as a string to retain floating point precision
|
||||
|
||||
# Transaction Overview
|
||||
@@ -316,14 +317,14 @@ Transaction instructions indicate how to execute a transaction, complementary wi
|
||||
Name | Type | Description
|
||||
---- | ---- | -----------
|
||||
fee | [value](#value) | *Optional* An exact fee to pay for the transaction. See [Transaction Fees](#transaction-fees) for more information.
|
||||
maxFee | [value](#value) | *Optional* The maximum fee to pay for the transaction. See [Transaction Fees](#transaction-fees) for more information.
|
||||
maxFee | [value](#value) | *Optional* Deprecated: Use `maxFeeXRP` in the RippleAPI constructor instead. The maximum fee to pay for this transaction. If this exceeds `maxFeeXRP`, `maxFeeXRP` will be used instead. See [Transaction Fees](#transaction-fees) for more information.
|
||||
maxLedgerVersion | integer,null | *Optional* The highest ledger version that the transaction can be included in. If this option and `maxLedgerVersionOffset` are both omitted, the `maxLedgerVersion` option will default to 3 greater than the current validated ledger version (equivalent to `maxLedgerVersionOffset=3`). Use `null` to not set a maximum ledger version.
|
||||
maxLedgerVersion | string,null | *Optional* The highest ledger version that the transaction can be included in. If this option and `maxLedgerVersionOffset` are both omitted, the `maxLedgerVersion` option will default to 3 greater than the current validated ledger version (equivalent to `maxLedgerVersionOffset=3`). Use `null` to not set a maximum ledger version.
|
||||
maxLedgerVersionOffset | integer | *Optional* Offset from current validated ledger version to highest ledger version that the transaction can be included in.
|
||||
sequence | [sequence](#account-sequence-number) | *Optional* The initiating account's sequence number for this transaction.
|
||||
signersCount | integer | *Optional* Number of signers that will be signing this transaction.
|
||||
|
||||
We recommended that you specify a `maxLedgerVersion` so that you can quickly determine that a failed transaction will never succeeed in the future. It is impossible for a transaction to succeed after the XRP Ledger's consensus-validated ledger version exceeds the transaction's `maxLedgerVersion`. If you omit `maxLedgerVersion`, the "prepare*" method automatically supplies a `maxLedgerVersion` equal to the current ledger plus 3, which it includes in the return value from the "prepare*" method.
|
||||
We recommend that you specify a `maxLedgerVersion` so that you can quickly determine that a failed transaction will never succeeed in the future. It is impossible for a transaction to succeed after the XRP Ledger's consensus-validated ledger version exceeds the transaction's `maxLedgerVersion`. If you omit `maxLedgerVersion`, the "prepare\*" method automatically supplies a `maxLedgerVersion` equal to the current ledger plus 3, which it includes in the return value from the "prepare\*" method.
|
||||
|
||||
## Transaction ID
|
||||
|
||||
@@ -362,7 +363,7 @@ source | object | The source of the funds to be sent.
|
||||
*source.* maxAmount | [laxAmount](#amount) | The maximum amount to send. (This field is exclusive with source.amount)
|
||||
destination | object | The destination of the funds to be sent.
|
||||
*destination.* address | [address](#address) | The address to receive at.
|
||||
*destination.* amount | [laxAmount](#amount) | An exact amount to deliver to the recipient. If the counterparty is not specified, amounts with any counterparty may be used. (This field is exclusive with destination.minAmount).
|
||||
*destination.* amount | [laxAmount](#amount) | An exact amount to deliver to the recipient. If the counterparty is not specified, amounts with any counterparty may be used. (This field cannot be used with `destination.minAmount`.)
|
||||
*destination.* tag | integer | *Optional* An arbitrary unsigned 32-bit integer that identifies a reason for payment or a non-Ripple account.
|
||||
*destination.* address | [address](#address) | The address to send to.
|
||||
*destination.* minAmount | [laxAmount](#amount) | The minimum amount to be delivered. (This field is exclusive with destination.amount)
|
||||
@@ -429,7 +430,7 @@ ripplingDisabled | boolean | *Optional* If true, payments cannot ripple through
|
||||
"memos": [
|
||||
{
|
||||
"type": "test",
|
||||
"format": "plain/text",
|
||||
"format": "text/plain",
|
||||
"data": "texted data"
|
||||
}
|
||||
]
|
||||
@@ -447,12 +448,14 @@ direction | string | Equal to "buy" for buy orders and "sell" for sell orders.
|
||||
quantity | [amount](#amount) | The amount of currency to buy or sell.
|
||||
totalPrice | [amount](#amount) | The total price to be paid for the `quantity` to be bought or sold.
|
||||
expirationTime | date-time string | *Optional* Time after which the offer is no longer active, as an [ISO 8601 date-time](https://en.wikipedia.org/wiki/ISO_8601).
|
||||
fillOrKill | boolean | *Optional* Treat the offer as a [Fill or Kill order](http://en.wikipedia.org/wiki/Fill_or_kill). Only attempt to match existing offers in the ledger, and only do so if the entire quantity can be exchanged.
|
||||
immediateOrCancel | boolean | *Optional* Treat the offer as an [Immediate or Cancel order](http://en.wikipedia.org/wiki/Immediate_or_cancel). If enabled, the offer will never become a ledger node: it only attempts to match existing offers in the ledger.
|
||||
fillOrKill | boolean | *Optional* Treat the offer as a [Fill or Kill order](http://en.wikipedia.org/wiki/Fill_or_kill). Only attempt to match existing offers in the ledger, and only do so if the entire quantity can be exchanged. This cannot be used with `immediateOrCancel`.
|
||||
immediateOrCancel | boolean | *Optional* Treat the offer as an [Immediate or Cancel order](http://en.wikipedia.org/wiki/Immediate_or_cancel). If enabled, the offer will never become a ledger node: it only attempts to match existing offers in the ledger. This cannot be used with `fillOrKill`.
|
||||
memos | [memos](#transaction-memos) | *Optional* Array of memos to attach to the transaction.
|
||||
orderToReplace | [sequence](#account-sequence-number) | *Optional* The [account sequence number](#account-sequence-number) of an order to cancel before the new order is created, effectively replacing the old order.
|
||||
passive | boolean | *Optional* If enabled, the offer will not consume offers that exactly match it, and instead becomes an Offer node in the ledger. It will still consume offers that cross it.
|
||||
|
||||
The following invalid flag combination causes a `ValidationError`: `immediateOrCancel` and `fillOrKill`. These fields are mutually exclusive, and cannot both be set at the same time.
|
||||
|
||||
### Example
|
||||
|
||||
|
||||
@@ -465,10 +468,10 @@ passive | boolean | *Optional* If enabled, the offer will not consume offers tha
|
||||
"value": "10.1"
|
||||
},
|
||||
"totalPrice": {
|
||||
"currency": "XRP",
|
||||
"value": "2"
|
||||
"currency": "drops",
|
||||
"value": "2000000"
|
||||
},
|
||||
"passive": true,
|
||||
"passive": false,
|
||||
"fillOrKill": true
|
||||
}
|
||||
```
|
||||
@@ -515,8 +518,8 @@ regularKey | [address](#address),null | *Optional* The public key of a new keypa
|
||||
requireAuthorization | boolean | *Optional* If set, this account must individually approve other users in order for those users to hold this account’s issuances.
|
||||
requireDestinationTag | boolean | *Optional* Requires incoming payments to specify a destination tag.
|
||||
signers | object | *Optional* Settings that determine what sets of accounts can be used to sign a transaction on behalf of this account using multisigning.
|
||||
*signers.* threshold | integer | *Optional* A target number for the signer weights. A multi-signature from this list is valid only if the sum weights of the signatures provided is equal or greater than this value. To delete the signers setting, use the value `0`.
|
||||
*signers.* weights | array | *Optional* Weights of signatures for each signer.
|
||||
*signers.* threshold | integer | A target number for the signer weights. A multi-signature from this list is valid only if the sum weights of the signatures provided is equal or greater than this value. To delete the signers setting, use the value `0`.
|
||||
*signers.* weights | array | Weights of signatures for each signer.
|
||||
*signers.* weights[] | object | An association of an address and a weight.
|
||||
*signers.weights[].* address | [address](#address) | A Ripple account address
|
||||
*signers.weights[].* weight | integer | The weight that the signature of this account counts as towards the threshold.
|
||||
@@ -531,7 +534,7 @@ transferRate | number,null | *Optional* The fee to charge when users transfer t
|
||||
"memos": [
|
||||
{
|
||||
"type": "test",
|
||||
"format": "plain/text",
|
||||
"format": "text/plain",
|
||||
"data": "texted data"
|
||||
}
|
||||
]
|
||||
@@ -632,8 +635,8 @@ invoiceID | string | *Optional* 256-bit hash, as a 64-character hexadecimal stri
|
||||
{
|
||||
"destination": "rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW",
|
||||
"sendMax": {
|
||||
"currency": "XRP",
|
||||
"value": "1"
|
||||
"currency": "drops",
|
||||
"value": "1000000"
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -673,8 +676,8 @@ deliverMin | [laxAmount](#amount) | *Optional* Redeem the Check for at least thi
|
||||
```json
|
||||
{
|
||||
"amount": {
|
||||
"currency": "XRP",
|
||||
"value": "1"
|
||||
"currency": "drops",
|
||||
"value": "1000000"
|
||||
},
|
||||
"checkID": "838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334"
|
||||
}
|
||||
@@ -760,11 +763,14 @@ ripple-lib relies on [rippled APIs](https://ripple.com/build/rippled-apis/) for
|
||||
* 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.
|
||||
When using rippled APIs:
|
||||
* [Specify XRP amounts in drops](https://developers.ripple.com/basic-data-types.html#specifying-currency-amounts).
|
||||
* [Specify timestamps as the number of seconds since the "Ripple Epoch"](https://developers.ripple.com/basic-data-types.html#specifying-time).
|
||||
* Instead of `counterparty`, use `issuer`.
|
||||
|
||||
## 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.
|
||||
The `rippled` server can push updates to your client when various events happen. Refer to [Subscriptions in the `rippled` API docs](https://developers.ripple.com/subscription-methods.html) for details.
|
||||
|
||||
Note that the `streams` parameter for generic streams takes an array. For example, to subscribe to the `validations` stream, use `{ streams: [ 'validations' ] }`.
|
||||
|
||||
@@ -1074,13 +1080,17 @@ return api.getServerInfo().then(info => {/* ... */});
|
||||
|
||||
Returns the estimated transaction fee for the rippled server the RippleAPI instance is connected to.
|
||||
|
||||
This will use the [feeCushion parameter](#parameters) provided to the RippleAPI constructor, or the default value of `1.2`.
|
||||
|
||||
### Parameters
|
||||
|
||||
This method has no parameters.
|
||||
Name | Type | Description
|
||||
---- | ---- | -----------
|
||||
cushion | number | *Optional* The fee is the product of the base fee, the `load_factor`, and this cushion. Default is provided by the `RippleAPI` constructor's `feeCushion`.
|
||||
|
||||
### Return Value
|
||||
|
||||
This method returns a promise that resolves with a string encoded floating point value representing the estimated fee to submit a transaction, expressed in XRP.
|
||||
This method returns a promise that resolves with a string-encoded floating point value representing the estimated fee to submit a transaction, expressed in XRP.
|
||||
|
||||
### Example
|
||||
|
||||
@@ -1089,7 +1099,7 @@ return api.getFee().then(fee => {/* ... */});
|
||||
```
|
||||
|
||||
```json
|
||||
"0.012"
|
||||
"0.000012"
|
||||
```
|
||||
|
||||
## getLedgerVersion
|
||||
@@ -1129,8 +1139,9 @@ Retrieves a transaction by its [Transaction ID](#transaction-id).
|
||||
|
||||
Name | Type | Description
|
||||
---- | ---- | -----------
|
||||
id | [id](#transaction-id) | A hash of a transaction used to identify the transaction, represented in hexadecimal.
|
||||
options | object | *Optional* Options to limit the ledger versions to search.
|
||||
id | [transactionHash](#transaction-id) | A hash of a transaction used to identify the transaction, represented in hexadecimal.
|
||||
options | object | *Optional* Options to limit the ledger versions to search and/or to include raw transaction data.
|
||||
*options.* includeRawTransaction | object | *Optional* Include raw transaction data. For advanced users; exercise caution when interpreting this data.
|
||||
*options.* maxLedgerVersion | integer | *Optional* The highest ledger version to search
|
||||
*options.* maxLedgerVersion | string | *Optional* The highest ledger version to search
|
||||
*options.* minLedgerVersion | integer | *Optional* The lowest ledger version to search.
|
||||
@@ -1142,16 +1153,16 @@ This method returns a promise that resolves with a transaction object containing
|
||||
|
||||
Name | Type | Description
|
||||
---- | ---- | -----------
|
||||
id | [id](#transaction-id) | A hash of the transaction that can be used to identify it.
|
||||
id | [transactionHash](#transaction-id) | A hash of the transaction that can be used to identify it.
|
||||
address | [address](#address) | The address of the account that initiated the transaction.
|
||||
sequence | [sequence](#account-sequence-number) | The account sequence number of the transaction for the account that initiated it.
|
||||
type | [transactionType](#transaction-types) | The type of the transaction.
|
||||
specification | object | A specification that would produce the same outcome as this transaction. The structure of the specification depends on the value of the `type` field (see [Transaction Types](#transaction-types) for details). *Note:* This is **not** necessarily the same as the original specification.
|
||||
specification | object | A specification that would produce the same outcome as this transaction. *Exception:* For payment transactions, this omits the `destination.amount` field, to prevent misunderstanding. The structure of the specification depends on the value of the `type` field (see [Transaction Types](#transaction-types) for details). *Note:* This is **not** necessarily the same as the original specification.
|
||||
outcome | object | The outcome of the transaction (what effects it had).
|
||||
*outcome.* result | string | Result code returned by rippled. See [Transaction Results](https://ripple.com/build/transactions/#full-transaction-response-list) for a complete list.
|
||||
*outcome.* fee | [value](#value) | The XRP fee that was charged for the transaction.
|
||||
*outcome.balanceChanges.* \* | array\<[balance](#amount)\> | Key is the ripple address; value is an array of signed amounts representing changes of balances for that address.
|
||||
*outcome.orderbookChanges.* \* | array | Key is the maker's ripple address; value is an array of changes
|
||||
*outcome.balanceChanges.* \* | array\<[balance](#amount)\> | Key is the XRP Ledger address; value is an array of signed amounts representing changes of balances for that address.
|
||||
*outcome.orderbookChanges.* \* | array | Key is the maker's XRP Ledger address; value is an array of changes
|
||||
*outcome.orderbookChanges.* \*[] | object | A change to an order.
|
||||
*outcome.orderbookChanges.\*[].* direction | string | Equal to "buy" for buy orders and "sell" for sell orders.
|
||||
*outcome.orderbookChanges.\*[].* quantity | [amount](#amount) | The amount to be bought or sold by the maker.
|
||||
@@ -1163,8 +1174,10 @@ outcome | object | The outcome of the transaction (what effects it had).
|
||||
*outcome.* ledgerVersion | integer | The ledger version that the transaction was validated in.
|
||||
*outcome.* ledgerVersion | string | The ledger version that the transaction was validated in.
|
||||
*outcome.* indexInLedger | integer | The ordering index of the transaction in the ledger.
|
||||
*outcome.* channelChanges | object | *Optional* Properties reflecting the details of the payment channel.
|
||||
*outcome.* deliveredAmount | [amount](#amount) | *Optional* For payment transactions, it is impossible to reliably compute the actual delivered amount from the balanceChanges due to fixed precision. If the payment is not a partial payment and the transaction succeeded, the deliveredAmount should always be considered to be the amount specified in the transaction.
|
||||
*outcome.* timestamp | date-time string | *Optional* The timestamp when the transaction was validated. (May be missing when requesting transactions in binary mode.)
|
||||
rawTransaction | string | *Optional* The raw transaction data as a JSON string. For advanced users only; exercise caution when interpreting this data.
|
||||
|
||||
### Example
|
||||
|
||||
@@ -1191,11 +1204,7 @@ return api.getTransaction(id).then(transaction => {
|
||||
}
|
||||
},
|
||||
"destination": {
|
||||
"address": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM",
|
||||
"amount": {
|
||||
"currency": "USD",
|
||||
"value": "0.001"
|
||||
}
|
||||
"address": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM"
|
||||
},
|
||||
"paths": "[[{\"currency\":\"USD\",\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"type\":48,\"type_hex\":\"0000000000000030\"},{\"account\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"currency\":\"USD\",\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"type\":49,\"type_hex\":\"0000000000000031\"}]]"
|
||||
},
|
||||
@@ -1288,6 +1297,7 @@ options | object | *Optional* Options to filter the resulting transactions.
|
||||
*options.* counterparty | [address](#address) | *Optional* If provided, only return transactions with this account as a counterparty to the transaction.
|
||||
*options.* earliestFirst | boolean | *Optional* If true, sort transactions so that the earliest ones come first. By default, the newest transactions will come first.
|
||||
*options.* excludeFailures | boolean | *Optional* If true, the result will omit transactions that did not succeed.
|
||||
*options.* includeRawTransactions | object | *Optional* Include raw transaction data. For advanced users; exercise caution when interpreting this data.
|
||||
*options.* initiated | boolean | *Optional* If true, return only transactions initiated by the account specified by `address`. If false, return only transactions not initiated by the account specified by `address`.
|
||||
*options.* limit | integer | *Optional* If specified, return at most this many transactions.
|
||||
*options.* maxLedgerVersion | integer | *Optional* Return only transactions in this ledger version or lower.
|
||||
@@ -1333,11 +1343,7 @@ return api.getTransactions(address).then(transaction => {
|
||||
}
|
||||
},
|
||||
"destination": {
|
||||
"address": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM",
|
||||
"amount": {
|
||||
"currency": "USD",
|
||||
"value": "0.001"
|
||||
}
|
||||
"address": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM"
|
||||
},
|
||||
"paths": "[[{\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"currency\":\"USD\"},{\"account\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"currency\":\"USD\"}]]"
|
||||
},
|
||||
@@ -1430,11 +1436,7 @@ return api.getTransactions(address).then(transaction => {
|
||||
}
|
||||
},
|
||||
"destination": {
|
||||
"address": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM",
|
||||
"amount": {
|
||||
"currency": "USD",
|
||||
"value": "0.001"
|
||||
}
|
||||
"address": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM"
|
||||
},
|
||||
"paths": "[[{\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"currency\":\"USD\"},{\"account\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"currency\":\"USD\"}]]"
|
||||
},
|
||||
@@ -1954,7 +1956,7 @@ source | object | Properties of the source of the payment.
|
||||
*source.* maxAmount | [laxAmount](#amount) | The maximum amount to send. (This field is exclusive with source.amount)
|
||||
destination | object | Properties of the destination of the payment.
|
||||
*destination.* address | [address](#address) | The address to receive at.
|
||||
*destination.* amount | [laxAmount](#amount) | An exact amount to deliver to the recipient. If the counterparty is not specified, amounts with any counterparty may be used. (This field is exclusive with destination.minAmount).
|
||||
*destination.* amount | [laxAmount](#amount) | An exact amount to deliver to the recipient. If the counterparty is not specified, amounts with any counterparty may be used. (This field cannot be used with `destination.minAmount`.)
|
||||
*destination.* tag | integer | *Optional* An arbitrary unsigned 32-bit integer that identifies a reason for payment or a non-Ripple account.
|
||||
*destination.* address | [address](#address) | The address to send to.
|
||||
*destination.* minAmount | [laxAmount](#amount) | The minimum amount to be delivered. (This field is exclusive with destination.amount)
|
||||
@@ -2470,9 +2472,9 @@ asks[] | object | An order in the order book.
|
||||
*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
|
||||
### Raw order data
|
||||
|
||||
The response includes a `data` property containing the raw order data. This may include `owner_funds`, `Flags`, and other fields.
|
||||
(Requires ripple-lib 0.22.0 or 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).
|
||||
|
||||
@@ -3563,8 +3565,8 @@ regularKey | [address](#address),null | *Optional* The public key of a new keypa
|
||||
requireAuthorization | boolean | *Optional* If set, this account must individually approve other users in order for those users to hold this account’s issuances.
|
||||
requireDestinationTag | boolean | *Optional* Requires incoming payments to specify a destination tag.
|
||||
signers | object | *Optional* Settings that determine what sets of accounts can be used to sign a transaction on behalf of this account using multisigning.
|
||||
*signers.* threshold | integer | *Optional* A target number for the signer weights. A multi-signature from this list is valid only if the sum weights of the signatures provided is equal or greater than this value. To delete the signers setting, use the value `0`.
|
||||
*signers.* weights | array | *Optional* Weights of signatures for each signer.
|
||||
*signers.* threshold | integer | A target number for the signer weights. A multi-signature from this list is valid only if the sum weights of the signatures provided is equal or greater than this value. To delete the signers setting, use the value `0`.
|
||||
*signers.* weights | array | Weights of signatures for each signer.
|
||||
*signers.* weights[] | object | An association of an address and a weight.
|
||||
*signers.weights[].* address | [address](#address) | A Ripple account address
|
||||
*signers.weights[].* weight | integer | The weight that the signature of this account counts as towards the threshold.
|
||||
@@ -4069,9 +4071,8 @@ parentCloseTime | date-time string | The time at which the previous ledger was c
|
||||
totalDrops | [value](#value) | Total number of drops (1/1,000,000th of an XRP) in the network, as a quoted integer. (This decreases as transaction fees cause XRP to be destroyed.)
|
||||
transactionHash | string | Hash of the transaction information included in this ledger.
|
||||
rawState | string | *Optional* A JSON string containing all state data for this ledger in rippled JSON format.
|
||||
rawTransactions | string | *Optional* A JSON string containing rippled format transaction JSON for all transactions that were validated in this ledger.
|
||||
stateHashes | array\<string\> | *Optional* An array of hashes of all state data in this ledger.
|
||||
transactionHashes | array\<[id](#transaction-id)\> | *Optional* An array of hashes of all transactions that were validated in this ledger.
|
||||
transactionHashes | array\<[transactionHash](#transaction-id)\> | *Optional* An array of hashes of all transactions that were validated in this ledger.
|
||||
transactions | array\<[getTransaction](#gettransaction)\> | *Optional* Array of all transactions that were validated in this ledger. Transactions are represented in the same format as the return value of [getTransaction](#gettransaction).
|
||||
|
||||
### Example
|
||||
@@ -4214,7 +4215,7 @@ const trustline = {
|
||||
"memos": [
|
||||
{
|
||||
"type": "test",
|
||||
"format": "plain/text",
|
||||
"format": "text/plain",
|
||||
"data": "texted data"
|
||||
}
|
||||
]
|
||||
@@ -4226,7 +4227,7 @@ return api.prepareTrustline(address, trustline).then(prepared =>
|
||||
|
||||
```json
|
||||
{
|
||||
"txJSON": "{\"TransactionType\":\"TrustSet\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"LimitAmount\":{\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\",\"value\":\"10000\"},\"Flags\":2149711872,\"QualityIn\":910000000,\"QualityOut\":870000000,\"Memos\":[{\"Memo\":{\"MemoData\":\"7465787465642064617461\",\"MemoType\":\"74657374\",\"MemoFormat\":\"706C61696E2F74657874\"}}],\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
|
||||
"txJSON": "{\"TransactionType\":\"TrustSet\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"LimitAmount\":{\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\",\"value\":\"10000\"},\"Flags\":2149711872,\"QualityIn\":910000000,\"QualityOut\":870000000,\"Memos\":[{\"Memo\":{\"MemoData\":\"7465787465642064617461\",\"MemoType\":\"74657374\",\"MemoFormat\":\"746578742F706C61696E\"}}],\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
|
||||
"instructions": {
|
||||
"fee": "0.000012",
|
||||
"sequence": 23,
|
||||
@@ -4271,6 +4272,8 @@ instructions | object | The instructions for how to execute the transaction afte
|
||||
|
||||
```javascript
|
||||
const address = 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59';
|
||||
|
||||
// Buy 10.10 USD (of the specified issuer) for 2.0 XRP (2000000 drops), fill or kill.
|
||||
const order = {
|
||||
"direction": "buy",
|
||||
"quantity": {
|
||||
@@ -4279,10 +4282,10 @@ const order = {
|
||||
"value": "10.1"
|
||||
},
|
||||
"totalPrice": {
|
||||
"currency": "XRP",
|
||||
"value": "2"
|
||||
"currency": "drops",
|
||||
"value": "2000000"
|
||||
},
|
||||
"passive": true,
|
||||
"passive": false,
|
||||
"fillOrKill": true
|
||||
};
|
||||
return api.prepareOrder(address, order)
|
||||
@@ -4292,7 +4295,7 @@ return api.prepareOrder(address, order)
|
||||
|
||||
```json
|
||||
{
|
||||
"txJSON": "{\"Flags\":2147811328,\"TransactionType\":\"OfferCreate\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"TakerGets\":\"2000000\",\"TakerPays\":{\"value\":\"10.1\",\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\"},\"LastLedgerSequence\":8819954,\"Fee\":\"12\",\"Sequence\":23}",
|
||||
"txJSON": "{\"Flags\":2147745792,\"TransactionType\":\"OfferCreate\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"TakerGets\":\"2000000\",\"TakerPays\":{\"value\":\"10.1\",\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\"},\"LastLedgerSequence\":8819954,\"Fee\":\"12\",\"Sequence\":23}",
|
||||
"instructions": {
|
||||
"fee": "0.000012",
|
||||
"sequence": 23,
|
||||
@@ -4395,7 +4398,7 @@ const settings = {
|
||||
"memos": [
|
||||
{
|
||||
"type": "test",
|
||||
"format": "plain/text",
|
||||
"format": "text/plain",
|
||||
"data": "texted data"
|
||||
}
|
||||
]
|
||||
@@ -4411,7 +4414,7 @@ return api.prepareSettings(address, settings)
|
||||
"memos": [
|
||||
{
|
||||
"type": "test",
|
||||
"format": "plain/text",
|
||||
"format": "text/plain",
|
||||
"data": "texted data"
|
||||
}
|
||||
]
|
||||
@@ -4433,6 +4436,12 @@ address | [address](#address) | The address of the account that is creating the
|
||||
escrowCreation | [escrowCreation](#escrow-creation) | The specification of the escrow creation to prepare.
|
||||
instructions | [instructions](#transaction-instructions) | *Optional* Instructions for executing the transaction
|
||||
|
||||
This is a convenience method for generating the EscrowCreate JSON used by rippled, so the same restrictions apply.
|
||||
|
||||
Field mapping: `allowCancelAfter` is equivalent to rippled's `CancelAfter`; `allowExecuteAfter` is equivalent to `FinishAfter`. At the `allowCancelAfter` time, the escrow is considered expired. This means that the funds can only be returned to the sender. At the `allowExecuteAfter` time, the escrow is permitted to be released to the recipient (if the `condition` is fulfilled).
|
||||
|
||||
Note that `allowCancelAfter` must be chronologically later than `allowExecuteAfter`.
|
||||
|
||||
### Return Value
|
||||
|
||||
This method returns a promise that resolves with an object with the following structure:
|
||||
@@ -4798,8 +4807,8 @@ const address = 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59';
|
||||
const checkCreate = {
|
||||
"destination": "rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW",
|
||||
"sendMax": {
|
||||
"currency": "XRP",
|
||||
"value": "1"
|
||||
"currency": "drops",
|
||||
"value": "1000000"
|
||||
}
|
||||
};
|
||||
return api.prepareCheckCreate(address, checkCreate).then(prepared =>
|
||||
@@ -4911,8 +4920,8 @@ instructions | object | The instructions for how to execute the transaction afte
|
||||
const address = 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59';
|
||||
const checkCash = {
|
||||
"amount": {
|
||||
"currency": "XRP",
|
||||
"value": "1"
|
||||
"currency": "drops",
|
||||
"value": "1000000"
|
||||
},
|
||||
"checkID": "838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334"
|
||||
};
|
||||
@@ -4961,7 +4970,7 @@ This method returns an object with the following structure:
|
||||
Name | Type | Description
|
||||
---- | ---- | -----------
|
||||
signedTransaction | string | The signed transaction represented as an uppercase hexadecimal string.
|
||||
id | [id](#transaction-id) | The [Transaction ID](#transaction-id) of the signed transaction.
|
||||
id | [transactionHash](#transaction-id) | The [Transaction ID](#transaction-id) of the signed transaction.
|
||||
|
||||
### Example
|
||||
|
||||
@@ -5000,7 +5009,7 @@ This method returns an object with the following structure:
|
||||
Name | Type | Description
|
||||
---- | ---- | -----------
|
||||
signedTransaction | string | The signed transaction represented as an uppercase hexadecimal string.
|
||||
id | [id](#transaction-id) | The [Transaction ID](#transaction-id) of the signed transaction.
|
||||
id | [transactionHash](#transaction-id) | The [Transaction ID](#transaction-id) of the signed transaction.
|
||||
|
||||
### Example
|
||||
|
||||
@@ -5200,9 +5209,8 @@ ledger | object | The ledger header to hash.
|
||||
*ledger.* totalDrops | [value](#value) | Total number of drops (1/1,000,000th of an XRP) in the network, as a quoted integer. (This decreases as transaction fees cause XRP to be destroyed.)
|
||||
*ledger.* transactionHash | string | Hash of the transaction information included in this ledger.
|
||||
*ledger.* rawState | string | *Optional* A JSON string containing all state data for this ledger in rippled JSON format.
|
||||
*ledger.* rawTransactions | string | *Optional* A JSON string containing rippled format transaction JSON for all transactions that were validated in this ledger.
|
||||
*ledger.* stateHashes | array\<string\> | *Optional* An array of hashes of all state data in this ledger.
|
||||
*ledger.* transactionHashes | array\<[id](#transaction-id)\> | *Optional* An array of hashes of all transactions that were validated in this ledger.
|
||||
*ledger.* transactionHashes | array\<[transactionHash](#transaction-id)\> | *Optional* An array of hashes of all transactions that were validated in this ledger.
|
||||
*ledger.* transactions | array\<[getTransaction](#gettransaction)\> | *Optional* Array of all transactions that were validated in this ledger. Transactions are represented in the same format as the return value of [getTransaction](#gettransaction).
|
||||
|
||||
### Return Value
|
||||
|
||||
@@ -19,14 +19,13 @@ Currencies are represented as either 3-character currency codes or 40-character
|
||||
## Value
|
||||
A *value* is a quantity of a currency represented as a decimal string. Be careful: JavaScript's native number format does not have sufficient precision to represent all values. XRP has different precision from other currencies.
|
||||
|
||||
**XRP** has 6 significant digits past the decimal point. In other words, XRP cannot be divided into positive values smaller than `0.000001` (1e-6). XRP has a maximum value of `100000000000` (1e11).
|
||||
**XRP** has 6 significant digits past the decimal point. In other words, XRP cannot be divided into positive values smaller than `0.000001` (1e-6). This smallest unit is called a "drop". XRP has a maximum value of `100000000000` (1e11). Some RippleAPI methods accept XRP in order to maintain compatibility with older versions of the API. For consistency with the `rippled` APIs, we recommend formally specifying XRP values in *drops* in all API requests, and converting them to XRP for display. This is similar to Bitcoin's *satoshis* and Ethereum's *wei*. 1 XRP = 1,000,000 drops.
|
||||
|
||||
**Non-XRP values** have 16 decimal digits of precision, with a maximum value of `9999999999999999e80`. The smallest positive non-XRP value is `1e-81`.
|
||||
|
||||
|
||||
## Amount
|
||||
|
||||
Example amount:
|
||||
Example 100.00 USD amount:
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -36,15 +35,16 @@ Example amount:
|
||||
}
|
||||
```
|
||||
|
||||
Example XRP amount:
|
||||
Example 3.0 XRP amount, in drops:
|
||||
```json
|
||||
{
|
||||
"currency": "XRP",
|
||||
"value": "2000"
|
||||
"currency": "drops",
|
||||
"value": "3000000"
|
||||
}
|
||||
```
|
||||
(Requires `ripple-lib` version 1.0.0 or higher.)
|
||||
|
||||
An *amount* is data structure representing a currency, a quantity of that currency, and the counterparty on the trustline that holds the value. For XRP, there is no counterparty.
|
||||
An *amount* is an object specifying a currency, a quantity of that currency, and the counterparty (issuer) on the trustline that holds the value. For XRP, there is no counterparty.
|
||||
|
||||
A *lax amount* allows the counterparty to be omitted for all currencies. If the counterparty is not specified in an amount within a transaction specification, then any counterparty may be used for that amount.
|
||||
|
||||
@@ -52,4 +52,4 @@ A *lax lax amount* allows either or both the counterparty and value to be omitte
|
||||
|
||||
A *balance* is an amount than can have a negative value.
|
||||
|
||||
<%- renderSchema('objects/amount-base.json') %>
|
||||
<%- renderSchema('objects/amountbase.json') %>
|
||||
|
||||
@@ -55,7 +55,7 @@ If you omit the `server` parameter, RippleAPI operates [offline](#offline-functi
|
||||
|
||||
1. Install [Node.js](https://nodejs.org) and [Yarn](https://yarnpkg.com/en/docs/install). Most Linux distros have a package for Node.js; check that it's the version you want.
|
||||
2. Use yarn to install RippleAPI:
|
||||
`yarn install ripple-lib`
|
||||
`yarn add ripple-lib`
|
||||
|
||||
After you have installed ripple-lib, you can create scripts using the [boilerplate](#boilerplate) and run them using the Node.js executable, typically named `node`:
|
||||
|
||||
|
||||
@@ -4,13 +4,15 @@
|
||||
|
||||
Returns the estimated transaction fee for the rippled server the RippleAPI instance is connected to.
|
||||
|
||||
This will use the [feeCushion parameter](#parameters) provided to the RippleAPI constructor, or the default value of `1.2`.
|
||||
|
||||
### Parameters
|
||||
|
||||
This method has no parameters.
|
||||
<%- renderSchema('input/get-fee.json') %>
|
||||
|
||||
### Return Value
|
||||
|
||||
This method returns a promise that resolves with a string encoded floating point value representing the estimated fee to submit a transaction, expressed in XRP.
|
||||
This method returns a promise that resolves with a string-encoded floating point value representing the estimated fee to submit a transaction, expressed in XRP.
|
||||
|
||||
### Example
|
||||
|
||||
@@ -19,5 +21,5 @@ return api.getFee().then(fee => {/* ... */});
|
||||
```
|
||||
|
||||
```json
|
||||
"0.012"
|
||||
"0.000012"
|
||||
```
|
||||
|
||||
@@ -14,9 +14,9 @@ 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
|
||||
### Raw order data
|
||||
|
||||
The response includes a `data` property containing the raw order data. This may include `owner_funds`, `Flags`, and other fields.
|
||||
(Requires ripple-lib 0.22.0 or 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).
|
||||
|
||||
|
||||
@@ -8,6 +8,12 @@ Prepare an escrow creation transaction. The prepared transaction must subsequent
|
||||
|
||||
<%- renderSchema('input/prepare-escrow-creation.json') %>
|
||||
|
||||
This is a convenience method for generating the EscrowCreate JSON used by rippled, so the same restrictions apply.
|
||||
|
||||
Field mapping: `allowCancelAfter` is equivalent to rippled's `CancelAfter`; `allowExecuteAfter` is equivalent to `FinishAfter`. At the `allowCancelAfter` time, the escrow is considered expired. This means that the funds can only be returned to the sender. At the `allowExecuteAfter` time, the escrow is permitted to be released to the recipient (if the `condition` is fulfilled).
|
||||
|
||||
Note that `allowCancelAfter` must be chronologically later than `allowExecuteAfter`.
|
||||
|
||||
### Return Value
|
||||
|
||||
This method returns a promise that resolves with an object with the following structure:
|
||||
|
||||
@@ -22,6 +22,8 @@ All "prepare*" methods have the same return type.
|
||||
|
||||
```javascript
|
||||
const address = 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59';
|
||||
|
||||
// Buy 10.10 USD (of the specified issuer) for 2.0 XRP (2000000 drops), fill or kill.
|
||||
const order = <%- importFile('test/fixtures/requests/prepare-order.json') %>;
|
||||
return api.prepareOrder(address, order)
|
||||
.then(prepared => {/* ... */});
|
||||
|
||||
@@ -5,11 +5,14 @@ ripple-lib relies on [rippled APIs](https://ripple.com/build/rippled-apis/) for
|
||||
* 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.
|
||||
When using rippled APIs:
|
||||
* [Specify XRP amounts in drops](https://developers.ripple.com/basic-data-types.html#specifying-currency-amounts).
|
||||
* [Specify timestamps as the number of seconds since the "Ripple Epoch"](https://developers.ripple.com/basic-data-types.html#specifying-time).
|
||||
* Instead of `counterparty`, use `issuer`.
|
||||
|
||||
## 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.
|
||||
The `rippled` server can push updates to your client when various events happen. Refer to [Subscriptions in the `rippled` API docs](https://developers.ripple.com/subscription-methods.html) for details.
|
||||
|
||||
Note that the `streams` parameter for generic streams takes an array. For example, to subscribe to the `validations` stream, use `{ streams: [ 'validations' ] }`.
|
||||
|
||||
|
||||
@@ -28,6 +28,8 @@ See [Transaction Types](#transaction-types) for a description.
|
||||
|
||||
<%- renderSchema('specifications/order.json') %>
|
||||
|
||||
The following invalid flag combination causes a `ValidationError`: `immediateOrCancel` and `fillOrKill`. These fields are mutually exclusive, and cannot both be set at the same time.
|
||||
|
||||
### Example
|
||||
|
||||
<%- renderFixture('requests/prepare-order.json') %>
|
||||
|
||||
@@ -53,7 +53,7 @@ Transaction instructions indicate how to execute a transaction, complementary wi
|
||||
|
||||
<%- renderSchema("objects/instructions.json") %>
|
||||
|
||||
We recommended that you specify a `maxLedgerVersion` so that you can quickly determine that a failed transaction will never succeeed in the future. It is impossible for a transaction to succeed after the XRP Ledger's consensus-validated ledger version exceeds the transaction's `maxLedgerVersion`. If you omit `maxLedgerVersion`, the "prepare*" method automatically supplies a `maxLedgerVersion` equal to the current ledger plus 3, which it includes in the return value from the "prepare*" method.
|
||||
We recommend that you specify a `maxLedgerVersion` so that you can quickly determine that a failed transaction will never succeeed in the future. It is impossible for a transaction to succeed after the XRP Ledger's consensus-validated ledger version exceeds the transaction's `maxLedgerVersion`. If you omit `maxLedgerVersion`, the "prepare\*" method automatically supplies a `maxLedgerVersion` equal to the current ledger plus 3, which it includes in the return value from the "prepare\*" method.
|
||||
|
||||
## Transaction ID
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ripple-lib",
|
||||
"version": "1.0.0-beta.0",
|
||||
"version": "1.0.0",
|
||||
"license": "ISC",
|
||||
"description": "A JavaScript API for interacting with Ripple in Node.js and the browser",
|
||||
"files": [
|
||||
@@ -26,7 +26,7 @@
|
||||
"ripple-binary-codec": "^0.1.13",
|
||||
"ripple-hashes": "^0.3.1",
|
||||
"ripple-keypairs": "^0.10.1",
|
||||
"ripple-lib-transactionparser": "^0.6.2",
|
||||
"ripple-lib-transactionparser": "0.7.1",
|
||||
"ws": "^3.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -53,7 +53,7 @@
|
||||
"ts-node": "^3.3.0",
|
||||
"tslint": "^5.8.0",
|
||||
"tslint-eslint-rules": "^4.1.1",
|
||||
"typescript": "^2.6.1",
|
||||
"typescript": "2.9.2",
|
||||
"uglifyjs-webpack-plugin": "^1.1.4",
|
||||
"webpack": "^3.10.0",
|
||||
"yargs": "^8.0.2"
|
||||
|
||||
74
src/api.ts
74
src/api.ts
@@ -1,11 +1,17 @@
|
||||
import {EventEmitter} from 'events'
|
||||
import {Connection, errors, validate} from './common'
|
||||
import {
|
||||
Connection,
|
||||
errors,
|
||||
validate,
|
||||
xrpToDrops,
|
||||
dropsToXrp,
|
||||
iso8601ToRippleTime,
|
||||
txFlags
|
||||
} from './common'
|
||||
import {
|
||||
connect,
|
||||
disconnect,
|
||||
isConnected,
|
||||
getServerInfo,
|
||||
getFee,
|
||||
getLedgerVersion,
|
||||
formatLedgerClose
|
||||
} from './server/server'
|
||||
@@ -52,18 +58,23 @@ import {
|
||||
BookOffersRequest, BookOffersResponse,
|
||||
GatewayBalancesRequest, GatewayBalancesResponse,
|
||||
LedgerRequest, LedgerResponse,
|
||||
LedgerEntryRequest, LedgerEntryResponse
|
||||
LedgerEntryRequest, LedgerEntryResponse,
|
||||
ServerInfoRequest, ServerInfoResponse
|
||||
} from './common/types/commands'
|
||||
|
||||
|
||||
import RangeSet from './common/rangeset'
|
||||
import * as ledgerUtils from './ledger/utils'
|
||||
import * as transactionUtils from './transaction/utils'
|
||||
import * as schemaValidator from './common/schema-validator'
|
||||
import {getServerInfo, getFee} from './common/serverinfo'
|
||||
import {clamp} from './ledger/utils'
|
||||
import {Instructions, Prepare} from './transaction/types'
|
||||
|
||||
export type APIOptions = {
|
||||
server?: string,
|
||||
feeCushion?: number,
|
||||
maxFeeXRP?: string,
|
||||
trace?: boolean,
|
||||
proxy?: string,
|
||||
timeout?: number
|
||||
@@ -88,6 +99,7 @@ function getCollectKeyFromCommand(command: string): string|undefined {
|
||||
|
||||
class RippleAPI extends EventEmitter {
|
||||
_feeCushion: number
|
||||
_maxFeeXRP: string
|
||||
|
||||
// New in > 0.21.0
|
||||
// non-validated ledger versions are allowed, and passed to rippled as-is.
|
||||
@@ -95,7 +107,7 @@ class RippleAPI extends EventEmitter {
|
||||
|
||||
// these are exposed only for use by unit tests; they are not part of the API.
|
||||
static _PRIVATE = {
|
||||
validate: validate,
|
||||
validate,
|
||||
RangeSet,
|
||||
ledgerUtils,
|
||||
schemaValidator
|
||||
@@ -105,6 +117,7 @@ class RippleAPI extends EventEmitter {
|
||||
super()
|
||||
validate.apiOptions(options)
|
||||
this._feeCushion = options.feeCushion || 1.2
|
||||
this._maxFeeXRP = options.maxFeeXRP || '2'
|
||||
const serverURL = options.server
|
||||
if (serverURL !== undefined) {
|
||||
this.connection = new Connection(serverURL, options)
|
||||
@@ -128,19 +141,16 @@ class RippleAPI extends EventEmitter {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Makes a request to the API with the given command and
|
||||
* additional request body parameters.
|
||||
*/
|
||||
async request(command: 'account_info', params: AccountInfoRequest):
|
||||
Promise<AccountInfoResponse>
|
||||
async request(command: 'account_lines', params: AccountLinesRequest):
|
||||
Promise<AccountLinesResponse>
|
||||
|
||||
/**
|
||||
* Returns objects owned by an account.
|
||||
* For an account's trust lines and balances,
|
||||
* see `getTrustlines` and `getBalances`.
|
||||
*/
|
||||
async request(command: 'account_objects', params: AccountObjectsRequest):
|
||||
Promise<AccountObjectsResponse>
|
||||
|
||||
async request(command: 'account_offers', params: AccountOffersRequest):
|
||||
Promise<AccountOffersResponse>
|
||||
async request(command: 'book_offers', params: BookOffersRequest):
|
||||
@@ -151,15 +161,11 @@ class RippleAPI extends EventEmitter {
|
||||
Promise<LedgerResponse>
|
||||
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.
|
||||
*/
|
||||
async request(command: string, params: object = {}): Promise<object> {
|
||||
async request(command: 'server_info', params?: ServerInfoRequest):
|
||||
Promise<ServerInfoResponse>
|
||||
async request(command: string, params: any):
|
||||
Promise<any>
|
||||
async request(command: string, params: any = {}): Promise<any> {
|
||||
return this.connection.request({
|
||||
...params,
|
||||
command
|
||||
@@ -194,6 +200,27 @@ class RippleAPI extends EventEmitter {
|
||||
return this.request(command, nextPageParams)
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare a transaction.
|
||||
*
|
||||
* You can later submit the transaction with `submit()`.
|
||||
*/
|
||||
async prepareTransaction(txJSON: object, instructions: Instructions = {}):
|
||||
Promise<Prepare> {
|
||||
return transactionUtils.prepareTransaction(txJSON, this, instructions)
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a string to hex.
|
||||
*
|
||||
* This can be used to generate `MemoData`, `MemoType`, and `MemoFormat`.
|
||||
*
|
||||
* @param string string to convert to hex
|
||||
*/
|
||||
convertStringToHex(string: string): string {
|
||||
return transactionUtils.convertStringToHex(string)
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes multiple paged requests to the API to return a given number of
|
||||
* resources. _requestAll() will make multiple requests until the `limit`
|
||||
@@ -298,6 +325,11 @@ class RippleAPI extends EventEmitter {
|
||||
signPaymentChannelClaim = signPaymentChannelClaim
|
||||
verifyPaymentChannelClaim = verifyPaymentChannelClaim
|
||||
errors = errors
|
||||
|
||||
xrpToDrops = xrpToDrops
|
||||
dropsToXrp = dropsToXrp
|
||||
iso8601ToRippleTime = iso8601ToRippleTime
|
||||
txFlags = txFlags
|
||||
}
|
||||
|
||||
export {
|
||||
|
||||
@@ -84,7 +84,7 @@ class Connection extends EventEmitter {
|
||||
const data = JSON.parse(message)
|
||||
if (data.type === 'response') {
|
||||
if (!(Number.isInteger(data.id) && data.id >= 0)) {
|
||||
throw new ResponseFormatError('valid id not found in response')
|
||||
throw new ResponseFormatError('valid id not found in response', data)
|
||||
}
|
||||
return [data.id.toString(), data]
|
||||
} else if (data.type === undefined && data.error) {
|
||||
@@ -241,7 +241,7 @@ class Connection extends EventEmitter {
|
||||
_onOpenError(reject, error) {
|
||||
this._onOpenErrorBound = null
|
||||
this._unbindOnUnxpectedClose()
|
||||
reject(new NotConnectedError(error && error.message))
|
||||
reject(new NotConnectedError(error.message, error))
|
||||
}
|
||||
|
||||
_createWebSocket(): WebSocket {
|
||||
@@ -399,7 +399,7 @@ class Connection extends EventEmitter {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._ws.send(message, undefined, error => {
|
||||
if (error) {
|
||||
reject(new DisconnectedError(error.message))
|
||||
reject(new DisconnectedError(error.message, error))
|
||||
} else {
|
||||
resolve()
|
||||
}
|
||||
@@ -445,12 +445,12 @@ class Connection extends EventEmitter {
|
||||
|
||||
this.once(eventName, response => {
|
||||
if (response.status === 'error') {
|
||||
_reject(new RippledError(response.error))
|
||||
_reject(new RippledError(response.error, response))
|
||||
} else if (response.status === 'success') {
|
||||
_resolve(response.result)
|
||||
} else {
|
||||
_reject(new ResponseFormatError(
|
||||
'unrecognized status: ' + response.status))
|
||||
'unrecognized status: ' + response.status, response))
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ class MissingLedgerHistoryError extends RippleError {
|
||||
|
||||
class PendingLedgerVersionError extends RippleError {
|
||||
constructor(message?: string) {
|
||||
super(message || 'maxLedgerVersion is greater than server\'s most recent ' +
|
||||
super(message || 'maxLedgerVersion is greater than server\'s most recent' +
|
||||
' validated ledger')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,13 +9,13 @@ function loadSchemas() {
|
||||
// listed explicitly for webpack (instead of scanning schemas directory)
|
||||
const schemas = [
|
||||
require('./schemas/objects/tx-json.json'),
|
||||
require('./schemas/objects/tx-type.json'),
|
||||
require('./schemas/objects/transaction-type.json'),
|
||||
require('./schemas/objects/hash128.json'),
|
||||
require('./schemas/objects/hash256.json'),
|
||||
require('./schemas/objects/sequence.json'),
|
||||
require('./schemas/objects/signature.json'),
|
||||
require('./schemas/objects/issue.json'),
|
||||
require('./schemas/objects/ledgerversion.json'),
|
||||
require('./schemas/objects/ledger-version.json'),
|
||||
require('./schemas/objects/max-adjustment.json'),
|
||||
require('./schemas/objects/memo.json'),
|
||||
require('./schemas/objects/memos.json'),
|
||||
@@ -31,21 +31,23 @@ function loadSchemas() {
|
||||
require('./schemas/objects/min-adjustment.json'),
|
||||
require('./schemas/objects/source-exact-adjustment.json'),
|
||||
require('./schemas/objects/destination-exact-adjustment.json'),
|
||||
require('./schemas/objects/tx-hash.json'),
|
||||
require('./schemas/objects/destination-address-tag.json'),
|
||||
require('./schemas/objects/transaction-hash.json'),
|
||||
require('./schemas/objects/address.json'),
|
||||
require('./schemas/objects/adjustment.json'),
|
||||
require('./schemas/objects/quality.json'),
|
||||
require('./schemas/objects/amount.json'),
|
||||
require('./schemas/objects/amount-base.json'),
|
||||
require('./schemas/objects/amountbase.json'),
|
||||
require('./schemas/objects/balance.json'),
|
||||
require('./schemas/objects/blob.json'),
|
||||
require('./schemas/objects/currency.json'),
|
||||
require('./schemas/objects/signed-value.json'),
|
||||
require('./schemas/objects/orderbook.json'),
|
||||
require('./schemas/objects/instructions.json'),
|
||||
require('./schemas/objects/settings.json'),
|
||||
require('./schemas/objects/settings-plus-memos.json'),
|
||||
require('./schemas/specifications/settings.json'),
|
||||
require('./schemas/specifications/payment.json'),
|
||||
require('./schemas/specifications/get-payment.json'),
|
||||
require('./schemas/specifications/escrow-cancellation.json'),
|
||||
require('./schemas/specifications/order-cancellation.json'),
|
||||
require('./schemas/specifications/order.json'),
|
||||
|
||||
@@ -12,6 +12,10 @@
|
||||
"minimum": 1,
|
||||
"description": "Factor to multiply estimated fee by to provide a cushion in case the required fee rises during submission of a transaction. Defaults to `1.2`."
|
||||
},
|
||||
"maxFeeXRP": {
|
||||
"type": "string",
|
||||
"description": "Maximum fee to use with transactions, in XRP. Must be a string-encoded number. Defaults to `'2'`."
|
||||
},
|
||||
"server": {
|
||||
"type": "string",
|
||||
"description": "URI for rippled websocket port to connect to. Must start with `wss://` or `ws://`.",
|
||||
|
||||
13
src/common/schemas/input/get-fee.json
Normal file
13
src/common/schemas/input/get-fee.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"title": "getFeeParameters",
|
||||
"description": "Parameters for getFee",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"cushion": {
|
||||
"type": "number",
|
||||
"description": "The fee is the product of the base fee, the `load_factor`, and this cushion. Default is provided by the `RippleAPI` constructor's `feeCushion`."
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
@@ -4,9 +4,9 @@
|
||||
"description": "Parameters for getTransaction",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {"$ref": "id"},
|
||||
"id": {"$ref": "transactionHash"},
|
||||
"options": {
|
||||
"description": "Options to limit the ledger versions to search.",
|
||||
"description": "Options to limit the ledger versions to search and/or to include raw transaction data.",
|
||||
"properties": {
|
||||
"minLedgerVersion": {
|
||||
"$ref": "ledgerVersion",
|
||||
@@ -15,6 +15,9 @@
|
||||
"maxLedgerVersion": {
|
||||
"$ref": "ledgerVersion",
|
||||
"description": "The highest ledger version to search"
|
||||
},
|
||||
"includeRawTransaction": {
|
||||
"description": "Include raw transaction data. For advanced users; exercise caution when interpreting this data. "
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
|
||||
@@ -49,6 +49,9 @@
|
||||
"items": {"$ref": "transactionType"},
|
||||
"description": "Only return transactions of the specified [Transaction Types](#transaction-types)."
|
||||
},
|
||||
"includeRawTransactions": {
|
||||
"description": "Include raw transaction data. For advanced users; exercise caution when interpreting this data. "
|
||||
},
|
||||
"binary": {
|
||||
"type": "boolean",
|
||||
"description": "If true, the transactions will be sent from the server in a condensed binary format rather than JSON."
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"title": "amount",
|
||||
"link": "amount",
|
||||
"description": "An Amount on the Ripple Protocol",
|
||||
"description": "An Amount on the XRP Ledger",
|
||||
"allOf": [
|
||||
{"$ref": "amountbase"},
|
||||
{"required": ["value"]}
|
||||
|
||||
@@ -9,11 +9,11 @@
|
||||
"$ref": "value"
|
||||
},
|
||||
"currency": {
|
||||
"description": "The three-character code or hexadecimal string used to denote currencies",
|
||||
"description": "The three-character code or hexadecimal string used to denote currencies, or \"drops\" for the smallest unit of XRP.",
|
||||
"$ref": "currency"
|
||||
},
|
||||
"counterparty": {
|
||||
"description": "The Ripple address of the account that owes or is owed the funds (omitted if `currency` is \"XRP\")",
|
||||
"description": "The Ripple address of the account that owes or is owed the funds (omitted if `currency` is \"XRP\" or \"drops\")",
|
||||
"$ref": "address"
|
||||
}
|
||||
},
|
||||
@@ -24,7 +24,7 @@
|
||||
"properties": {
|
||||
"currency": {
|
||||
"not": {
|
||||
"enum": ["XRP"]
|
||||
"enum": ["XRP", "drops"]
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -33,7 +33,7 @@
|
||||
{
|
||||
"properties": {
|
||||
"currency": {
|
||||
"enum": ["XRP"]
|
||||
"enum": ["XRP", "drops"]
|
||||
}
|
||||
},
|
||||
"not": {
|
||||
@@ -4,5 +4,5 @@
|
||||
"description": "The three-character code or hexadecimal string used to denote currencies",
|
||||
"type": "string",
|
||||
"link": "currency",
|
||||
"pattern": "^([a-zA-Z0-9<>(){}[\\]|?!@#$%^&*]{3}|[A-F0-9]{40})$"
|
||||
"pattern": "^([a-zA-Z0-9<>(){}[\\]|?!@#$%^&*]{3}|[A-F0-9]{40}|drops)$"
|
||||
}
|
||||
|
||||
15
src/common/schemas/objects/destination-address-tag.json
Normal file
15
src/common/schemas/objects/destination-address-tag.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"title": "destinationAddressTag",
|
||||
"description": "A destination address and optional tag, with no amount included. When parsing an incoming transaction, the original specification's amount is hidden to prevent misinterpretation. For the amount that the transaction delivered, see `outcome.deliveredAmount`.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"address": {
|
||||
"$ref": "address",
|
||||
"description": "The address to receive at."
|
||||
},
|
||||
"tag": {"$ref": "tag"}
|
||||
},
|
||||
"required": ["address"],
|
||||
"additionalProperties": false
|
||||
}
|
||||
@@ -9,7 +9,7 @@
|
||||
},
|
||||
"amount": {
|
||||
"$ref": "laxAmount",
|
||||
"description": "An exact amount to deliver to the recipient. If the counterparty is not specified, amounts with any counterparty may be used. (This field is exclusive with destination.minAmount)."
|
||||
"description": "An exact amount to deliver to the recipient. If the counterparty is not specified, amounts with any counterparty may be used. (This field cannot be used with `destination.minAmount`.)"
|
||||
},
|
||||
"tag": {"$ref": "tag"}
|
||||
},
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
"$ref": "value"
|
||||
},
|
||||
"maxFee": {
|
||||
"description": "The maximum fee to pay for the transaction. See [Transaction Fees](#transaction-fees) for more information.",
|
||||
"description": "Deprecated: Use `maxFeeXRP` in the RippleAPI constructor instead. The maximum fee to pay for this transaction. If this exceeds `maxFeeXRP`, `maxFeeXRP` will be used instead. See [Transaction Fees](#transaction-fees) for more information.",
|
||||
"$ref": "value"
|
||||
},
|
||||
"maxLedgerVersion": {
|
||||
|
||||
@@ -93,7 +93,9 @@
|
||||
"minItems": 1,
|
||||
"maxItems": 8
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": ["threshold", "weights"],
|
||||
"additionalProperties": false
|
||||
},
|
||||
"transferRate": {
|
||||
"description": " The fee to charge when users transfer this account’s issuances, as the decimal amount that must be sent to deliver 1 unit. Has precision up to 9 digits beyond the decimal point. Use `null` to set no fee.",
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"title": "id",
|
||||
"title": "transactionHash",
|
||||
"link": "transaction-id",
|
||||
"description": "A hash of a transaction used to identify the transaction, represented in hexadecimal.",
|
||||
"type": "string",
|
||||
@@ -55,15 +55,11 @@
|
||||
"description": "A transaction in the same format as the return value of [getTransaction](#gettransaction)."
|
||||
}
|
||||
},
|
||||
"rawTransactions": {
|
||||
"type": "string",
|
||||
"description": "A JSON string containing rippled format transaction JSON for all transactions that were validated in this ledger."
|
||||
},
|
||||
"transactionHashes": {
|
||||
"description": "An array of hashes of all transactions that were validated in this ledger.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "id"
|
||||
"$ref": "transactionHash"
|
||||
}
|
||||
},
|
||||
"rawState": {
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"title": "getTransaction",
|
||||
"description": "getTransaction response",
|
||||
"link": "gettransaction",
|
||||
"properties": {
|
||||
"type": {
|
||||
"$ref": "transactionType"
|
||||
},
|
||||
"specification": {
|
||||
"description": "A specification that would produce the same outcome as this transaction. The structure of the specification depends on the value of the `type` field (see [Transaction Types](#transaction-types) for details). *Note:* This is **not** necessarily the same as the original specification."
|
||||
"description": "A specification that would produce the same outcome as this transaction. *Exception:* For payment transactions, this omits the `destination.amount` field, to prevent misunderstanding. The structure of the specification depends on the value of the `type` field (see [Transaction Types](#transaction-types) for details). *Note:* This is **not** necessarily the same as the original specification."
|
||||
},
|
||||
"outcome": {
|
||||
"$ref": "outcome",
|
||||
"description": "The outcome of the transaction (what effects it had)."
|
||||
},
|
||||
"id": {
|
||||
"$ref": "id",
|
||||
"$ref": "transactionHash",
|
||||
"description": "A hash of the transaction that can be used to identify it."
|
||||
},
|
||||
"address": {
|
||||
@@ -24,6 +25,10 @@
|
||||
"sequence": {
|
||||
"$ref": "sequence",
|
||||
"description": "The account sequence number of the transaction for the account that initiated it."
|
||||
},
|
||||
"rawTransaction": {
|
||||
"description": "The raw transaction data as a JSON string. For advanced users only; exercise caution when interpreting this data.",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
@@ -44,7 +49,7 @@
|
||||
]
|
||||
},
|
||||
"specification": {
|
||||
"$ref": "payment"
|
||||
"$ref": "getPayment"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "array",
|
||||
"description": "Key is the ripple address; value is an array of signed amounts representing changes of balances for that address.",
|
||||
"description": "Key is the XRP Ledger address; value is an array of signed amounts representing changes of balances for that address.",
|
||||
"items": {"$ref": "balance"}
|
||||
}
|
||||
},
|
||||
@@ -33,10 +33,14 @@
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "array",
|
||||
"description": "Key is the maker's ripple address; value is an array of changes",
|
||||
"description": "Key is the maker's XRP Ledger address; value is an array of changes",
|
||||
"items": {"$ref": "orderChange"}
|
||||
}
|
||||
},
|
||||
"channelChanges": {
|
||||
"type": "object",
|
||||
"description": "Properties reflecting the details of the payment channel."
|
||||
},
|
||||
"ledgerVersion": {
|
||||
"$ref": "ledgerVersion",
|
||||
"description": "The ledger version that the transaction was validated in."
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"description": "The signed transaction represented as an uppercase hexadecimal string."
|
||||
},
|
||||
"id": {
|
||||
"$ref": "id",
|
||||
"$ref": "transactionHash",
|
||||
"description": "The [Transaction ID](#transaction-id) of the signed transaction."
|
||||
}
|
||||
},
|
||||
|
||||
39
src/common/schemas/specifications/get-payment.json
Normal file
39
src/common/schemas/specifications/get-payment.json
Normal file
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"title": "getPayment",
|
||||
"description": "A specification of a payment in a response for getTransaction or getTransactions.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"source": {
|
||||
"$ref": "sourceAdjustment",
|
||||
"description": "The source of the funds to be sent."
|
||||
},
|
||||
"destination": {
|
||||
"$ref": "destinationAddressTag",
|
||||
"description": "The destination of the funds to be sent. Since this is a payment response, the amount is not shown here. For the amount that the transaction delivered, see `outcome.deliveredAmount`."
|
||||
},
|
||||
"paths": {
|
||||
"type": "string",
|
||||
"description": "The paths of trustlines and orders to use in executing the payment."
|
||||
},
|
||||
"memos": {"$ref": "memos"},
|
||||
"invoiceID": {
|
||||
"description": "A 256-bit hash that can be used to identify a particular payment.",
|
||||
"$ref": "hash256"
|
||||
},
|
||||
"allowPartialPayment": {
|
||||
"description": "If true, this payment should proceed even if the whole amount cannot be delivered due to a lack of liquidity or a lack of funds in the source account.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"noDirectRipple": {
|
||||
"description": "If true and paths are specified, the sender would like the XRP Ledger to disregard any direct paths from the source account to the destination account. This may be used to take advantage of an arbitrage opportunity or by gateways wishing to issue balances from a hot wallet to a user who has mistakenly set a trustline directly to the hot wallet.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"limitQuality": {
|
||||
"description": "Only take paths where all the conversions have an input:output ratio that is equal or better than the ratio of destination.amount:source.maxAmount.",
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": ["source", "destination"],
|
||||
"additionalProperties": false
|
||||
}
|
||||
@@ -19,11 +19,11 @@
|
||||
},
|
||||
"immediateOrCancel": {
|
||||
"type": "boolean",
|
||||
"description": "Treat the offer as an [Immediate or Cancel order](http://en.wikipedia.org/wiki/Immediate_or_cancel). If enabled, the offer will never become a ledger node: it only attempts to match existing offers in the ledger."
|
||||
"description": "Treat the offer as an [Immediate or Cancel order](http://en.wikipedia.org/wiki/Immediate_or_cancel). If enabled, the offer will never become a ledger node: it only attempts to match existing offers in the ledger. This cannot be used with `fillOrKill`."
|
||||
},
|
||||
"fillOrKill": {
|
||||
"type": "boolean",
|
||||
"description": "Treat the offer as a [Fill or Kill order](http://en.wikipedia.org/wiki/Fill_or_kill). Only attempt to match existing offers in the ledger, and only do so if the entire quantity can be exchanged."
|
||||
"description": "Treat the offer as a [Fill or Kill order](http://en.wikipedia.org/wiki/Fill_or_kill). Only attempt to match existing offers in the ledger, and only do so if the entire quantity can be exchanged. This cannot be used with `immediateOrCancel`."
|
||||
},
|
||||
"passive": {
|
||||
"description": "If enabled, the offer will not consume offers that exactly match it, and instead becomes an Offer node in the ledger. It will still consume offers that cross it.",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as _ from 'lodash'
|
||||
import {convertKeysFromSnakeCaseToCamelCase} from './utils'
|
||||
import Connection from './connection'
|
||||
import BigNumber from 'bignumber.js'
|
||||
import {RippleAPI} from '../index'
|
||||
|
||||
export type GetServerInfoResponse = {
|
||||
buildVersion: string,
|
||||
@@ -39,8 +39,8 @@ function renameKeys(object, mapping) {
|
||||
})
|
||||
}
|
||||
|
||||
function getServerInfo(connection: Connection): Promise<GetServerInfoResponse> {
|
||||
return connection.request({command: 'server_info'}).then(response => {
|
||||
function getServerInfo(this: RippleAPI): Promise<GetServerInfoResponse> {
|
||||
return this.request('server_info').then(response => {
|
||||
const info = convertKeysFromSnakeCaseToCamelCase(response.info)
|
||||
renameKeys(info, {hostid: 'hostID'})
|
||||
if (info.validatedLedger) {
|
||||
@@ -61,18 +61,27 @@ function getServerInfo(connection: Connection): Promise<GetServerInfoResponse> {
|
||||
})
|
||||
}
|
||||
|
||||
function computeFeeFromServerInfo(cushion: number,
|
||||
serverInfo: GetServerInfoResponse
|
||||
): string {
|
||||
return (new BigNumber(serverInfo.validatedLedger.baseFeeXRP)).
|
||||
times(serverInfo.loadFactor).
|
||||
times(cushion).toString()
|
||||
}
|
||||
// This is a public API that can be called directly.
|
||||
// This is not used by the `prepare*` methods. See `src/transaction/utils.ts`
|
||||
async function getFee(
|
||||
this: RippleAPI,
|
||||
cushion?: number
|
||||
): Promise<string> {
|
||||
if (cushion === undefined) {
|
||||
cushion = this._feeCushion
|
||||
}
|
||||
if (cushion === undefined) {
|
||||
cushion = 1.2
|
||||
}
|
||||
|
||||
function getFee(connection: Connection, cushion: number): Promise<string> {
|
||||
return getServerInfo(connection).then(serverInfo => {
|
||||
return computeFeeFromServerInfo(cushion, serverInfo)
|
||||
})
|
||||
const serverInfo = (await this.request('server_info')).info
|
||||
const baseFeeXrp = new BigNumber(serverInfo.validated_ledger.base_fee_xrp)
|
||||
let fee = baseFeeXrp.times(serverInfo.load_factor).times(cushion)
|
||||
|
||||
// Cap fee to `this._maxFeeXRP`
|
||||
fee = BigNumber.min(fee, this._maxFeeXRP)
|
||||
// Round fee to 6 decimal places
|
||||
return (new BigNumber(fee.toFixed(6))).toString(10)
|
||||
}
|
||||
|
||||
export {
|
||||
|
||||
@@ -6,3 +6,4 @@ export * from './book_offers'
|
||||
export * from './gateway_balances'
|
||||
export * from './ledger'
|
||||
export * from './ledger_entry'
|
||||
export * from './server_info'
|
||||
|
||||
51
src/common/types/commands/server_info.ts
Normal file
51
src/common/types/commands/server_info.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
export interface ServerInfoRequest {
|
||||
id?: number
|
||||
}
|
||||
|
||||
export interface ServerInfoResponse {
|
||||
info: {
|
||||
amendment_blocked?: boolean,
|
||||
build_version: string,
|
||||
closed_ledger?: LedgerInfo,
|
||||
complete_ledgers: string,
|
||||
hostid: string,
|
||||
io_latency_ms: number,
|
||||
last_close: {
|
||||
converge_time_s: number,
|
||||
proposers: number
|
||||
},
|
||||
load?: {
|
||||
job_types: {
|
||||
job_type: string,
|
||||
per_second: number,
|
||||
in_progress: number
|
||||
}[],
|
||||
threads: number
|
||||
},
|
||||
load_factor: number,
|
||||
load_factor_local?: number,
|
||||
load_factor_net?: number,
|
||||
load_factor_cluster?: number,
|
||||
load_factor_fee_escalation?: number,
|
||||
load_factor_fee_queue?: number,
|
||||
load_factor_server?: number,
|
||||
peers: number,
|
||||
pubkey_node: string,
|
||||
pubkey_validator: string,
|
||||
server_state: string,
|
||||
state_accounting: any,
|
||||
uptime: number,
|
||||
validated_ledger?: LedgerInfo,
|
||||
validation_quorum: number,
|
||||
validator_list_expires: string
|
||||
},
|
||||
}
|
||||
|
||||
export interface LedgerInfo {
|
||||
age: number,
|
||||
base_fee_xrp: number,
|
||||
hash: string,
|
||||
reserve_base_xrp: number,
|
||||
reserve_inc_xrp: number,
|
||||
seq: number,
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
import * as _ from 'lodash'
|
||||
import BigNumber from 'bignumber.js'
|
||||
const {deriveKeypair} = require('ripple-keypairs')
|
||||
|
||||
import {deriveKeypair} from 'ripple-keypairs'
|
||||
import {Amount, RippledAmount} from './types/objects'
|
||||
import {ValidationError} from './errors'
|
||||
|
||||
function isValidSecret(secret: string): boolean {
|
||||
try {
|
||||
@@ -13,18 +13,86 @@ function isValidSecret(secret: string): boolean {
|
||||
}
|
||||
}
|
||||
|
||||
function dropsToXrp(drops: string): string {
|
||||
return (new BigNumber(drops)).dividedBy(1000000.0).toString()
|
||||
function dropsToXrp(drops: string | BigNumber): string {
|
||||
if (typeof drops === 'string') {
|
||||
if (!drops.match(/^-?[0-9]*\.?[0-9]*$/)) {
|
||||
throw new ValidationError(`dropsToXrp: invalid value '${drops}',` +
|
||||
` should be a number matching (^-?[0-9]*\.?[0-9]*$).`)
|
||||
} else if (drops === '.') {
|
||||
throw new ValidationError(`dropsToXrp: invalid value '${drops}',` +
|
||||
` should be a BigNumber or string-encoded number.`)
|
||||
}
|
||||
}
|
||||
|
||||
// Converting to BigNumber and then back to string should remove any
|
||||
// decimal point followed by zeros, e.g. '1.00'.
|
||||
// Important: specify base 10 to avoid exponential notation, e.g. '1e-7'.
|
||||
drops = (new BigNumber(drops)).toString(10)
|
||||
|
||||
// drops are only whole units
|
||||
if (drops.includes('.')) {
|
||||
throw new ValidationError(`dropsToXrp: value '${drops}' has` +
|
||||
` too many decimal places.`)
|
||||
}
|
||||
|
||||
// This should never happen; the value has already been
|
||||
// validated above. This just ensures BigNumber did not do
|
||||
// something unexpected.
|
||||
if (!drops.match(/^-?[0-9]+$/)) {
|
||||
throw new ValidationError(`dropsToXrp: failed sanity check -` +
|
||||
` value '${drops}',` +
|
||||
` does not match (^-?[0-9]+$).`)
|
||||
}
|
||||
|
||||
return (new BigNumber(drops)).dividedBy(1000000.0).toString(10)
|
||||
}
|
||||
|
||||
function xrpToDrops(xrp: string): string {
|
||||
return (new BigNumber(xrp)).times(1000000.0).floor().toString()
|
||||
function xrpToDrops(xrp: string | BigNumber): string {
|
||||
if (typeof xrp === 'string') {
|
||||
if (!xrp.match(/^-?[0-9]*\.?[0-9]*$/)) {
|
||||
throw new ValidationError(`xrpToDrops: invalid value '${xrp}',` +
|
||||
` should be a number matching (^-?[0-9]*\.?[0-9]*$).`)
|
||||
} else if (xrp === '.') {
|
||||
throw new ValidationError(`xrpToDrops: invalid value '${xrp}',` +
|
||||
` should be a BigNumber or string-encoded number.`)
|
||||
}
|
||||
}
|
||||
|
||||
// Important: specify base 10 to avoid exponential notation, e.g. '1e-7'.
|
||||
xrp = (new BigNumber(xrp)).toString(10)
|
||||
|
||||
// This should never happen; the value has already been
|
||||
// validated above. This just ensures BigNumber did not do
|
||||
// something unexpected.
|
||||
if (!xrp.match(/^-?[0-9.]+$/)) {
|
||||
throw new ValidationError(`xrpToDrops: failed sanity check -` +
|
||||
` value '${xrp}',` +
|
||||
` does not match (^-?[0-9.]+$).`)
|
||||
}
|
||||
|
||||
const components = xrp.split('.')
|
||||
if (components.length > 2) {
|
||||
throw new ValidationError(`xrpToDrops: failed sanity check -` +
|
||||
` value '${xrp}' has` +
|
||||
` too many decimal points.`)
|
||||
}
|
||||
|
||||
const fraction = components[1] || '0'
|
||||
if (fraction.length > 6) {
|
||||
throw new ValidationError(`xrpToDrops: value '${xrp}' has` +
|
||||
` too many decimal places.`)
|
||||
}
|
||||
|
||||
return (new BigNumber(xrp)).times(1000000.0).floor().toString(10)
|
||||
}
|
||||
|
||||
function toRippledAmount(amount: Amount): RippledAmount {
|
||||
if (amount.currency === 'XRP') {
|
||||
return xrpToDrops(amount.value)
|
||||
}
|
||||
if (amount.currency === 'drops') {
|
||||
return amount.value
|
||||
}
|
||||
return {
|
||||
currency: amount.currency,
|
||||
issuer: amount.counterparty ? amount.counterparty :
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
|
||||
|
||||
export {RippleAPI} from './api'
|
||||
|
||||
export {
|
||||
FormattedTransactionType
|
||||
} from './transaction/types'
|
||||
|
||||
// Broadcast api is experimental
|
||||
export {RippleAPIBroadcast} from './broadcast'
|
||||
|
||||
@@ -18,18 +18,18 @@ export type FormattedLedger = {
|
||||
totalDrops: string,
|
||||
transactionHash: string,
|
||||
transactions?: Array<Object>,
|
||||
rawTransactions?: string,
|
||||
transactionHashes?: Array<string>,
|
||||
rawState?: string,
|
||||
stateHashes?: Array<string>
|
||||
}
|
||||
|
||||
function parseTransactionWrapper(ledgerVersion, tx) {
|
||||
// renames metaData to meta and adds ledger_index
|
||||
const transaction = _.assign({}, _.omit(tx, 'metaData'), {
|
||||
meta: tx.metaData,
|
||||
ledger_index: ledgerVersion
|
||||
})
|
||||
const result = parseTransaction(transaction)
|
||||
const result = parseTransaction(transaction, true)
|
||||
if (!result.outcome.ledgerVersion) {
|
||||
result.outcome.ledgerVersion = ledgerVersion
|
||||
}
|
||||
@@ -45,8 +45,7 @@ function parseTransactions(transactions, ledgerVersion) {
|
||||
}
|
||||
return {
|
||||
transactions: _.map(transactions,
|
||||
_.partial(parseTransactionWrapper, ledgerVersion)),
|
||||
rawTransactions: JSON.stringify(transactions)
|
||||
_.partial(parseTransactionWrapper, ledgerVersion))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,19 +61,20 @@ function parseState(state) {
|
||||
|
||||
export function parseLedger(ledger: Ledger): FormattedLedger {
|
||||
const ledgerVersion = parseInt(ledger.ledger_index || ledger.seqNum, 10)
|
||||
return removeUndefined(Object.assign({
|
||||
stateHash: ledger.account_hash,
|
||||
closeTime: rippleTimeToISO8601(ledger.close_time),
|
||||
closeTimeResolution: ledger.close_time_resolution,
|
||||
closeFlags: ledger.close_flags,
|
||||
ledgerHash: ledger.hash || ledger.ledger_hash,
|
||||
ledgerVersion: ledgerVersion,
|
||||
parentLedgerHash: ledger.parent_hash,
|
||||
parentCloseTime: rippleTimeToISO8601(ledger.parent_close_time),
|
||||
totalDrops: ledger.total_coins || ledger.totalCoins,
|
||||
transactionHash: ledger.transaction_hash
|
||||
},
|
||||
parseTransactions(ledger.transactions, ledgerVersion),
|
||||
parseState(ledger.accountState)
|
||||
return removeUndefined(Object.assign(
|
||||
{
|
||||
stateHash: ledger.account_hash,
|
||||
closeTime: rippleTimeToISO8601(ledger.close_time),
|
||||
closeTimeResolution: ledger.close_time_resolution,
|
||||
closeFlags: ledger.close_flags,
|
||||
ledgerHash: ledger.hash || ledger.ledger_hash,
|
||||
ledgerVersion: ledgerVersion,
|
||||
parentLedgerHash: ledger.parent_hash,
|
||||
parentCloseTime: rippleTimeToISO8601(ledger.parent_close_time),
|
||||
totalDrops: ledger.total_coins || ledger.totalCoins,
|
||||
transactionHash: ledger.transaction_hash
|
||||
},
|
||||
parseTransactions(ledger.transactions, ledgerVersion),
|
||||
parseState(ledger.accountState)
|
||||
))
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ function removeGenericCounterparty(amount, address) {
|
||||
_.omit(amount, 'counterparty') : amount
|
||||
}
|
||||
|
||||
// Payment specification
|
||||
function parsePayment(tx: any): Object {
|
||||
assert(tx.TransactionType === 'Payment')
|
||||
|
||||
@@ -27,10 +28,13 @@ function parsePayment(tx: any): Object {
|
||||
tag: tx.SourceTag
|
||||
}
|
||||
|
||||
const destination = {
|
||||
const destination: {
|
||||
address: string,
|
||||
tag: number | undefined
|
||||
} = {
|
||||
address: tx.Destination,
|
||||
amount: removeGenericCounterparty(parseAmount(tx.Amount), tx.Destination),
|
||||
tag: tx.DestinationTag
|
||||
// Notice that `amount` is omitted to prevent misinterpretation
|
||||
}
|
||||
|
||||
return removeUndefined({
|
||||
|
||||
@@ -42,7 +42,7 @@ function parseTransactionType(type) {
|
||||
return mapping[type] || null
|
||||
}
|
||||
|
||||
function parseTransaction(tx: any): any {
|
||||
function parseTransaction(tx: any, includeRawTransaction: boolean): any {
|
||||
const type = parseTransactionType(tx.TransactionType)
|
||||
const mapping = {
|
||||
'payment': parsePayment,
|
||||
@@ -72,7 +72,8 @@ function parseTransaction(tx: any): any {
|
||||
sequence: tx.Sequence,
|
||||
id: tx.hash,
|
||||
specification: removeUndefined(specification),
|
||||
outcome: outcome ? removeUndefined(outcome) : undefined
|
||||
outcome: outcome ? removeUndefined(outcome) : undefined,
|
||||
rawTransaction: includeRawTransaction ? JSON.stringify(tx) : undefined
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -103,6 +103,8 @@ function parseOutcome(tx: any): any|undefined {
|
||||
}
|
||||
const balanceChanges = transactionParser.parseBalanceChanges(metadata)
|
||||
const orderbookChanges = transactionParser.parseOrderbookChanges(metadata)
|
||||
const channelChanges = transactionParser.parseChannelChanges(metadata)
|
||||
|
||||
removeEmptyCounterpartyInBalanceChanges(balanceChanges)
|
||||
removeEmptyCounterpartyInOrderbookChanges(orderbookChanges)
|
||||
|
||||
@@ -112,6 +114,7 @@ function parseOutcome(tx: any): any|undefined {
|
||||
fee: common.dropsToXrp(tx.Fee),
|
||||
balanceChanges: balanceChanges,
|
||||
orderbookChanges: orderbookChanges,
|
||||
channelChanges: channelChanges,
|
||||
ledgerVersion: tx.ledger_index,
|
||||
indexInLedger: tx.meta.TransactionIndex,
|
||||
deliveredAmount: parseDeliveredAmount(tx)
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
import * as _ from 'lodash'
|
||||
import BigNumber from 'bignumber.js'
|
||||
import {getXRPBalance, renameCounterpartyToIssuer} from './utils'
|
||||
import {validate, toRippledAmount, errors} from '../common'
|
||||
import {
|
||||
validate,
|
||||
toRippledAmount,
|
||||
errors,
|
||||
xrpToDrops,
|
||||
dropsToXrp
|
||||
} from '../common'
|
||||
import {Connection} from '../common'
|
||||
import parsePathfind from './parse/pathfind'
|
||||
import {RippledAmount, Amount} from '../common/types/objects'
|
||||
@@ -23,7 +29,11 @@ function addParams(request: PathFindRequest, result: RippledPathsResponse
|
||||
function requestPathFind(connection: Connection, pathfind: PathFind
|
||||
): Promise<RippledPathsResponse> {
|
||||
const destinationAmount: Amount = _.assign(
|
||||
{value: '-1'},
|
||||
{
|
||||
// This is converted back to drops by toRippledAmount()
|
||||
value: pathfind.destination.amount.currency === 'XRP' ?
|
||||
dropsToXrp('-1') : '-1'
|
||||
},
|
||||
pathfind.destination.amount
|
||||
)
|
||||
const request: PathFindRequest = {
|
||||
@@ -95,13 +105,21 @@ function filterSourceFundsLowPaths(pathfind: PathFind,
|
||||
): RippledPathsResponse {
|
||||
if (pathfind.source.amount &&
|
||||
pathfind.destination.amount.value === undefined && paths.alternatives) {
|
||||
paths.alternatives = _.filter(paths.alternatives, alt =>
|
||||
!!alt.source_amount &&
|
||||
!!pathfind.source.amount &&
|
||||
// TODO: Returns false when alt.source_amount is a string. Fix?
|
||||
typeof alt.source_amount !== 'string' &&
|
||||
new BigNumber(alt.source_amount.value).eq(pathfind.source.amount.value)
|
||||
)
|
||||
paths.alternatives = _.filter(paths.alternatives, alt => {
|
||||
if (!alt.source_amount) {
|
||||
return false
|
||||
}
|
||||
const pathfindSourceAmountValue = new BigNumber(
|
||||
pathfind.source.amount.currency === 'XRP' ?
|
||||
xrpToDrops(pathfind.source.amount.value) :
|
||||
pathfind.source.amount.value)
|
||||
const altSourceAmountValue = new BigNumber(
|
||||
typeof alt.source_amount === 'string' ?
|
||||
alt.source_amount :
|
||||
alt.source_amount.value
|
||||
)
|
||||
return altSourceAmountValue.eq(pathfindSourceAmountValue)
|
||||
})
|
||||
}
|
||||
return paths
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@ import {FormattedTransactionType} from '../transaction/types'
|
||||
|
||||
export type TransactionOptions = {
|
||||
minLedgerVersion?: number,
|
||||
maxLedgerVersion?: number
|
||||
maxLedgerVersion?: number,
|
||||
includeRawTransaction?: boolean
|
||||
}
|
||||
type TransactionResponse = FormattedTransactionType & {
|
||||
hash: string,
|
||||
@@ -18,7 +19,7 @@ type TransactionResponse = FormattedTransactionType & {
|
||||
|
||||
|
||||
function attachTransactionDate(connection: Connection, tx: any
|
||||
): Promise<FormattedTransactionType> {
|
||||
): Promise<TransactionResponse> {
|
||||
if (tx.date) {
|
||||
return Promise.resolve(tx)
|
||||
}
|
||||
@@ -83,31 +84,25 @@ function convertError(connection: Connection, options: TransactionOptions,
|
||||
function formatResponse(options: TransactionOptions, tx: TransactionResponse
|
||||
): FormattedTransactionType {
|
||||
if (tx.validated !== true || !isTransactionInRange(tx, options)) {
|
||||
throw new errors.NotFoundError('Transaction not found')
|
||||
throw new errors.NotFoundError('Transaction not found')
|
||||
}
|
||||
return parseTransaction(tx)
|
||||
return parseTransaction(tx, options.includeRawTransaction)
|
||||
}
|
||||
|
||||
function getTransaction(id: string, options: TransactionOptions = {}
|
||||
async function getTransaction(id: string, options: TransactionOptions = {}
|
||||
): Promise<FormattedTransactionType> {
|
||||
validate.getTransaction({id, options})
|
||||
|
||||
const request = {
|
||||
command: 'tx',
|
||||
transaction: id,
|
||||
binary: false
|
||||
const _options = await utils.ensureLedgerVersion.call(this, options)
|
||||
try {
|
||||
const tx = await this.request('tx', {
|
||||
transaction: id,
|
||||
binary: false
|
||||
})
|
||||
const txWithDate = await attachTransactionDate(this.connection, tx)
|
||||
return formatResponse(_options, txWithDate)
|
||||
} catch (error) {
|
||||
throw (await convertError(this.connection, _options, error))
|
||||
}
|
||||
|
||||
return utils.ensureLedgerVersion.call(this, options).then(_options => {
|
||||
return this.connection.request(request).then((tx: TransactionResponse) =>
|
||||
attachTransactionDate(this.connection, tx)
|
||||
).then(_.partial(formatResponse, _options))
|
||||
.catch(error => {
|
||||
return convertError(this.connection, _options, error).then(_error => {
|
||||
throw _error
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export default getTransaction
|
||||
|
||||
@@ -18,6 +18,7 @@ export type TransactionsOptions = {
|
||||
initiated?: boolean,
|
||||
counterparty?: string,
|
||||
types?: Array<string>,
|
||||
includeRawTransactions?: boolean,
|
||||
binary?: boolean,
|
||||
startTx?: FormattedTransactionType
|
||||
}
|
||||
@@ -35,11 +36,11 @@ function parseBinaryTransaction(transaction) {
|
||||
}
|
||||
}
|
||||
|
||||
function parseAccountTxTransaction(tx) {
|
||||
function parseAccountTxTransaction(tx, includeRawTransaction: boolean) {
|
||||
const _tx = tx.tx_blob ? parseBinaryTransaction(tx) : tx
|
||||
// rippled uses a different response format for 'account_tx' than 'tx'
|
||||
return parseTransaction(_.assign({}, _tx.tx,
|
||||
{meta: _tx.meta, validated: _tx.validated}))
|
||||
{meta: _tx.meta, validated: _tx.validated}), includeRawTransaction)
|
||||
}
|
||||
|
||||
function counterpartyFilter(filters, tx: FormattedTransactionType) {
|
||||
@@ -87,11 +88,13 @@ function orderFilter(
|
||||
function formatPartialResponse(address: string,
|
||||
options: TransactionsOptions, data
|
||||
) {
|
||||
const parse = tx =>
|
||||
parseAccountTxTransaction(tx, options.includeRawTransactions)
|
||||
return {
|
||||
marker: data.marker,
|
||||
results: data.transactions
|
||||
.filter(tx => tx.validated)
|
||||
.map(parseAccountTxTransaction)
|
||||
.map(parse)
|
||||
.filter(_.partial(transactionFilter, address, options))
|
||||
.filter(_.partial(orderFilter, options))
|
||||
}
|
||||
|
||||
@@ -25,13 +25,33 @@ function hashLedgerHeader(ledgerHeader) {
|
||||
return hashes.computeLedgerHash(header)
|
||||
}
|
||||
|
||||
function computeTransactionHash(ledger, version) {
|
||||
if (ledger.rawTransactions === undefined) {
|
||||
function computeTransactionHash(ledger, version,
|
||||
options: ComputeLedgerHashOptions) {
|
||||
let transactions: any[]
|
||||
if (ledger.rawTransactions) {
|
||||
transactions = JSON.parse(ledger.rawTransactions)
|
||||
} else if (ledger.transactions) {
|
||||
try {
|
||||
transactions = ledger.transactions.map(tx =>
|
||||
JSON.parse(tx.rawTransaction))
|
||||
} catch (e) {
|
||||
if (e.toString() === 'SyntaxError: Unexpected' +
|
||||
' token u in JSON at position 0') {
|
||||
// one or more of the `tx.rawTransaction`s is undefined
|
||||
throw new common.errors.ValidationError('ledger'
|
||||
+ ' is missing raw transactions')
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (options.computeTreeHashes) {
|
||||
throw new common.errors.ValidationError('transactions'
|
||||
+ ' property is missing from the ledger')
|
||||
}
|
||||
return ledger.transactionHash
|
||||
}
|
||||
const transactions: any[] = JSON.parse(ledger.rawTransactions)
|
||||
const txs = _.map(transactions, tx => {
|
||||
const mergeTx = _.assign({}, _.omit(tx, 'tx'), tx.tx || {})
|
||||
// rename `meta` back to `metaData`
|
||||
const renameMeta = _.assign({}, _.omit(mergeTx, 'meta'),
|
||||
tx.meta ? {metaData: tx.meta} : {})
|
||||
return renameMeta
|
||||
@@ -40,13 +60,21 @@ function computeTransactionHash(ledger, version) {
|
||||
if (ledger.transactionHash !== undefined
|
||||
&& ledger.transactionHash !== transactionHash) {
|
||||
throw new common.errors.ValidationError('transactionHash in header'
|
||||
+ ' does not match computed hash of transactions')
|
||||
+ ' does not match computed hash of transactions', {
|
||||
transactionHashInHeader: ledger.transactionHash,
|
||||
computedHashOfTransactions: transactionHash
|
||||
})
|
||||
}
|
||||
return transactionHash
|
||||
}
|
||||
|
||||
function computeStateHash(ledger, version) {
|
||||
function computeStateHash(ledger, version,
|
||||
options: ComputeLedgerHashOptions) {
|
||||
if (ledger.rawState === undefined) {
|
||||
if (options.computeTreeHashes) {
|
||||
throw new common.errors.ValidationError('rawState'
|
||||
+ ' property is missing from the ledger')
|
||||
}
|
||||
return ledger.stateHash
|
||||
}
|
||||
const state = JSON.parse(ledger.rawState)
|
||||
@@ -60,11 +88,16 @@ function computeStateHash(ledger, version) {
|
||||
|
||||
const sLCF_SHAMapV2 = 0x02
|
||||
|
||||
function computeLedgerHash(ledger: any): string {
|
||||
export type ComputeLedgerHashOptions = {
|
||||
computeTreeHashes?: boolean
|
||||
}
|
||||
|
||||
function computeLedgerHash(ledger: any,
|
||||
options: ComputeLedgerHashOptions = {}): string {
|
||||
const version = ((ledger.closeFlags & sLCF_SHAMapV2) === 0) ? 1 : 2
|
||||
const subhashes = {
|
||||
transactionHash: computeTransactionHash(ledger, version),
|
||||
stateHash: computeStateHash(ledger, version)
|
||||
transactionHash: computeTransactionHash(ledger, version, options),
|
||||
stateHash: computeStateHash(ledger, version, options)
|
||||
}
|
||||
return hashLedgerHeader(_.assign({}, ledger, subhashes))
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import * as common from '../common'
|
||||
import {GetServerInfoResponse} from '../common/serverinfo'
|
||||
|
||||
function isConnected(): boolean {
|
||||
return this.connection.isConnected()
|
||||
@@ -17,15 +16,6 @@ function disconnect(): Promise<void> {
|
||||
return this.connection.disconnect()
|
||||
}
|
||||
|
||||
function getServerInfo(): Promise<GetServerInfoResponse> {
|
||||
return common.serverInfo.getServerInfo(this.connection)
|
||||
}
|
||||
|
||||
function getFee(): Promise<string> {
|
||||
const cushion = this._feeCushion || 1.2
|
||||
return common.serverInfo.getFee(this.connection, cushion)
|
||||
}
|
||||
|
||||
function formatLedgerClose(ledgerClose: any): Object {
|
||||
return {
|
||||
baseFeeXRP: common.dropsToXrp(ledgerClose.fee_base),
|
||||
@@ -43,8 +33,6 @@ export {
|
||||
connect,
|
||||
disconnect,
|
||||
isConnected,
|
||||
getServerInfo,
|
||||
getFee,
|
||||
getLedgerVersion,
|
||||
formatLedgerClose
|
||||
}
|
||||
|
||||
@@ -46,8 +46,8 @@ function createEscrowCreationTransaction(account: string,
|
||||
}
|
||||
if (Boolean(payment.allowCancelAfter) && Boolean(payment.allowExecuteAfter) &&
|
||||
txJSON.CancelAfter <= txJSON.FinishAfter) {
|
||||
throw new ValidationError('"CancelAfter" must be after "FinishAfter" for'
|
||||
+ ' EscrowCreate')
|
||||
throw new ValidationError('prepareEscrowCreation: ' +
|
||||
'"allowCancelAfter" must be after "allowExecuteAfter"')
|
||||
}
|
||||
return txJSON
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ const ValidationError = utils.common.errors.ValidationError
|
||||
import {Instructions, Prepare} from './types'
|
||||
import {Amount, Adjustment, MaxAdjustment,
|
||||
MinAdjustment, Memo} from '../common/types/objects'
|
||||
import {xrpToDrops} from '../common'
|
||||
|
||||
|
||||
export interface Payment {
|
||||
@@ -32,12 +33,12 @@ export interface Payment {
|
||||
|
||||
function isMaxAdjustment(
|
||||
source: Adjustment | MaxAdjustment): source is MaxAdjustment {
|
||||
return (source as MaxAdjustment).maxAmount !== undefined
|
||||
return (source as MaxAdjustment).maxAmount !== undefined
|
||||
}
|
||||
|
||||
function isMinAdjustment(
|
||||
destination: Adjustment | MinAdjustment): destination is MinAdjustment {
|
||||
return (destination as MinAdjustment).minAmount !== undefined
|
||||
return (destination as MinAdjustment).minAmount !== undefined
|
||||
}
|
||||
|
||||
function isXRPToXRPPayment(payment: Payment): boolean {
|
||||
@@ -50,7 +51,7 @@ function isXRPToXRPPayment(payment: Payment): boolean {
|
||||
}
|
||||
|
||||
function isIOUWithoutCounterparty(amount: Amount): boolean {
|
||||
return amount && amount.currency !== 'XRP'
|
||||
return amount && amount.currency !== 'XRP' && amount.currency !== 'drops'
|
||||
&& amount.counterparty === undefined
|
||||
}
|
||||
|
||||
@@ -72,7 +73,14 @@ function applyAnyCounterpartyEncoding(payment: Payment): void {
|
||||
function createMaximalAmount(amount: Amount): Amount {
|
||||
const maxXRPValue = '100000000000'
|
||||
const maxIOUValue = '9999999999999999e80'
|
||||
const maxValue = amount.currency === 'XRP' ? maxXRPValue : maxIOUValue
|
||||
let maxValue
|
||||
if (amount.currency === 'XRP') {
|
||||
maxValue = maxXRPValue
|
||||
} else if (amount.currency === 'drops') {
|
||||
maxValue = xrpToDrops(maxXRPValue)
|
||||
} else {
|
||||
maxValue = maxIOUValue
|
||||
}
|
||||
return _.assign({}, amount, {value: maxValue})
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,9 @@ import keypairs = require('ripple-keypairs')
|
||||
import binary = require('ripple-binary-codec')
|
||||
import {computeBinaryTransactionHash} from 'ripple-hashes'
|
||||
import {SignOptions, KeyPair} from './types'
|
||||
import {BigNumber} from 'bignumber.js'
|
||||
import {xrpToDrops} from '../common'
|
||||
import {RippleAPI} from '../api'
|
||||
const validate = utils.common.validate
|
||||
|
||||
function computeSignature(tx: Object, privateKey: string, signAs?: string) {
|
||||
@@ -13,6 +16,7 @@ function computeSignature(tx: Object, privateKey: string, signAs?: string) {
|
||||
}
|
||||
|
||||
function signWithKeypair(
|
||||
api: RippleAPI,
|
||||
txJSON: string,
|
||||
keypair: KeyPair,
|
||||
options: SignOptions = {
|
||||
@@ -28,6 +32,15 @@ function signWithKeypair(
|
||||
)
|
||||
}
|
||||
|
||||
const fee = new BigNumber(tx.Fee)
|
||||
const maxFeeDrops = xrpToDrops(api._maxFeeXRP)
|
||||
if (fee.greaterThan(maxFeeDrops)) {
|
||||
throw new utils.common.errors.ValidationError(
|
||||
`"Fee" should not exceed "${maxFeeDrops}". ` +
|
||||
'To use a higher fee, set `maxFeeXRP` in the RippleAPI constructor.'
|
||||
)
|
||||
}
|
||||
|
||||
tx.SigningPubKey = options.signAs ? '' : keypair.publicKey
|
||||
|
||||
if (options.signAs) {
|
||||
@@ -49,6 +62,7 @@ function signWithKeypair(
|
||||
}
|
||||
|
||||
function sign(
|
||||
this: RippleAPI,
|
||||
txJSON: string,
|
||||
secret?: any,
|
||||
options?: SignOptions,
|
||||
@@ -58,9 +72,18 @@ function sign(
|
||||
// we can't validate that the secret matches the account because
|
||||
// the secret could correspond to the regular key
|
||||
validate.sign({txJSON, secret})
|
||||
return signWithKeypair(txJSON, keypairs.deriveKeypair(secret), options)
|
||||
return signWithKeypair(
|
||||
this,
|
||||
txJSON,
|
||||
keypairs.deriveKeypair(secret),
|
||||
options
|
||||
)
|
||||
} else {
|
||||
return signWithKeypair(txJSON, keypair ? keypair : secret, options)
|
||||
return signWithKeypair(
|
||||
this,
|
||||
txJSON,
|
||||
keypair ? keypair : secret,
|
||||
options)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
import * as _ from 'lodash'
|
||||
import * as utils from './utils'
|
||||
import {validate} from '../common'
|
||||
import {Submit} from './types'
|
||||
import {RippleAPI} from '..'
|
||||
|
||||
export interface FormattedSubmitResponse {
|
||||
resultCode: string,
|
||||
resultMessage: string
|
||||
}
|
||||
|
||||
function isImmediateRejection(engineResult: string): boolean {
|
||||
// note: "tel" errors mean the local server refused to process the
|
||||
@@ -13,7 +18,7 @@ function isImmediateRejection(engineResult: string): boolean {
|
||||
return _.startsWith(engineResult, 'tem')
|
||||
}
|
||||
|
||||
function formatSubmitResponse(response) {
|
||||
function formatSubmitResponse(response): FormattedSubmitResponse {
|
||||
const data = {
|
||||
resultCode: response.engine_result,
|
||||
resultMessage: response.engine_result_message
|
||||
@@ -24,14 +29,15 @@ function formatSubmitResponse(response) {
|
||||
return data
|
||||
}
|
||||
|
||||
function submit(signedTransaction: string): Promise<Submit> {
|
||||
async function submit(
|
||||
this: RippleAPI, signedTransaction: string
|
||||
): Promise<FormattedSubmitResponse> {
|
||||
// 1. Validate
|
||||
validate.submit({signedTransaction})
|
||||
|
||||
const request = {
|
||||
command: 'submit',
|
||||
tx_blob: signedTransaction
|
||||
}
|
||||
return this.connection.request(request).then(formatSubmitResponse)
|
||||
// 2. Make Request
|
||||
const response = await this.request('submit', {tx_blob: signedTransaction})
|
||||
// 3. Return Formatted Response
|
||||
return formatSubmitResponse(response)
|
||||
}
|
||||
|
||||
export default submit
|
||||
|
||||
@@ -12,6 +12,7 @@ import {ApiMemo} from './utils'
|
||||
export type Instructions = {
|
||||
sequence?: number,
|
||||
fee?: string,
|
||||
// @deprecated
|
||||
maxFee?: string,
|
||||
maxLedgerVersion?: number,
|
||||
maxLedgerVersionOffset?: number,
|
||||
@@ -21,10 +22,10 @@ export type Instructions = {
|
||||
export type Prepare = {
|
||||
txJSON: string,
|
||||
instructions: {
|
||||
fee: string,
|
||||
sequence: number,
|
||||
maxLedgerVersion?: number
|
||||
}
|
||||
fee: string,
|
||||
sequence: number,
|
||||
maxLedgerVersion?: number
|
||||
}
|
||||
}
|
||||
|
||||
export type Submit = {
|
||||
|
||||
@@ -4,6 +4,7 @@ import {Memo} from '../common/types/objects'
|
||||
const txFlags = common.txFlags
|
||||
import {Instructions, Prepare} from './types'
|
||||
import {RippleAPI} from '../api'
|
||||
import {ValidationError} from '../common/errors'
|
||||
|
||||
export type ApiMemo = {
|
||||
MemoData?: string,
|
||||
@@ -63,11 +64,18 @@ function prepareTransaction(txJSON: any, api: RippleAPI,
|
||||
const multiplier = instructions.signersCount === undefined ? 1 :
|
||||
instructions.signersCount + 1
|
||||
if (instructions.fee !== undefined) {
|
||||
const fee = new BigNumber(instructions.fee)
|
||||
if (fee.greaterThan(api._maxFeeXRP)) {
|
||||
const errorMessage = `Fee of ${fee.toString(10)} XRP exceeds ` +
|
||||
`max of ${api._maxFeeXRP} XRP. To use this fee, increase ` +
|
||||
'`maxFeeXRP` in the RippleAPI constructor.'
|
||||
throw new ValidationError(errorMessage)
|
||||
}
|
||||
txJSON.Fee = scaleValue(common.xrpToDrops(instructions.fee), multiplier)
|
||||
return Promise.resolve(txJSON)
|
||||
}
|
||||
const cushion = api._feeCushion
|
||||
return common.serverInfo.getFee(api.connection, cushion).then(fee => {
|
||||
return api.getFee(cushion).then(fee => {
|
||||
return api.connection.getFeeRef().then(feeRef => {
|
||||
const extraFee =
|
||||
(txJSON.TransactionType !== 'EscrowFinish' ||
|
||||
@@ -75,31 +83,27 @@ function prepareTransaction(txJSON: any, api: RippleAPI,
|
||||
(cushion * feeRef * (32 + Math.floor(
|
||||
new Buffer(txJSON.Fulfillment, 'hex').length / 16)))
|
||||
const feeDrops = common.xrpToDrops(fee)
|
||||
if (instructions.maxFee !== undefined) {
|
||||
const maxFeeDrops = common.xrpToDrops(instructions.maxFee)
|
||||
const normalFee = scaleValue(feeDrops, multiplier, extraFee)
|
||||
txJSON.Fee = BigNumber.min(normalFee, maxFeeDrops).toString()
|
||||
} else {
|
||||
txJSON.Fee = scaleValue(feeDrops, multiplier, extraFee)
|
||||
}
|
||||
const maxFeeXRP = instructions.maxFee ?
|
||||
BigNumber.min(api._maxFeeXRP, instructions.maxFee) : api._maxFeeXRP
|
||||
const maxFeeDrops = common.xrpToDrops(maxFeeXRP)
|
||||
const normalFee = scaleValue(feeDrops, multiplier, extraFee)
|
||||
txJSON.Fee = BigNumber.min(normalFee, maxFeeDrops).toString(10)
|
||||
|
||||
return txJSON
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function prepareSequence(): Promise<Object> {
|
||||
async function prepareSequence(): Promise<Object> {
|
||||
if (instructions.sequence !== undefined) {
|
||||
txJSON.Sequence = instructions.sequence
|
||||
return Promise.resolve(txJSON)
|
||||
}
|
||||
const request = {
|
||||
command: 'account_info',
|
||||
account: account
|
||||
}
|
||||
return api.connection.request(request).then(response => {
|
||||
txJSON.Sequence = response.account_data.Sequence
|
||||
return txJSON
|
||||
const response = await api.request('account_info', {
|
||||
account: account as string
|
||||
})
|
||||
txJSON.Sequence = response.account_data.Sequence
|
||||
return txJSON
|
||||
}
|
||||
|
||||
return Promise.all([
|
||||
|
||||
1021
test/api-test.js
1021
test/api-test.js
File diff suppressed because it is too large
Load Diff
@@ -381,7 +381,7 @@ describe('Connection', function() {
|
||||
}));
|
||||
});
|
||||
|
||||
it('propagate error message', function(done) {
|
||||
it('propagates error message', function(done) {
|
||||
this.api.on('error', (errorCode, errorMessage, data) => {
|
||||
assert.strictEqual(errorCode, 'slowDown');
|
||||
assert.strictEqual(errorMessage, 'slow down');
|
||||
@@ -393,6 +393,19 @@ describe('Connection', function() {
|
||||
}));
|
||||
});
|
||||
|
||||
it('propagates RippledError data', function(done) {
|
||||
this.api.request('subscribe', {streams: 'validations'}).catch(error => {
|
||||
assert.strictEqual(error.name, 'RippledError')
|
||||
assert.strictEqual(error.message, 'invalidParams')
|
||||
assert.strictEqual(error.data.error_code, 31)
|
||||
assert.strictEqual(error.data.error_message, 'Invalid parameters.')
|
||||
assert.deepEqual(error.data.request, { command: 'subscribe', id: 0, streams: 'validations' })
|
||||
assert.strictEqual(error.data.status, 'error')
|
||||
assert.strictEqual(error.data.type, 'response')
|
||||
done()
|
||||
})
|
||||
});
|
||||
|
||||
it('unrecognized message type', function(done) {
|
||||
// This enables us to automatically support any
|
||||
// new messages added by rippled in the future.
|
||||
@@ -414,8 +427,8 @@ describe('Connection', function() {
|
||||
});
|
||||
|
||||
it('should throw RippledNotInitializedError if server does not have ' +
|
||||
'validated ledgers',
|
||||
function() {
|
||||
'validated ledgers', function() {
|
||||
|
||||
this.timeout(3000);
|
||||
|
||||
this.api.connection._send(JSON.stringify({
|
||||
@@ -439,13 +452,13 @@ describe('Connection', function() {
|
||||
this.api.on('error', error => {
|
||||
done(error || new Error('Should not emit error.'));
|
||||
});
|
||||
let disconncedCount = 0;
|
||||
let disconnectedCount = 0;
|
||||
this.api.on('connected', () => {
|
||||
done(disconncedCount !== 1 ?
|
||||
done(disconnectedCount !== 1 ?
|
||||
new Error('Wrong number of disconnects') : undefined);
|
||||
});
|
||||
this.api.on('disconnected', () => {
|
||||
disconncedCount++;
|
||||
disconnectedCount++;
|
||||
});
|
||||
|
||||
this.api.connection._send(JSON.stringify({
|
||||
|
||||
6
test/fixtures/requests/index.js
vendored
6
test/fixtures/requests/index.js
vendored
@@ -22,7 +22,11 @@ module.exports = {
|
||||
},
|
||||
prepareSettings: {
|
||||
domain: require('./prepare-settings'),
|
||||
signers: require('./prepare-settings-signers')
|
||||
signers: {
|
||||
normal: require('./prepare-settings-signers'),
|
||||
noThreshold: require('./prepare-settings-signers-no-threshold'),
|
||||
noWeights: require('./prepare-settings-signers-no-weights')
|
||||
}
|
||||
},
|
||||
prepareEscrowCreation: {
|
||||
normal: require('./prepare-escrow-creation'),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"amount": {
|
||||
"currency": "XRP",
|
||||
"value": "1"
|
||||
"currency": "drops",
|
||||
"value": "1000000"
|
||||
},
|
||||
"checkID": "838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334"
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"destination": "rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW",
|
||||
"sendMax": {
|
||||
"currency": "XRP",
|
||||
"value": "1"
|
||||
"currency": "drops",
|
||||
"value": "1000000"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"memos": [
|
||||
{
|
||||
"type": "test",
|
||||
"format": "plain/text",
|
||||
"format": "text/plain",
|
||||
"data": "texted data"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"memos": [
|
||||
{
|
||||
"type": "test",
|
||||
"format": "plain/text",
|
||||
"format": "text/plain",
|
||||
"data": "texted data"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"memos": [
|
||||
{
|
||||
"type": "test",
|
||||
"format": "plain/text",
|
||||
"format": "text/plain",
|
||||
"data": "texted data"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
"memos": [
|
||||
{
|
||||
"type": "test",
|
||||
"format": "plain/text",
|
||||
"format": "text/plain",
|
||||
"data": "texted data"
|
||||
}
|
||||
]
|
||||
|
||||
6
test/fixtures/requests/prepare-order.json
vendored
6
test/fixtures/requests/prepare-order.json
vendored
@@ -6,9 +6,9 @@
|
||||
"value": "10.1"
|
||||
},
|
||||
"totalPrice": {
|
||||
"currency": "XRP",
|
||||
"value": "2"
|
||||
"currency": "drops",
|
||||
"value": "2000000"
|
||||
},
|
||||
"passive": true,
|
||||
"passive": false,
|
||||
"fillOrKill": true
|
||||
}
|
||||
|
||||
@@ -18,12 +18,11 @@
|
||||
"memos": [
|
||||
{
|
||||
"type": "test",
|
||||
"format": "plain/text",
|
||||
"format": "text/plain",
|
||||
"data": "texted data"
|
||||
}
|
||||
],
|
||||
"invoiceID": "A98FD36C17BE2B8511AD36DC335478E7E89F06262949F36EB88E2D683BBCC50A",
|
||||
"noDirectRipple": true,
|
||||
"limitQuality": true,
|
||||
"paths": "[[{\"account\":\"rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q\",\"currency\":\"USD\",\"issuer\":\"rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q\",\"type\":49,\"type_hex\":\"0000000000000031\"},{\"currency\":\"LTC\",\"issuer\":\"rfYv1TXnwgDDK4WQNbFALykYuEBnrR4pDX\",\"type\":48,\"type_hex\":\"0000000000000030\"},{\"account\":\"rfYv1TXnwgDDK4WQNbFALykYuEBnrR4pDX\",\"currency\":\"LTC\",\"issuer\":\"rfYv1TXnwgDDK4WQNbFALykYuEBnrR4pDX\",\"type\":49,\"type_hex\":\"0000000000000031\"}]]"
|
||||
"limitQuality": true
|
||||
}
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
"address": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
||||
"amount": {
|
||||
"value": "0.01",
|
||||
"currency": "XRP",
|
||||
"counterparty": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM"
|
||||
"currency": "XRP"
|
||||
}
|
||||
},
|
||||
"destination": {
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
"memos": [
|
||||
{
|
||||
"type": "test",
|
||||
"format": "plain/text",
|
||||
"format": "text/plain",
|
||||
"data": "texted data"
|
||||
}
|
||||
],
|
||||
|
||||
18
test/fixtures/requests/prepare-settings-signers-no-threshold.json
vendored
Normal file
18
test/fixtures/requests/prepare-settings-signers-no-threshold.json
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"signers": {
|
||||
"weights": [
|
||||
{
|
||||
"address": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
||||
"weight": 1
|
||||
},
|
||||
{
|
||||
"address": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
|
||||
"weight": 1
|
||||
},
|
||||
{
|
||||
"address": "rwBYyfufTzk77zUSKEu4MvixfarC35av1J",
|
||||
"weight": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
5
test/fixtures/requests/prepare-settings-signers-no-weights.json
vendored
Normal file
5
test/fixtures/requests/prepare-settings-signers-no-weights.json
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"signers": {
|
||||
"threshold": 2
|
||||
}
|
||||
}
|
||||
2
test/fixtures/requests/prepare-settings.json
vendored
2
test/fixtures/requests/prepare-settings.json
vendored
@@ -3,7 +3,7 @@
|
||||
"memos": [
|
||||
{
|
||||
"type": "test",
|
||||
"format": "plain/text",
|
||||
"format": "text/plain",
|
||||
"data": "texted data"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"memos": [
|
||||
{
|
||||
"type": "test",
|
||||
"format": "plain/text",
|
||||
"format": "text/plain",
|
||||
"data": "texted data"
|
||||
}
|
||||
]
|
||||
|
||||
10
test/fixtures/responses/get-ledger-full.json
vendored
10
test/fixtures/responses/get-ledger-full.json
vendored
File diff suppressed because one or more lines are too long
@@ -25,12 +25,7 @@
|
||||
}
|
||||
},
|
||||
"destination": {
|
||||
"address": "rNNuQMuExCiEjeZ4h9JJnj5PSWypdMXDj4",
|
||||
"amount": {
|
||||
"currency": "USD",
|
||||
"value": "10",
|
||||
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
|
||||
}
|
||||
"address": "rNNuQMuExCiEjeZ4h9JJnj5PSWypdMXDj4"
|
||||
},
|
||||
"allowPartialPayment": true
|
||||
},
|
||||
@@ -72,8 +67,8 @@
|
||||
"orderbookChanges": {},
|
||||
"ledgerVersion": 12345,
|
||||
"indexInLedger": 1
|
||||
}
|
||||
},
|
||||
"rawTransaction": "{\"Account\":\"rGFuMiw48HdbnrUbkRYuitXTmfrDBNTCnX\",\"Amount\":{\"currency\":\"USD\",\"issuer\":\"rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B\",\"value\":\"10\"},\"Destination\":\"rNNuQMuExCiEjeZ4h9JJnj5PSWypdMXDj4\",\"Fee\":\"10000\",\"Flags\":131072,\"Sequence\":23295,\"SigningPubKey\":\"02B205F4B92351AC0EEB04254B636F4C49EF922CFA3CAAD03C6477DA1E04E94B53\",\"TransactionType\":\"Payment\",\"TxnSignature\":\"3045022100FAF247A836D601DE74A515B2AADE31186D8B0DA9C23DE489E09753F5CF4BB81F0220477C5B5BC3AC89F2347744F9E00CCA62267E198489D747578162C4C7D156211D\",\"hash\":\"A0A074D10355223CBE2520A42F93A52E3CC8B4D692570EB4841084F9BBB39F7A\",\"meta\":{\"AffectedNodes\":[{\"ModifiedNode\":{\"FinalFields\":{\"Account\":\"rGFuMiw48HdbnrUbkRYuitXTmfrDBNTCnX\",\"Balance\":\"1930599790\",\"Flags\":0,\"OwnerCount\":2,\"Sequence\":23296},\"LedgerEntryType\":\"AccountRoot\",\"LedgerIndex\":\"267C16D24EC42EEF8B03D5BE4E94266B1675FA54AFCE42DE795E02AB61031CBD\",\"PreviousFields\":{\"Balance\":\"1930609790\",\"Sequence\":23295},\"PreviousTxnID\":\"0F5396388E91D37BB26C8E24073A57E7C5D51E79AEE4CD855653B8499AE4E3DD\",\"PreviousTxnLgrSeq\":22419806}},{\"ModifiedNode\":{\"FinalFields\":{\"Balance\":{\"currency\":\"USD\",\"issuer\":\"rrrrrrrrrrrrrrrrrrrrBZbvji\",\"value\":\"-9.980959751659681\"},\"Flags\":2228224,\"HighLimit\":{\"currency\":\"USD\",\"issuer\":\"rNNuQMuExCiEjeZ4h9JJnj5PSWypdMXDj4\",\"value\":\"1000000\"},\"HighNode\":\"0000000000000000\",\"LowLimit\":{\"currency\":\"USD\",\"issuer\":\"rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B\",\"value\":\"0\"},\"LowNode\":\"0000000000000423\"},\"LedgerEntryType\":\"RippleState\",\"LedgerIndex\":\"C66957AF25229357F9C2D2BA17CE47D88169788EDA7610AD0F29AD5BCB225EE5\",\"PreviousFields\":{\"Balance\":{\"currency\":\"USD\",\"issuer\":\"rrrrrrrrrrrrrrrrrrrrBZbvji\",\"value\":\"-0.0009198315\"}},\"PreviousTxnID\":\"2A01E994D7000000B43DD63825A081B4440A44AB2F6FA0D506158AC9CA6B2869\",\"PreviousTxnLgrSeq\":22420532}},{\"ModifiedNode\":{\"FinalFields\":{\"Balance\":{\"currency\":\"USD\",\"issuer\":\"rrrrrrrrrrrrrrrrrrrrBZbvji\",\"value\":\"-276666.975959\"},\"Flags\":131072,\"HighLimit\":{\"currency\":\"USD\",\"issuer\":\"rGFuMiw48HdbnrUbkRYuitXTmfrDBNTCnX\",\"value\":\"1000000\"},\"HighNode\":\"0000000000000000\",\"LowLimit\":{\"currency\":\"USD\",\"issuer\":\"rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B\",\"value\":\"0\"},\"LowNode\":\"00000000000002D7\"},\"LedgerEntryType\":\"RippleState\",\"LedgerIndex\":\"FFD710AE2074A98D920D00CC352F25744899F069A6C1B9E31DD32D2C6606E615\",\"PreviousFields\":{\"Balance\":{\"currency\":\"USD\",\"issuer\":\"rrrrrrrrrrrrrrrrrrrrBZbvji\",\"value\":\"-276676.975959\"}},\"PreviousTxnID\":\"BB9DFC87E9D4ED09CA2726DDFE83A4A396ED0D6545536322DE17CDACF45C0D5B\",\"PreviousTxnLgrSeq\":22419307}}],\"TransactionIndex\":1,\"TransactionResult\":\"tesSUCCESS\"},\"ledger_index\":12345}"
|
||||
}
|
||||
],
|
||||
"rawTransactions": "[{\"Account\":\"rGFuMiw48HdbnrUbkRYuitXTmfrDBNTCnX\",\"Amount\":{\"currency\":\"USD\",\"issuer\":\"rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B\",\"value\":\"10\"},\"Destination\":\"rNNuQMuExCiEjeZ4h9JJnj5PSWypdMXDj4\",\"Fee\":\"10000\",\"Flags\":131072,\"Sequence\":23295,\"SigningPubKey\":\"02B205F4B92351AC0EEB04254B636F4C49EF922CFA3CAAD03C6477DA1E04E94B53\",\"TransactionType\":\"Payment\",\"TxnSignature\":\"3045022100FAF247A836D601DE74A515B2AADE31186D8B0DA9C23DE489E09753F5CF4BB81F0220477C5B5BC3AC89F2347744F9E00CCA62267E198489D747578162C4C7D156211D\",\"hash\":\"A0A074D10355223CBE2520A42F93A52E3CC8B4D692570EB4841084F9BBB39F7A\",\"metaData\":{\"AffectedNodes\":[{\"ModifiedNode\":{\"FinalFields\":{\"Account\":\"rGFuMiw48HdbnrUbkRYuitXTmfrDBNTCnX\",\"Balance\":\"1930599790\",\"Flags\":0,\"OwnerCount\":2,\"Sequence\":23296},\"LedgerEntryType\":\"AccountRoot\",\"LedgerIndex\":\"267C16D24EC42EEF8B03D5BE4E94266B1675FA54AFCE42DE795E02AB61031CBD\",\"PreviousFields\":{\"Balance\":\"1930609790\",\"Sequence\":23295},\"PreviousTxnID\":\"0F5396388E91D37BB26C8E24073A57E7C5D51E79AEE4CD855653B8499AE4E3DD\",\"PreviousTxnLgrSeq\":22419806}},{\"ModifiedNode\":{\"FinalFields\":{\"Balance\":{\"currency\":\"USD\",\"issuer\":\"rrrrrrrrrrrrrrrrrrrrBZbvji\",\"value\":\"-9.980959751659681\"},\"Flags\":2228224,\"HighLimit\":{\"currency\":\"USD\",\"issuer\":\"rNNuQMuExCiEjeZ4h9JJnj5PSWypdMXDj4\",\"value\":\"1000000\"},\"HighNode\":\"0000000000000000\",\"LowLimit\":{\"currency\":\"USD\",\"issuer\":\"rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B\",\"value\":\"0\"},\"LowNode\":\"0000000000000423\"},\"LedgerEntryType\":\"RippleState\",\"LedgerIndex\":\"C66957AF25229357F9C2D2BA17CE47D88169788EDA7610AD0F29AD5BCB225EE5\",\"PreviousFields\":{\"Balance\":{\"currency\":\"USD\",\"issuer\":\"rrrrrrrrrrrrrrrrrrrrBZbvji\",\"value\":\"-0.0009198315\"}},\"PreviousTxnID\":\"2A01E994D7000000B43DD63825A081B4440A44AB2F6FA0D506158AC9CA6B2869\",\"PreviousTxnLgrSeq\":22420532}},{\"ModifiedNode\":{\"FinalFields\":{\"Balance\":{\"currency\":\"USD\",\"issuer\":\"rrrrrrrrrrrrrrrrrrrrBZbvji\",\"value\":\"-276666.975959\"},\"Flags\":131072,\"HighLimit\":{\"currency\":\"USD\",\"issuer\":\"rGFuMiw48HdbnrUbkRYuitXTmfrDBNTCnX\",\"value\":\"1000000\"},\"HighNode\":\"0000000000000000\",\"LowLimit\":{\"currency\":\"USD\",\"issuer\":\"rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B\",\"value\":\"0\"},\"LowNode\":\"00000000000002D7\"},\"LedgerEntryType\":\"RippleState\",\"LedgerIndex\":\"FFD710AE2074A98D920D00CC352F25744899F069A6C1B9E31DD32D2C6606E615\",\"PreviousFields\":{\"Balance\":{\"currency\":\"USD\",\"issuer\":\"rrrrrrrrrrrrrrrrrrrrBZbvji\",\"value\":\"-276676.975959\"}},\"PreviousTxnID\":\"BB9DFC87E9D4ED09CA2726DDFE83A4A396ED0D6545536322DE17CDACF45C0D5B\",\"PreviousTxnLgrSeq\":22419307}}],\"TransactionIndex\":1,\"TransactionResult\":\"tesSUCCESS\"}}]"
|
||||
]
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -30,8 +30,8 @@
|
||||
},
|
||||
"orderbookChanges": {},
|
||||
"indexInLedger": 0
|
||||
}
|
||||
},
|
||||
"rawTransaction": "{\"Account\":\"rEGy9CxMTFGXFgUHUMreTy2FbqArabGy38\",\"Fee\":\"10\",\"ledger_index\":4181996,\"Flags\":0,\"Sequence\":6478,\"SigningPubKey\":\"02CAB6F3A798712136DB5F105A98B0DE27C99AEDB68500181706B087CF1B6D0F2D\",\"TransactionType\":\"AccountSet\",\"TxnSignature\":\"304402202144BD33CC30793455B0F90954576EEE80F13C4C73538D2AEE012564C48E522E02207A8A4AD2CF2B4DB549FB2F05D38E065B5DD1EAA386310698E5247F1BB515E99F\",\"hash\":\"FEEFC959B0351156F58A2275F5A6B37B07AA85CCCE2C4AF8A1342A0196A3CD4D\",\"meta\":{\"AffectedNodes\":[{\"ModifiedNode\":{\"FinalFields\":{\"Account\":\"rEGy9CxMTFGXFgUHUMreTy2FbqArabGy38\",\"Balance\":\"403657865\",\"Flags\":0,\"OwnerCount\":2,\"Sequence\":6479},\"LedgerEntryType\":\"AccountRoot\",\"LedgerIndex\":\"F64FAA4CAFDB9931DC06890FE30B4E29C32F7AD574FC7C3362B81265682BFAEA\",\"PreviousFields\":{\"Balance\":\"403657875\",\"Sequence\":6478},\"PreviousTxnID\":\"B257B95A637C6C396507AD0AE122161A849C701F065B67009BB939690DB74BC9\",\"PreviousTxnLgrSeq\":4181972}}],\"TransactionIndex\":0,\"TransactionResult\":\"tesSUCCESS\"}}"
|
||||
}
|
||||
],
|
||||
"rawTransactions": "[{\"Account\":\"rEGy9CxMTFGXFgUHUMreTy2FbqArabGy38\",\"Fee\":\"10\",\"ledger_index\":4181996,\"Flags\":0,\"Sequence\":6478,\"SigningPubKey\":\"02CAB6F3A798712136DB5F105A98B0DE27C99AEDB68500181706B087CF1B6D0F2D\",\"TransactionType\":\"AccountSet\",\"TxnSignature\":\"304402202144BD33CC30793455B0F90954576EEE80F13C4C73538D2AEE012564C48E522E02207A8A4AD2CF2B4DB549FB2F05D38E065B5DD1EAA386310698E5247F1BB515E99F\",\"hash\":\"FEEFC959B0351156F58A2275F5A6B37B07AA85CCCE2C4AF8A1342A0196A3CD4D\",\"metaData\":{\"AffectedNodes\":[{\"ModifiedNode\":{\"FinalFields\":{\"Account\":\"rEGy9CxMTFGXFgUHUMreTy2FbqArabGy38\",\"Balance\":\"403657865\",\"Flags\":0,\"OwnerCount\":2,\"Sequence\":6479},\"LedgerEntryType\":\"AccountRoot\",\"LedgerIndex\":\"F64FAA4CAFDB9931DC06890FE30B4E29C32F7AD574FC7C3362B81265682BFAEA\",\"PreviousFields\":{\"Balance\":\"403657875\",\"Sequence\":6478},\"PreviousTxnID\":\"B257B95A637C6C396507AD0AE122161A849C701F065B67009BB939690DB74BC9\",\"PreviousTxnLgrSeq\":4181972}}],\"TransactionIndex\":0,\"TransactionResult\":\"tesSUCCESS\"}}]"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -12,11 +12,7 @@
|
||||
}
|
||||
},
|
||||
"destination": {
|
||||
"address": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM",
|
||||
"amount": {
|
||||
"currency": "USD",
|
||||
"value": "0.001"
|
||||
}
|
||||
"address": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM"
|
||||
},
|
||||
"paths": "[[{\"currency\":\"USD\",\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"type\":48,\"type_hex\":\"0000000000000030\"},{\"account\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"currency\":\"USD\",\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"type\":49,\"type_hex\":\"0000000000000031\"}]]"
|
||||
}
|
||||
|
||||
@@ -23,6 +23,16 @@
|
||||
},
|
||||
"orderbookChanges": {},
|
||||
"ledgerVersion": 786310,
|
||||
"indexInLedger": 0
|
||||
"indexInLedger": 0,
|
||||
"channelChanges": {
|
||||
"status": "modified",
|
||||
"channelId": "43904CBFCDCEC530B4037871F86EE90BF799DF8D2E0EA564BC8A3F332E4F5FB1",
|
||||
"source": "rfAuMkVuZQnQhvdMcUKg4ndBb9SPDhzNmK",
|
||||
"destination": "rBmNDZ7vbTCwakKXsX3pDAwDdQuxM7yBRa",
|
||||
"channelBalanceChangeDrops": "801000",
|
||||
"channelAmountDrops": "1000000",
|
||||
"channelBalanceDrops": "801000",
|
||||
"previousTxnId": "0E9CA3AB1053FC0C1CBAA75F636FE1EC92F118C7056BBEF5D63E4C116458A16D"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,14 @@
|
||||
},
|
||||
"orderbookChanges": {},
|
||||
"ledgerVersion": 786309,
|
||||
"indexInLedger": 0
|
||||
"indexInLedger": 0,
|
||||
"channelChanges": {
|
||||
"status": "created",
|
||||
"channelId": "43904CBFCDCEC530B4037871F86EE90BF799DF8D2E0EA564BC8A3F332E4F5FB1",
|
||||
"source": "rfAuMkVuZQnQhvdMcUKg4ndBb9SPDhzNmK",
|
||||
"destination": "rBmNDZ7vbTCwakKXsX3pDAwDdQuxM7yBRa",
|
||||
"channelAmountDrops": "1000000",
|
||||
"channelBalanceDrops": "0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,16 @@
|
||||
},
|
||||
"orderbookChanges": {},
|
||||
"ledgerVersion": 786310,
|
||||
"indexInLedger": 1
|
||||
"indexInLedger": 1,
|
||||
"channelChanges": {
|
||||
"status": "modified",
|
||||
"channelId": "43904CBFCDCEC530B4037871F86EE90BF799DF8D2E0EA564BC8A3F332E4F5FB1",
|
||||
"source": "rfAuMkVuZQnQhvdMcUKg4ndBb9SPDhzNmK",
|
||||
"destination": "rBmNDZ7vbTCwakKXsX3pDAwDdQuxM7yBRa",
|
||||
"channelAmountChangeDrops": "1000000",
|
||||
"channelAmountDrops": "2000000",
|
||||
"channelBalanceDrops": "801000",
|
||||
"previousTxnId": "81B9ECAE7195EB6E8034AEDF44D8415A7A803E14513FDBB34FA984AB37D59563"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
89
test/fixtures/responses/get-transaction-payment-include-raw-transaction.json
vendored
Normal file
89
test/fixtures/responses/get-transaction-payment-include-raw-transaction.json
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
{
|
||||
"type": "payment",
|
||||
"address": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
||||
"sequence": 4,
|
||||
"id": "F4AB442A6D4CBB935D66E1DA7309A5FC71C7143ED4049053EC14E3875B0CF9BF",
|
||||
"specification": {
|
||||
"source": {
|
||||
"address": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
||||
"maxAmount": {
|
||||
"currency": "XRP",
|
||||
"value": "1.112209"
|
||||
}
|
||||
},
|
||||
"destination": {
|
||||
"address": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM"
|
||||
},
|
||||
"paths": "[[{\"currency\":\"USD\",\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"type\":48,\"type_hex\":\"0000000000000030\"},{\"account\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"currency\":\"USD\",\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"type\":49,\"type_hex\":\"0000000000000031\"}]]"
|
||||
},
|
||||
"outcome": {
|
||||
"result": "tesSUCCESS",
|
||||
"timestamp": "2013-03-12T23:56:50.000Z",
|
||||
"fee": "0.00001",
|
||||
"deliveredAmount": {
|
||||
"currency": "USD",
|
||||
"value": "0.001",
|
||||
"counterparty": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM"
|
||||
},
|
||||
"balanceChanges": {
|
||||
"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo": [
|
||||
{
|
||||
"counterparty": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM",
|
||||
"currency": "USD",
|
||||
"value": "-0.001"
|
||||
},
|
||||
{
|
||||
"counterparty": "r9tGqzZgKxVFvzKFdUqXAqTzazWBUia8Qr",
|
||||
"currency": "USD",
|
||||
"value": "0.001002"
|
||||
}
|
||||
],
|
||||
"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM": [
|
||||
{
|
||||
"counterparty": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
|
||||
"currency": "USD",
|
||||
"value": "0.001"
|
||||
}
|
||||
],
|
||||
"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59": [
|
||||
{
|
||||
"currency": "XRP",
|
||||
"value": "-1.101208"
|
||||
}
|
||||
],
|
||||
"r9tGqzZgKxVFvzKFdUqXAqTzazWBUia8Qr": [
|
||||
{
|
||||
"currency": "XRP",
|
||||
"value": "1.101198"
|
||||
},
|
||||
{
|
||||
"counterparty": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
|
||||
"currency": "USD",
|
||||
"value": "-0.001002"
|
||||
}
|
||||
]
|
||||
},
|
||||
"orderbookChanges": {
|
||||
"r9tGqzZgKxVFvzKFdUqXAqTzazWBUia8Qr": [
|
||||
{
|
||||
"direction": "buy",
|
||||
"quantity": {
|
||||
"currency": "XRP",
|
||||
"value": "1.101198"
|
||||
},
|
||||
"totalPrice": {
|
||||
"currency": "USD",
|
||||
"counterparty": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
|
||||
"value": "0.001002"
|
||||
},
|
||||
"makerExchangeRate": "1099",
|
||||
"sequence": 58,
|
||||
"status": "partially-filled"
|
||||
}
|
||||
]
|
||||
},
|
||||
"ledgerVersion": 348860,
|
||||
"indexInLedger": 0
|
||||
},
|
||||
"rawTransaction": "{\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Amount\":{\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\",\"value\":\"0.001\"},\"Destination\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\",\"Fee\":\"10\",\"Flags\":0,\"Paths\":[[{\"currency\":\"USD\",\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"type\":48,\"type_hex\":\"0000000000000030\"},{\"account\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"currency\":\"USD\",\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"type\":49,\"type_hex\":\"0000000000000031\"}]],\"SendMax\":\"1112209\",\"Sequence\":4,\"SigningPubKey\":\"02BC8C02199949B15C005B997E7C8594574E9B02BA2D0628902E0532989976CF9D\",\"TransactionType\":\"Payment\",\"TxnSignature\":\"304502204EE3E9D1B01D8959B08450FCA9E22025AF503DEF310E34A93863A85CAB3C0BC5022100B61F5B567F77026E8DEED89EED0B7CAF0E6C96C228A2A65216F0DC2D04D52083\",\"date\":416447810,\"hash\":\"F4AB442A6D4CBB935D66E1DA7309A5FC71C7143ED4049053EC14E3875B0CF9BF\",\"inLedger\":348860,\"ledger_index\":348860,\"validated\":true,\"meta\":{\"AffectedNodes\":[{\"ModifiedNode\":{\"FinalFields\":{\"Account\":\"r9tGqzZgKxVFvzKFdUqXAqTzazWBUia8Qr\",\"BookDirectory\":\"4627DFFCFF8B5A265EDBD8AE8C14A52325DBFEDAF4F5C32E5E03E788E09BB000\",\"BookNode\":\"0000000000000000\",\"Flags\":0,\"OwnerNode\":\"0000000000000000\",\"Sequence\":58,\"TakerGets\":{\"currency\":\"USD\",\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"value\":\"5.648998\"},\"TakerPays\":\"6208248802\"},\"LedgerEntryType\":\"Offer\",\"LedgerIndex\":\"3CFB3C79D4F1BDB1EE5245259372576D926D9A875713422F7169A6CC60AFA68B\",\"PreviousFields\":{\"TakerGets\":{\"currency\":\"USD\",\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"value\":\"5.65\"},\"TakerPays\":\"6209350000\"},\"PreviousTxnID\":\"8F571C346688D89AC1F737AE3B6BB5D976702B171CC7B4DE5CA3D444D5B8D6B4\",\"PreviousTxnLgrSeq\":348433}},{\"ModifiedNode\":{\"FinalFields\":{\"Balance\":{\"currency\":\"USD\",\"issuer\":\"rrrrrrrrrrrrrrrrrrrrBZbvji\",\"value\":\"-0.001\"},\"Flags\":131072,\"HighLimit\":{\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\",\"value\":\"1\"},\"HighNode\":\"0000000000000000\",\"LowLimit\":{\"currency\":\"USD\",\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"value\":\"0\"},\"LowNode\":\"0000000000000002\"},\"LedgerEntryType\":\"RippleState\",\"LedgerIndex\":\"4BD1874F8F3A60EDB0C23F5BD43E07953C2B8741B226648310D113DE2B486F01\",\"PreviousFields\":{\"Balance\":{\"currency\":\"USD\",\"issuer\":\"rrrrrrrrrrrrrrrrrrrrBZbvji\",\"value\":\"0\"}},\"PreviousTxnID\":\"5B2006DAD0B3130F57ACF7CC5CCAC2EEBCD4B57AAA091A6FD0A24B073D08ABB8\",\"PreviousTxnLgrSeq\":343703}},{\"ModifiedNode\":{\"FinalFields\":{\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Balance\":\"9998898762\",\"Flags\":0,\"OwnerCount\":3,\"Sequence\":5},\"LedgerEntryType\":\"AccountRoot\",\"LedgerIndex\":\"4F83A2CF7E70F77F79A307E6A472BFC2585B806A70833CCD1C26105BAE0D6E05\",\"PreviousFields\":{\"Balance\":\"9999999970\",\"Sequence\":4},\"PreviousTxnID\":\"53354D84BAE8FDFC3F4DA879D984D24B929E7FEB9100D2AD9EFCD2E126BCCDC8\",\"PreviousTxnLgrSeq\":343570}},{\"ModifiedNode\":{\"FinalFields\":{\"Account\":\"r9tGqzZgKxVFvzKFdUqXAqTzazWBUia8Qr\",\"Balance\":\"912695302618\",\"Flags\":0,\"OwnerCount\":10,\"Sequence\":59},\"LedgerEntryType\":\"AccountRoot\",\"LedgerIndex\":\"F3E119AAA87AF3607CF87F5523BB8278A83BCB4142833288305D767DD30C392A\",\"PreviousFields\":{\"Balance\":\"912694201420\"},\"PreviousTxnID\":\"8F571C346688D89AC1F737AE3B6BB5D976702B171CC7B4DE5CA3D444D5B8D6B4\",\"PreviousTxnLgrSeq\":348433}},{\"ModifiedNode\":{\"FinalFields\":{\"Balance\":{\"currency\":\"USD\",\"issuer\":\"rrrrrrrrrrrrrrrrrrrrBZbvji\",\"value\":\"-5.5541638883365\"},\"Flags\":131072,\"HighLimit\":{\"currency\":\"USD\",\"issuer\":\"r9tGqzZgKxVFvzKFdUqXAqTzazWBUia8Qr\",\"value\":\"1000\"},\"HighNode\":\"0000000000000000\",\"LowLimit\":{\"currency\":\"USD\",\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"value\":\"0\"},\"LowNode\":\"000000000000000C\"},\"LedgerEntryType\":\"RippleState\",\"LedgerIndex\":\"FA1255C2E0407F1945BCF9351257C7C5C28B0F5F09BB81C08D35A03E9F0136BC\",\"PreviousFields\":{\"Balance\":{\"currency\":\"USD\",\"issuer\":\"rrrrrrrrrrrrrrrrrrrrBZbvji\",\"value\":\"-5.5551658883365\"}},\"PreviousTxnID\":\"8F571C346688D89AC1F737AE3B6BB5D976702B171CC7B4DE5CA3D444D5B8D6B4\",\"PreviousTxnLgrSeq\":348433}}],\"TransactionIndex\":0,\"TransactionResult\":\"tesSUCCESS\"}}"
|
||||
}
|
||||
@@ -12,11 +12,7 @@
|
||||
}
|
||||
},
|
||||
"destination": {
|
||||
"address": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM",
|
||||
"amount": {
|
||||
"currency": "USD",
|
||||
"value": "0.001"
|
||||
}
|
||||
"address": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM"
|
||||
},
|
||||
"paths": "[[{\"currency\":\"USD\",\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"type\":48,\"type_hex\":\"0000000000000030\"},{\"account\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"currency\":\"USD\",\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"type\":49,\"type_hex\":\"0000000000000031\"}]]"
|
||||
},
|
||||
|
||||
190
test/fixtures/responses/get-transactions-include-raw-transactions.json
vendored
Normal file
190
test/fixtures/responses/get-transactions-include-raw-transactions.json
vendored
Normal file
@@ -0,0 +1,190 @@
|
||||
[
|
||||
{
|
||||
"type": "payment",
|
||||
"address": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
||||
"sequence": 4,
|
||||
"id": "99404A34E8170319521223A6C604AF48B9F1E3000C377E6141F9A1BF60B0B865",
|
||||
"specification": {
|
||||
"memos": [
|
||||
{
|
||||
"type": "client",
|
||||
"format": "rt1.5.2"
|
||||
}
|
||||
],
|
||||
"source": {
|
||||
"address": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
||||
"maxAmount": {
|
||||
"currency": "XRP",
|
||||
"value": "1.112209"
|
||||
}
|
||||
},
|
||||
"destination": {
|
||||
"address": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM"
|
||||
},
|
||||
"paths": "[[{\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"currency\":\"USD\"},{\"account\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"currency\":\"USD\"}]]"
|
||||
},
|
||||
"outcome": {
|
||||
"result": "tesSUCCESS",
|
||||
"fee": "0.00001",
|
||||
"deliveredAmount": {
|
||||
"currency": "USD",
|
||||
"value": "0.001",
|
||||
"counterparty": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM"
|
||||
},
|
||||
"balanceChanges": {
|
||||
"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo": [
|
||||
{
|
||||
"counterparty": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM",
|
||||
"currency": "USD",
|
||||
"value": "-0.001"
|
||||
},
|
||||
{
|
||||
"counterparty": "r9tGqzZgKxVFvzKFdUqXAqTzazWBUia8Qr",
|
||||
"currency": "USD",
|
||||
"value": "0.001002"
|
||||
}
|
||||
],
|
||||
"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM": [
|
||||
{
|
||||
"counterparty": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
|
||||
"currency": "USD",
|
||||
"value": "0.001"
|
||||
}
|
||||
],
|
||||
"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59": [
|
||||
{
|
||||
"currency": "XRP",
|
||||
"value": "-1.101208"
|
||||
}
|
||||
],
|
||||
"r9tGqzZgKxVFvzKFdUqXAqTzazWBUia8Qr": [
|
||||
{
|
||||
"currency": "XRP",
|
||||
"value": "1.101198"
|
||||
},
|
||||
{
|
||||
"counterparty": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
|
||||
"currency": "USD",
|
||||
"value": "-0.001002"
|
||||
}
|
||||
]
|
||||
},
|
||||
"orderbookChanges": {
|
||||
"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59": [
|
||||
{
|
||||
"direction": "buy",
|
||||
"quantity": {
|
||||
"currency": "XRP",
|
||||
"value": "1.101198"
|
||||
},
|
||||
"totalPrice": {
|
||||
"currency": "USD",
|
||||
"counterparty": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
|
||||
"value": "0.001002"
|
||||
},
|
||||
"makerExchangeRate": "1099",
|
||||
"sequence": 58,
|
||||
"status": "partially-filled"
|
||||
}
|
||||
]
|
||||
},
|
||||
"ledgerVersion": 348859,
|
||||
"indexInLedger": 0
|
||||
},
|
||||
"rawTransaction": "{\"TransactionType\":\"Payment\",\"Flags\":0,\"Sequence\":4,\"Amount\":{\"value\":\"0.001\",\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\"},\"Fee\":\"10\",\"SendMax\":\"1112209\",\"SigningPubKey\":\"02BC8C02199949B15C005B997E7C8594574E9B02BA2D0628902E0532989976CF9D\",\"TxnSignature\":\"304502204EE3E9D1B01D8959B08450FCA9E22025AF503DEF310E34A93863A85CAB3C0BC5022100B61F5B567F77026E8DEED89EED0B7CAF0E6C96C228A2A65216F0DC2D04D52083\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Destination\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\",\"Memos\":[{\"Memo\":{\"MemoType\":\"636C69656E74\",\"MemoFormat\":\"7274312E352E32\"}}],\"Paths\":[[{\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"currency\":\"USD\"},{\"account\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"currency\":\"USD\"}]],\"hash\":\"99404A34E8170319521223A6C604AF48B9F1E3000C377E6141F9A1BF60B0B865\",\"ledger_index\":348859,\"meta\":{\"TransactionIndex\":0,\"AffectedNodes\":[{\"ModifiedNode\":{\"LedgerEntryType\":\"Offer\",\"PreviousTxnLgrSeq\":348433,\"PreviousTxnID\":\"8F571C346688D89AC1F737AE3B6BB5D976702B171CC7B4DE5CA3D444D5B8D6B4\",\"LedgerIndex\":\"3CFB3C79D4F1BDB1EE5245259372576D926D9A875713422F7169A6CC60AFA68B\",\"PreviousFields\":{\"TakerPays\":\"6209350000\",\"TakerGets\":{\"value\":\"5.65\",\"currency\":\"USD\",\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\"}},\"FinalFields\":{\"Flags\":0,\"Sequence\":58,\"BookNode\":\"0000000000000000\",\"OwnerNode\":\"0000000000000000\",\"BookDirectory\":\"4627DFFCFF8B5A265EDBD8AE8C14A52325DBFEDAF4F5C32E5E03E788E09BB000\",\"TakerPays\":\"6208248802\",\"TakerGets\":{\"value\":\"5.648998\",\"currency\":\"USD\",\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\"},\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\"}}},{\"ModifiedNode\":{\"LedgerEntryType\":\"RippleState\",\"PreviousTxnLgrSeq\":343703,\"PreviousTxnID\":\"5B2006DAD0B3130F57ACF7CC5CCAC2EEBCD4B57AAA091A6FD0A24B073D08ABB8\",\"LedgerIndex\":\"4BD1874F8F3A60EDB0C23F5BD43E07953C2B8741B226648310D113DE2B486F01\",\"PreviousFields\":{\"Balance\":{\"value\":\"0\",\"currency\":\"USD\",\"issuer\":\"rrrrrrrrrrrrrrrrrrrrBZbvji\"}},\"FinalFields\":{\"Flags\":131072,\"LowNode\":\"0000000000000002\",\"HighNode\":\"0000000000000000\",\"Balance\":{\"value\":\"-0.001\",\"currency\":\"USD\",\"issuer\":\"rrrrrrrrrrrrrrrrrrrrBZbvji\"},\"LowLimit\":{\"value\":\"0\",\"currency\":\"USD\",\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\"},\"HighLimit\":{\"value\":\"1\",\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\"}}}},{\"ModifiedNode\":{\"LedgerEntryType\":\"AccountRoot\",\"PreviousTxnLgrSeq\":343570,\"PreviousTxnID\":\"53354D84BAE8FDFC3F4DA879D984D24B929E7FEB9100D2AD9EFCD2E126BCCDC8\",\"LedgerIndex\":\"4F83A2CF7E70F77F79A307E6A472BFC2585B806A70833CCD1C26105BAE0D6E05\",\"PreviousFields\":{\"Sequence\":4,\"Balance\":\"9999999970\"},\"FinalFields\":{\"Flags\":0,\"Sequence\":5,\"OwnerCount\":3,\"Balance\":\"9998898762\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\"}}},{\"ModifiedNode\":{\"LedgerEntryType\":\"AccountRoot\",\"PreviousTxnLgrSeq\":348433,\"PreviousTxnID\":\"8F571C346688D89AC1F737AE3B6BB5D976702B171CC7B4DE5CA3D444D5B8D6B4\",\"LedgerIndex\":\"F3E119AAA87AF3607CF87F5523BB8278A83BCB4142833288305D767DD30C392A\",\"PreviousFields\":{\"Balance\":\"912694201420\"},\"FinalFields\":{\"Flags\":0,\"Sequence\":59,\"OwnerCount\":10,\"Balance\":\"912695302618\",\"Account\":\"r9tGqzZgKxVFvzKFdUqXAqTzazWBUia8Qr\"}}},{\"ModifiedNode\":{\"LedgerEntryType\":\"RippleState\",\"PreviousTxnLgrSeq\":348433,\"PreviousTxnID\":\"8F571C346688D89AC1F737AE3B6BB5D976702B171CC7B4DE5CA3D444D5B8D6B4\",\"LedgerIndex\":\"FA1255C2E0407F1945BCF9351257C7C5C28B0F5F09BB81C08D35A03E9F0136BC\",\"PreviousFields\":{\"Balance\":{\"value\":\"-5.5551658883365\",\"currency\":\"USD\",\"issuer\":\"rrrrrrrrrrrrrrrrrrrrBZbvji\"}},\"FinalFields\":{\"Flags\":131072,\"LowNode\":\"000000000000000C\",\"HighNode\":\"0000000000000000\",\"Balance\":{\"value\":\"-5.5541638883365\",\"currency\":\"USD\",\"issuer\":\"rrrrrrrrrrrrrrrrrrrrBZbvji\"},\"LowLimit\":{\"value\":\"0\",\"currency\":\"USD\",\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\"},\"HighLimit\":{\"value\":\"1000\",\"currency\":\"USD\",\"issuer\":\"r9tGqzZgKxVFvzKFdUqXAqTzazWBUia8Qr\"}}}}],\"TransactionResult\":\"tesSUCCESS\"},\"validated\":true}"
|
||||
},
|
||||
{
|
||||
"type": "payment",
|
||||
"address": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
||||
"id": "99404A34E8170319521223A6C604AF48B9F1E3000C377E6141F9A1BF60B0B865",
|
||||
"sequence": 4,
|
||||
"specification": {
|
||||
"memos": [
|
||||
{
|
||||
"type": "client",
|
||||
"format": "rt1.5.2"
|
||||
}
|
||||
],
|
||||
"source": {
|
||||
"address": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
||||
"maxAmount": {
|
||||
"currency": "XRP",
|
||||
"value": "1.112209"
|
||||
}
|
||||
},
|
||||
"destination": {
|
||||
"address": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM"
|
||||
},
|
||||
"paths": "[[{\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"currency\":\"USD\"},{\"account\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"currency\":\"USD\"}]]"
|
||||
},
|
||||
"outcome": {
|
||||
"result": "tesSUCCESS",
|
||||
"fee": "0.00001",
|
||||
"deliveredAmount": {
|
||||
"currency": "USD",
|
||||
"value": "0.001",
|
||||
"counterparty": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM"
|
||||
},
|
||||
"balanceChanges": {
|
||||
"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo": [
|
||||
{
|
||||
"counterparty": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM",
|
||||
"currency": "USD",
|
||||
"value": "-0.001"
|
||||
},
|
||||
{
|
||||
"counterparty": "r9tGqzZgKxVFvzKFdUqXAqTzazWBUia8Qr",
|
||||
"currency": "USD",
|
||||
"value": "0.001002"
|
||||
}
|
||||
],
|
||||
"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM": [
|
||||
{
|
||||
"counterparty": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
|
||||
"currency": "USD",
|
||||
"value": "0.001"
|
||||
}
|
||||
],
|
||||
"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59": [
|
||||
{
|
||||
"currency": "XRP",
|
||||
"value": "-1.101208"
|
||||
}
|
||||
],
|
||||
"r9tGqzZgKxVFvzKFdUqXAqTzazWBUia8Qr": [
|
||||
{
|
||||
"currency": "XRP",
|
||||
"value": "1.101198"
|
||||
},
|
||||
{
|
||||
"counterparty": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
|
||||
"currency": "USD",
|
||||
"value": "-0.001002"
|
||||
}
|
||||
]
|
||||
},
|
||||
"orderbookChanges": {
|
||||
"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59": [
|
||||
{
|
||||
"direction": "buy",
|
||||
"quantity": {
|
||||
"currency": "XRP",
|
||||
"value": "1.101198"
|
||||
},
|
||||
"totalPrice": {
|
||||
"currency": "USD",
|
||||
"counterparty": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
|
||||
"value": "0.001002"
|
||||
},
|
||||
"makerExchangeRate": "1099",
|
||||
"sequence": 58,
|
||||
"status": "partially-filled"
|
||||
}
|
||||
]
|
||||
},
|
||||
"ledgerVersion": 348858,
|
||||
"indexInLedger": 0
|
||||
},
|
||||
"rawTransaction": "{\"TransactionType\":\"Payment\",\"Flags\":0,\"Sequence\":4,\"Amount\":{\"value\":\"0.001\",\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\"},\"Fee\":\"10\",\"SendMax\":\"1112209\",\"SigningPubKey\":\"02BC8C02199949B15C005B997E7C8594574E9B02BA2D0628902E0532989976CF9D\",\"TxnSignature\":\"304502204EE3E9D1B01D8959B08450FCA9E22025AF503DEF310E34A93863A85CAB3C0BC5022100B61F5B567F77026E8DEED89EED0B7CAF0E6C96C228A2A65216F0DC2D04D52083\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Destination\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\",\"Memos\":[{\"Memo\":{\"MemoType\":\"636C69656E74\",\"MemoFormat\":\"7274312E352E32\"}}],\"Paths\":[[{\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"currency\":\"USD\"},{\"account\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"currency\":\"USD\"}]],\"hash\":\"99404A34E8170319521223A6C604AF48B9F1E3000C377E6141F9A1BF60B0B865\",\"ledger_index\":348858,\"meta\":{\"TransactionIndex\":0,\"AffectedNodes\":[{\"ModifiedNode\":{\"LedgerEntryType\":\"Offer\",\"PreviousTxnLgrSeq\":348433,\"PreviousTxnID\":\"8F571C346688D89AC1F737AE3B6BB5D976702B171CC7B4DE5CA3D444D5B8D6B4\",\"LedgerIndex\":\"3CFB3C79D4F1BDB1EE5245259372576D926D9A875713422F7169A6CC60AFA68B\",\"PreviousFields\":{\"TakerPays\":\"6209350000\",\"TakerGets\":{\"value\":\"5.65\",\"currency\":\"USD\",\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\"}},\"FinalFields\":{\"Flags\":0,\"Sequence\":58,\"BookNode\":\"0000000000000000\",\"OwnerNode\":\"0000000000000000\",\"BookDirectory\":\"4627DFFCFF8B5A265EDBD8AE8C14A52325DBFEDAF4F5C32E5E03E788E09BB000\",\"TakerPays\":\"6208248802\",\"TakerGets\":{\"value\":\"5.648998\",\"currency\":\"USD\",\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\"},\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\"}}},{\"ModifiedNode\":{\"LedgerEntryType\":\"RippleState\",\"PreviousTxnLgrSeq\":343703,\"PreviousTxnID\":\"5B2006DAD0B3130F57ACF7CC5CCAC2EEBCD4B57AAA091A6FD0A24B073D08ABB8\",\"LedgerIndex\":\"4BD1874F8F3A60EDB0C23F5BD43E07953C2B8741B226648310D113DE2B486F01\",\"PreviousFields\":{\"Balance\":{\"value\":\"0\",\"currency\":\"USD\",\"issuer\":\"rrrrrrrrrrrrrrrrrrrrBZbvji\"}},\"FinalFields\":{\"Flags\":131072,\"LowNode\":\"0000000000000002\",\"HighNode\":\"0000000000000000\",\"Balance\":{\"value\":\"-0.001\",\"currency\":\"USD\",\"issuer\":\"rrrrrrrrrrrrrrrrrrrrBZbvji\"},\"LowLimit\":{\"value\":\"0\",\"currency\":\"USD\",\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\"},\"HighLimit\":{\"value\":\"1\",\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\"}}}},{\"ModifiedNode\":{\"LedgerEntryType\":\"AccountRoot\",\"PreviousTxnLgrSeq\":343570,\"PreviousTxnID\":\"53354D84BAE8FDFC3F4DA879D984D24B929E7FEB9100D2AD9EFCD2E126BCCDC8\",\"LedgerIndex\":\"4F83A2CF7E70F77F79A307E6A472BFC2585B806A70833CCD1C26105BAE0D6E05\",\"PreviousFields\":{\"Sequence\":4,\"Balance\":\"9999999970\"},\"FinalFields\":{\"Flags\":0,\"Sequence\":5,\"OwnerCount\":3,\"Balance\":\"9998898762\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\"}}},{\"ModifiedNode\":{\"LedgerEntryType\":\"AccountRoot\",\"PreviousTxnLgrSeq\":348433,\"PreviousTxnID\":\"8F571C346688D89AC1F737AE3B6BB5D976702B171CC7B4DE5CA3D444D5B8D6B4\",\"LedgerIndex\":\"F3E119AAA87AF3607CF87F5523BB8278A83BCB4142833288305D767DD30C392A\",\"PreviousFields\":{\"Balance\":\"912694201420\"},\"FinalFields\":{\"Flags\":0,\"Sequence\":59,\"OwnerCount\":10,\"Balance\":\"912695302618\",\"Account\":\"r9tGqzZgKxVFvzKFdUqXAqTzazWBUia8Qr\"}}},{\"ModifiedNode\":{\"LedgerEntryType\":\"RippleState\",\"PreviousTxnLgrSeq\":348433,\"PreviousTxnID\":\"8F571C346688D89AC1F737AE3B6BB5D976702B171CC7B4DE5CA3D444D5B8D6B4\",\"LedgerIndex\":\"FA1255C2E0407F1945BCF9351257C7C5C28B0F5F09BB81C08D35A03E9F0136BC\",\"PreviousFields\":{\"Balance\":{\"value\":\"-5.5551658883365\",\"currency\":\"USD\",\"issuer\":\"rrrrrrrrrrrrrrrrrrrrBZbvji\"}},\"FinalFields\":{\"Flags\":131072,\"LowNode\":\"000000000000000C\",\"HighNode\":\"0000000000000000\",\"Balance\":{\"value\":\"-5.5541638883365\",\"currency\":\"USD\",\"issuer\":\"rrrrrrrrrrrrrrrrrrrrBZbvji\"},\"LowLimit\":{\"value\":\"0\",\"currency\":\"USD\",\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\"},\"HighLimit\":{\"value\":\"1000\",\"currency\":\"USD\",\"issuer\":\"r9tGqzZgKxVFvzKFdUqXAqTzazWBUia8Qr\"}}}}],\"TransactionResult\":\"tesSUCCESS\"},\"validated\":true}"
|
||||
}
|
||||
]
|
||||
12
test/fixtures/responses/get-transactions.json
vendored
12
test/fixtures/responses/get-transactions.json
vendored
@@ -19,11 +19,7 @@
|
||||
}
|
||||
},
|
||||
"destination": {
|
||||
"address": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM",
|
||||
"amount": {
|
||||
"currency": "USD",
|
||||
"value": "0.001"
|
||||
}
|
||||
"address": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM"
|
||||
},
|
||||
"paths": "[[{\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"currency\":\"USD\"},{\"account\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"currency\":\"USD\"}]]"
|
||||
},
|
||||
@@ -116,11 +112,7 @@
|
||||
}
|
||||
},
|
||||
"destination": {
|
||||
"address": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM",
|
||||
"amount": {
|
||||
"currency": "USD",
|
||||
"value": "0.001"
|
||||
}
|
||||
"address": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM"
|
||||
},
|
||||
"paths": "[[{\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"currency\":\"USD\"},{\"account\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"currency\":\"USD\"}]]"
|
||||
},
|
||||
|
||||
2
test/fixtures/responses/index.js
vendored
2
test/fixtures/responses/index.js
vendored
@@ -35,6 +35,7 @@ module.exports = {
|
||||
orderSell: require('./get-transaction-order-sell.json'),
|
||||
noMeta: require('./get-transaction-no-meta.json'),
|
||||
payment: require('./get-transaction-payment.json'),
|
||||
paymentIncludeRawTransaction: require('./get-transaction-payment-include-raw-transaction.json'),
|
||||
settings: require('./get-transaction-settings.json'),
|
||||
trustline: require('./get-transaction-trustline-set.json'),
|
||||
trackingOn: require('./get-transaction-settings-tracking-on.json'),
|
||||
@@ -68,6 +69,7 @@ module.exports = {
|
||||
},
|
||||
getTransactions: {
|
||||
normal: require('./get-transactions.json'),
|
||||
includeRawTransactions: require('./get-transactions-include-raw-transactions.json'),
|
||||
one: require('./get-transactions-one.json')
|
||||
},
|
||||
getTrustlines: {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"txJSON": "{\"TransactionType\":\"EscrowCancel\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Owner\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"OfferSequence\":1234,\"Memos\":[{\"Memo\":{\"MemoData\":\"7465787465642064617461\",\"MemoType\":\"74657374\",\"MemoFormat\":\"706C61696E2F74657874\"}}],\"Flags\":2147483648,\"LastLedgerSequence\":8819954,\"Fee\":\"12\",\"Sequence\":23}",
|
||||
"txJSON": "{\"TransactionType\":\"EscrowCancel\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Owner\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"OfferSequence\":1234,\"Memos\":[{\"Memo\":{\"MemoData\":\"7465787465642064617461\",\"MemoType\":\"74657374\",\"MemoFormat\":\"746578742F706C61696E\"}}],\"Flags\":2147483648,\"LastLedgerSequence\":8819954,\"Fee\":\"12\",\"Sequence\":23}",
|
||||
"instructions": {
|
||||
"fee": "0.000012",
|
||||
"sequence": 23,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"txJSON": "{\"TransactionType\":\"EscrowFinish\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Owner\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"OfferSequence\":1234,\"Memos\":[{\"Memo\":{\"MemoData\":\"7465787465642064617461\",\"MemoType\":\"74657374\",\"MemoFormat\":\"706C61696E2F74657874\"}}],\"Flags\":2147483648,\"LastLedgerSequence\":8819954,\"Fee\":\"12\",\"Sequence\":23}",
|
||||
"txJSON": "{\"TransactionType\":\"EscrowFinish\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Owner\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"OfferSequence\":1234,\"Memos\":[{\"Memo\":{\"MemoData\":\"7465787465642064617461\",\"MemoType\":\"74657374\",\"MemoFormat\":\"746578742F706C61696E\"}}],\"Flags\":2147483648,\"LastLedgerSequence\":8819954,\"Fee\":\"12\",\"Sequence\":23}",
|
||||
"instructions": {
|
||||
"fee": "0.000012",
|
||||
"sequence": 23,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"txJSON": "{\"TransactionType\":\"OfferCancel\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"OfferSequence\":23,\"Memos\":[{\"Memo\":{\"MemoData\":\"7465787465642064617461\",\"MemoType\":\"74657374\",\"MemoFormat\":\"706C61696E2F74657874\"}}],\"Flags\":2147483648,\"LastLedgerSequence\":8819954,\"Fee\":\"12\",\"Sequence\":23}",
|
||||
"txJSON": "{\"TransactionType\":\"OfferCancel\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"OfferSequence\":23,\"Memos\":[{\"Memo\":{\"MemoData\":\"7465787465642064617461\",\"MemoType\":\"74657374\",\"MemoFormat\":\"746578742F706C61696E\"}}],\"Flags\":2147483648,\"LastLedgerSequence\":8819954,\"Fee\":\"12\",\"Sequence\":23}",
|
||||
"instructions": {
|
||||
"fee": "0.000012",
|
||||
"sequence": 23,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"txJSON": "{\"TransactionType\":\"OfferCreate\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"TakerGets\":{\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\",\"value\":\"10.1\"},\"TakerPays\":\"2000000\",\"Flags\":2148139008,\"Memos\":[{\"Memo\":{\"MemoData\":\"7465787465642064617461\",\"MemoType\":\"74657374\",\"MemoFormat\":\"706C61696E2F74657874\"}}],\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23,\"OfferSequence\":12345}",
|
||||
"txJSON": "{\"TransactionType\":\"OfferCreate\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"TakerGets\":{\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\",\"value\":\"10.1\"},\"TakerPays\":\"2000000\",\"Flags\":2148139008,\"Memos\":[{\"Memo\":{\"MemoData\":\"7465787465642064617461\",\"MemoType\":\"74657374\",\"MemoFormat\":\"746578742F706C61696E\"}}],\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23,\"OfferSequence\":12345}",
|
||||
"instructions": {
|
||||
"fee": "0.000012",
|
||||
"sequence": 23,
|
||||
|
||||
2
test/fixtures/responses/prepare-order.json
vendored
2
test/fixtures/responses/prepare-order.json
vendored
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"txJSON": "{\"Flags\":2147811328,\"TransactionType\":\"OfferCreate\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"TakerGets\":\"2000000\",\"TakerPays\":{\"value\":\"10.1\",\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\"},\"LastLedgerSequence\":8819954,\"Fee\":\"12\",\"Sequence\":23}",
|
||||
"txJSON": "{\"Flags\":2147745792,\"TransactionType\":\"OfferCreate\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"TakerGets\":\"2000000\",\"TakerPays\":{\"value\":\"10.1\",\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\"},\"LastLedgerSequence\":8819954,\"Fee\":\"12\",\"Sequence\":23}",
|
||||
"instructions": {
|
||||
"fee": "0.000012",
|
||||
"sequence": 23,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"txJSON": "{\"Flags\":2147811328,\"TransactionType\":\"Payment\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Destination\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"Amount\":\"10000\",\"InvoiceID\":\"A98FD36C17BE2B8511AD36DC335478E7E89F06262949F36EB88E2D683BBCC50A\",\"SourceTag\":14,\"DestinationTag\":58,\"Memos\":[{\"Memo\":{\"MemoType\":\"74657374\",\"MemoFormat\":\"706C61696E2F74657874\",\"MemoData\":\"7465787465642064617461\"}}],\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
|
||||
"txJSON": "{\"Flags\":2147811328,\"TransactionType\":\"Payment\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Destination\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"Amount\":\"10000\",\"InvoiceID\":\"A98FD36C17BE2B8511AD36DC335478E7E89F06262949F36EB88E2D683BBCC50A\",\"SourceTag\":14,\"DestinationTag\":58,\"Memos\":[{\"Memo\":{\"MemoType\":\"74657374\",\"MemoFormat\":\"746578742F706C61696E\",\"MemoData\":\"7465787465642064617461\"}}],\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
|
||||
"instructions": {
|
||||
"fee": "0.000012",
|
||||
"sequence": 23,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"txJSON": "{\"Flags\":2147942400,\"TransactionType\":\"Payment\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Destination\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"Amount\":{\"value\":\"0.01\",\"currency\":\"LTC\",\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\"},\"InvoiceID\":\"A98FD36C17BE2B8511AD36DC335478E7E89F06262949F36EB88E2D683BBCC50A\",\"SourceTag\":14,\"DestinationTag\":58,\"Memos\":[{\"Memo\":{\"MemoType\":\"74657374\",\"MemoFormat\":\"706C61696E2F74657874\",\"MemoData\":\"7465787465642064617461\"}}],\"SendMax\":{\"value\":\"0.01\",\"currency\":\"USD\",\"issuer\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\"},\"Paths\":[[{\"account\":\"rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q\",\"issuer\":\"rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q\",\"currency\":\"USD\"},{\"issuer\":\"rfYv1TXnwgDDK4WQNbFALykYuEBnrR4pDX\",\"currency\":\"LTC\"},{\"account\":\"rfYv1TXnwgDDK4WQNbFALykYuEBnrR4pDX\",\"issuer\":\"rfYv1TXnwgDDK4WQNbFALykYuEBnrR4pDX\",\"currency\":\"LTC\"}]],\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
|
||||
"txJSON": "{\"Flags\":2147942400,\"TransactionType\":\"Payment\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Destination\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"Amount\":{\"value\":\"0.01\",\"currency\":\"LTC\",\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\"},\"InvoiceID\":\"A98FD36C17BE2B8511AD36DC335478E7E89F06262949F36EB88E2D683BBCC50A\",\"SourceTag\":14,\"DestinationTag\":58,\"Memos\":[{\"Memo\":{\"MemoType\":\"74657374\",\"MemoFormat\":\"746578742F706C61696E\",\"MemoData\":\"7465787465642064617461\"}}],\"SendMax\":{\"value\":\"0.01\",\"currency\":\"USD\",\"issuer\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\"},\"Paths\":[[{\"account\":\"rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q\",\"issuer\":\"rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q\",\"currency\":\"USD\"},{\"issuer\":\"rfYv1TXnwgDDK4WQNbFALykYuEBnrR4pDX\",\"currency\":\"LTC\"},{\"account\":\"rfYv1TXnwgDDK4WQNbFALykYuEBnrR4pDX\",\"issuer\":\"rfYv1TXnwgDDK4WQNbFALykYuEBnrR4pDX\",\"currency\":\"LTC\"}]],\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
|
||||
"instructions": {
|
||||
"fee": "0.000012",
|
||||
"sequence": 23,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"txJSON": "{\"TransactionType\":\"AccountSet\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Memos\":[{\"Memo\":{\"MemoData\":\"7465787465642064617461\",\"MemoType\":\"74657374\",\"MemoFormat\":\"706C61696E2F74657874\"}}],\"Domain\":\"726970706C652E636F6D\",\"Flags\":2147483648,\"LastLedgerSequence\":8820051,\"Fee\":\"60\",\"Sequence\":23}",
|
||||
"txJSON": "{\"TransactionType\":\"AccountSet\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Memos\":[{\"Memo\":{\"MemoData\":\"7465787465642064617461\",\"MemoType\":\"74657374\",\"MemoFormat\":\"746578742F706C61696E\"}}],\"Domain\":\"726970706C652E636F6D\",\"Flags\":2147483648,\"LastLedgerSequence\":8820051,\"Fee\":\"60\",\"Sequence\":23}",
|
||||
"instructions": {
|
||||
"fee": "0.00006",
|
||||
"sequence": 23,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"txJSON": "{\"TransactionType\":\"AccountSet\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Memos\":[{\"Memo\":{\"MemoData\":\"7465787465642064617461\",\"MemoType\":\"74657374\",\"MemoFormat\":\"706C61696E2F74657874\"}}],\"Domain\":\"726970706C652E636F6D\",\"Flags\":2147483648,\"LastLedgerSequence\":8819954,\"Fee\":\"12\",\"Sequence\":23}",
|
||||
"txJSON": "{\"TransactionType\":\"AccountSet\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Memos\":[{\"Memo\":{\"MemoData\":\"7465787465642064617461\",\"MemoType\":\"74657374\",\"MemoFormat\":\"746578742F706C61696E\"}}],\"Domain\":\"726970706C652E636F6D\",\"Flags\":2147483648,\"LastLedgerSequence\":8819954,\"Fee\":\"12\",\"Sequence\":23}",
|
||||
"instructions": {
|
||||
"fee": "0.000012",
|
||||
"sequence": 23,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"txJSON": "{\"TransactionType\":\"AccountSet\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Memos\":[{\"Memo\":{\"MemoData\":\"7465787465642064617461\",\"MemoType\":\"74657374\",\"MemoFormat\":\"706C61696E2F74657874\"}}],\"Domain\":\"726970706C652E636F6D\",\"Flags\":2147483648,\"Fee\":\"12\",\"Sequence\":23}",
|
||||
"txJSON": "{\"TransactionType\":\"AccountSet\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Memos\":[{\"Memo\":{\"MemoData\":\"7465787465642064617461\",\"MemoType\":\"74657374\",\"MemoFormat\":\"746578742F706C61696E\"}}],\"Domain\":\"726970706C652E636F6D\",\"Flags\":2147483648,\"Fee\":\"12\",\"Sequence\":23}",
|
||||
"instructions": {
|
||||
"fee": "0.000012",
|
||||
"sequence": 23,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"signedTransaction": "12000322800000002400000017201B0086955368400000000000000C732102F89EAEC7667B30F33D0687BBA86C3FE2A08CCA40A9186C5BDE2DAA6FA97A37D87446304402202FBF6A6F74DFDA17C7341D532B66141206BC71A147C08DBDA6A950AA9A1741DC022055859A39F2486A46487F8DA261E3D80B4FDD26178A716A929F26377D1BEC7E43770A726970706C652E636F6D81145E7B112523F68D2F5E879DB4EAC51C6698A69304F9EA7C04746573747D0B74657874656420646174617E0A706C61696E2F74657874E1F1",
|
||||
"id": "4755D26FAC39E3E477870D4E03CC6783DDDF967FFBE240606755D3D03702FC16"
|
||||
"signedTransaction": "12000322800000002400000017201B0086955368400000000000000C732102F89EAEC7667B30F33D0687BBA86C3FE2A08CCA40A9186C5BDE2DAA6FA97A37D874463044022047E8275DD2D9796E1A749DD8613B512AB3F5800A4B4738F97CD6904701E185D9022062736A12F5AD9135D188EF20DA3995D8C8F3823FB52B9659E6B74DFF797DADFD770A726970706C652E636F6D81145E7B112523F68D2F5E879DB4EAC51C6698A69304F9EA7C04746573747D0B74657874656420646174617E0A746578742F706C61696EE1F1",
|
||||
"id": "00731CDA974C125217CAD6DFA8D733BDBD35F3F722D5FE4710634A3FD7A0339C"
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"txJSON": "{\"TransactionType\":\"AccountSet\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Memos\":[{\"Memo\":{\"MemoData\":\"7465787465642064617461\",\"MemoType\":\"74657374\",\"MemoFormat\":\"706C61696E2F74657874\"}}],\"Domain\":\"726970706C652E636F6D\",\"Flags\":2147483648,\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
|
||||
"txJSON": "{\"TransactionType\":\"AccountSet\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Memos\":[{\"Memo\":{\"MemoData\":\"7465787465642064617461\",\"MemoType\":\"74657374\",\"MemoFormat\":\"746578742F706C61696E\"}}],\"Domain\":\"726970706C652E636F6D\",\"Flags\":2147483648,\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
|
||||
"instructions": {
|
||||
"fee": "0.000012",
|
||||
"sequence": 23,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user