mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-10 07:45:49 +00:00
Compare commits
62 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c23c6e4fc9 | ||
|
|
afdd60efe8 | ||
|
|
8f6ea573ff | ||
|
|
3271b544ef | ||
|
|
6e83130754 | ||
|
|
f6ebe32519 | ||
|
|
3caed3c761 | ||
|
|
ce1c55427a | ||
|
|
9cd72595f0 | ||
|
|
ad1d3e135f | ||
|
|
76866ab901 | ||
|
|
20b647dfbf | ||
|
|
99d08065e4 | ||
|
|
261fba3d21 | ||
|
|
e1d9de7b1f | ||
|
|
391b2f3622 | ||
|
|
86ff315ef2 | ||
|
|
8d8a850864 | ||
|
|
7bf2da6014 | ||
|
|
7eae3ce709 | ||
|
|
5f5e48e414 | ||
|
|
4f6a37f7b1 | ||
|
|
82613e7e8b | ||
|
|
588aa382a1 | ||
|
|
809d981987 | ||
|
|
cfc21fde8c | ||
|
|
5c06ef547b | ||
|
|
0990ad4a6f | ||
|
|
d8f967d2b8 | ||
|
|
fe1c3e7130 | ||
|
|
062148674c | ||
|
|
11320693fd | ||
|
|
7af7eaccb4 | ||
|
|
5d5cf868a2 | ||
|
|
ddf8fe5b1a | ||
|
|
dc24f6afe0 | ||
|
|
f7dac6ab25 | ||
|
|
4b4fc36ebd | ||
|
|
7626ea5ed8 | ||
|
|
7061e9afe4 | ||
|
|
a124635c2c | ||
|
|
c9704137b7 | ||
|
|
ab8d75d3cc | ||
|
|
5e720891f5 | ||
|
|
27ed1aadd5 | ||
|
|
001f203983 | ||
|
|
515047d2dc | ||
|
|
995606b1e6 | ||
|
|
b5081344da | ||
|
|
4f86691fb8 | ||
|
|
45aca016d4 | ||
|
|
7f33d8a71e | ||
|
|
af620755c5 | ||
|
|
a76b554cad | ||
|
|
ef1e9e1b70 | ||
|
|
fdbac63f46 | ||
|
|
377f1dbfa1 | ||
|
|
14b840f3fe | ||
|
|
beb1cc0cde | ||
|
|
ef2515507d | ||
|
|
a271b9e816 | ||
|
|
8a3d4a64db |
56
HISTORY.md
56
HISTORY.md
@@ -1,3 +1,59 @@
|
|||||||
|
##0.16.2
|
||||||
|
**Changes**
|
||||||
|
+ [Bump ripple-binary-codec dependency version to 0.1.1 to fix issue with computeLedgerHash for transactions with DeliverMin]
|
||||||
|
|
||||||
|
##0.16.1
|
||||||
|
**Changes**
|
||||||
|
+ [FIX: Use assert not assert-diff](https://github.com/ripple/ripple-lib/commit/f6ebe325193e7208c5ee8d8e84a7504714f0009e)
|
||||||
|
|
||||||
|
##0.16.0
|
||||||
|
**Breaking Changes**
|
||||||
|
+ [Fix types of XRP values in getServerInfo response](https://github.com/ripple/ripple-lib/commit/99d08065e4bda3dda6ae1f183adbd11abc70a9b7)
|
||||||
|
+ [Change error event format and fix crash due to error event on webscocket](https://github.com/ripple/ripple-lib/commit/9cd72595f0efc062d77b9d625695d6030c524cc6)
|
||||||
|
|
||||||
|
**Changes**
|
||||||
|
+ [Fix generateAddress docs and add error event listener to boilerplate](https://github.com/ripple/ripple-lib/commit/809d981987a2890fac3a73a40a05c598b9040334)
|
||||||
|
+ [Allow setting maxLedgerVersion to null to specify no maximum](https://github.com/ripple/ripple-lib/commit/82613e7e8b360d1ae1552eab4559ab4763c06d7e)
|
||||||
|
+ [Add support for client certificates](https://github.com/ripple/ripple-lib/commit/5f5e48e4140345d166b8c1a3ee0847b0d9e2d893)
|
||||||
|
+ [getFee returns a string not float](https://github.com/ripple/ripple-lib/commit/7bf2da6014c87e164542e69356efeaabb575a157)
|
||||||
|
+ [Fix parsing of quality for getTrustlines](https://github.com/ripple/ripple-lib/commit/86ff315ef2a39dfdc2ce97e0e1c4aa73f04e363b)
|
||||||
|
+ [Fix DeliverMin value when specifying minAmount](Fix DeliverMin value when specifying minAmount)
|
||||||
|
+ [http server example](https://github.com/ripple/ripple-lib/commit/76866ab901ea46a2dd73181605e0f7f4220043d4)
|
||||||
|
|
||||||
|
|
||||||
|
##0.15.2
|
||||||
|
**Changes**
|
||||||
|
+ [Fix support for proxy credentials in proxy URL and fix error when there are more than 10 outstanding requests](https://github.com/ripple/ripple-lib/commit/0990ad4a6f1d59ca9d2cb859b4e2d71693f3fc4b)
|
||||||
|
|
||||||
|
##0.15.1
|
||||||
|
**Changes**
|
||||||
|
+ [Fix babel-polyfill require](https://github.com/ripple/ripple-lib/commit/062148674c3b1293ab82c28e25615ddd530339fa)
|
||||||
|
+ [Fix samples](https://github.com/ripple/ripple-lib/commit/5d5cf868a2ddb1b1cd40e4a4f0a782d0066c2055)
|
||||||
|
+ [add unit tests for RippleAPIBroadcast](https://github.com/ripple/ripple-lib/commit/ddf8fe5b1a9c750490dca98fb9ffaaf8017f87e0)
|
||||||
|
|
||||||
|
##0.15.0
|
||||||
|
**Breaking Changes**
|
||||||
|
+ ["servers" parameter changed to single "server"](https://github.com/ripple/ripple-lib/commit/7061e9afe46f0682254d098adeff3dd7157521a1)
|
||||||
|
|
||||||
|
**Changes**
|
||||||
|
+ [fix handling memos in prepareSettings](https://github.com/ripple/ripple-lib/commit/c9704137b7b538e8dbf31c483bcdcf2dcfd7cd75)
|
||||||
|
+ [Docs: SusPay warnings, offline mode, and other tweaks](https://github.com/ripple/ripple-lib/commit/4b4fc36ebd93f1360781a65f2869bd2c4f0a5093)
|
||||||
|
+ [Fix prepareOrderCancellation documentation](https://github.com/ripple/ripple-lib/commit/5e720891f579fd73d43c64e5ec519d9121023c10)
|
||||||
|
|
||||||
|
##0.14.0
|
||||||
|
**Breaking Changes**
|
||||||
|
+ [prepareOrderCancellation now takes orderCancellation specification](https://github.com/ripple/ripple-lib/commit/7f33d8a71e56289e5a5e0ead1c74f75ebcde72bc)
|
||||||
|
+ [Rename "ledgerClosed" event to "ledger" and change format](https://github.com/ripple/ripple-lib/commit/8a3d4a64db5fbf560ebf87dc62e0212513c5e18a)
|
||||||
|
|
||||||
|
**Changes**
|
||||||
|
+ [Fix proxy support and add support for proxy authorization](https://github.com/ripple/ripple-lib/commit/14b840f3feca758e0384b746c94e36d8bf59b8c2)
|
||||||
|
+ [Fix trace option](https://github.com/ripple/ripple-lib/commit/af620755c53556c55eed12de4b0013ef5a349ce2)
|
||||||
|
+ [Allow memos on all transaction types](https://github.com/ripple/ripple-lib/commit/b5081344da8e66fbd3a5113cc3313325ef72a494)
|
||||||
|
+ [Add documentation for RippleAPI options](https://github.com/ripple/ripple-lib/commit/a76b554cadb9f9f918b06f8386bc29355682a1a4)
|
||||||
|
+ [Docs: more on basic types, tx types](https://github.com/ripple/ripple-lib/commit/fdbac63f466b4fd3be701d4878800d856692e26e)
|
||||||
|
+ [Docs: revised introductory material](https://github.com/ripple/ripple-lib/commit/ef2515507dbd3c6a426ab5b31332a1bdf72d5b2d)
|
||||||
|
+ [boost coverage to almost 100%](https://github.com/ripple/ripple-lib/commit/995606b1e6f3643af34d9fd442ccd31f320b03eb)
|
||||||
|
|
||||||
##0.13.2
|
##0.13.2
|
||||||
|
|
||||||
**Changes**
|
**Changes**
|
||||||
|
|||||||
368
docs/index.md
368
docs/index.md
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
- [Introduction](#introduction)
|
- [Introduction](#introduction)
|
||||||
- [Boilerplate](#boilerplate)
|
- [Boilerplate](#boilerplate)
|
||||||
|
- [Offline functionality](#offline-functionality)
|
||||||
- [Basic Types](#basic-types)
|
- [Basic Types](#basic-types)
|
||||||
- [Ripple Address](#ripple-address)
|
- [Ripple Address](#ripple-address)
|
||||||
- [Account Sequence Number](#account-sequence-number)
|
- [Account Sequence Number](#account-sequence-number)
|
||||||
@@ -16,6 +17,7 @@
|
|||||||
- [Transaction Fees](#transaction-fees)
|
- [Transaction Fees](#transaction-fees)
|
||||||
- [Transaction Instructions](#transaction-instructions)
|
- [Transaction Instructions](#transaction-instructions)
|
||||||
- [Transaction ID](#transaction-id)
|
- [Transaction ID](#transaction-id)
|
||||||
|
- [Transaction Memos](#transaction-memos)
|
||||||
- [Transaction Specifications](#transaction-specifications)
|
- [Transaction Specifications](#transaction-specifications)
|
||||||
- [Payment](#payment)
|
- [Payment](#payment)
|
||||||
- [Trustline](#trustline)
|
- [Trustline](#trustline)
|
||||||
@@ -56,24 +58,36 @@
|
|||||||
- [generateAddress](#generateaddress)
|
- [generateAddress](#generateaddress)
|
||||||
- [computeLedgerHash](#computeledgerhash)
|
- [computeLedgerHash](#computeledgerhash)
|
||||||
- [API Events](#api-events)
|
- [API Events](#api-events)
|
||||||
- [ledgerClosed](#ledgerclosed)
|
- [ledger](#ledger)
|
||||||
- [error](#error)
|
- [error](#error)
|
||||||
|
|
||||||
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
||||||
|
|
||||||
# Introduction
|
# Introduction
|
||||||
|
|
||||||
RippleAPI allows you to query and submit transactions to a node on the Ripple network.
|
RippleAPI is the official client library to the Ripple Consensus Ledger. Currently, RippleAPI is only available in JavaScript.
|
||||||
|
Using RippleAPI, you can:
|
||||||
|
|
||||||
|
* [Query transactions from the network](#gettransaction)
|
||||||
|
* [Sign](#sign) transactions securely without connecting to any server
|
||||||
|
* [Submit](#submit) transactions to the Ripple Consensus Ledger, including [Payments](#payment), [Orders](#order), [Settings changes](#settings), and [other types](#transaction-types)
|
||||||
|
* [Generate a new Ripple Address](#generateaddress)
|
||||||
|
* ... and [much more](#api-methods).
|
||||||
|
|
||||||
RippleAPI only provides access to *validated*, *immutable* transaction data.
|
RippleAPI only provides access to *validated*, *immutable* transaction data.
|
||||||
|
|
||||||
## Boilerplate
|
## Boilerplate
|
||||||
|
|
||||||
|
Use the following [boilerplate code](https://en.wikipedia.org/wiki/Boilerplate_code) to wrap your custom code using RippleAPI.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const {RippleAPI} = require('ripple-lib');
|
const {RippleAPI} = require('ripple-lib');
|
||||||
|
|
||||||
const api = new RippleAPI({
|
const api = new RippleAPI({
|
||||||
servers: ['wss://s1.ripple.com']
|
server: 'wss://s1.ripple.com' // Public rippled server hosted by Ripple, Inc.
|
||||||
|
});
|
||||||
|
api.on('error', (errorCode, errorMessage) => {
|
||||||
|
console.log(errorCode + ': ' + errorMessage);
|
||||||
});
|
});
|
||||||
api.connect().then(() => {
|
api.connect().then(() => {
|
||||||
/* insert code here */
|
/* insert code here */
|
||||||
@@ -82,26 +96,87 @@ api.connect().then(() => {
|
|||||||
}).catch(console.error);
|
}).catch(console.error);
|
||||||
```
|
```
|
||||||
|
|
||||||
To get started, first install [nodejs](https://nodejs.org) version `0.12.0` or greater, then:
|
RippleAPI is designed to work in [NodeJS](https://nodejs.org) (version `0.12.0` or greater) using [Babel](https://babeljs.io/) for [ECMAScript 6](https://babeljs.io/docs/learn-es2015/) support.
|
||||||
|
|
||||||
`npm install -g babel`
|
The code samples in this documentation are written in ES6, but `RippleAPI` will work with ES5 also. Regardless of whether you use ES5 or ES6, the methods that return promises will return [ES6-style promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise).
|
||||||
|
|
||||||
`npm install ripple-lib`
|
|
||||||
|
|
||||||
Then create a script based on the boilerplate shown here and run with:
|
|
||||||
|
|
||||||
`babel-node script.js`
|
|
||||||
|
|
||||||
The code samples in this documentation are written in ES6, but `RippleAPI` will work with ES5 also. Regardless of whether you use ES5 or ES6, the methods that return promises will return ES6-style promises.
|
|
||||||
|
|
||||||
<aside class="notice">
|
<aside class="notice">
|
||||||
All the code snippets in this documentation assume that you have surrounded them with this boilerplate.
|
All the code snippets in this documentation assume that you have surrounded them with this boilerplate.
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
<aside class="notice">
|
<aside class="notice">
|
||||||
Dont forget the "catch" or errors may not be visible.
|
If you omit the "catch" section, errors may not be visible.
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
|
<aside class="notice">
|
||||||
|
The "error" event is emitted whenever an error occurs that cannot be associated with a specific request. If the listener is not registered, an exception will be thrown whenever the event is emitted.
|
||||||
|
</aside>
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
The RippleAPI constructor optionally takes one argument, an object with the following options:
|
||||||
|
|
||||||
|
Name | Type | Description
|
||||||
|
---- | ---- | -----------
|
||||||
|
authorization | string | *Optional* Username and password for HTTP basic authentication to the rippled server in the format **username:password**.
|
||||||
|
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).
|
||||||
|
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**.
|
||||||
|
server | uri string | *Optional* URI for rippled websocket port to connect to. Must start with `wss://` or `ws://`.
|
||||||
|
timeout | integer | *Optional* Timeout in milliseconds before considering a request to have failed.
|
||||||
|
trace | boolean | *Optional* If true, log rippled requests and responses to stdout.
|
||||||
|
trustedCertificates | array\<string\> | *Optional* Array of PEM-formatted SSL certificates to trust when connecting to a proxy. This is useful if you want to use a self-signed certificate on the proxy server. Note: Each element must contain a single certificate; concatenated certificates are not valid.
|
||||||
|
|
||||||
|
If you omit the `server` parameter, RippleAPI operates [offline](#offline-functionality).
|
||||||
|
|
||||||
|
|
||||||
|
### Installation ###
|
||||||
|
|
||||||
|
1. Install [NodeJS](https://nodejs.org) and the Node Package Manager (npm). Most Linux distros have a package for NodeJS, but make sure you have version `0.12.0` or higher.
|
||||||
|
2. Use npm to install [Babel](https://babeljs.io/) globally:
|
||||||
|
`npm install -g babel`
|
||||||
|
3. Use npm to install RippleAPI:
|
||||||
|
`npm install ripple-lib`
|
||||||
|
|
||||||
|
After you have installed ripple-lib, you can create scripts using the [boilerplate](#boilerplate) and run them using babel-node:
|
||||||
|
`babel-node script.js`
|
||||||
|
|
||||||
|
<aside class="notice">
|
||||||
|
Instead of using babel-node in production, we recommend using Babel to transpile to ECMAScript 5 first.
|
||||||
|
</aside>
|
||||||
|
|
||||||
|
|
||||||
|
## Offline functionality
|
||||||
|
|
||||||
|
RippleAPI can also function without internet connectivity. This can be useful in order to generate secrets and sign transactions from a secure, isolated machine.
|
||||||
|
|
||||||
|
To instantiate RippleAPI in offline mode, use the following boilerplate code:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
const {RippleAPI} = require('ripple-lib');
|
||||||
|
|
||||||
|
const api = new RippleAPI();
|
||||||
|
/* insert code here */
|
||||||
|
```
|
||||||
|
|
||||||
|
Methods that depend on the state of the Ripple Consensus Ledger are unavailable in offline mode. To prepare transactions offline, you **must** specify the `fee`, `sequence`, and `maxLedgerVersion` parameters in the [transaction instructions](#transaction-instructions). The following methods should work offline:
|
||||||
|
|
||||||
|
* [preparePayment](#preparepayment)
|
||||||
|
* [prepareTrustline](#preparetrustline)
|
||||||
|
* [prepareOrder](#prepareorder)
|
||||||
|
* [prepareOrderCancellation](#prepareordercancellation)
|
||||||
|
* [prepareSettings](#preparesettings)
|
||||||
|
* [prepareSuspendedPaymentCreation](#preparesuspendedpaymentcreation)
|
||||||
|
* [prepareSuspendedPaymentCancellation](#preparesuspendedpaymentcancellation)
|
||||||
|
* [prepareSuspendedPaymentExecution](#preparesuspendedpaymentexecution)
|
||||||
|
* [sign](#sign)
|
||||||
|
* [generateAddress](#generateaddress)
|
||||||
|
* [computeLedgerHash](#computeledgerhash)
|
||||||
|
|
||||||
|
|
||||||
# Basic Types
|
# Basic Types
|
||||||
|
|
||||||
## Ripple Address
|
## Ripple Address
|
||||||
@@ -110,23 +185,28 @@ Dont forget the "catch" or errors may not be visible.
|
|||||||
"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59"
|
"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59"
|
||||||
```
|
```
|
||||||
|
|
||||||
Every Ripple account has an *address*, which is a base58-encoding of a hash of the account's public key.
|
Every Ripple account has an *address*, which is a base58-encoding of a hash of the account's public key. Ripple addresses always start with the lowercase letter `r`.
|
||||||
|
|
||||||
## Account Sequence Number
|
## Account Sequence Number
|
||||||
|
|
||||||
Every Ripple account has a *sequence number* that is used to order transactions. Every transaction must have a sequence number and transaction can only be executed in order by sequence number. This prevents one transaction from executing twice and transactions executing out of order. The sequence number starts at `1` and increments for each transaction that the account makes.
|
Every Ripple account has a *sequence number* that is used to keep transactions in order. Every transaction must have a sequence number. A transaction can only be executed if it has the next sequence number in order, of the account sending it. This prevents one transaction from executing twice and transactions executing out of order. The sequence number starts at `1` and increments for each transaction that the account makes.
|
||||||
|
|
||||||
## Currency
|
## Currency
|
||||||
|
|
||||||
Currencies are represented as either 3-character currency codes or 40-character uppercase hexadecimal strings. We recommend using uppercase [ISO 4217 Currency Codes](http://www.xe.com/iso4217.php) only. The string "XRP" is disallowed on trustlines because it is reserved for the Ripple native currency. The following characters are permitted: all uppercase and lowercase letters, digits, as well as the symbols `?`, `!`, `@`, `#`, `$`, `%`, `^`, `&`, `*`, `<`, `>`, `(`, `)`, `{`, `}`, `[`, `]`, and `|`.
|
Currencies are represented as either 3-character currency codes or 40-character uppercase hexadecimal strings. We recommend using uppercase [ISO 4217 Currency Codes](http://www.xe.com/iso4217.php) only. The string "XRP" is disallowed on trustlines because it is reserved for the Ripple native currency. The following characters are permitted: all uppercase and lowercase letters, digits, as well as the symbols `?`, `!`, `@`, `#`, `$`, `%`, `^`, `&`, `*`, `<`, `>`, `(`, `)`, `{`, `}`, `[`, `]`, and `|`.
|
||||||
|
|
||||||
## Value
|
## Value
|
||||||
A *value* is a quantity of a currency represented as a decimal string (string encoding is used because javascript numbers do not have sufficient precision).
|
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).
|
||||||
|
|
||||||
|
**Non-XRP values** have 15 decimal digits of precision, with a maximum value of `9999999999999999e80`. The smallest positive non-XRP value is `1e-81`.
|
||||||
|
|
||||||
An XRP value has 6 significant digits past the decimal point. A non-XRP value has 16 total digits of precision.
|
|
||||||
|
|
||||||
## Amount
|
## Amount
|
||||||
|
|
||||||
|
Example amount:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"currency": "USD",
|
"currency": "USD",
|
||||||
@@ -135,6 +215,7 @@ An XRP value has 6 significant digits past the decimal point. A non-XRP value ha
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Example XRP amount:
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"currency": "XRP",
|
"currency": "XRP",
|
||||||
@@ -142,7 +223,7 @@ An XRP value has 6 significant digits past the decimal point. A non-XRP value ha
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
An *amount* is data structure representing a currency, a quantity of that currency, and the counterparty on the trustline that holds the value (for all currencies besides "XRP").
|
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.
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
@@ -164,7 +245,7 @@ A transaction type is specified by the strings in the first column in the table
|
|||||||
|
|
||||||
Type | Description
|
Type | Description
|
||||||
---- | -----------
|
---- | -----------
|
||||||
[payment](#payment) | A `payment` transaction represents a transfer of value from one account to another. Depending on the path taken, additional exchanges of value may occur atomically to facilitate the payment.
|
[payment](#payment) | A `payment` transaction represents a transfer of value from one account to another. Depending on the [path](https://ripple.com/build/paths/) taken, additional exchanges of value may occur atomically to facilitate the payment.
|
||||||
[order](#order) | An `order` transaction creates a limit order. It defines an intent to exchange currencies, and creates an order in the Ripple Consensus Ledger's order book if not completely fulfilled when placed. Orders can be partially fulfilled.
|
[order](#order) | An `order` transaction creates a limit order. It defines an intent to exchange currencies, and creates an order in the Ripple Consensus Ledger's order book if not completely fulfilled when placed. Orders can be partially fulfilled.
|
||||||
[orderCancellation](#order-cancellation) | An `orderCancellation` transaction cancels an order in the Ripple Consensus Ledger's order book.
|
[orderCancellation](#order-cancellation) | An `orderCancellation` transaction cancels an order in the Ripple Consensus Ledger's order book.
|
||||||
[trustline](#trustline) | A `trustline` transactions creates or modifies a trust line between two accounts.
|
[trustline](#trustline) | A `trustline` transactions creates or modifies a trust line between two accounts.
|
||||||
@@ -173,40 +254,64 @@ Type | Description
|
|||||||
[suspendedPaymentCancellation](#suspended-payment-cancellation) | A `suspendedPaymentCancellation` transaction unlocks the funds in a suspended payment and sends them back to the creator of the suspended payment, but it will only work after the suspended payment expires.
|
[suspendedPaymentCancellation](#suspended-payment-cancellation) | A `suspendedPaymentCancellation` transaction unlocks the funds in a suspended payment and sends them back to the creator of the suspended payment, but it will only work after the suspended payment expires.
|
||||||
[suspendedPaymentExecution](#suspended-payment-execution) | A `suspendedPaymentExecution` transaction unlocks the funds in a suspended payment and sends them to the destination of the suspended payment, but it will only work if the cryptographic condition is provided.
|
[suspendedPaymentExecution](#suspended-payment-execution) | A `suspendedPaymentExecution` transaction unlocks the funds in a suspended payment and sends them to the destination of the suspended payment, but it will only work if the cryptographic condition is provided.
|
||||||
|
|
||||||
|
The three "suspended payment" transaction types are not supported by the production Ripple peer-to-peer network at this time. They are available for testing purposes if you [configure RippleAPI](#boilerplate) to connect to the [Ripple Test Net](https://ripple.com/build/ripple-test-net/) instead.
|
||||||
|
|
||||||
## Transaction Flow
|
## Transaction Flow
|
||||||
|
|
||||||
Executing a transaction with `RippleAPI` requires the following four steps:
|
Executing a transaction with `RippleAPI` requires the following four steps:
|
||||||
|
|
||||||
1. prepare - Create an unsigned transaction based on a [specification](#transaction-specifications) and [instructions](#transaction-instructions).
|
1. Prepare - Create an unsigned transaction based on a [specification](#transaction-specifications) and [instructions](#transaction-instructions). There is a method to prepare each type of transaction:
|
||||||
2. sign - Cryptographically sign the transaction locally and save the [transaction ID](#transaction-id). Signing is how the owner of an account authorizes a transaction to take place.
|
* [preparePayment](#preparepayment)
|
||||||
3. submit - Submit the transaction to the connected server.
|
* [prepareTrustline](#preparetrustline)
|
||||||
4. verify - Verify that the transaction got validated by querying with [getTransaction](#gettransaction). This is necessary because transactions may fail even if they were successfully submitted. It is recommended that you specify a `maxLedgerVersion` in the instructions when preparing a transaction because without it there is no way to know that a failed transaction will never succeeed in the future. It is impossible for a transaction to succeed after the network ledger version exceeds the `maxLedgerVersion` provided in the transaction instructions.
|
* [prepareOrder](#prepareorder)
|
||||||
|
* [prepareOrderCancellation](#prepareordercancellation)
|
||||||
|
* [prepareSettings](#preparesettings)
|
||||||
|
* [prepareSuspendedPaymentCreation](#preparesuspendedpaymentcreation)
|
||||||
|
* [prepareSuspendedPaymentCancellation](#preparesuspendedpaymentcancellation)
|
||||||
|
* [prepareSuspendedPaymentExecution](#preparesuspendedpaymentexecution)
|
||||||
|
2. [Sign](#sign) - Cryptographically sign the transaction locally and save the [transaction ID](#transaction-id). Signing is how the owner of an account authorizes a transaction to take place.
|
||||||
|
3. [Submit](#submit) - Submit the transaction to the connected server.
|
||||||
|
4. Verify - Verify that the transaction got validated by querying with [getTransaction](#gettransaction). This is necessary because transactions may fail even if they were successfully submitted.
|
||||||
|
|
||||||
## Transaction Fees
|
## Transaction Fees
|
||||||
|
|
||||||
Every transaction requires a *fee* to be paid in XRP. The fee is destroyed; it is not sent to any other party. The purpose of the fee is to prevent denial of service attacks on the Ripple network.
|
Every transaction must destroy a small amount of XRP as a cost to send the transaction. This is also called a *transaction fee*. The transaction cost is designed to increase along with the load on the Ripple network, making it very expensive to deliberately or inadvertently overload the network.
|
||||||
|
|
||||||
You can choose the size of the fee you want to pay or let a default be used. The fee is like a bid in an auction for slots in the next ledger closing. If the fee you choose is too low, your transaction will not be included in the next ledger closing. You can get an estimate of the fee required to be included in the next ledger closing with the [getFee](#getfee) method.
|
You can choose the size of the fee you want to pay or let a default be used. You can get an estimate of the fee required to be included in the next ledger closing with the [getFee](#getfee) method.
|
||||||
|
|
||||||
## Transaction Instructions
|
## Transaction Instructions
|
||||||
|
|
||||||
Transactions instructions indicates how to execute a transaction, complementary with the [transaction specification](#transaction-specifications).
|
Transaction instructions indicate how to execute a transaction, complementary with the [transaction specification](#transaction-specifications).
|
||||||
|
|
||||||
Name | Type | Description
|
Name | Type | Description
|
||||||
---- | ---- | -----------
|
---- | ---- | -----------
|
||||||
fee | [value](#value) | *Optional* An exact fee to pay for the transaction. See [Transaction Fees](#transaction-fees) for more information.
|
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* The maximum fee to pay for the transaction. See [Transaction Fees](#transaction-fees) for more information.
|
||||||
maxLedgerVersion | integer | *Optional* The highest ledger version that the transaction can be included in.
|
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.
|
||||||
maxLedgerVersionOffset | integer | *Optional* Offset from current legder version to highest ledger version that the transaction can be included in.
|
maxLedgerVersionOffset | integer | *Optional* Offset from current validated legder 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.
|
sequence | [sequence](#account-sequence-number) | *Optional* The initiating account's sequence number for 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 network 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
|
## Transaction ID
|
||||||
|
|
||||||
```json
|
```json
|
||||||
"F4AB442A6D4CBB935D66E1DA7309A5FC71C7143ED4049053EC14E3875B0CF9BF"
|
"F4AB442A6D4CBB935D66E1DA7309A5FC71C7143ED4049053EC14E3875B0CF9BF"
|
||||||
```
|
```
|
||||||
|
|
||||||
A hash of the transaction that can be used to identify it. A transaction can be looked up by its ID using the [getTransaction](#gettransaction) method.
|
A transaction ID is a 64-bit hexadecimal string that uniquely identifies the transaction. The transaction ID is derived from the transaction instruction and specifications, using a strong hash function.
|
||||||
|
|
||||||
|
You can look up a transaction by ID using the [getTransaction](#gettransaction) method.
|
||||||
|
|
||||||
|
## Transaction Memos
|
||||||
|
|
||||||
|
Every transaction can optionally have an array of memos for user applications. The `memos` field in each [transaction specification](#transaction-specifications) is an array of objects with the following structure:
|
||||||
|
|
||||||
|
Name | Type | Description
|
||||||
|
---- | ---- | -----------
|
||||||
|
data | string | *Optional* Arbitrary string, conventionally containing the content of the memo.
|
||||||
|
format | string | *Optional* Conventionally containing information on how the memo is encoded, for example as a [MIME type](http://www.iana.org/assignments/media-types/media-types.xhtml). Only characters allowed in URLs are permitted.
|
||||||
|
type | string | *Optional* Conventionally, a unique relation (according to [RFC 5988](http://tools.ietf.org/html/rfc5988#section-4)) that defines the format of this memo. Only characters allowed in URLs are permitted.
|
||||||
|
|
||||||
# Transaction Specifications
|
# Transaction Specifications
|
||||||
|
|
||||||
@@ -221,22 +326,18 @@ Name | Type | Description
|
|||||||
source | object | The source of the funds to be sent.
|
source | object | The source of the funds to be sent.
|
||||||
*source.* address | [address](#ripple-address) | The address to send from.
|
*source.* address | [address](#ripple-address) | The address to send from.
|
||||||
*source.* amount | [laxAmount](#amount) | An exact amount to send. If the counterparty is not specified, amounts with any counterparty may be used. (This field is exclusive with source.maxAmount)
|
*source.* amount | [laxAmount](#amount) | An exact amount to send. If the counterparty is not specified, amounts with any counterparty may be used. (This field is exclusive with source.maxAmount)
|
||||||
*source.* tag | integer | *Optional* An arbitrary unsigned 32-bit integer most commonly used to identify a non-Ripple account.
|
*source.* tag | integer | *Optional* An arbitrary unsigned 32-bit integer that identifies a reason for payment or a non-Ripple account.
|
||||||
*source.* maxAmount | [laxAmount](#amount) | The maximum amount to send. (This field is exclusive with source.amount)
|
*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 | object | The destination of the funds to be sent.
|
||||||
*destination.* address | [address](#ripple-address) | The address to receive at.
|
*destination.* address | [address](#ripple-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 is exclusive with destination.minAmount).
|
||||||
*destination.* tag | integer | *Optional* An arbitrary unsigned 32-bit integer most commonly used to identify a non-Ripple account.
|
*destination.* tag | integer | *Optional* An arbitrary unsigned 32-bit integer that identifies a reason for payment or a non-Ripple account.
|
||||||
*destination.* address | [address](#ripple-address) | The address to send to.
|
*destination.* address | [address](#ripple-address) | The address to send to.
|
||||||
*destination.* minAmount | [laxAmount](#amount) | The minimum amount to be delivered. (This field is exclusive with destination.amount)
|
*destination.* minAmount | [laxAmount](#amount) | The minimum amount to be delivered. (This field is exclusive with destination.amount)
|
||||||
allowPartialPayment | boolean | *Optional* A boolean that, if set to true, indicates that this payment should go through even if the whole amount cannot be delivered because of a lack of liquidity or funds in the source account account
|
allowPartialPayment | boolean | *Optional* A boolean that, if set to true, indicates that this payment should go through even if the whole amount cannot be delivered because of a lack of liquidity or funds in the source account account
|
||||||
invoiceID | string | *Optional* A 256-bit hash that can be used to identify a particular payment.
|
invoiceID | string | *Optional* A 256-bit hash that can be used to identify a particular payment.
|
||||||
limitQuality | boolean | *Optional* 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.
|
limitQuality | boolean | *Optional* 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.
|
||||||
memos | array | *Optional* Array of memos to attach to the transaction.
|
memos | [memos](#transaction-memos) | *Optional* Array of memos to attach to the transaction.
|
||||||
memos[] | object | Memo objects represent arbitrary data that can be included in a transaction
|
|
||||||
*memos[].* data | string | *Optional* Arbitrary string, conventionally containing the content of the memo.
|
|
||||||
*memos[].* format | string | *Optional* Conventionally containing information on how the memo is encoded, for example as a [MIME type](http://www.iana.org/assignments/media-types/media-types.xhtml). Only characters allowed in URLs are permitted.
|
|
||||||
*memos[].* type | string | *Optional* Conventionally, a unique relation (according to [RFC 5988](http://tools.ietf.org/html/rfc5988#section-4)) that defines the format of this memo. Only characters allowed in URLs are permitted.
|
|
||||||
noDirectRipple | boolean | *Optional* A boolean that can be set to true if paths are specified and the sender would like the Ripple Network 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
|
noDirectRipple | boolean | *Optional* A boolean that can be set to true if paths are specified and the sender would like the Ripple Network 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
|
||||||
paths | string | *Optional* The paths of trustlines and orders to use in executing the payment.
|
paths | string | *Optional* The paths of trustlines and orders to use in executing the payment.
|
||||||
|
|
||||||
@@ -276,6 +377,7 @@ counterparty | [address](#ripple-address) | The address of the account this trus
|
|||||||
limit | [value](#value) | The maximum amount that the owner of the trustline can be owed through the trustline.
|
limit | [value](#value) | The maximum amount that the owner of the trustline can be owed through the trustline.
|
||||||
authorized | boolean | *Optional* If true, authorize the counterparty to hold issuances from this account.
|
authorized | boolean | *Optional* If true, authorize the counterparty to hold issuances from this account.
|
||||||
frozen | boolean | *Optional* If true, the trustline is frozen, which means that funds can only be sent to the owner.
|
frozen | boolean | *Optional* If true, the trustline is frozen, which means that funds can only be sent to the owner.
|
||||||
|
memos | [memos](#transaction-memos) | *Optional* Array of memos to attach to the transaction.
|
||||||
qualityIn | number | *Optional* Incoming balances on this trustline are valued at this ratio.
|
qualityIn | number | *Optional* Incoming balances on this trustline are valued at this ratio.
|
||||||
qualityOut | number | *Optional* Outgoing balances on this trustline are valued at this ratio.
|
qualityOut | number | *Optional* Outgoing balances on this trustline are valued at this ratio.
|
||||||
ripplingDisabled | boolean | *Optional* If true, payments cannot ripple through this trustline.
|
ripplingDisabled | boolean | *Optional* If true, payments cannot ripple through this trustline.
|
||||||
@@ -291,7 +393,14 @@ ripplingDisabled | boolean | *Optional* If true, payments cannot ripple through
|
|||||||
"qualityIn": 0.91,
|
"qualityIn": 0.91,
|
||||||
"qualityOut": 0.87,
|
"qualityOut": 0.87,
|
||||||
"ripplingDisabled": true,
|
"ripplingDisabled": true,
|
||||||
"frozen": false
|
"frozen": false,
|
||||||
|
"memos": [
|
||||||
|
{
|
||||||
|
"type": "test",
|
||||||
|
"format": "plain/text",
|
||||||
|
"data": "texted data"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -308,6 +417,7 @@ totalPrice | [amount](#amount) | The total price to be paid for the `quantity` t
|
|||||||
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).
|
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.
|
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.
|
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.
|
||||||
|
memos | [memos](#transaction-memos) | *Optional* Array of memos to attach to the transaction.
|
||||||
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.
|
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.
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
@@ -325,7 +435,8 @@ passive | boolean | *Optional* If enabled, the offer will not consume offers tha
|
|||||||
"currency": "XRP",
|
"currency": "XRP",
|
||||||
"value": "2"
|
"value": "2"
|
||||||
},
|
},
|
||||||
"immediateOrCancel": true
|
"passive": true,
|
||||||
|
"fillOrKill": true
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -337,12 +448,15 @@ See [Transaction Types](#transaction-types) for a description.
|
|||||||
Name | Type | Description
|
Name | Type | Description
|
||||||
---- | ---- | -----------
|
---- | ---- | -----------
|
||||||
orderSequence | [sequence](#account-sequence-number) | The [account sequence number](#account-sequence-number) of the order to cancel.
|
orderSequence | [sequence](#account-sequence-number) | The [account sequence number](#account-sequence-number) of the order to cancel.
|
||||||
|
memos | [memos](#transaction-memos) | *Optional* Array of memos to attach to the transaction.
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
|
|
||||||
|
|
||||||
```json
|
```json
|
||||||
23
|
{
|
||||||
|
"orderSequence": 23
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@@ -359,6 +473,7 @@ domain | string | *Optional* The domain that owns this account, as a hexadecima
|
|||||||
emailHash | string,null | *Optional* Hash of an email address to be used for generating an avatar image. Conventionally, clients use Gravatar to display this image. Use `null` to clear.
|
emailHash | string,null | *Optional* Hash of an email address to be used for generating an avatar image. Conventionally, clients use Gravatar to display this image. Use `null` to clear.
|
||||||
enableTransactionIDTracking | boolean | *Optional* Track the ID of this account’s most recent transaction.
|
enableTransactionIDTracking | boolean | *Optional* Track the ID of this account’s most recent transaction.
|
||||||
globalFreeze | boolean | *Optional* Freeze all assets issued by this account.
|
globalFreeze | boolean | *Optional* Freeze all assets issued by this account.
|
||||||
|
memos | [memos](#transaction-memos) | *Optional* Array of memos to attach to the transaction.
|
||||||
messageKey | string | *Optional* Public key for sending encrypted messages to this account. Conventionally, it should be a secp256k1 key, the same encryption that is used by the rest of Ripple.
|
messageKey | string | *Optional* Public key for sending encrypted messages to this account. Conventionally, it should be a secp256k1 key, the same encryption that is used by the rest of Ripple.
|
||||||
noFreeze | boolean | *Optional* Permanently give up the ability to freeze individual trust lines. This flag can never be disabled after being enabled.
|
noFreeze | boolean | *Optional* Permanently give up the ability to freeze individual trust lines. This flag can never be disabled after being enabled.
|
||||||
passwordSpent | boolean | *Optional* Indicates that the account has used its free SetRegularKey transaction.
|
passwordSpent | boolean | *Optional* Indicates that the account has used its free SetRegularKey transaction.
|
||||||
@@ -372,7 +487,14 @@ transferRate | number,null | *Optional* The fee to charge when users transfer t
|
|||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"domain": "ripple.com"
|
"domain": "ripple.com",
|
||||||
|
"memos": [
|
||||||
|
{
|
||||||
|
"type": "test",
|
||||||
|
"format": "plain/text",
|
||||||
|
"data": "texted data"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -386,19 +508,15 @@ Name | Type | Description
|
|||||||
source | object | Fields pertaining to the source of the payment.
|
source | object | Fields pertaining to the source of the payment.
|
||||||
*source.* address | [address](#ripple-address) | The address to send from.
|
*source.* address | [address](#ripple-address) | The address to send from.
|
||||||
*source.* maxAmount | [laxAmount](#amount) | The maximum amount to send. (This field is exclusive with source.amount)
|
*source.* maxAmount | [laxAmount](#amount) | The maximum amount to send. (This field is exclusive with source.amount)
|
||||||
*source.* tag | integer | *Optional* An arbitrary unsigned 32-bit integer most commonly used to identify a non-Ripple account.
|
*source.* tag | integer | *Optional* An arbitrary unsigned 32-bit integer that identifies a reason for payment or a non-Ripple account.
|
||||||
destination | object | Fields pertaining to the destination of the payment.
|
destination | object | Fields pertaining to the destination of the payment.
|
||||||
*destination.* address | [address](#ripple-address) | The address to receive at.
|
*destination.* address | [address](#ripple-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 is exclusive with destination.minAmount).
|
||||||
*destination.* tag | integer | *Optional* An arbitrary unsigned 32-bit integer most commonly used to identify a non-Ripple account.
|
*destination.* tag | integer | *Optional* An arbitrary unsigned 32-bit integer that identifies a reason for payment or a non-Ripple account.
|
||||||
allowCancelAfter | date-time string | *Optional* If present, the suspended payment may be cancelled after this time.
|
allowCancelAfter | date-time string | *Optional* If present, the suspended payment may be cancelled after this time.
|
||||||
allowExecuteAfter | date-time string | *Optional* If present, the suspended payment can not be executed before this time.
|
allowExecuteAfter | date-time string | *Optional* If present, the suspended payment can not be executed before this time.
|
||||||
digest | string | *Optional* If present, proof is required upon execution.
|
digest | string | *Optional* If present, proof is required upon execution.
|
||||||
memos | array | *Optional* Array of memos to attach to the transaction.
|
memos | [memos](#transaction-memos) | *Optional* Array of memos to attach to the transaction.
|
||||||
memos[] | object | Memo objects represent arbitrary data that can be included in a transaction
|
|
||||||
*memos[].* data | string | *Optional* Arbitrary string, conventionally containing the content of the memo.
|
|
||||||
*memos[].* format | string | *Optional* Conventionally containing information on how the memo is encoded, for example as a [MIME type](http://www.iana.org/assignments/media-types/media-types.xhtml). Only characters allowed in URLs are permitted.
|
|
||||||
*memos[].* type | string | *Optional* Conventionally, a unique relation (according to [RFC 5988](http://tools.ietf.org/html/rfc5988#section-4)) that defines the format of this memo. Only characters allowed in URLs are permitted.
|
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
|
|
||||||
@@ -434,11 +552,7 @@ Name | Type | Description
|
|||||||
---- | ---- | -----------
|
---- | ---- | -----------
|
||||||
owner | [address](#ripple-address) | The address of the owner of the suspended payment to cancel.
|
owner | [address](#ripple-address) | The address of the owner of the suspended payment to cancel.
|
||||||
suspensionSequence | [sequence](#account-sequence-number) | The [account sequence number](#account-sequence-number) of the [Suspended Payment Creation](#suspended-payment-creation) transaction for the suspended payment to cancel.
|
suspensionSequence | [sequence](#account-sequence-number) | The [account sequence number](#account-sequence-number) of the [Suspended Payment Creation](#suspended-payment-creation) transaction for the suspended payment to cancel.
|
||||||
memos | array | *Optional* Array of memos to attach to the transaction.
|
memos | [memos](#transaction-memos) | *Optional* Array of memos to attach to the transaction.
|
||||||
memos[] | object | Memo objects represent arbitrary data that can be included in a transaction
|
|
||||||
*memos[].* data | string | *Optional* Arbitrary string, conventionally containing the content of the memo.
|
|
||||||
*memos[].* format | string | *Optional* Conventionally containing information on how the memo is encoded, for example as a [MIME type](http://www.iana.org/assignments/media-types/media-types.xhtml). Only characters allowed in URLs are permitted.
|
|
||||||
*memos[].* type | string | *Optional* Conventionally, a unique relation (according to [RFC 5988](http://tools.ietf.org/html/rfc5988#section-4)) that defines the format of this memo. Only characters allowed in URLs are permitted.
|
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
|
|
||||||
@@ -460,11 +574,7 @@ Name | Type | Description
|
|||||||
owner | [address](#ripple-address) | The address of the owner of the suspended payment to execute.
|
owner | [address](#ripple-address) | The address of the owner of the suspended payment to execute.
|
||||||
suspensionSequence | [sequence](#account-sequence-number) | The [account sequence number](#account-sequence-number) of the [Suspended Payment Creation](#suspended-payment-creation) transaction for the suspended payment to execute.
|
suspensionSequence | [sequence](#account-sequence-number) | The [account sequence number](#account-sequence-number) of the [Suspended Payment Creation](#suspended-payment-creation) transaction for the suspended payment to execute.
|
||||||
digest | string | *Optional* The original `digest` from the suspended payment creation transaction. This is sha256 hash of `proof` string. It is replicated here so that the relatively expensive hashing operation can be delegated to a server without ledger history and the server with ledger history only has to do a quick comparison of the old digest with the new digest.
|
digest | string | *Optional* The original `digest` from the suspended payment creation transaction. This is sha256 hash of `proof` string. It is replicated here so that the relatively expensive hashing operation can be delegated to a server without ledger history and the server with ledger history only has to do a quick comparison of the old digest with the new digest.
|
||||||
memos | array | *Optional* Array of memos to attach to the transaction.
|
memos | [memos](#transaction-memos) | *Optional* Array of memos to attach to the transaction.
|
||||||
memos[] | object | Memo objects represent arbitrary data that can be included in a transaction
|
|
||||||
*memos[].* data | string | *Optional* Arbitrary string, conventionally containing the content of the memo.
|
|
||||||
*memos[].* format | string | *Optional* Conventionally containing information on how the memo is encoded, for example as a [MIME type](http://www.iana.org/assignments/media-types/media-types.xhtml). Only characters allowed in URLs are permitted.
|
|
||||||
*memos[].* type | string | *Optional* Conventionally, a unique relation (according to [RFC 5988](http://tools.ietf.org/html/rfc5988#section-4)) that defines the format of this memo. Only characters allowed in URLs are permitted.
|
|
||||||
method | integer | *Optional* The method for verifying the proof; only method `1` is supported.
|
method | integer | *Optional* The method for verifying the proof; only method `1` is supported.
|
||||||
proof | string | *Optional* A value that produces the digest when hashed. It must be 32 charaters long and contain only 8-bit characters.
|
proof | string | *Optional* A value that produces the digest when hashed. It must be 32 charaters long and contain only 8-bit characters.
|
||||||
|
|
||||||
@@ -488,7 +598,7 @@ proof | string | *Optional* A value that produces the digest when hashed. It mus
|
|||||||
|
|
||||||
`connect(): Promise<void>`
|
`connect(): Promise<void>`
|
||||||
|
|
||||||
Tells the RippleAPI instance to connect to its server(s).
|
Tells the RippleAPI instance to connect to its rippled server.
|
||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
|
|
||||||
@@ -506,7 +616,7 @@ See [Boilerplate](#boilerplate) for code sample.
|
|||||||
|
|
||||||
`disconnect(): Promise<void>`
|
`disconnect(): Promise<void>`
|
||||||
|
|
||||||
Tells the RippleAPI instance to disconnect from its server(s).
|
Tells the RippleAPI instance to disconnect from its rippled server.
|
||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
|
|
||||||
@@ -524,7 +634,7 @@ See [Boilerplate](#boilerplate) for code sample
|
|||||||
|
|
||||||
`isConnected(): boolean`
|
`isConnected(): boolean`
|
||||||
|
|
||||||
Checks if the RippleAPI instance is connected to its server(s).
|
Checks if the RippleAPI instance is connected to its rippled server.
|
||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
|
|
||||||
@@ -573,10 +683,10 @@ pubkeyNode | string | Public key used to verify this node for internal communica
|
|||||||
serverState | string | A string indicating to what extent the server is participating in the network. See [Possible Server States](https://ripple.com/build/rippled-apis/#possible-server-states) for more details.
|
serverState | string | A string indicating to what extent the server is participating in the network. See [Possible Server States](https://ripple.com/build/rippled-apis/#possible-server-states) for more details.
|
||||||
validatedLedger | object | Information about the fully-validated ledger with the highest sequence number (the most recent).
|
validatedLedger | object | Information about the fully-validated ledger with the highest sequence number (the most recent).
|
||||||
*validatedLedger.* age | integer | The time since the ledger was closed, in seconds.
|
*validatedLedger.* age | integer | The time since the ledger was closed, in seconds.
|
||||||
*validatedLedger.* baseFeeXRP | number | Base fee, in XRP. This may be represented in scientific notation such as 1e-05 for 0.00005.
|
*validatedLedger.* baseFeeXRP | [value](#value) | Base fee, in XRP. This may be represented in scientific notation such as 1e-05 for 0.00005.
|
||||||
*validatedLedger.* hash | string | Unique hash for the ledger, as an uppercase hexadecimal string.
|
*validatedLedger.* hash | string | Unique hash for the ledger, as an uppercase hexadecimal string.
|
||||||
*validatedLedger.* reserveBaseXRP | integer | Minimum amount of XRP (not drops) necessary for every account to keep in reserve.
|
*validatedLedger.* reserveBaseXRP | [value](#value) | Minimum amount of XRP necessary for every account to keep in reserve.
|
||||||
*validatedLedger.* reserveIncrementXRP | integer | Amount of XRP (not drops) added to the account reserve for each object an account is responsible for in the ledger.
|
*validatedLedger.* reserveIncrementXRP | [value](#value) | Amount of XRP added to the account reserve for each object an account is responsible for in the ledger.
|
||||||
*validatedLedger.* ledgerVersion | integer | Identifying sequence number of this ledger version.
|
*validatedLedger.* ledgerVersion | integer | Identifying sequence number of this ledger version.
|
||||||
validationQuorum | number | Minimum number of trusted validations required in order to validate a ledger version. Some circumstances may cause the server to require more validations.
|
validationQuorum | number | Minimum number of trusted validations required in order to validate a ledger version. Some circumstances may cause the server to require more validations.
|
||||||
load | object | *Optional* *(Admin only)* Detailed information about the current load state of the server.
|
load | object | *Optional* *(Admin only)* Detailed information about the current load state of the server.
|
||||||
@@ -607,10 +717,10 @@ return api.getServerInfo().then(info => {/* ... */});
|
|||||||
"serverState": "full",
|
"serverState": "full",
|
||||||
"validatedLedger": {
|
"validatedLedger": {
|
||||||
"age": 5,
|
"age": 5,
|
||||||
"baseFeeXRP": 0.00001,
|
"baseFeeXRP": "0.00001",
|
||||||
"hash": "4482DEE5362332F54A4036ED57EE1767C9F33CF7CE5A6670355C16CECE381D46",
|
"hash": "4482DEE5362332F54A4036ED57EE1767C9F33CF7CE5A6670355C16CECE381D46",
|
||||||
"reserveBaseXRP": 20,
|
"reserveBaseXRP": "20",
|
||||||
"reserveIncrementXRP": 5,
|
"reserveIncrementXRP": "5",
|
||||||
"ledgerVersion": 6595042
|
"ledgerVersion": 6595042
|
||||||
},
|
},
|
||||||
"validationQuorum": 3
|
"validationQuorum": 3
|
||||||
@@ -622,7 +732,7 @@ return api.getServerInfo().then(info => {/* ... */});
|
|||||||
|
|
||||||
`getFee(): Promise<number>`
|
`getFee(): Promise<number>`
|
||||||
|
|
||||||
Returns the estimated transaction fee for the server(s) the RippleAPI instance is connected to.
|
Returns the estimated transaction fee for the rippled server the RippleAPI instance is connected to.
|
||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
|
|
||||||
@@ -630,7 +740,7 @@ This method has no parameters.
|
|||||||
|
|
||||||
### Return Value
|
### Return Value
|
||||||
|
|
||||||
This method returns a promise that resolves with a 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
|
### Example
|
||||||
|
|
||||||
@@ -639,7 +749,7 @@ return api.getFee().then(fee => {/* ... */});
|
|||||||
```
|
```
|
||||||
|
|
||||||
```json
|
```json
|
||||||
0.012
|
"0.012"
|
||||||
```
|
```
|
||||||
|
|
||||||
## getLedgerVersion
|
## getLedgerVersion
|
||||||
@@ -1070,7 +1180,7 @@ counterparty | object | Properties of the trustline from the perspective of the
|
|||||||
*counterparty.* frozen | boolean | *Optional* If true, the trustline is frozen, which means that funds can only be sent to the counterparty.
|
*counterparty.* frozen | boolean | *Optional* If true, the trustline is frozen, which means that funds can only be sent to the counterparty.
|
||||||
*counterparty.* ripplingDisabled | boolean | *Optional* If true, payments cannot ripple through this trustline.
|
*counterparty.* ripplingDisabled | boolean | *Optional* If true, payments cannot ripple through this trustline.
|
||||||
state | object | Properties of the trustline regarding it's current state that are not part of the specification.
|
state | object | Properties of the trustline regarding it's current state that are not part of the specification.
|
||||||
*state.* balance | [value](#value) | The balance on the trustline, representing which party owes the other and by how much.
|
*state.* balance | [signedValue](#value) | The balance on the trustline, representing which party owes the other and by how much.
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
|
|
||||||
@@ -1476,12 +1586,12 @@ Name | Type | Description
|
|||||||
source | object | Properties of the source of the payment.
|
source | object | Properties of the source of the payment.
|
||||||
*source.* address | [address](#ripple-address) | The address to send from.
|
*source.* address | [address](#ripple-address) | The address to send from.
|
||||||
*source.* amount | [laxAmount](#amount) | An exact amount to send. If the counterparty is not specified, amounts with any counterparty may be used. (This field is exclusive with source.maxAmount)
|
*source.* amount | [laxAmount](#amount) | An exact amount to send. If the counterparty is not specified, amounts with any counterparty may be used. (This field is exclusive with source.maxAmount)
|
||||||
*source.* tag | integer | *Optional* An arbitrary unsigned 32-bit integer most commonly used to identify a non-Ripple account.
|
*source.* tag | integer | *Optional* An arbitrary unsigned 32-bit integer that identifies a reason for payment or a non-Ripple account.
|
||||||
*source.* maxAmount | [laxAmount](#amount) | The maximum amount to send. (This field is exclusive with source.amount)
|
*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 | object | Properties of the destination of the payment.
|
||||||
*destination.* address | [address](#ripple-address) | The address to receive at.
|
*destination.* address | [address](#ripple-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 is exclusive with destination.minAmount).
|
||||||
*destination.* tag | integer | *Optional* An arbitrary unsigned 32-bit integer most commonly used to identify a non-Ripple account.
|
*destination.* tag | integer | *Optional* An arbitrary unsigned 32-bit integer that identifies a reason for payment or a non-Ripple account.
|
||||||
*destination.* address | [address](#ripple-address) | The address to send to.
|
*destination.* address | [address](#ripple-address) | The address to send to.
|
||||||
*destination.* minAmount | [laxAmount](#amount) | The minimum amount to be delivered. (This field is exclusive with destination.amount)
|
*destination.* minAmount | [laxAmount](#amount) | The minimum amount to be delivered. (This field is exclusive with destination.amount)
|
||||||
paths | string | The paths of trustlines and orders to use in executing the payment.
|
paths | string | The paths of trustlines and orders to use in executing the payment.
|
||||||
@@ -2527,6 +2637,7 @@ domain | string | *Optional* The domain that owns this account, as a hexadecima
|
|||||||
emailHash | string,null | *Optional* Hash of an email address to be used for generating an avatar image. Conventionally, clients use Gravatar to display this image. Use `null` to clear.
|
emailHash | string,null | *Optional* Hash of an email address to be used for generating an avatar image. Conventionally, clients use Gravatar to display this image. Use `null` to clear.
|
||||||
enableTransactionIDTracking | boolean | *Optional* Track the ID of this account’s most recent transaction.
|
enableTransactionIDTracking | boolean | *Optional* Track the ID of this account’s most recent transaction.
|
||||||
globalFreeze | boolean | *Optional* Freeze all assets issued by this account.
|
globalFreeze | boolean | *Optional* Freeze all assets issued by this account.
|
||||||
|
memos | [memos](#transaction-memos) | *Optional* Array of memos to attach to the transaction.
|
||||||
messageKey | string | *Optional* Public key for sending encrypted messages to this account. Conventionally, it should be a secp256k1 key, the same encryption that is used by the rest of Ripple.
|
messageKey | string | *Optional* Public key for sending encrypted messages to this account. Conventionally, it should be a secp256k1 key, the same encryption that is used by the rest of Ripple.
|
||||||
noFreeze | boolean | *Optional* Permanently give up the ability to freeze individual trust lines. This flag can never be disabled after being enabled.
|
noFreeze | boolean | *Optional* Permanently give up the ability to freeze individual trust lines. This flag can never be disabled after being enabled.
|
||||||
passwordSpent | boolean | *Optional* Indicates that the account has used its free SetRegularKey transaction.
|
passwordSpent | boolean | *Optional* Indicates that the account has used its free SetRegularKey transaction.
|
||||||
@@ -2692,7 +2803,7 @@ txJSON | string | The prepared transaction in rippled JSON format.
|
|||||||
instructions | object | The instructions for how to execute the transaction after adding automatic defaults.
|
instructions | object | The instructions for how to execute the transaction after adding automatic defaults.
|
||||||
*instructions.* fee | [value](#value) | An exact fee to pay for the transaction. See [Transaction Fees](#transaction-fees) for more information.
|
*instructions.* fee | [value](#value) | An exact fee to pay for the transaction. See [Transaction Fees](#transaction-fees) for more information.
|
||||||
*instructions.* sequence | [sequence](#account-sequence-number) | The initiating account's sequence number for this transaction.
|
*instructions.* sequence | [sequence](#account-sequence-number) | The initiating account's sequence number for this transaction.
|
||||||
*instructions.* maxLedgerVersion | integer | *Optional* The highest ledger version that the transaction can be included in.
|
*instructions.* maxLedgerVersion | integer,null | The highest ledger version that the transaction can be included in. Set to `null` if there is no maximum.
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
|
|
||||||
@@ -2761,7 +2872,7 @@ txJSON | string | The prepared transaction in rippled JSON format.
|
|||||||
instructions | object | The instructions for how to execute the transaction after adding automatic defaults.
|
instructions | object | The instructions for how to execute the transaction after adding automatic defaults.
|
||||||
*instructions.* fee | [value](#value) | An exact fee to pay for the transaction. See [Transaction Fees](#transaction-fees) for more information.
|
*instructions.* fee | [value](#value) | An exact fee to pay for the transaction. See [Transaction Fees](#transaction-fees) for more information.
|
||||||
*instructions.* sequence | [sequence](#account-sequence-number) | The initiating account's sequence number for this transaction.
|
*instructions.* sequence | [sequence](#account-sequence-number) | The initiating account's sequence number for this transaction.
|
||||||
*instructions.* maxLedgerVersion | integer | *Optional* The highest ledger version that the transaction can be included in.
|
*instructions.* maxLedgerVersion | integer,null | The highest ledger version that the transaction can be included in. Set to `null` if there is no maximum.
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
|
|
||||||
@@ -2774,7 +2885,14 @@ const trustline = {
|
|||||||
"qualityIn": 0.91,
|
"qualityIn": 0.91,
|
||||||
"qualityOut": 0.87,
|
"qualityOut": 0.87,
|
||||||
"ripplingDisabled": true,
|
"ripplingDisabled": true,
|
||||||
"frozen": false
|
"frozen": false,
|
||||||
|
"memos": [
|
||||||
|
{
|
||||||
|
"type": "test",
|
||||||
|
"format": "plain/text",
|
||||||
|
"data": "texted data"
|
||||||
|
}
|
||||||
|
]
|
||||||
};
|
};
|
||||||
return api.preparePayment(address, trustline).then(prepared =>
|
return api.preparePayment(address, trustline).then(prepared =>
|
||||||
{/* ... */});
|
{/* ... */});
|
||||||
@@ -2783,7 +2901,7 @@ return api.preparePayment(address, trustline).then(prepared =>
|
|||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"txJSON": "{\"Flags\":2149711872,\"TransactionType\":\"TrustSet\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"LimitAmount\":{\"value\":\"10000\",\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\"},\"QualityIn\":910000000,\"QualityOut\":870000000,\"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\":\"706C61696E2F74657874\"}}],\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
|
||||||
"instructions": {
|
"instructions": {
|
||||||
"fee": "0.000012",
|
"fee": "0.000012",
|
||||||
"sequence": 23,
|
"sequence": 23,
|
||||||
@@ -2812,7 +2930,7 @@ instructions | [instructions](#transaction-instructions) | *Optional* Instructio
|
|||||||
This method returns a promise that resolves with an object with the following structure:
|
This method returns a promise that resolves with an object with the following structure:
|
||||||
|
|
||||||
<aside class="notice">
|
<aside class="notice">
|
||||||
All "prepare" methods have the same return type.
|
All "prepare*" methods have the same return type.
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
Name | Type | Description
|
Name | Type | Description
|
||||||
@@ -2821,7 +2939,7 @@ txJSON | string | The prepared transaction in rippled JSON format.
|
|||||||
instructions | object | The instructions for how to execute the transaction after adding automatic defaults.
|
instructions | object | The instructions for how to execute the transaction after adding automatic defaults.
|
||||||
*instructions.* fee | [value](#value) | An exact fee to pay for the transaction. See [Transaction Fees](#transaction-fees) for more information.
|
*instructions.* fee | [value](#value) | An exact fee to pay for the transaction. See [Transaction Fees](#transaction-fees) for more information.
|
||||||
*instructions.* sequence | [sequence](#account-sequence-number) | The initiating account's sequence number for this transaction.
|
*instructions.* sequence | [sequence](#account-sequence-number) | The initiating account's sequence number for this transaction.
|
||||||
*instructions.* maxLedgerVersion | integer | *Optional* The highest ledger version that the transaction can be included in.
|
*instructions.* maxLedgerVersion | integer,null | The highest ledger version that the transaction can be included in. Set to `null` if there is no maximum.
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
|
|
||||||
@@ -2838,7 +2956,8 @@ const order = {
|
|||||||
"currency": "XRP",
|
"currency": "XRP",
|
||||||
"value": "2"
|
"value": "2"
|
||||||
},
|
},
|
||||||
"immediateOrCancel": true
|
"passive": true,
|
||||||
|
"fillOrKill": true
|
||||||
};
|
};
|
||||||
return api.prepareOrder(address, order)
|
return api.prepareOrder(address, order)
|
||||||
.then(prepared => {/* ... */});
|
.then(prepared => {/* ... */});
|
||||||
@@ -2847,11 +2966,11 @@ return api.prepareOrder(address, order)
|
|||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"txJSON": "{\"Flags\":2147614720,\"TransactionType\":\"OfferCreate\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"TakerGets\":\"2000000\",\"TakerPays\":{\"value\":\"10.1\",\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\"},\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
|
"txJSON": "{\"Flags\":2147811328,\"TransactionType\":\"OfferCreate\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"TakerGets\":\"2000000\",\"TakerPays\":{\"value\":\"10.1\",\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\"},\"LastLedgerSequence\":8819954,\"Fee\":\"12\",\"Sequence\":23}",
|
||||||
"instructions": {
|
"instructions": {
|
||||||
"fee": "0.000012",
|
"fee": "0.000012",
|
||||||
"sequence": 23,
|
"sequence": 23,
|
||||||
"maxLedgerVersion": 8820051
|
"maxLedgerVersion": 8819954
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@@ -2859,7 +2978,7 @@ return api.prepareOrder(address, order)
|
|||||||
|
|
||||||
## prepareOrderCancellation
|
## prepareOrderCancellation
|
||||||
|
|
||||||
`prepareOrderCancellation(address: string, sequence: number, instructions: Object): Promise<Object>`
|
`prepareOrderCancellation(address: string, orderCancellation: Object, instructions: Object): Promise<Object>`
|
||||||
|
|
||||||
Prepare an order cancellation transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
|
Prepare an order cancellation transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
|
||||||
|
|
||||||
@@ -2868,7 +2987,7 @@ Prepare an order cancellation transaction. The prepared transaction must subsequ
|
|||||||
Name | Type | Description
|
Name | Type | Description
|
||||||
---- | ---- | -----------
|
---- | ---- | -----------
|
||||||
address | [address](#ripple-address) | The address of the account that is creating the transaction.
|
address | [address](#ripple-address) | The address of the account that is creating the transaction.
|
||||||
sequence | [sequence](#account-sequence-number) | The account sequence number of the transaction that created the order to cancel.
|
orderCancellation | [orderCancellation](#order-cancellation) | The specification of the order cancellation to prepare.
|
||||||
instructions | [instructions](#transaction-instructions) | *Optional* Instructions for executing the transaction
|
instructions | [instructions](#transaction-instructions) | *Optional* Instructions for executing the transaction
|
||||||
|
|
||||||
### Return Value
|
### Return Value
|
||||||
@@ -2876,7 +2995,7 @@ instructions | [instructions](#transaction-instructions) | *Optional* Instructio
|
|||||||
This method returns a promise that resolves with an object with the following structure:
|
This method returns a promise that resolves with an object with the following structure:
|
||||||
|
|
||||||
<aside class="notice">
|
<aside class="notice">
|
||||||
All "prepare" methods have the same return type.
|
All "prepare*" methods have the same return type.
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
Name | Type | Description
|
Name | Type | Description
|
||||||
@@ -2885,13 +3004,13 @@ txJSON | string | The prepared transaction in rippled JSON format.
|
|||||||
instructions | object | The instructions for how to execute the transaction after adding automatic defaults.
|
instructions | object | The instructions for how to execute the transaction after adding automatic defaults.
|
||||||
*instructions.* fee | [value](#value) | An exact fee to pay for the transaction. See [Transaction Fees](#transaction-fees) for more information.
|
*instructions.* fee | [value](#value) | An exact fee to pay for the transaction. See [Transaction Fees](#transaction-fees) for more information.
|
||||||
*instructions.* sequence | [sequence](#account-sequence-number) | The initiating account's sequence number for this transaction.
|
*instructions.* sequence | [sequence](#account-sequence-number) | The initiating account's sequence number for this transaction.
|
||||||
*instructions.* maxLedgerVersion | integer | *Optional* The highest ledger version that the transaction can be included in.
|
*instructions.* maxLedgerVersion | integer,null | The highest ledger version that the transaction can be included in. Set to `null` if there is no maximum.
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const address = 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59';
|
const address = 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59';
|
||||||
const sequence = 123;
|
const orderCancellation = {orderSequence: 123};
|
||||||
return api.prepareOrderCancellation(address, sequence)
|
return api.prepareOrderCancellation(address, sequence)
|
||||||
.then(prepared => {/* ... */});
|
.then(prepared => {/* ... */});
|
||||||
```
|
```
|
||||||
@@ -2937,14 +3056,21 @@ txJSON | string | The prepared transaction in rippled JSON format.
|
|||||||
instructions | object | The instructions for how to execute the transaction after adding automatic defaults.
|
instructions | object | The instructions for how to execute the transaction after adding automatic defaults.
|
||||||
*instructions.* fee | [value](#value) | An exact fee to pay for the transaction. See [Transaction Fees](#transaction-fees) for more information.
|
*instructions.* fee | [value](#value) | An exact fee to pay for the transaction. See [Transaction Fees](#transaction-fees) for more information.
|
||||||
*instructions.* sequence | [sequence](#account-sequence-number) | The initiating account's sequence number for this transaction.
|
*instructions.* sequence | [sequence](#account-sequence-number) | The initiating account's sequence number for this transaction.
|
||||||
*instructions.* maxLedgerVersion | integer | *Optional* The highest ledger version that the transaction can be included in.
|
*instructions.* maxLedgerVersion | integer,null | The highest ledger version that the transaction can be included in. Set to `null` if there is no maximum.
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const address = 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59';
|
const address = 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59';
|
||||||
const settings = {
|
const settings = {
|
||||||
"domain": "ripple.com"
|
"domain": "ripple.com",
|
||||||
|
"memos": [
|
||||||
|
{
|
||||||
|
"type": "test",
|
||||||
|
"format": "plain/text",
|
||||||
|
"data": "texted data"
|
||||||
|
}
|
||||||
|
]
|
||||||
};
|
};
|
||||||
return api.prepareSettings(address, settings)
|
return api.prepareSettings(address, settings)
|
||||||
.then(prepared => {/* ... */});
|
.then(prepared => {/* ... */});
|
||||||
@@ -2953,7 +3079,14 @@ return api.prepareSettings(address, settings)
|
|||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"domain": "ripple.com"
|
"domain": "ripple.com",
|
||||||
|
"memos": [
|
||||||
|
{
|
||||||
|
"type": "test",
|
||||||
|
"format": "plain/text",
|
||||||
|
"data": "texted data"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -2964,6 +3097,8 @@ return api.prepareSettings(address, settings)
|
|||||||
|
|
||||||
Prepare a suspended payment creation transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
|
Prepare a suspended payment creation transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
|
||||||
|
|
||||||
|
**Caution:** Suspended Payments are currently available on the [Ripple Test Net](https://ripple.com/build/ripple-test-net/) only.
|
||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
|
|
||||||
Name | Type | Description
|
Name | Type | Description
|
||||||
@@ -2986,7 +3121,7 @@ txJSON | string | The prepared transaction in rippled JSON format.
|
|||||||
instructions | object | The instructions for how to execute the transaction after adding automatic defaults.
|
instructions | object | The instructions for how to execute the transaction after adding automatic defaults.
|
||||||
*instructions.* fee | [value](#value) | An exact fee to pay for the transaction. See [Transaction Fees](#transaction-fees) for more information.
|
*instructions.* fee | [value](#value) | An exact fee to pay for the transaction. See [Transaction Fees](#transaction-fees) for more information.
|
||||||
*instructions.* sequence | [sequence](#account-sequence-number) | The initiating account's sequence number for this transaction.
|
*instructions.* sequence | [sequence](#account-sequence-number) | The initiating account's sequence number for this transaction.
|
||||||
*instructions.* maxLedgerVersion | integer | *Optional* The highest ledger version that the transaction can be included in.
|
*instructions.* maxLedgerVersion | integer,null | The highest ledger version that the transaction can be included in. Set to `null` if there is no maximum.
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
|
|
||||||
@@ -3034,6 +3169,8 @@ return api.prepareSuspendedPaymentCreation(address, suspendedPaymentCreation).th
|
|||||||
|
|
||||||
Prepare a suspended payment cancellation transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
|
Prepare a suspended payment cancellation transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
|
||||||
|
|
||||||
|
**Caution:** Suspended Payments are currently available on the [Ripple Test Net](https://ripple.com/build/ripple-test-net/) only.
|
||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
|
|
||||||
Name | Type | Description
|
Name | Type | Description
|
||||||
@@ -3056,7 +3193,7 @@ txJSON | string | The prepared transaction in rippled JSON format.
|
|||||||
instructions | object | The instructions for how to execute the transaction after adding automatic defaults.
|
instructions | object | The instructions for how to execute the transaction after adding automatic defaults.
|
||||||
*instructions.* fee | [value](#value) | An exact fee to pay for the transaction. See [Transaction Fees](#transaction-fees) for more information.
|
*instructions.* fee | [value](#value) | An exact fee to pay for the transaction. See [Transaction Fees](#transaction-fees) for more information.
|
||||||
*instructions.* sequence | [sequence](#account-sequence-number) | The initiating account's sequence number for this transaction.
|
*instructions.* sequence | [sequence](#account-sequence-number) | The initiating account's sequence number for this transaction.
|
||||||
*instructions.* maxLedgerVersion | integer | *Optional* The highest ledger version that the transaction can be included in.
|
*instructions.* maxLedgerVersion | integer,null | The highest ledger version that the transaction can be included in. Set to `null` if there is no maximum.
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
|
|
||||||
@@ -3089,6 +3226,8 @@ return api.prepareSuspendedPaymentCancellation(address, suspendedPaymentCancella
|
|||||||
|
|
||||||
Prepare a suspended payment execution transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
|
Prepare a suspended payment execution transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
|
||||||
|
|
||||||
|
**Caution:** Suspended Payments are currently available on the [Ripple Test Net](https://ripple.com/build/ripple-test-net/) only.
|
||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
|
|
||||||
Name | Type | Description
|
Name | Type | Description
|
||||||
@@ -3111,7 +3250,7 @@ txJSON | string | The prepared transaction in rippled JSON format.
|
|||||||
instructions | object | The instructions for how to execute the transaction after adding automatic defaults.
|
instructions | object | The instructions for how to execute the transaction after adding automatic defaults.
|
||||||
*instructions.* fee | [value](#value) | An exact fee to pay for the transaction. See [Transaction Fees](#transaction-fees) for more information.
|
*instructions.* fee | [value](#value) | An exact fee to pay for the transaction. See [Transaction Fees](#transaction-fees) for more information.
|
||||||
*instructions.* sequence | [sequence](#account-sequence-number) | The initiating account's sequence number for this transaction.
|
*instructions.* sequence | [sequence](#account-sequence-number) | The initiating account's sequence number for this transaction.
|
||||||
*instructions.* maxLedgerVersion | integer | *Optional* The highest ledger version that the transaction can be included in.
|
*instructions.* maxLedgerVersion | integer,null | The highest ledger version that the transaction can be included in. Set to `null` if there is no maximum.
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
|
|
||||||
@@ -3226,7 +3365,11 @@ Generate a new Ripple address and corresponding secret.
|
|||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
|
|
||||||
This method has no parameters.
|
Name | Type | Description
|
||||||
|
---- | ---- | -----------
|
||||||
|
options | object | *Optional* Options to control how the address and secret are generated.
|
||||||
|
*options.* algorithm | string | *Optional* The digital signature algorithm to generate an address for. Can be `ecdsa-secp256k1` (default) or `ed25519`.
|
||||||
|
*options.* entropy | array\<integer\> | *Optional* The entropy to use to generate the seed.
|
||||||
|
|
||||||
### Return Value
|
### Return Value
|
||||||
|
|
||||||
@@ -3240,8 +3383,7 @@ secret | secret string | The secret corresponding to the `address`.
|
|||||||
### Example
|
### Example
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
return api.generateAddress()
|
return api.generateAddress();
|
||||||
.then(result => {/* ... */});
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@@ -3311,7 +3453,7 @@ return api.computeLedgerHash(ledger);
|
|||||||
|
|
||||||
# API Events
|
# API Events
|
||||||
|
|
||||||
## ledgerClosed
|
## ledger
|
||||||
|
|
||||||
This event is emitted whenever a new ledger version is validated on the connected server.
|
This event is emitted whenever a new ledger version is validated on the connected server.
|
||||||
|
|
||||||
@@ -3319,12 +3461,11 @@ This event is emitted whenever a new ledger version is validated on the connecte
|
|||||||
|
|
||||||
Name | Type | Description
|
Name | Type | Description
|
||||||
---- | ---- | -----------
|
---- | ---- | -----------
|
||||||
feeBase | integer | Base fee, in drops.
|
baseFeeXRP | [value](#value) | Base fee, in XRP.
|
||||||
feeReference | integer | Cost of the 'reference transaction' in 'fee units'.
|
|
||||||
ledgerHash | string | Unique hash of the ledger that was closed, as hex.
|
ledgerHash | string | Unique hash of the ledger that was closed, as hex.
|
||||||
ledgerTimestamp | date-time string | The time at which this ledger closed.
|
ledgerTimestamp | date-time string | The time at which this ledger closed.
|
||||||
reserveBase | integer | The minimum reserve, in drops of XRP, that is required for an account.
|
reserveBaseXRP | [value](#value) | The minimum reserve, in XRP, that is required for an account.
|
||||||
reserveIncrement | integer | The increase in account reserve that is added for each item the account owns, such as offers or trust lines.
|
reserveIncrementXRP | [value](#value) | The increase in account reserve that is added for each item the account owns, such as offers or trust lines.
|
||||||
transactionCount | integer | Number of new transactions included in this ledger.
|
transactionCount | integer | Number of new transactions included in this ledger.
|
||||||
ledgerVersion | integer | Ledger version of the ledger that closed.
|
ledgerVersion | integer | Ledger version of the ledger that closed.
|
||||||
validatedLedgerVersions | string | Range of ledgers that the server has available. This may be discontiguous.
|
validatedLedgerVersions | string | Range of ledgers that the server has available. This may be discontiguous.
|
||||||
@@ -3332,7 +3473,7 @@ validatedLedgerVersions | string | Range of ledgers that the server has availabl
|
|||||||
### Example
|
### Example
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
api.on('ledgerClosed', ledger => {
|
api.on('ledger', ledger => {
|
||||||
console.log(JSON.stringify(ledger, null, 2));
|
console.log(JSON.stringify(ledger, null, 2));
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
@@ -3340,13 +3481,12 @@ api.on('ledgerClosed', ledger => {
|
|||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"feeBase": 10,
|
"baseFeeXRP": "0.00001",
|
||||||
"feeReference": 10,
|
|
||||||
"ledgerVersion": 14804627,
|
"ledgerVersion": 14804627,
|
||||||
"ledgerHash": "9141FA171F2C0CE63E609466AF728FF66C12F7ACD4B4B50B0947A7F3409D593A",
|
"ledgerHash": "9141FA171F2C0CE63E609466AF728FF66C12F7ACD4B4B50B0947A7F3409D593A",
|
||||||
"ledgerTimestamp": "2015-07-23T05:50:40.000Z",
|
"ledgerTimestamp": "2015-07-23T05:50:40.000Z",
|
||||||
"reserveBase": 20000000,
|
"reserveBaseXRP": "20",
|
||||||
"reserveIncrement": 5000000,
|
"reserveIncrementXRP": "5",
|
||||||
"transactionCount": 19,
|
"transactionCount": 19,
|
||||||
"validatedLedgerVersions": "13983423-14804627"
|
"validatedLedgerVersions": "13983423-14804627"
|
||||||
}
|
}
|
||||||
@@ -3355,16 +3495,26 @@ api.on('ledgerClosed', ledger => {
|
|||||||
|
|
||||||
## error
|
## error
|
||||||
|
|
||||||
This event is emitted when there is an error on the connection to the server.
|
This event is emitted when there is an error on the connection to the server that cannot be associated to a specific request.
|
||||||
|
|
||||||
### Return Value
|
### Return Value
|
||||||
|
|
||||||
The first parameter is a string indicating the error type, which may be `badMessage` (meaning that rippled returned a malformed message), or one of the [rippled Universal Errors](https://ripple.com/build/rippled-apis/#universal-errors). The second parameter is a message explaining the error, or the message that caused the error in the case of `badMessage`.
|
The first parameter is a string indicating the error type:
|
||||||
|
* `badMessage` - rippled returned a malformed message
|
||||||
|
* `websocket` - the websocket library emitted an error
|
||||||
|
* one of the error codes found in the [rippled Universal Errors](https://ripple.com/build/rippled-apis/#universal-errors).
|
||||||
|
|
||||||
|
The second parameter is a message explaining the error.
|
||||||
|
|
||||||
|
The third parameter is:
|
||||||
|
* the message that caused the error for `badMessage`
|
||||||
|
* the error object emitted for `websocket`
|
||||||
|
* the parsed response for rippled errors
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
api.on('error', (errorCode, errorMessage) => {
|
api.on('error', (errorCode, errorMessage, data) => {
|
||||||
console.log(errorCode + ': ' + errorMessage);
|
console.log(errorCode + ': ' + errorMessage);
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const RippleAPI = require('../../src').RippleAPI; // require('ripple-lib')
|
const RippleAPI = require('../../src').RippleAPI; // require('ripple-lib')
|
||||||
|
|
||||||
const api = new RippleAPI({servers: ['wss://s1.ripple.com:443']});
|
const api = new RippleAPI({server: 'wss://s1.ripple.com:443'});
|
||||||
const address = 'r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV';
|
const address = 'r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV';
|
||||||
|
|
||||||
api.connect().then(() => {
|
api.connect().then(() => {
|
||||||
|
|||||||
@@ -4,13 +4,13 @@ const RippleAPI = require('../../src').RippleAPI; // require('ripple-lib')
|
|||||||
const address = 'INSERT ADDRESS HERE';
|
const address = 'INSERT ADDRESS HERE';
|
||||||
const secret = 'INSERT SECRET HERE';
|
const secret = 'INSERT SECRET HERE';
|
||||||
|
|
||||||
const api = new RippleAPI({servers: ['wss://s1.ripple.com:443']});
|
const api = new RippleAPI({server: 'wss://s1.ripple.com:443'});
|
||||||
const instructions = {maxLedgerVersionOffset: 5};
|
const instructions = {maxLedgerVersionOffset: 5};
|
||||||
|
|
||||||
const payment = {
|
const payment = {
|
||||||
source: {
|
source: {
|
||||||
address: address,
|
address: address,
|
||||||
amount: {
|
maxAmount: {
|
||||||
value: '0.01',
|
value: '0.01',
|
||||||
currency: 'XRP'
|
currency: 'XRP'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,23 +6,28 @@
|
|||||||
"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59"
|
"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59"
|
||||||
```
|
```
|
||||||
|
|
||||||
Every Ripple account has an *address*, which is a base58-encoding of a hash of the account's public key.
|
Every Ripple account has an *address*, which is a base58-encoding of a hash of the account's public key. Ripple addresses always start with the lowercase letter `r`.
|
||||||
|
|
||||||
## Account Sequence Number
|
## Account Sequence Number
|
||||||
|
|
||||||
Every Ripple account has a *sequence number* that is used to order transactions. Every transaction must have a sequence number and transaction can only be executed in order by sequence number. This prevents one transaction from executing twice and transactions executing out of order. The sequence number starts at `1` and increments for each transaction that the account makes.
|
Every Ripple account has a *sequence number* that is used to keep transactions in order. Every transaction must have a sequence number. A transaction can only be executed if it has the next sequence number in order, of the account sending it. This prevents one transaction from executing twice and transactions executing out of order. The sequence number starts at `1` and increments for each transaction that the account makes.
|
||||||
|
|
||||||
## Currency
|
## Currency
|
||||||
|
|
||||||
Currencies are represented as either 3-character currency codes or 40-character uppercase hexadecimal strings. We recommend using uppercase [ISO 4217 Currency Codes](http://www.xe.com/iso4217.php) only. The string "XRP" is disallowed on trustlines because it is reserved for the Ripple native currency. The following characters are permitted: all uppercase and lowercase letters, digits, as well as the symbols `?`, `!`, `@`, `#`, `$`, `%`, `^`, `&`, `*`, `<`, `>`, `(`, `)`, `{`, `}`, `[`, `]`, and `|`.
|
Currencies are represented as either 3-character currency codes or 40-character uppercase hexadecimal strings. We recommend using uppercase [ISO 4217 Currency Codes](http://www.xe.com/iso4217.php) only. The string "XRP" is disallowed on trustlines because it is reserved for the Ripple native currency. The following characters are permitted: all uppercase and lowercase letters, digits, as well as the symbols `?`, `!`, `@`, `#`, `$`, `%`, `^`, `&`, `*`, `<`, `>`, `(`, `)`, `{`, `}`, `[`, `]`, and `|`.
|
||||||
|
|
||||||
## Value
|
## Value
|
||||||
A *value* is a quantity of a currency represented as a decimal string (string encoding is used because javascript numbers do not have sufficient precision).
|
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).
|
||||||
|
|
||||||
|
**Non-XRP values** have 15 decimal digits of precision, with a maximum value of `9999999999999999e80`. The smallest positive non-XRP value is `1e-81`.
|
||||||
|
|
||||||
An XRP value has 6 significant digits past the decimal point. A non-XRP value has 16 total digits of precision.
|
|
||||||
|
|
||||||
## Amount
|
## Amount
|
||||||
|
|
||||||
|
Example amount:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"currency": "USD",
|
"currency": "USD",
|
||||||
@@ -31,6 +36,7 @@ An XRP value has 6 significant digits past the decimal point. A non-XRP value ha
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Example XRP amount:
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"currency": "XRP",
|
"currency": "XRP",
|
||||||
@@ -38,7 +44,7 @@ An XRP value has 6 significant digits past the decimal point. A non-XRP value ha
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
An *amount* is data structure representing a currency, a quantity of that currency, and the counterparty on the trustline that holds the value (for all currencies besides "XRP").
|
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.
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,15 @@
|
|||||||
## Boilerplate
|
## Boilerplate
|
||||||
|
|
||||||
|
Use the following [boilerplate code](https://en.wikipedia.org/wiki/Boilerplate_code) to wrap your custom code using RippleAPI.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const {RippleAPI} = require('ripple-lib');
|
const {RippleAPI} = require('ripple-lib');
|
||||||
|
|
||||||
const api = new RippleAPI({
|
const api = new RippleAPI({
|
||||||
servers: ['wss://s1.ripple.com']
|
server: 'wss://s1.ripple.com' // Public rippled server hosted by Ripple, Inc.
|
||||||
|
});
|
||||||
|
api.on('error', (errorCode, errorMessage) => {
|
||||||
|
console.log(errorCode + ': ' + errorMessage);
|
||||||
});
|
});
|
||||||
api.connect().then(() => {
|
api.connect().then(() => {
|
||||||
/* insert code here */
|
/* insert code here */
|
||||||
@@ -13,22 +18,43 @@ api.connect().then(() => {
|
|||||||
}).catch(console.error);
|
}).catch(console.error);
|
||||||
```
|
```
|
||||||
|
|
||||||
To get started, first install [nodejs](https://nodejs.org) version `0.12.0` or greater, then:
|
RippleAPI is designed to work in [NodeJS](https://nodejs.org) (version `0.12.0` or greater) using [Babel](https://babeljs.io/) for [ECMAScript 6](https://babeljs.io/docs/learn-es2015/) support.
|
||||||
|
|
||||||
`npm install -g babel`
|
The code samples in this documentation are written in ES6, but `RippleAPI` will work with ES5 also. Regardless of whether you use ES5 or ES6, the methods that return promises will return [ES6-style promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise).
|
||||||
|
|
||||||
`npm install ripple-lib`
|
|
||||||
|
|
||||||
Then create a script based on the boilerplate shown here and run with:
|
|
||||||
|
|
||||||
`babel-node script.js`
|
|
||||||
|
|
||||||
The code samples in this documentation are written in ES6, but `RippleAPI` will work with ES5 also. Regardless of whether you use ES5 or ES6, the methods that return promises will return ES6-style promises.
|
|
||||||
|
|
||||||
<aside class="notice">
|
<aside class="notice">
|
||||||
All the code snippets in this documentation assume that you have surrounded them with this boilerplate.
|
All the code snippets in this documentation assume that you have surrounded them with this boilerplate.
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
<aside class="notice">
|
<aside class="notice">
|
||||||
Dont forget the "catch" or errors may not be visible.
|
If you omit the "catch" section, errors may not be visible.
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
|
<aside class="notice">
|
||||||
|
The "error" event is emitted whenever an error occurs that cannot be associated with a specific request. If the listener is not registered, an exception will be thrown whenever the event is emitted.
|
||||||
|
</aside>
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
The RippleAPI constructor optionally takes one argument, an object with the following options:
|
||||||
|
|
||||||
|
<%- renderSchema('input/api-options.json') %>
|
||||||
|
|
||||||
|
If you omit the `server` parameter, RippleAPI operates [offline](#offline-functionality).
|
||||||
|
|
||||||
|
|
||||||
|
### Installation ###
|
||||||
|
|
||||||
|
1. Install [NodeJS](https://nodejs.org) and the Node Package Manager (npm). Most Linux distros have a package for NodeJS, but make sure you have version `0.12.0` or higher.
|
||||||
|
2. Use npm to install [Babel](https://babeljs.io/) globally:
|
||||||
|
`npm install -g babel`
|
||||||
|
3. Use npm to install RippleAPI:
|
||||||
|
`npm install ripple-lib`
|
||||||
|
|
||||||
|
After you have installed ripple-lib, you can create scripts using the [boilerplate](#boilerplate) and run them using babel-node:
|
||||||
|
`babel-node script.js`
|
||||||
|
|
||||||
|
<aside class="notice">
|
||||||
|
Instead of using babel-node in production, we recommend using Babel to transpile to ECMAScript 5 first.
|
||||||
|
</aside>
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
`connect(): Promise<void>`
|
`connect(): Promise<void>`
|
||||||
|
|
||||||
Tells the RippleAPI instance to connect to its server(s).
|
Tells the RippleAPI instance to connect to its rippled server.
|
||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
`disconnect(): Promise<void>`
|
`disconnect(): Promise<void>`
|
||||||
|
|
||||||
Tells the RippleAPI instance to disconnect from its server(s).
|
Tells the RippleAPI instance to disconnect from its rippled server.
|
||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
|
|
||||||
|
|||||||
@@ -1,35 +1,45 @@
|
|||||||
# API Events
|
# API Events
|
||||||
|
|
||||||
## ledgerClosed
|
## ledger
|
||||||
|
|
||||||
This event is emitted whenever a new ledger version is validated on the connected server.
|
This event is emitted whenever a new ledger version is validated on the connected server.
|
||||||
|
|
||||||
### Return Value
|
### Return Value
|
||||||
|
|
||||||
<%- renderSchema('output/ledger-closed.json') %>
|
<%- renderSchema('output/ledger-event.json') %>
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
api.on('ledgerClosed', ledger => {
|
api.on('ledger', ledger => {
|
||||||
console.log(JSON.stringify(ledger, null, 2));
|
console.log(JSON.stringify(ledger, null, 2));
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
<%- renderFixture('responses/ledger-closed.json') %>
|
<%- renderFixture('responses/ledger-event.json') %>
|
||||||
|
|
||||||
## error
|
## error
|
||||||
|
|
||||||
This event is emitted when there is an error on the connection to the server.
|
This event is emitted when there is an error on the connection to the server that cannot be associated to a specific request.
|
||||||
|
|
||||||
### Return Value
|
### Return Value
|
||||||
|
|
||||||
The first parameter is a string indicating the error type, which may be `badMessage` (meaning that rippled returned a malformed message), or one of the [rippled Universal Errors](https://ripple.com/build/rippled-apis/#universal-errors). The second parameter is a message explaining the error, or the message that caused the error in the case of `badMessage`.
|
The first parameter is a string indicating the error type:
|
||||||
|
* `badMessage` - rippled returned a malformed message
|
||||||
|
* `websocket` - the websocket library emitted an error
|
||||||
|
* one of the error codes found in the [rippled Universal Errors](https://ripple.com/build/rippled-apis/#universal-errors).
|
||||||
|
|
||||||
|
The second parameter is a message explaining the error.
|
||||||
|
|
||||||
|
The third parameter is:
|
||||||
|
* the message that caused the error for `badMessage`
|
||||||
|
* the error object emitted for `websocket`
|
||||||
|
* the parsed response for rippled errors
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
api.on('error', (errorCode, errorMessage) => {
|
api.on('error', (errorCode, errorMessage, data) => {
|
||||||
console.log(errorCode + ': ' + errorMessage);
|
console.log(errorCode + ': ' + errorMessage);
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ Generate a new Ripple address and corresponding secret.
|
|||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
|
|
||||||
This method has no parameters.
|
<%- renderSchema('input/generate-address.json') %>
|
||||||
|
|
||||||
### Return Value
|
### Return Value
|
||||||
|
|
||||||
@@ -17,8 +17,7 @@ This method returns an object with the following structure:
|
|||||||
### Example
|
### Example
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
return api.generateAddress()
|
return api.generateAddress();
|
||||||
.then(result => {/* ... */});
|
|
||||||
```
|
```
|
||||||
|
|
||||||
<%- renderFixture('responses/generate-address.json') %>
|
<%- renderFixture('responses/generate-address.json') %>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
`getFee(): Promise<number>`
|
`getFee(): Promise<number>`
|
||||||
|
|
||||||
Returns the estimated transaction fee for the server(s) the RippleAPI instance is connected to.
|
Returns the estimated transaction fee for the rippled server the RippleAPI instance is connected to.
|
||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@ This method has no parameters.
|
|||||||
|
|
||||||
### Return Value
|
### Return Value
|
||||||
|
|
||||||
This method returns a promise that resolves with a 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
|
### Example
|
||||||
|
|
||||||
@@ -19,5 +19,5 @@ return api.getFee().then(fee => {/* ... */});
|
|||||||
```
|
```
|
||||||
|
|
||||||
```json
|
```json
|
||||||
0.012
|
"0.012"
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<% include introduction.md.ejs %>
|
<% include introduction.md.ejs %>
|
||||||
<% include boilerplate.md.ejs %>
|
<% include boilerplate.md.ejs %>
|
||||||
|
<% include offline.md.ejs %>
|
||||||
<% include basictypes.md.ejs %>
|
<% include basictypes.md.ejs %>
|
||||||
<% include transactions.md.ejs %>
|
<% include transactions.md.ejs %>
|
||||||
<% include specifications.md.ejs %>
|
<% include specifications.md.ejs %>
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
# Introduction
|
# Introduction
|
||||||
|
|
||||||
RippleAPI allows you to query and submit transactions to a node on the Ripple network.
|
RippleAPI is the official client library to the Ripple Consensus Ledger. Currently, RippleAPI is only available in JavaScript.
|
||||||
|
Using RippleAPI, you can:
|
||||||
|
|
||||||
|
* [Query transactions from the network](#gettransaction)
|
||||||
|
* [Sign](#sign) transactions securely without connecting to any server
|
||||||
|
* [Submit](#submit) transactions to the Ripple Consensus Ledger, including [Payments](#payment), [Orders](#order), [Settings changes](#settings), and [other types](#transaction-types)
|
||||||
|
* [Generate a new Ripple Address](#generateaddress)
|
||||||
|
* ... and [much more](#api-methods).
|
||||||
|
|
||||||
RippleAPI only provides access to *validated*, *immutable* transaction data.
|
RippleAPI only provides access to *validated*, *immutable* transaction data.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
`isConnected(): boolean`
|
`isConnected(): boolean`
|
||||||
|
|
||||||
Checks if the RippleAPI instance is connected to its server(s).
|
Checks if the RippleAPI instance is connected to its rippled server.
|
||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
|
|
||||||
|
|||||||
27
docs/src/offline.md.ejs
Normal file
27
docs/src/offline.md.ejs
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
## Offline functionality
|
||||||
|
|
||||||
|
RippleAPI can also function without internet connectivity. This can be useful in order to generate secrets and sign transactions from a secure, isolated machine.
|
||||||
|
|
||||||
|
To instantiate RippleAPI in offline mode, use the following boilerplate code:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
const {RippleAPI} = require('ripple-lib');
|
||||||
|
|
||||||
|
const api = new RippleAPI();
|
||||||
|
/* insert code here */
|
||||||
|
```
|
||||||
|
|
||||||
|
Methods that depend on the state of the Ripple Consensus Ledger are unavailable in offline mode. To prepare transactions offline, you **must** specify the `fee`, `sequence`, and `maxLedgerVersion` parameters in the [transaction instructions](#transaction-instructions). The following methods should work offline:
|
||||||
|
|
||||||
|
* [preparePayment](#preparepayment)
|
||||||
|
* [prepareTrustline](#preparetrustline)
|
||||||
|
* [prepareOrder](#prepareorder)
|
||||||
|
* [prepareOrderCancellation](#prepareordercancellation)
|
||||||
|
* [prepareSettings](#preparesettings)
|
||||||
|
* [prepareSuspendedPaymentCreation](#preparesuspendedpaymentcreation)
|
||||||
|
* [prepareSuspendedPaymentCancellation](#preparesuspendedpaymentcancellation)
|
||||||
|
* [prepareSuspendedPaymentExecution](#preparesuspendedpaymentexecution)
|
||||||
|
* [sign](#sign)
|
||||||
|
* [generateAddress](#generateaddress)
|
||||||
|
* [computeLedgerHash](#computeledgerhash)
|
||||||
|
|
||||||
@@ -13,7 +13,7 @@ Prepare an order transaction. The prepared transaction must subsequently be [sig
|
|||||||
This method returns a promise that resolves with an object with the following structure:
|
This method returns a promise that resolves with an object with the following structure:
|
||||||
|
|
||||||
<aside class="notice">
|
<aside class="notice">
|
||||||
All "prepare" methods have the same return type.
|
All "prepare*" methods have the same return type.
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
<%- renderSchema('output/prepare.json') %>
|
<%- renderSchema('output/prepare.json') %>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
## prepareOrderCancellation
|
## prepareOrderCancellation
|
||||||
|
|
||||||
`prepareOrderCancellation(address: string, sequence: number, instructions: Object): Promise<Object>`
|
`prepareOrderCancellation(address: string, orderCancellation: Object, instructions: Object): Promise<Object>`
|
||||||
|
|
||||||
Prepare an order cancellation transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
|
Prepare an order cancellation transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
|
||||||
|
|
||||||
@@ -13,7 +13,7 @@ Prepare an order cancellation transaction. The prepared transaction must subsequ
|
|||||||
This method returns a promise that resolves with an object with the following structure:
|
This method returns a promise that resolves with an object with the following structure:
|
||||||
|
|
||||||
<aside class="notice">
|
<aside class="notice">
|
||||||
All "prepare" methods have the same return type.
|
All "prepare*" methods have the same return type.
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
<%- renderSchema("output/prepare.json") %>
|
<%- renderSchema("output/prepare.json") %>
|
||||||
@@ -22,7 +22,7 @@ All "prepare" methods have the same return type.
|
|||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const address = 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59';
|
const address = 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59';
|
||||||
const sequence = 123;
|
const orderCancellation = {orderSequence: 123};
|
||||||
return api.prepareOrderCancellation(address, sequence)
|
return api.prepareOrderCancellation(address, sequence)
|
||||||
.then(prepared => {/* ... */});
|
.then(prepared => {/* ... */});
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
Prepare a suspended payment cancellation transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
|
Prepare a suspended payment cancellation transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
|
||||||
|
|
||||||
|
**Caution:** Suspended Payments are currently available on the [Ripple Test Net](https://ripple.com/build/ripple-test-net/) only.
|
||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
|
|
||||||
<%- renderSchema('input/prepare-suspended-payment-cancellation.json') %>
|
<%- renderSchema('input/prepare-suspended-payment-cancellation.json') %>
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
Prepare a suspended payment creation transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
|
Prepare a suspended payment creation transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
|
||||||
|
|
||||||
|
**Caution:** Suspended Payments are currently available on the [Ripple Test Net](https://ripple.com/build/ripple-test-net/) only.
|
||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
|
|
||||||
<%- renderSchema('input/prepare-suspended-payment-creation.json') %>
|
<%- renderSchema('input/prepare-suspended-payment-creation.json') %>
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
Prepare a suspended payment execution transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
|
Prepare a suspended payment execution transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
|
||||||
|
|
||||||
|
**Caution:** Suspended Payments are currently available on the [Ripple Test Net](https://ripple.com/build/ripple-test-net/) only.
|
||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
|
|
||||||
<%- renderSchema('input/prepare-suspended-payment-execution.json') %>
|
<%- renderSchema('input/prepare-suspended-payment-execution.json') %>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ A transaction type is specified by the strings in the first column in the table
|
|||||||
|
|
||||||
Type | Description
|
Type | Description
|
||||||
---- | -----------
|
---- | -----------
|
||||||
[payment](#payment) | A `payment` transaction represents a transfer of value from one account to another. Depending on the path taken, additional exchanges of value may occur atomically to facilitate the payment.
|
[payment](#payment) | A `payment` transaction represents a transfer of value from one account to another. Depending on the [path](https://ripple.com/build/paths/) taken, additional exchanges of value may occur atomically to facilitate the payment.
|
||||||
[order](#order) | An `order` transaction creates a limit order. It defines an intent to exchange currencies, and creates an order in the Ripple Consensus Ledger's order book if not completely fulfilled when placed. Orders can be partially fulfilled.
|
[order](#order) | An `order` transaction creates a limit order. It defines an intent to exchange currencies, and creates an order in the Ripple Consensus Ledger's order book if not completely fulfilled when placed. Orders can be partially fulfilled.
|
||||||
[orderCancellation](#order-cancellation) | An `orderCancellation` transaction cancels an order in the Ripple Consensus Ledger's order book.
|
[orderCancellation](#order-cancellation) | An `orderCancellation` transaction cancels an order in the Ripple Consensus Ledger's order book.
|
||||||
[trustline](#trustline) | A `trustline` transactions creates or modifies a trust line between two accounts.
|
[trustline](#trustline) | A `trustline` transactions creates or modifies a trust line between two accounts.
|
||||||
@@ -15,31 +15,51 @@ Type | Description
|
|||||||
[suspendedPaymentCancellation](#suspended-payment-cancellation) | A `suspendedPaymentCancellation` transaction unlocks the funds in a suspended payment and sends them back to the creator of the suspended payment, but it will only work after the suspended payment expires.
|
[suspendedPaymentCancellation](#suspended-payment-cancellation) | A `suspendedPaymentCancellation` transaction unlocks the funds in a suspended payment and sends them back to the creator of the suspended payment, but it will only work after the suspended payment expires.
|
||||||
[suspendedPaymentExecution](#suspended-payment-execution) | A `suspendedPaymentExecution` transaction unlocks the funds in a suspended payment and sends them to the destination of the suspended payment, but it will only work if the cryptographic condition is provided.
|
[suspendedPaymentExecution](#suspended-payment-execution) | A `suspendedPaymentExecution` transaction unlocks the funds in a suspended payment and sends them to the destination of the suspended payment, but it will only work if the cryptographic condition is provided.
|
||||||
|
|
||||||
|
The three "suspended payment" transaction types are not supported by the production Ripple peer-to-peer network at this time. They are available for testing purposes if you [configure RippleAPI](#boilerplate) to connect to the [Ripple Test Net](https://ripple.com/build/ripple-test-net/) instead.
|
||||||
|
|
||||||
## Transaction Flow
|
## Transaction Flow
|
||||||
|
|
||||||
Executing a transaction with `RippleAPI` requires the following four steps:
|
Executing a transaction with `RippleAPI` requires the following four steps:
|
||||||
|
|
||||||
1. prepare - Create an unsigned transaction based on a [specification](#transaction-specifications) and [instructions](#transaction-instructions).
|
1. Prepare - Create an unsigned transaction based on a [specification](#transaction-specifications) and [instructions](#transaction-instructions). There is a method to prepare each type of transaction:
|
||||||
2. sign - Cryptographically sign the transaction locally and save the [transaction ID](#transaction-id). Signing is how the owner of an account authorizes a transaction to take place.
|
* [preparePayment](#preparepayment)
|
||||||
3. submit - Submit the transaction to the connected server.
|
* [prepareTrustline](#preparetrustline)
|
||||||
4. verify - Verify that the transaction got validated by querying with [getTransaction](#gettransaction). This is necessary because transactions may fail even if they were successfully submitted. It is recommended that you specify a `maxLedgerVersion` in the instructions when preparing a transaction because without it there is no way to know that a failed transaction will never succeeed in the future. It is impossible for a transaction to succeed after the network ledger version exceeds the `maxLedgerVersion` provided in the transaction instructions.
|
* [prepareOrder](#prepareorder)
|
||||||
|
* [prepareOrderCancellation](#prepareordercancellation)
|
||||||
|
* [prepareSettings](#preparesettings)
|
||||||
|
* [prepareSuspendedPaymentCreation](#preparesuspendedpaymentcreation)
|
||||||
|
* [prepareSuspendedPaymentCancellation](#preparesuspendedpaymentcancellation)
|
||||||
|
* [prepareSuspendedPaymentExecution](#preparesuspendedpaymentexecution)
|
||||||
|
2. [Sign](#sign) - Cryptographically sign the transaction locally and save the [transaction ID](#transaction-id). Signing is how the owner of an account authorizes a transaction to take place.
|
||||||
|
3. [Submit](#submit) - Submit the transaction to the connected server.
|
||||||
|
4. Verify - Verify that the transaction got validated by querying with [getTransaction](#gettransaction). This is necessary because transactions may fail even if they were successfully submitted.
|
||||||
|
|
||||||
## Transaction Fees
|
## Transaction Fees
|
||||||
|
|
||||||
Every transaction requires a *fee* to be paid in XRP. The fee is destroyed; it is not sent to any other party. The purpose of the fee is to prevent denial of service attacks on the Ripple network.
|
Every transaction must destroy a small amount of XRP as a cost to send the transaction. This is also called a *transaction fee*. The transaction cost is designed to increase along with the load on the Ripple network, making it very expensive to deliberately or inadvertently overload the network.
|
||||||
|
|
||||||
You can choose the size of the fee you want to pay or let a default be used. The fee is like a bid in an auction for slots in the next ledger closing. If the fee you choose is too low, your transaction will not be included in the next ledger closing. You can get an estimate of the fee required to be included in the next ledger closing with the [getFee](#getfee) method.
|
You can choose the size of the fee you want to pay or let a default be used. You can get an estimate of the fee required to be included in the next ledger closing with the [getFee](#getfee) method.
|
||||||
|
|
||||||
## Transaction Instructions
|
## Transaction Instructions
|
||||||
|
|
||||||
Transactions instructions indicates how to execute a transaction, complementary with the [transaction specification](#transaction-specifications).
|
Transaction instructions indicate how to execute a transaction, complementary with the [transaction specification](#transaction-specifications).
|
||||||
|
|
||||||
<%- renderSchema("objects/instructions.json") %>
|
<%- 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 network 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
|
## Transaction ID
|
||||||
|
|
||||||
```json
|
```json
|
||||||
"F4AB442A6D4CBB935D66E1DA7309A5FC71C7143ED4049053EC14E3875B0CF9BF"
|
"F4AB442A6D4CBB935D66E1DA7309A5FC71C7143ED4049053EC14E3875B0CF9BF"
|
||||||
```
|
```
|
||||||
|
|
||||||
A hash of the transaction that can be used to identify it. A transaction can be looked up by its ID using the [getTransaction](#gettransaction) method.
|
A transaction ID is a 64-bit hexadecimal string that uniquely identifies the transaction. The transaction ID is derived from the transaction instruction and specifications, using a strong hash function.
|
||||||
|
|
||||||
|
You can look up a transaction by ID using the [getTransaction](#gettransaction) method.
|
||||||
|
|
||||||
|
## Transaction Memos
|
||||||
|
|
||||||
|
Every transaction can optionally have an array of memos for user applications. The `memos` field in each [transaction specification](#transaction-specifications) is an array of objects with the following structure:
|
||||||
|
|
||||||
|
<%- renderSchema('objects/memos.json') %>
|
||||||
|
|||||||
137
npm-shrinkwrap.json
generated
137
npm-shrinkwrap.json
generated
@@ -1,30 +1,35 @@
|
|||||||
{
|
{
|
||||||
"name": "ripple-lib",
|
"name": "ripple-lib",
|
||||||
"version": "0.13.2",
|
"version": "0.16.2",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ajv": {
|
"ajv": {
|
||||||
"version": "1.4.8",
|
"version": "1.4.10",
|
||||||
"from": "https://registry.npmjs.org/ajv/-/ajv-1.4.8.tgz",
|
"from": "ajv@>=1.4.8 <2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/ajv/-/ajv-1.4.8.tgz",
|
"resolved": "https://registry.npmjs.org/ajv/-/ajv-1.4.10.tgz",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"json-stable-stringify": {
|
"json-stable-stringify": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"from": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.0.tgz",
|
"from": "json-stable-stringify@>=1.0.0 <2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.0.tgz",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"jsonify": {
|
"jsonify": {
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"from": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz",
|
"from": "jsonify@>=0.0.0 <0.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz"
|
"resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"ajv-i18n": {
|
||||||
|
"version": "0.1.1",
|
||||||
|
"from": "ajv-i18n@>=0.1.0 <0.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/ajv-i18n/-/ajv-i18n-0.1.1.tgz"
|
||||||
|
},
|
||||||
"babel-polyfill": {
|
"babel-polyfill": {
|
||||||
"version": "6.2.0",
|
"version": "6.3.14",
|
||||||
"from": "babel-polyfill@*",
|
"from": "babel-polyfill@>=6.2.0 <7.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/babel-polyfill/-/babel-polyfill-6.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/babel-polyfill/-/babel-polyfill-6.3.14.tgz",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"core-js": {
|
"core-js": {
|
||||||
"version": "1.2.6",
|
"version": "1.2.6",
|
||||||
@@ -32,28 +37,28 @@
|
|||||||
"resolved": "https://registry.npmjs.org/core-js/-/core-js-1.2.6.tgz"
|
"resolved": "https://registry.npmjs.org/core-js/-/core-js-1.2.6.tgz"
|
||||||
},
|
},
|
||||||
"babel-regenerator-runtime": {
|
"babel-regenerator-runtime": {
|
||||||
"version": "6.2.0",
|
"version": "6.3.13",
|
||||||
"from": "babel-regenerator-runtime@>=6.2.0 <7.0.0",
|
"from": "babel-regenerator-runtime@>=6.3.13 <7.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/babel-regenerator-runtime/-/babel-regenerator-runtime-6.2.0.tgz"
|
"resolved": "https://registry.npmjs.org/babel-regenerator-runtime/-/babel-regenerator-runtime-6.3.13.tgz"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"babel-runtime": {
|
"babel-runtime": {
|
||||||
"version": "5.8.29",
|
"version": "5.8.34",
|
||||||
"from": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-5.8.29.tgz",
|
"from": "babel-runtime@>=5.5.4 <6.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-5.8.29.tgz",
|
"resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-5.8.34.tgz",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"core-js": {
|
"core-js": {
|
||||||
"version": "1.2.3",
|
"version": "1.2.6",
|
||||||
"from": "https://registry.npmjs.org/core-js/-/core-js-1.2.3.tgz",
|
"from": "core-js@>=1.0.0 <2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/core-js/-/core-js-1.2.3.tgz"
|
"resolved": "https://registry.npmjs.org/core-js/-/core-js-1.2.6.tgz"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"bignumber.js": {
|
"bignumber.js": {
|
||||||
"version": "2.1.0",
|
"version": "2.1.2",
|
||||||
"from": "bignumber.js@>=2.0.3 <3.0.0",
|
"from": "bignumber.js@>=2.0.3 <3.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-2.1.0.tgz"
|
"resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-2.1.2.tgz"
|
||||||
},
|
},
|
||||||
"https-proxy-agent": {
|
"https-proxy-agent": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
@@ -91,6 +96,52 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"jayson": {
|
||||||
|
"version": "1.2.2",
|
||||||
|
"from": "jayson@>=1.2.2 <2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/jayson/-/jayson-1.2.2.tgz",
|
||||||
|
"dependencies": {
|
||||||
|
"JSONStream": {
|
||||||
|
"version": "1.0.3",
|
||||||
|
"from": "JSONStream@1.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.0.3.tgz",
|
||||||
|
"dependencies": {
|
||||||
|
"jsonparse": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"from": "jsonparse@>=1.0.0 <1.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.0.0.tgz"
|
||||||
|
},
|
||||||
|
"through": {
|
||||||
|
"version": "2.3.8",
|
||||||
|
"from": "through@>=2.2.7 <3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"commander": {
|
||||||
|
"version": "1.3.2",
|
||||||
|
"from": "commander@1.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/commander/-/commander-1.3.2.tgz",
|
||||||
|
"dependencies": {
|
||||||
|
"keypress": {
|
||||||
|
"version": "0.1.0",
|
||||||
|
"from": "keypress@>=0.1.0 <0.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/keypress/-/keypress-0.1.0.tgz"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"eyes": {
|
||||||
|
"version": "0.1.8",
|
||||||
|
"from": "eyes@0.1.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/eyes/-/eyes-0.1.8.tgz"
|
||||||
|
},
|
||||||
|
"lodash": {
|
||||||
|
"version": "3.6.0",
|
||||||
|
"from": "lodash@3.6.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/lodash/-/lodash-3.6.0.tgz"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"lodash": {
|
"lodash": {
|
||||||
"version": "3.10.1",
|
"version": "3.10.1",
|
||||||
"from": "lodash@>=3.1.0 <4.0.0",
|
"from": "lodash@>=3.1.0 <4.0.0",
|
||||||
@@ -128,9 +179,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ripple-binary-codec": {
|
"ripple-binary-codec": {
|
||||||
"version": "0.1.0",
|
"version": "0.1.1",
|
||||||
"from": "ripple-binary-codec@0.1.0",
|
"from": "ripple-binary-codec@>=0.1.1 <0.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/ripple-binary-codec/-/ripple-binary-codec-0.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/ripple-binary-codec/-/ripple-binary-codec-0.1.1.tgz",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bn.js": {
|
"bn.js": {
|
||||||
"version": "3.3.0",
|
"version": "3.3.0",
|
||||||
@@ -166,14 +217,14 @@
|
|||||||
},
|
},
|
||||||
"inherits": {
|
"inherits": {
|
||||||
"version": "2.0.1",
|
"version": "2.0.1",
|
||||||
"from": "inherits@>=2.0.1 <3.0.0",
|
"from": "inherits@>=2.0.0 <3.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz"
|
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ripple-hashes": {
|
"ripple-hashes": {
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"from": "ripple-hashes@0.1.0",
|
"from": "ripple-hashes@>=0.1.0 <0.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/ripple-hashes/-/ripple-hashes-0.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/ripple-hashes/-/ripple-hashes-0.1.0.tgz",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"create-hash": {
|
"create-hash": {
|
||||||
@@ -227,7 +278,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"inherits": {
|
"inherits": {
|
||||||
"version": "2.0.1",
|
"version": "2.0.1",
|
||||||
"from": "inherits@>=2.0.1 <3.0.0",
|
"from": "inherits@>=2.0.1 <2.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz"
|
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -265,40 +316,6 @@
|
|||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"from": "ultron@>=1.0.0 <1.1.0",
|
"from": "ultron@>=1.0.0 <1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/ultron/-/ultron-1.0.2.tgz"
|
"resolved": "https://registry.npmjs.org/ultron/-/ultron-1.0.2.tgz"
|
||||||
},
|
|
||||||
"bufferutil": {
|
|
||||||
"version": "1.1.0",
|
|
||||||
"from": "bufferutil@>=1.1.0 <1.2.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-1.1.0.tgz",
|
|
||||||
"dependencies": {
|
|
||||||
"bindings": {
|
|
||||||
"version": "1.2.1",
|
|
||||||
"from": "bindings@>=1.2.0 <1.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.2.1.tgz"
|
|
||||||
},
|
|
||||||
"nan": {
|
|
||||||
"version": "1.8.4",
|
|
||||||
"from": "nan@>=1.8.0 <1.9.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/nan/-/nan-1.8.4.tgz"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"utf-8-validate": {
|
|
||||||
"version": "1.1.0",
|
|
||||||
"from": "utf-8-validate@>=1.1.0 <1.2.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-1.1.0.tgz",
|
|
||||||
"dependencies": {
|
|
||||||
"bindings": {
|
|
||||||
"version": "1.2.1",
|
|
||||||
"from": "bindings@>=1.2.0 <1.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.2.1.tgz"
|
|
||||||
},
|
|
||||||
"nan": {
|
|
||||||
"version": "1.8.4",
|
|
||||||
"from": "nan@>=1.8.0 <1.9.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/nan/-/nan-1.8.4.tgz"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ripple-lib",
|
"name": "ripple-lib",
|
||||||
"version": "0.13.2",
|
"version": "0.16.2",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"description": "A JavaScript API for interacting with Ripple in Node.js and the browser",
|
"description": "A JavaScript API for interacting with Ripple in Node.js and the browser",
|
||||||
"files": [
|
"files": [
|
||||||
@@ -20,9 +20,10 @@
|
|||||||
"babel-runtime": "^5.5.4",
|
"babel-runtime": "^5.5.4",
|
||||||
"bignumber.js": "^2.0.3",
|
"bignumber.js": "^2.0.3",
|
||||||
"https-proxy-agent": "^1.0.0",
|
"https-proxy-agent": "^1.0.0",
|
||||||
|
"jayson": "^1.2.2",
|
||||||
"lodash": "^3.1.0",
|
"lodash": "^3.1.0",
|
||||||
"ripple-address-codec": "^2.0.1",
|
"ripple-address-codec": "^2.0.1",
|
||||||
"ripple-binary-codec": "^0.1.0",
|
"ripple-binary-codec": "^0.1.1",
|
||||||
"ripple-hashes": "^0.1.0",
|
"ripple-hashes": "^0.1.0",
|
||||||
"ripple-keypairs": "^0.10.0",
|
"ripple-keypairs": "^0.10.0",
|
||||||
"ripple-lib-transactionparser": "^0.6.0",
|
"ripple-lib-transactionparser": "^0.6.0",
|
||||||
@@ -65,7 +66,8 @@
|
|||||||
"test": "istanbul test _mocha",
|
"test": "istanbul test _mocha",
|
||||||
"coveralls": "cat ./coverage/lcov.info | coveralls",
|
"coveralls": "cat ./coverage/lcov.info | coveralls",
|
||||||
"lint": "if ! [ -f eslintrc ]; then curl -o eslintrc 'https://raw.githubusercontent.com/ripple/javascript-style-guide/es6/eslintrc'; echo 'parser: babel-eslint' >> eslintrc; fi; eslint -c eslintrc src/",
|
"lint": "if ! [ -f eslintrc ]; then curl -o eslintrc 'https://raw.githubusercontent.com/ripple/javascript-style-guide/es6/eslintrc'; echo 'parser: babel-eslint' >> eslintrc; fi; eslint -c eslintrc src/",
|
||||||
"perf": "./scripts/perf_test.sh"
|
"perf": "./scripts/perf_test.sh",
|
||||||
|
"start": "babel-node scripts/http.js"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ unittest() {
|
|||||||
|
|
||||||
integrationtest() {
|
integrationtest() {
|
||||||
mocha test/integration/integration-test.js
|
mocha test/integration/integration-test.js
|
||||||
|
mocha test/integration/http-integration-test.js
|
||||||
}
|
}
|
||||||
|
|
||||||
doctest() {
|
doctest() {
|
||||||
|
|||||||
16
scripts/http.js
Normal file
16
scripts/http.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const createHTTPServer = require('../src/index').createHTTPServer;
|
||||||
|
const port = 5990;
|
||||||
|
const serverUrl = 'wss://s1.ripple.com';
|
||||||
|
|
||||||
|
|
||||||
|
function main() {
|
||||||
|
const server = createHTTPServer({server: serverUrl}, port);
|
||||||
|
server.start().then(() => {
|
||||||
|
console.log('Server started on port ' + String(port));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
main();
|
||||||
145
src/api.js
Normal file
145
src/api.js
Normal file
@@ -0,0 +1,145 @@
|
|||||||
|
/* @flow */
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
/* eslint-disable max-len */
|
||||||
|
// Enable core-js polyfills. This allows use of ES6/7 extensions listed here:
|
||||||
|
// https://github.com/zloirock/core-js/blob/fb0890f32dabe8d4d88a4350d1b268446127132e/shim.js#L1-L103
|
||||||
|
/* eslint-enable max-len */
|
||||||
|
|
||||||
|
// In node.js env, polyfill might be already loaded (from any npm package),
|
||||||
|
// that's why we do this check.
|
||||||
|
if (!global._babelPolyfill) {
|
||||||
|
require('babel-polyfill');
|
||||||
|
}
|
||||||
|
|
||||||
|
const _ = require('lodash');
|
||||||
|
const EventEmitter = require('events').EventEmitter;
|
||||||
|
const common = require('./common');
|
||||||
|
const server = require('./server/server');
|
||||||
|
const connect = server.connect;
|
||||||
|
const disconnect = server.disconnect;
|
||||||
|
const getServerInfo = server.getServerInfo;
|
||||||
|
const getFee = server.getFee;
|
||||||
|
const isConnected = server.isConnected;
|
||||||
|
const getLedgerVersion = server.getLedgerVersion;
|
||||||
|
const getTransaction = require('./ledger/transaction');
|
||||||
|
const getTransactions = require('./ledger/transactions');
|
||||||
|
const getTrustlines = require('./ledger/trustlines');
|
||||||
|
const getBalances = require('./ledger/balances');
|
||||||
|
const getBalanceSheet = require('./ledger/balance-sheet');
|
||||||
|
const getPaths = require('./ledger/pathfind');
|
||||||
|
const getOrders = require('./ledger/orders');
|
||||||
|
const getOrderbook = require('./ledger/orderbook');
|
||||||
|
const getSettings = require('./ledger/settings');
|
||||||
|
const getAccountInfo = require('./ledger/accountinfo');
|
||||||
|
const preparePayment = require('./transaction/payment');
|
||||||
|
const prepareTrustline = require('./transaction/trustline');
|
||||||
|
const prepareOrder = require('./transaction/order');
|
||||||
|
const prepareOrderCancellation = require('./transaction/ordercancellation');
|
||||||
|
const prepareSuspendedPaymentCreation =
|
||||||
|
require('./transaction/suspended-payment-creation');
|
||||||
|
const prepareSuspendedPaymentExecution =
|
||||||
|
require('./transaction/suspended-payment-execution');
|
||||||
|
const prepareSuspendedPaymentCancellation =
|
||||||
|
require('./transaction/suspended-payment-cancellation');
|
||||||
|
const prepareSettings = require('./transaction/settings');
|
||||||
|
const sign = require('./transaction/sign');
|
||||||
|
const submit = require('./transaction/submit');
|
||||||
|
const errors = require('./common').errors;
|
||||||
|
const generateAddress =
|
||||||
|
require('./offline/generate-address').generateAddressAPI;
|
||||||
|
const computeLedgerHash = require('./offline/ledgerhash');
|
||||||
|
const getLedger = require('./ledger/ledger');
|
||||||
|
|
||||||
|
type APIOptions = {
|
||||||
|
server?: string,
|
||||||
|
feeCushion?: number,
|
||||||
|
trace?: boolean,
|
||||||
|
proxy?: string,
|
||||||
|
timeout?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
// prevent access to non-validated ledger versions
|
||||||
|
class RestrictedConnection extends common.Connection {
|
||||||
|
request(request, timeout) {
|
||||||
|
const ledger_index = request.ledger_index;
|
||||||
|
if (ledger_index !== undefined && ledger_index !== 'validated') {
|
||||||
|
if (!_.isNumber(ledger_index) || ledger_index > this._ledgerVersion) {
|
||||||
|
return Promise.reject(new errors.LedgerVersionError(
|
||||||
|
`ledgerVersion ${ledger_index} is greater than server\'s ` +
|
||||||
|
`most recent validated ledger: ${this._ledgerVersion}`));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return super.request(request, timeout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class RippleAPI extends EventEmitter {
|
||||||
|
constructor(options: APIOptions = {}) {
|
||||||
|
common.validate.apiOptions(options);
|
||||||
|
super();
|
||||||
|
this._feeCushion = options.feeCushion || 1.2;
|
||||||
|
const serverURL = options.server;
|
||||||
|
if (serverURL !== undefined) {
|
||||||
|
this.connection = new RestrictedConnection(serverURL, options);
|
||||||
|
this.connection.on('ledgerClosed', message => {
|
||||||
|
this.emit('ledger', server.formatLedgerClose(message));
|
||||||
|
});
|
||||||
|
this.connection.on('error', (errorCode, errorMessage, data) => {
|
||||||
|
this.emit('error', errorCode, errorMessage, data);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// use null object pattern to provide better error message if user
|
||||||
|
// tries to call a method that requires a connection
|
||||||
|
this.connection = new RestrictedConnection(null, options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_.assign(RippleAPI.prototype, {
|
||||||
|
connect,
|
||||||
|
disconnect,
|
||||||
|
isConnected,
|
||||||
|
getServerInfo,
|
||||||
|
getFee,
|
||||||
|
getLedgerVersion,
|
||||||
|
|
||||||
|
getTransaction,
|
||||||
|
getTransactions,
|
||||||
|
getTrustlines,
|
||||||
|
getBalances,
|
||||||
|
getBalanceSheet,
|
||||||
|
getPaths,
|
||||||
|
getOrders,
|
||||||
|
getOrderbook,
|
||||||
|
getSettings,
|
||||||
|
getAccountInfo,
|
||||||
|
getLedger,
|
||||||
|
|
||||||
|
preparePayment,
|
||||||
|
prepareTrustline,
|
||||||
|
prepareOrder,
|
||||||
|
prepareOrderCancellation,
|
||||||
|
prepareSuspendedPaymentCreation,
|
||||||
|
prepareSuspendedPaymentExecution,
|
||||||
|
prepareSuspendedPaymentCancellation,
|
||||||
|
prepareSettings,
|
||||||
|
sign,
|
||||||
|
submit,
|
||||||
|
|
||||||
|
generateAddress,
|
||||||
|
computeLedgerHash,
|
||||||
|
errors
|
||||||
|
});
|
||||||
|
|
||||||
|
// these are exposed only for use by unit tests; they are not part of the API
|
||||||
|
RippleAPI._PRIVATE = {
|
||||||
|
validate: common.validate,
|
||||||
|
RangeSet: require('./common/rangeset').RangeSet,
|
||||||
|
ledgerUtils: require('./ledger/utils'),
|
||||||
|
schemaValidator: require('./common/schema-validator')
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
RippleAPI
|
||||||
|
};
|
||||||
67
src/broadcast.js
Normal file
67
src/broadcast.js
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
'use strict';
|
||||||
|
const _ = require('lodash');
|
||||||
|
const RippleAPI = require('./api').RippleAPI;
|
||||||
|
|
||||||
|
class RippleAPIBroadcast extends RippleAPI {
|
||||||
|
constructor(servers, options) {
|
||||||
|
super(options);
|
||||||
|
this.ledgerVersion = 0;
|
||||||
|
|
||||||
|
const apis = servers.map(server => new RippleAPI(
|
||||||
|
_.assign({}, options, {server})
|
||||||
|
));
|
||||||
|
|
||||||
|
this.getMethodNames().forEach(name => {
|
||||||
|
this[name] = function() { // eslint-disable-line no-loop-func
|
||||||
|
return Promise.race(apis.map(api => api[name].apply(api, arguments)));
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
// connection methods must be overridden to apply to all api instances
|
||||||
|
this.connect = function() {
|
||||||
|
return Promise.all(apis.map(api => api.connect()));
|
||||||
|
};
|
||||||
|
this.disconnect = function() {
|
||||||
|
return Promise.all(apis.map(api => api.disconnect()));
|
||||||
|
};
|
||||||
|
this.isConnected = function() {
|
||||||
|
return _.every(apis.map(api => api.isConnected()));
|
||||||
|
};
|
||||||
|
|
||||||
|
// synchronous methods are all passed directly to the first api instance
|
||||||
|
const defaultAPI = apis[0];
|
||||||
|
const syncMethods = ['sign', 'generateAddress', 'computeLedgerHash'];
|
||||||
|
syncMethods.forEach(name => {
|
||||||
|
this[name] = defaultAPI[name].bind(defaultAPI);
|
||||||
|
});
|
||||||
|
|
||||||
|
apis.forEach(api => {
|
||||||
|
api.on('ledger', this.onLedgerEvent.bind(this));
|
||||||
|
api.on('error', (errorCode, errorMessage, data) =>
|
||||||
|
this.emit('error', errorCode, errorMessage, data));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onLedgerEvent(ledger) {
|
||||||
|
if (ledger.ledgerVersion > this.ledgerVersion) {
|
||||||
|
this.ledgerVersion = ledger.ledgerVersion;
|
||||||
|
this.emit('ledger', ledger);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getMethodNames() {
|
||||||
|
const methodNames = [];
|
||||||
|
for (const name in RippleAPI.prototype) {
|
||||||
|
if (RippleAPI.prototype.hasOwnProperty(name)) {
|
||||||
|
if (typeof RippleAPI.prototype[name] === 'function') {
|
||||||
|
methodNames.push(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return methodNames;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
RippleAPIBroadcast
|
||||||
|
};
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
const _ = require('lodash');
|
||||||
const {EventEmitter} = require('events');
|
const {EventEmitter} = require('events');
|
||||||
const WebSocket = require('ws');
|
const WebSocket = require('ws');
|
||||||
const parseURL = require('url').parse;
|
const parseURL = require('url').parse;
|
||||||
@@ -15,9 +16,20 @@ function isStreamMessageType(type) {
|
|||||||
class Connection extends EventEmitter {
|
class Connection extends EventEmitter {
|
||||||
constructor(url, options = {}) {
|
constructor(url, options = {}) {
|
||||||
super();
|
super();
|
||||||
|
this.setMaxListeners(Infinity);
|
||||||
this._url = url;
|
this._url = url;
|
||||||
this._proxyURL = options.proxyURL;
|
this._trace = options.trace;
|
||||||
|
if (this._trace) {
|
||||||
|
// for easier unit testing
|
||||||
|
this._console = console;
|
||||||
|
}
|
||||||
|
this._proxyURL = options.proxy;
|
||||||
|
this._proxyAuthorization = options.proxyAuthorization;
|
||||||
this._authorization = options.authorization;
|
this._authorization = options.authorization;
|
||||||
|
this._trustedCertificates = options.trustedCertificates;
|
||||||
|
this._key = options.key;
|
||||||
|
this._passphrase = options.passphrase;
|
||||||
|
this._certificate = options.certificate;
|
||||||
this._timeout = options.timeout || (20 * 1000);
|
this._timeout = options.timeout || (20 * 1000);
|
||||||
this._isReady = false;
|
this._isReady = false;
|
||||||
this._ws = null;
|
this._ws = null;
|
||||||
@@ -43,17 +55,20 @@ class Connection extends EventEmitter {
|
|||||||
}
|
}
|
||||||
return [data.type, data];
|
return [data.type, data];
|
||||||
} else if (data.type === undefined && data.error) {
|
} else if (data.type === undefined && data.error) {
|
||||||
return ['error', data.error, data.error_message]; // e.g. slowDown
|
return ['error', data.error, data.error_message, data]; // e.g. slowDown
|
||||||
}
|
}
|
||||||
throw new ResponseFormatError('unrecognized message type: ' + data.type);
|
throw new ResponseFormatError('unrecognized message type: ' + data.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
_onMessage(message) {
|
_onMessage(message) {
|
||||||
let parameters;
|
let parameters;
|
||||||
|
if (this._trace) {
|
||||||
|
this._console.log(message);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
parameters = this._parseMessage(message);
|
parameters = this._parseMessage(message);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.emit('error', 'badMessage', message);
|
this.emit('error', 'badMessage', error.message, message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// we don't want this inside the try/catch or exceptions in listener
|
// we don't want this inside the try/catch or exceptions in listener
|
||||||
@@ -74,6 +89,7 @@ class Connection extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_onUnexpectedClose() {
|
_onUnexpectedClose() {
|
||||||
|
this._ws = null;
|
||||||
this._isReady = false;
|
this._isReady = false;
|
||||||
this.connect().then();
|
this.connect().then();
|
||||||
}
|
}
|
||||||
@@ -92,12 +108,21 @@ class Connection extends EventEmitter {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_createWebSocket(url, proxyURL, authorization) {
|
_createWebSocket() {
|
||||||
const options = {};
|
const options = {};
|
||||||
if (proxyURL !== undefined) {
|
if (this._proxyURL !== undefined) {
|
||||||
const parsedURL = parseURL(url);
|
const parsedURL = parseURL(this._url);
|
||||||
const proxyOptions = parseURL(proxyURL);
|
const parsedProxyURL = parseURL(this._proxyURL);
|
||||||
proxyOptions.secureEndpoint = (parsedURL.protocol === 'wss:');
|
const proxyOverrides = _.omit({
|
||||||
|
secureEndpoint: (parsedURL.protocol === 'wss:'),
|
||||||
|
secureProxy: (parsedProxyURL.protocol === 'https:'),
|
||||||
|
auth: this._proxyAuthorization,
|
||||||
|
ca: this._trustedCertificates,
|
||||||
|
key: this._key,
|
||||||
|
passphrase: this._passphrase,
|
||||||
|
cert: this._certificate
|
||||||
|
}, _.isUndefined);
|
||||||
|
const proxyOptions = _.assign({}, parsedProxyURL, proxyOverrides);
|
||||||
let HttpsProxyAgent;
|
let HttpsProxyAgent;
|
||||||
try {
|
try {
|
||||||
HttpsProxyAgent = require('https-proxy-agent');
|
HttpsProxyAgent = require('https-proxy-agent');
|
||||||
@@ -106,11 +131,22 @@ class Connection extends EventEmitter {
|
|||||||
}
|
}
|
||||||
options.agent = new HttpsProxyAgent(proxyOptions);
|
options.agent = new HttpsProxyAgent(proxyOptions);
|
||||||
}
|
}
|
||||||
if (authorization !== undefined) {
|
if (this._authorization !== undefined) {
|
||||||
const base64 = new Buffer(authorization).toString('base64');
|
const base64 = new Buffer(this._authorization).toString('base64');
|
||||||
options.headers = {Authorization: `Basic ${base64}`};
|
options.headers = {Authorization: `Basic ${base64}`};
|
||||||
}
|
}
|
||||||
return new WebSocket(url, options);
|
const optionsOverrides = _.omit({
|
||||||
|
ca: this._trustedCertificates,
|
||||||
|
key: this._key,
|
||||||
|
passphrase: this._passphrase,
|
||||||
|
cert: this._certificate
|
||||||
|
}, _.isUndefined);
|
||||||
|
const websocketOptions = _.assign({}, options, optionsOverrides);
|
||||||
|
const websocket = new WebSocket(this._url, websocketOptions);
|
||||||
|
// we will have a listener for each outstanding request,
|
||||||
|
// so we have to raise the limit (the default is 10)
|
||||||
|
websocket.setMaxListeners(Infinity);
|
||||||
|
return websocket;
|
||||||
}
|
}
|
||||||
|
|
||||||
connect() {
|
connect() {
|
||||||
@@ -124,10 +160,16 @@ class Connection extends EventEmitter {
|
|||||||
} else if (this._state === WebSocket.CONNECTING) {
|
} else if (this._state === WebSocket.CONNECTING) {
|
||||||
this._ws.once('open', resolve);
|
this._ws.once('open', resolve);
|
||||||
} else {
|
} else {
|
||||||
this._ws = this._createWebSocket(this._url, this._proxyURL,
|
this._ws = this._createWebSocket();
|
||||||
this._authorization);
|
// when an error causes the connection to close, the close event
|
||||||
|
// should still be emitted; the "ws" documentation says: "The close
|
||||||
|
// event is also emitted when then underlying net.Socket closes the
|
||||||
|
// connection (end or close)."
|
||||||
|
this._ws.on('error', error =>
|
||||||
|
this.emit('error', 'websocket', error.messsage, error));
|
||||||
this._ws.on('message', this._onMessage.bind(this));
|
this._ws.on('message', this._onMessage.bind(this));
|
||||||
this._ws.once('close', () => this._onUnexpectedClose);
|
this._onUnexpectedCloseBound = this._onUnexpectedClose.bind(this);
|
||||||
|
this._ws.once('close', this._onUnexpectedCloseBound);
|
||||||
this._ws.once('open', () => this._onOpen().then(resolve, reject));
|
this._ws.once('open', () => this._onOpen().then(resolve, reject));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -140,7 +182,7 @@ class Connection extends EventEmitter {
|
|||||||
} else if (this._state === WebSocket.CLOSING) {
|
} else if (this._state === WebSocket.CLOSING) {
|
||||||
this._ws.once('close', resolve);
|
this._ws.once('close', resolve);
|
||||||
} else {
|
} else {
|
||||||
this._ws.removeListener('close', this._onUnexpectedClose);
|
this._ws.removeListener('close', this._onUnexpectedCloseBound);
|
||||||
this._ws.once('close', () => {
|
this._ws.once('close', () => {
|
||||||
this._ws = null;
|
this._ws = null;
|
||||||
this._isReady = false;
|
this._isReady = false;
|
||||||
@@ -182,6 +224,9 @@ class Connection extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_send(message) {
|
_send(message) {
|
||||||
|
if (this._trace) {
|
||||||
|
this._console.log(message);
|
||||||
|
}
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this._ws.send(message, undefined, (error, result) => {
|
this._ws.send(message, undefined, (error, result) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ function loadSchemas() {
|
|||||||
require('./schemas/objects/signed-value.json'),
|
require('./schemas/objects/signed-value.json'),
|
||||||
require('./schemas/objects/orderbook.json'),
|
require('./schemas/objects/orderbook.json'),
|
||||||
require('./schemas/objects/instructions.json'),
|
require('./schemas/objects/instructions.json'),
|
||||||
|
require('./schemas/objects/settings.json'),
|
||||||
require('./schemas/specifications/settings.json'),
|
require('./schemas/specifications/settings.json'),
|
||||||
require('./schemas/specifications/payment.json'),
|
require('./schemas/specifications/payment.json'),
|
||||||
require('./schemas/specifications/suspended-payment-cancellation.json'),
|
require('./schemas/specifications/suspended-payment-cancellation.json'),
|
||||||
@@ -61,7 +62,7 @@ function loadSchemas() {
|
|||||||
require('./schemas/output/get-orders.json'),
|
require('./schemas/output/get-orders.json'),
|
||||||
require('./schemas/output/order-change.json'),
|
require('./schemas/output/order-change.json'),
|
||||||
require('./schemas/output/prepare.json'),
|
require('./schemas/output/prepare.json'),
|
||||||
require('./schemas/output/ledger-closed.json'),
|
require('./schemas/output/ledger-event.json'),
|
||||||
require('./schemas/output/get-paths.json'),
|
require('./schemas/output/get-paths.json'),
|
||||||
require('./schemas/output/get-server-info.json'),
|
require('./schemas/output/get-server-info.json'),
|
||||||
require('./schemas/output/get-settings.json'),
|
require('./schemas/output/get-settings.json'),
|
||||||
@@ -91,8 +92,9 @@ function loadSchemas() {
|
|||||||
require('./schemas/input/prepare-suspended-payment-cancellation.json'),
|
require('./schemas/input/prepare-suspended-payment-cancellation.json'),
|
||||||
require('./schemas/input/prepare-suspended-payment-execution.json'),
|
require('./schemas/input/prepare-suspended-payment-execution.json'),
|
||||||
require('./schemas/input/compute-ledger-hash'),
|
require('./schemas/input/compute-ledger-hash'),
|
||||||
require('./schemas/input/sign'),
|
require('./schemas/input/sign.json'),
|
||||||
require('./schemas/input/submit')
|
require('./schemas/input/submit.json'),
|
||||||
|
require('./schemas/input/generate-address.json')
|
||||||
];
|
];
|
||||||
const titles = _.map(schemas, schema => schema.title);
|
const titles = _.map(schemas, schema => schema.title);
|
||||||
const duplicates = _.keys(_.pick(_.countBy(titles), count => count > 1));
|
const duplicates = _.keys(_.pick(_.countBy(titles), count => count > 1));
|
||||||
|
|||||||
@@ -3,21 +3,57 @@
|
|||||||
"title": "api-options",
|
"title": "api-options",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"trace": {"type": "boolean"},
|
"trace": {
|
||||||
"feeCushion": {"$ref": "value"},
|
"type": "boolean",
|
||||||
"servers": {
|
"description": "If true, log rippled requests and responses to stdout."
|
||||||
"type": "array",
|
},
|
||||||
"items": {
|
"feeCushion": {
|
||||||
"type": "string",
|
"type": "number",
|
||||||
"format": "uri",
|
"minimum": 1,
|
||||||
"pattern": "^wss?://"
|
"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`."
|
||||||
}
|
},
|
||||||
|
"server": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "URI for rippled websocket port to connect to. Must start with `wss://` or `ws://`.",
|
||||||
|
"format": "uri",
|
||||||
|
"pattern": "^wss?://"
|
||||||
},
|
},
|
||||||
"proxy": {
|
"proxy": {
|
||||||
"format": "uri"
|
"format": "uri",
|
||||||
|
"description": "URI for HTTP/HTTPS proxy to use to connect to the rippled server."
|
||||||
|
},
|
||||||
|
"timeout": {
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Timeout in milliseconds before considering a request to have failed.",
|
||||||
|
"minimum": 1
|
||||||
|
},
|
||||||
|
"proxyAuthorization": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Username and password for HTTP basic authentication to the proxy in the format **username:password**."
|
||||||
},
|
},
|
||||||
"authorization": {
|
"authorization": {
|
||||||
"type": "string"
|
"type": "string",
|
||||||
|
"description": "Username and password for HTTP basic authentication to the rippled server in the format **username:password**."
|
||||||
|
},
|
||||||
|
"trustedCertificates": {
|
||||||
|
"type": "array",
|
||||||
|
"description": "Array of PEM-formatted SSL certificates to trust when connecting to a proxy. This is useful if you want to use a self-signed certificate on the proxy server. Note: Each element must contain a single certificate; concatenated certificates are not valid.",
|
||||||
|
"items": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "A PEM-formatted SSL certificate to trust when connecting to a proxy."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"key": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "A string containing the private key of the client in PEM format. (Can be an array of keys)."
|
||||||
|
},
|
||||||
|
"passphrase": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "The passphrase for the private key of the client."
|
||||||
|
},
|
||||||
|
"certificate": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "A string containing the certificate key of the client in PEM format. (Can be an array of certificates)."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
|
|||||||
29
src/common/schemas/input/generate-address.json
Normal file
29
src/common/schemas/input/generate-address.json
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||||
|
"title": "generateAddressParameters",
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"options": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "Options to control how the address and secret are generated.",
|
||||||
|
"properties": {
|
||||||
|
"entropy": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "integer",
|
||||||
|
"minimum": 0,
|
||||||
|
"maximum": 255
|
||||||
|
},
|
||||||
|
"description": "The entropy to use to generate the seed."
|
||||||
|
},
|
||||||
|
"algorithm": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["ecdsa-secp256k1", "ed25519"],
|
||||||
|
"description": "The digital signature algorithm to generate an address for. Can be `ecdsa-secp256k1` (default) or `ed25519`."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
||||||
@@ -7,12 +7,12 @@
|
|||||||
"$ref": "address",
|
"$ref": "address",
|
||||||
"description": "The address of the account that is creating the transaction."
|
"description": "The address of the account that is creating the transaction."
|
||||||
},
|
},
|
||||||
"sequence": {
|
"orderCancellation": {
|
||||||
"$ref": "sequence",
|
"$ref": "orderCancellation",
|
||||||
"description": "The account sequence number of the transaction that created the order to cancel."
|
"description": "The specification of the order cancellation to prepare."
|
||||||
},
|
},
|
||||||
"instructions": {"$ref": "instructions"}
|
"instructions": {"$ref": "instructions"}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"required": ["address", "sequence"]
|
"required": ["address", "orderCancellation"]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,11 +18,14 @@
|
|||||||
"$ref": "value"
|
"$ref": "value"
|
||||||
},
|
},
|
||||||
"maxLedgerVersion": {
|
"maxLedgerVersion": {
|
||||||
"description": "The highest ledger version that the transaction can be included in.",
|
"description": "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.",
|
||||||
"$ref": "ledgerVersion"
|
"oneOf": [
|
||||||
|
{"$ref": "ledgerVersion"},
|
||||||
|
{"type": "null"}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"maxLedgerVersionOffset": {
|
"maxLedgerVersionOffset": {
|
||||||
"description": "Offset from current legder version to highest ledger version that the transaction can be included in.",
|
"description": "Offset from current validated legder version to highest ledger version that the transaction can be included in.",
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"minimum": 0
|
"minimum": 0
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||||
"title": "memos",
|
"title": "memos",
|
||||||
|
"link": "transaction-memos",
|
||||||
"description": "Array of memos to attach to the transaction.",
|
"description": "Array of memos to attach to the transaction.",
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
|
|||||||
74
src/common/schemas/objects/settings.json
Normal file
74
src/common/schemas/objects/settings.json
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
{
|
||||||
|
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||||
|
"title": "settingsPlusMemos",
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"passwordSpent": {
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Indicates that the account has used its free SetRegularKey transaction."
|
||||||
|
},
|
||||||
|
"requireDestinationTag": {
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Requires incoming payments to specify a destination tag."
|
||||||
|
},
|
||||||
|
"requireAuthorization": {
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "If set, this account must individually approve other users in order for those users to hold this account’s issuances."
|
||||||
|
},
|
||||||
|
"disallowIncomingXRP": {
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Indicates that client applications should not send XRP to this account. Not enforced by rippled."
|
||||||
|
},
|
||||||
|
"disableMasterKey": {
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Disallows use of the master key to sign transactions for this account."
|
||||||
|
},
|
||||||
|
"enableTransactionIDTracking": {
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Track the ID of this account’s most recent transaction."
|
||||||
|
},
|
||||||
|
"noFreeze": {
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Permanently give up the ability to freeze individual trust lines. This flag can never be disabled after being enabled."
|
||||||
|
},
|
||||||
|
"globalFreeze": {
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Freeze all assets issued by this account."
|
||||||
|
},
|
||||||
|
"defaultRipple": {
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Enable [rippling](https://ripple.com/knowledge_center/understanding-the-noripple-flag/) on this account’s trust lines by default. (New in [rippled 0.27.3](https://github.com/ripple/rippled/releases/tag/0.27.3))"
|
||||||
|
},
|
||||||
|
"emailHash": {
|
||||||
|
"description": "Hash of an email address to be used for generating an avatar image. Conventionally, clients use Gravatar to display this image. Use `null` to clear.",
|
||||||
|
"oneOf": [
|
||||||
|
{"type": "null"},
|
||||||
|
{"$ref": "hash128"}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"messageKey": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Public key for sending encrypted messages to this account. Conventionally, it should be a secp256k1 key, the same encryption that is used by the rest of Ripple."
|
||||||
|
},
|
||||||
|
"domain": {
|
||||||
|
"type": "string",
|
||||||
|
"description": " The domain that owns this account, as a hexadecimal string representing the ASCII for the domain in lowercase."
|
||||||
|
},
|
||||||
|
"transferRate": {
|
||||||
|
"description": " The fee to charge when users transfer this account’s issuances, represented as billionths of a unit. Use `null` to set no fee.",
|
||||||
|
"oneOf": [
|
||||||
|
{"type": "null"},
|
||||||
|
{"type": "number", "minimum": 1, "maximum": 4.294967295}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"regularKey": {
|
||||||
|
"oneOf": [
|
||||||
|
{"$ref": "address"},
|
||||||
|
{"type": "null"}
|
||||||
|
],
|
||||||
|
"description": "The public key of a new keypair, to use as the regular key to this account, as a base-58-encoded string in the same format as an account address. Use `null` to remove the regular key."
|
||||||
|
},
|
||||||
|
"memos": {"$ref": "memos"}
|
||||||
|
},
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||||
"title": "tag",
|
"title": "tag",
|
||||||
"description": "An arbitrary unsigned 32-bit integer most commonly used to identify a non-Ripple account.",
|
"description": "An arbitrary unsigned 32-bit integer that identifies a reason for payment or a non-Ripple account.",
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"$ref": "uint32"
|
"$ref": "uint32"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,7 +83,7 @@
|
|||||||
"description": "The time since the ledger was closed, in seconds."
|
"description": "The time since the ledger was closed, in seconds."
|
||||||
},
|
},
|
||||||
"baseFeeXRP": {
|
"baseFeeXRP": {
|
||||||
"type": "number",
|
"$ref": "value",
|
||||||
"description": "Base fee, in XRP. This may be represented in scientific notation such as 1e-05 for 0.00005."
|
"description": "Base fee, in XRP. This may be represented in scientific notation such as 1e-05 for 0.00005."
|
||||||
},
|
},
|
||||||
"hash": {
|
"hash": {
|
||||||
@@ -91,14 +91,12 @@
|
|||||||
"description": "Unique hash for the ledger, as an uppercase hexadecimal string."
|
"description": "Unique hash for the ledger, as an uppercase hexadecimal string."
|
||||||
},
|
},
|
||||||
"reserveBaseXRP": {
|
"reserveBaseXRP": {
|
||||||
"type": "integer",
|
"$ref": "value",
|
||||||
"minimum": 0,
|
"description": "Minimum amount of XRP necessary for every account to keep in reserve."
|
||||||
"description": "Minimum amount of XRP (not drops) necessary for every account to keep in reserve."
|
|
||||||
},
|
},
|
||||||
"reserveIncrementXRP": {
|
"reserveIncrementXRP": {
|
||||||
"type": "integer",
|
"$ref": "value",
|
||||||
"minimum": 0,
|
"description": "Amount of XRP added to the account reserve for each object an account is responsible for in the ledger."
|
||||||
"description": "Amount of XRP (not drops) added to the account reserve for each object an account is responsible for in the ledger."
|
|
||||||
},
|
},
|
||||||
"ledgerVersion": {
|
"ledgerVersion": {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
|
|||||||
@@ -1,73 +1,8 @@
|
|||||||
{
|
{
|
||||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||||
"title": "getSettings",
|
"title": "getSettings",
|
||||||
"type": "object",
|
"$ref": "settingsPlusMemos",
|
||||||
"properties": {
|
"not": {
|
||||||
"passwordSpent": {
|
"required": ["memos"]
|
||||||
"type": "boolean",
|
}
|
||||||
"description": "Indicates that the account has used its free SetRegularKey transaction."
|
|
||||||
},
|
|
||||||
"requireDestinationTag": {
|
|
||||||
"type": "boolean",
|
|
||||||
"description": "Requires incoming payments to specify a destination tag."
|
|
||||||
},
|
|
||||||
"requireAuthorization": {
|
|
||||||
"type": "boolean",
|
|
||||||
"description": "If set, this account must individually approve other users in order for those users to hold this account’s issuances."
|
|
||||||
},
|
|
||||||
"disallowIncomingXRP": {
|
|
||||||
"type": "boolean",
|
|
||||||
"description": "Indicates that client applications should not send XRP to this account. Not enforced by rippled."
|
|
||||||
},
|
|
||||||
"disableMasterKey": {
|
|
||||||
"type": "boolean",
|
|
||||||
"description": "Disallows use of the master key to sign transactions for this account."
|
|
||||||
},
|
|
||||||
"enableTransactionIDTracking": {
|
|
||||||
"type": "boolean",
|
|
||||||
"description": "Track the ID of this account’s most recent transaction."
|
|
||||||
},
|
|
||||||
"noFreeze": {
|
|
||||||
"type": "boolean",
|
|
||||||
"description": "Permanently give up the ability to freeze individual trust lines. This flag can never be disabled after being enabled."
|
|
||||||
},
|
|
||||||
"globalFreeze": {
|
|
||||||
"type": "boolean",
|
|
||||||
"description": "Freeze all assets issued by this account."
|
|
||||||
},
|
|
||||||
"defaultRipple": {
|
|
||||||
"type": "boolean",
|
|
||||||
"description": "Enable [rippling](https://ripple.com/knowledge_center/understanding-the-noripple-flag/) on this account’s trust lines by default. (New in [rippled 0.27.3](https://github.com/ripple/rippled/releases/tag/0.27.3))"
|
|
||||||
},
|
|
||||||
"emailHash": {
|
|
||||||
"description": "Hash of an email address to be used for generating an avatar image. Conventionally, clients use Gravatar to display this image. Use `null` to clear.",
|
|
||||||
"oneOf": [
|
|
||||||
{"type": "null"},
|
|
||||||
{"$ref": "hash128"}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"messageKey": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "Public key for sending encrypted messages to this account. Conventionally, it should be a secp256k1 key, the same encryption that is used by the rest of Ripple."
|
|
||||||
},
|
|
||||||
"domain": {
|
|
||||||
"type": "string",
|
|
||||||
"description": " The domain that owns this account, as a hexadecimal string representing the ASCII for the domain in lowercase."
|
|
||||||
},
|
|
||||||
"transferRate": {
|
|
||||||
"description": " The fee to charge when users transfer this account’s issuances, represented as billionths of a unit. Use `null` to set no fee.",
|
|
||||||
"oneOf": [
|
|
||||||
{"type": "null"},
|
|
||||||
{"type": "number", "minimum": 1, "maximum": 4.294967295}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"regularKey": {
|
|
||||||
"oneOf": [
|
|
||||||
{"$ref": "address"},
|
|
||||||
{"type": "null"}
|
|
||||||
],
|
|
||||||
"description": "The public key of a new keypair, to use as the regular key to this account, as a base-58-encoded string in the same format as an account address. Use `null` to remove the regular key."
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"additionalProperties": false
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
"state": {
|
"state": {
|
||||||
"properties": {
|
"properties": {
|
||||||
"balance": {
|
"balance": {
|
||||||
"$ref": "value",
|
"$ref": "signedValue",
|
||||||
"description": "The balance on the trustline, representing which party owes the other and by how much."
|
"description": "The balance on the trustline, representing which party owes the other and by how much."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,18 +1,12 @@
|
|||||||
{
|
{
|
||||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||||
"title": "ledgerClosed",
|
"title": "ledgerEvent",
|
||||||
"description": "A ledgerClosed event message",
|
"description": "A ledger event message",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"feeBase": {
|
"baseFeeXRP": {
|
||||||
"type": "integer",
|
"$ref": "value",
|
||||||
"minimum": 0,
|
"description": "Base fee, in XRP."
|
||||||
"description": "Base fee, in drops."
|
|
||||||
},
|
|
||||||
"feeReference": {
|
|
||||||
"type": "integer",
|
|
||||||
"minimum": 0,
|
|
||||||
"description": "Cost of the 'reference transaction' in 'fee units'."
|
|
||||||
},
|
},
|
||||||
"ledgerHash": {
|
"ledgerHash": {
|
||||||
"$ref": "hash256",
|
"$ref": "hash256",
|
||||||
@@ -27,14 +21,12 @@
|
|||||||
"format": "date-time",
|
"format": "date-time",
|
||||||
"description": "The time at which this ledger closed."
|
"description": "The time at which this ledger closed."
|
||||||
},
|
},
|
||||||
"reserveBase": {
|
"reserveBaseXRP": {
|
||||||
"type": "integer",
|
"$ref": "value",
|
||||||
"minimum": 0,
|
"description": "The minimum reserve, in XRP, that is required for an account."
|
||||||
"description": "The minimum reserve, in drops of XRP, that is required for an account."
|
|
||||||
},
|
},
|
||||||
"reserveIncrement": {
|
"reserveIncrementXRP": {
|
||||||
"type": "integer",
|
"$ref": "value",
|
||||||
"minimum": 0,
|
|
||||||
"description": "The increase in account reserve that is added for each item the account owns, such as offers or trust lines."
|
"description": "The increase in account reserve that is added for each item the account owns, such as offers or trust lines."
|
||||||
},
|
},
|
||||||
"transactionCount": {
|
"transactionCount": {
|
||||||
@@ -48,7 +40,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"addtionalProperties": false,
|
"addtionalProperties": false,
|
||||||
"required": ["feeBase", "feeReference", "ledgerHash", "ledgerTimestamp",
|
"required": ["baseFeeXRP", "ledgerHash", "ledgerTimestamp",
|
||||||
"reserveBase", "reserveIncrement", "transactionCount",
|
"reserveBaseXRP", "reserveIncrementXRP", "transactionCount",
|
||||||
"ledgerVersion", "validatedLedgerVersions"]
|
"ledgerVersion", "validatedLedgerVersions"]
|
||||||
}
|
}
|
||||||
@@ -21,12 +21,15 @@
|
|||||||
"description": "The initiating account's sequence number for this transaction."
|
"description": "The initiating account's sequence number for this transaction."
|
||||||
},
|
},
|
||||||
"maxLedgerVersion": {
|
"maxLedgerVersion": {
|
||||||
"$ref": "ledgerVersion",
|
"oneOf": [
|
||||||
"description": "The highest ledger version that the transaction can be included in."
|
{"$ref": "ledgerVersion"},
|
||||||
|
{"type": "null"}
|
||||||
|
],
|
||||||
|
"description": "The highest ledger version that the transaction can be included in. Set to `null` if there is no maximum."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"required": ["fee", "sequence"]
|
"required": ["fee", "sequence", "maxLedgerVersion"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
|
|||||||
@@ -7,7 +7,8 @@
|
|||||||
"orderSequence": {
|
"orderSequence": {
|
||||||
"$ref": "sequence",
|
"$ref": "sequence",
|
||||||
"description": "The [account sequence number](#account-sequence-number) of the order to cancel."
|
"description": "The [account sequence number](#account-sequence-number) of the order to cancel."
|
||||||
}
|
},
|
||||||
|
"memos": {"$ref": "memos"}
|
||||||
},
|
},
|
||||||
"required": ["orderSequence"],
|
"required": ["orderSequence"],
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
|
|||||||
@@ -33,7 +33,8 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"format": "date-time",
|
"format": "date-time",
|
||||||
"description": "Time after which the offer is no longer active, as an [ISO 8601 date-time](https://en.wikipedia.org/wiki/ISO_8601)."
|
"description": "Time after which the offer is no longer active, as an [ISO 8601 date-time](https://en.wikipedia.org/wiki/ISO_8601)."
|
||||||
}
|
},
|
||||||
|
"memos": {"$ref": "memos"}
|
||||||
},
|
},
|
||||||
"required": ["direction", "quantity", "totalPrice"],
|
"required": ["direction", "quantity", "totalPrice"],
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
|
|||||||
@@ -2,11 +2,17 @@
|
|||||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||||
"title": "settings",
|
"title": "settings",
|
||||||
"link": "settings",
|
"link": "settings",
|
||||||
"allOf": [
|
"$ref": "settingsPlusMemos",
|
||||||
|
"oneOf": [
|
||||||
{
|
{
|
||||||
"$ref": "getSettings"
|
"required": ["memos"],
|
||||||
|
"minProperties": 2,
|
||||||
|
"maxProperties": 2
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"not": {
|
||||||
|
"required": ["memos"]
|
||||||
|
},
|
||||||
"minProperties": 1,
|
"minProperties": 1,
|
||||||
"maxProperties": 1
|
"maxProperties": 1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,8 @@
|
|||||||
"frozen": {
|
"frozen": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "If true, the trustline is frozen, which means that funds can only be sent to the owner."
|
"description": "If true, the trustline is frozen, which means that funds can only be sent to the owner."
|
||||||
}
|
},
|
||||||
|
"memos": {"$ref": "memos"}
|
||||||
},
|
},
|
||||||
"required": ["currency", "counterparty", "limit"],
|
"required": ["currency", "counterparty", "limit"],
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import type {Connection} from './connection';
|
|||||||
export type GetServerInfoResponse = {
|
export type GetServerInfoResponse = {
|
||||||
buildVersion: string,
|
buildVersion: string,
|
||||||
completeLedgers: string,
|
completeLedgers: string,
|
||||||
hostid: string,
|
hostID: string,
|
||||||
ioLatencyMs: number,
|
ioLatencyMs: number,
|
||||||
load?: {
|
load?: {
|
||||||
jobTypes: Array<Object>,
|
jobTypes: Array<Object>,
|
||||||
@@ -23,11 +23,11 @@ export type GetServerInfoResponse = {
|
|||||||
serverState: string,
|
serverState: string,
|
||||||
validatedLedger: {
|
validatedLedger: {
|
||||||
age: number,
|
age: number,
|
||||||
baseFeeXrp: number,
|
baseFeeXRP: string,
|
||||||
hash: string,
|
hash: string,
|
||||||
reserveBaseXrp: number,
|
reserveBaseXRP: string,
|
||||||
reserveIncXrp: number,
|
reserveIncrementXRP: string,
|
||||||
seq: number
|
ledgerVersion: number
|
||||||
},
|
},
|
||||||
validationQuorum: number
|
validationQuorum: number
|
||||||
}
|
}
|
||||||
@@ -49,6 +49,12 @@ function getServerInfo(connection: Connection): Promise<GetServerInfoResponse> {
|
|||||||
reserveIncXrp: 'reserveIncrementXRP',
|
reserveIncXrp: 'reserveIncrementXRP',
|
||||||
seq: 'ledgerVersion'
|
seq: 'ledgerVersion'
|
||||||
});
|
});
|
||||||
|
info.validatedLedger.baseFeeXRP =
|
||||||
|
info.validatedLedger.baseFeeXRP.toString();
|
||||||
|
info.validatedLedger.reserveBaseXRP =
|
||||||
|
info.validatedLedger.reserveBaseXRP.toString();
|
||||||
|
info.validatedLedger.reserveIncrementXRP =
|
||||||
|
info.validatedLedger.reserveIncrementXRP.toString();
|
||||||
return info;
|
return info;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const BigNumber = require('bignumber.js');
|
const BigNumber = require('bignumber.js');
|
||||||
const errors = require('./errors');
|
|
||||||
const keypairs = require('ripple-keypairs');
|
|
||||||
const {deriveKeypair} = require('ripple-keypairs');
|
const {deriveKeypair} = require('ripple-keypairs');
|
||||||
|
|
||||||
import type {Amount, RippledAmount} from './types.js';
|
import type {Amount, RippledAmount} from './types.js';
|
||||||
@@ -37,21 +35,6 @@ function toRippledAmount(amount: Amount): RippledAmount {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateAddress(options?: Object): Object {
|
|
||||||
const secret = keypairs.generateSeed(options);
|
|
||||||
const keypair = keypairs.deriveKeypair(secret);
|
|
||||||
const address = keypairs.deriveAddress(keypair.publicKey);
|
|
||||||
return {secret, address};
|
|
||||||
}
|
|
||||||
|
|
||||||
function generateAddressAPI(options?: Object): Object {
|
|
||||||
try {
|
|
||||||
return generateAddress(options);
|
|
||||||
} catch (error) {
|
|
||||||
throw new errors.UnexpectedError(error.message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const FINDSNAKE = /([a-zA-Z]_[a-zA-Z])/g;
|
const FINDSNAKE = /([a-zA-Z]_[a-zA-Z])/g;
|
||||||
function convertKeysFromSnakeCaseToCamelCase(obj: any): any {
|
function convertKeysFromSnakeCaseToCamelCase(obj: any): any {
|
||||||
if (typeof obj === 'object') {
|
if (typeof obj === 'object') {
|
||||||
@@ -101,8 +84,6 @@ module.exports = {
|
|||||||
dropsToXrp,
|
dropsToXrp,
|
||||||
xrpToDrops,
|
xrpToDrops,
|
||||||
toRippledAmount,
|
toRippledAmount,
|
||||||
generateAddress,
|
|
||||||
generateAddressAPI,
|
|
||||||
convertKeysFromSnakeCaseToCamelCase,
|
convertKeysFromSnakeCaseToCamelCase,
|
||||||
removeUndefined,
|
removeUndefined,
|
||||||
rippleTimeToISO8601,
|
rippleTimeToISO8601,
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ module.exports = {
|
|||||||
sign: _.partial(schemaValidate, 'signParameters'),
|
sign: _.partial(schemaValidate, 'signParameters'),
|
||||||
submit: _.partial(schemaValidate, 'submitParameters'),
|
submit: _.partial(schemaValidate, 'submitParameters'),
|
||||||
computeLedgerHash: _.partial(schemaValidate, 'computeLedgerHashParameters'),
|
computeLedgerHash: _.partial(schemaValidate, 'computeLedgerHashParameters'),
|
||||||
|
generateAddress: _.partial(schemaValidate, 'generateAddressParameters'),
|
||||||
apiOptions: _.partial(schemaValidate, 'api-options'),
|
apiOptions: _.partial(schemaValidate, 'api-options'),
|
||||||
instructions: _.partial(schemaValidate, 'instructions')
|
instructions: _.partial(schemaValidate, 'instructions')
|
||||||
};
|
};
|
||||||
|
|||||||
85
src/http.js
Normal file
85
src/http.js
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
/* eslint-disable new-cap */
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const assert = require('assert');
|
||||||
|
const _ = require('lodash');
|
||||||
|
const jayson = require('jayson');
|
||||||
|
|
||||||
|
const RippleAPI = require('./api').RippleAPI;
|
||||||
|
|
||||||
|
|
||||||
|
function createHTTPServer(options, httpPort) {
|
||||||
|
const rippleAPI = new RippleAPI(options);
|
||||||
|
|
||||||
|
const methodNames = _.filter(_.keys(RippleAPI.prototype), k => {
|
||||||
|
return typeof RippleAPI.prototype[k] === 'function'
|
||||||
|
&& k !== 'connect'
|
||||||
|
&& k !== 'disconnect'
|
||||||
|
&& k !== 'constructor'
|
||||||
|
&& k !== 'RippleAPI';
|
||||||
|
});
|
||||||
|
|
||||||
|
function applyPromiseWithCallback(fnName, callback, args_) {
|
||||||
|
try {
|
||||||
|
let args = args_;
|
||||||
|
if (!_.isArray(args_)) {
|
||||||
|
const fnParameters = jayson.Utils.getParameterNames(rippleAPI[fnName]);
|
||||||
|
args = fnParameters.map(name => args_[name]);
|
||||||
|
const defaultArgs = _.omit(args_, fnParameters);
|
||||||
|
assert(_.size(defaultArgs) <= 1,
|
||||||
|
'Function must have no more than one default argument');
|
||||||
|
if (_.size(defaultArgs) > 0) {
|
||||||
|
args.push(defaultArgs[_.keys(defaultArgs)[0]]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Promise.resolve(rippleAPI[fnName].apply(rippleAPI, args))
|
||||||
|
.then(res => callback(null, res))
|
||||||
|
.catch(err => {
|
||||||
|
callback({code: 99, message: err.message, data: {name: err.name}});
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
callback({code: 99, message: err.message, data: {name: err.name}});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const methods = {};
|
||||||
|
_.forEach(methodNames, fn => {
|
||||||
|
methods[fn] = jayson.Method((args, cb) => {
|
||||||
|
applyPromiseWithCallback(fn, cb, args);
|
||||||
|
}, {collect: true});
|
||||||
|
});
|
||||||
|
|
||||||
|
const server = jayson.server(methods);
|
||||||
|
let httpServer = null;
|
||||||
|
|
||||||
|
return {
|
||||||
|
server: server,
|
||||||
|
start: function() {
|
||||||
|
if (httpServer !== null) {
|
||||||
|
return Promise.reject('Already started');
|
||||||
|
}
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
rippleAPI.connect().then(() => {
|
||||||
|
httpServer = server.http();
|
||||||
|
httpServer.listen(httpPort, resolve);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
stop: function() {
|
||||||
|
if (httpServer === null) {
|
||||||
|
return Promise.reject('Not started');
|
||||||
|
}
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
rippleAPI.disconnect();
|
||||||
|
httpServer.close(() => {
|
||||||
|
httpServer = null;
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
createHTTPServer
|
||||||
|
};
|
||||||
148
src/index.js
148
src/index.js
@@ -1,145 +1,9 @@
|
|||||||
/* @flow */
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
/* eslint-disable max-len */
|
module.exports = {
|
||||||
// Enable core-js polyfills. This allows use of ES6/7 extensions listed here:
|
RippleAPI: require('./api').RippleAPI,
|
||||||
// https://github.com/zloirock/core-js/blob/fb0890f32dabe8d4d88a4350d1b268446127132e/shim.js#L1-L103
|
// Broadcast api is experimental
|
||||||
/* eslint-enable max-len */
|
RippleAPIBroadcast: require('./broadcast').RippleAPIBroadcast,
|
||||||
|
// HTTP server is experimental
|
||||||
// In node.js env, polyfill might be already loaded (from any npm package),
|
createHTTPServer: require('./http').createHTTPServer
|
||||||
// that's why we do this check.
|
|
||||||
if (!global._babelPolyfill) {
|
|
||||||
require('babel-core/polyfill');
|
|
||||||
}
|
|
||||||
|
|
||||||
const _ = require('lodash');
|
|
||||||
const EventEmitter = require('events').EventEmitter;
|
|
||||||
const common = require('./common');
|
|
||||||
const server = require('./server/server');
|
|
||||||
const connect = server.connect;
|
|
||||||
const disconnect = server.disconnect;
|
|
||||||
const getServerInfo = server.getServerInfo;
|
|
||||||
const getFee = server.getFee;
|
|
||||||
const isConnected = server.isConnected;
|
|
||||||
const getLedgerVersion = server.getLedgerVersion;
|
|
||||||
const getTransaction = require('./ledger/transaction');
|
|
||||||
const getTransactions = require('./ledger/transactions');
|
|
||||||
const getTrustlines = require('./ledger/trustlines');
|
|
||||||
const getBalances = require('./ledger/balances');
|
|
||||||
const getBalanceSheet = require('./ledger/balance-sheet');
|
|
||||||
const getPaths = require('./ledger/pathfind');
|
|
||||||
const getOrders = require('./ledger/orders');
|
|
||||||
const getOrderbook = require('./ledger/orderbook');
|
|
||||||
const getSettings = require('./ledger/settings');
|
|
||||||
const getAccountInfo = require('./ledger/accountinfo');
|
|
||||||
const preparePayment = require('./transaction/payment');
|
|
||||||
const prepareTrustline = require('./transaction/trustline');
|
|
||||||
const prepareOrder = require('./transaction/order');
|
|
||||||
const prepareOrderCancellation = require('./transaction/ordercancellation');
|
|
||||||
const prepareSuspendedPaymentCreation =
|
|
||||||
require('./transaction/suspended-payment-creation');
|
|
||||||
const prepareSuspendedPaymentExecution =
|
|
||||||
require('./transaction/suspended-payment-execution');
|
|
||||||
const prepareSuspendedPaymentCancellation =
|
|
||||||
require('./transaction/suspended-payment-cancellation');
|
|
||||||
const prepareSettings = require('./transaction/settings');
|
|
||||||
const sign = require('./transaction/sign');
|
|
||||||
const submit = require('./transaction/submit');
|
|
||||||
const errors = require('./common').errors;
|
|
||||||
const generateAddress = common.generateAddressAPI;
|
|
||||||
const computeLedgerHash = require('./offline/ledgerhash');
|
|
||||||
const getLedger = require('./ledger/ledger');
|
|
||||||
|
|
||||||
type APIOptions = {
|
|
||||||
servers?: Array<string>,
|
|
||||||
feeCushion?: number,
|
|
||||||
trace?: boolean,
|
|
||||||
proxy?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
// prevent access to non-validated ledger versions
|
|
||||||
class RestrictedConnection extends common.Connection {
|
|
||||||
request(request, timeout) {
|
|
||||||
const ledger_index = request.ledger_index;
|
|
||||||
if (ledger_index !== undefined && ledger_index !== 'validated') {
|
|
||||||
if (!_.isNumber(ledger_index) || ledger_index > this._ledgerVersion) {
|
|
||||||
return Promise.reject(new errors.LedgerVersionError(
|
|
||||||
`ledgerVersion ${ledger_index} is greater than server\'s ` +
|
|
||||||
`most recent validated ledger: ${this._ledgerVersion}`));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return super.request(request, timeout);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class RippleAPI extends EventEmitter {
|
|
||||||
constructor(options: APIOptions = {}) {
|
|
||||||
common.validate.apiOptions(options);
|
|
||||||
super();
|
|
||||||
this._feeCushion = options.feeCushion || 1.2;
|
|
||||||
if (options.servers !== undefined) {
|
|
||||||
const servers: Array<string> = options.servers;
|
|
||||||
if (servers.length === 1) {
|
|
||||||
this.connection = new RestrictedConnection(servers[0], options);
|
|
||||||
this.connection.on('ledgerClosed', message => {
|
|
||||||
this.emit('ledgerClosed', server.formatLedgerClose(message));
|
|
||||||
});
|
|
||||||
this.connection.on('error', (type, info) => {
|
|
||||||
this.emit('error', type, info);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
throw new errors.RippleError('Multi-server not implemented');
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// use null object pattern to provide better error message if user
|
|
||||||
// tries to call a method that requires a connection
|
|
||||||
this.connection = new RestrictedConnection(null, options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_.assign(RippleAPI.prototype, {
|
|
||||||
connect,
|
|
||||||
disconnect,
|
|
||||||
isConnected,
|
|
||||||
getServerInfo,
|
|
||||||
getFee,
|
|
||||||
getLedgerVersion,
|
|
||||||
|
|
||||||
getTransaction,
|
|
||||||
getTransactions,
|
|
||||||
getTrustlines,
|
|
||||||
getBalances,
|
|
||||||
getBalanceSheet,
|
|
||||||
getPaths,
|
|
||||||
getOrders,
|
|
||||||
getOrderbook,
|
|
||||||
getSettings,
|
|
||||||
getAccountInfo,
|
|
||||||
getLedger,
|
|
||||||
|
|
||||||
preparePayment,
|
|
||||||
prepareTrustline,
|
|
||||||
prepareOrder,
|
|
||||||
prepareOrderCancellation,
|
|
||||||
prepareSuspendedPaymentCreation,
|
|
||||||
prepareSuspendedPaymentExecution,
|
|
||||||
prepareSuspendedPaymentCancellation,
|
|
||||||
prepareSettings,
|
|
||||||
sign,
|
|
||||||
submit,
|
|
||||||
|
|
||||||
generateAddress,
|
|
||||||
computeLedgerHash,
|
|
||||||
errors
|
|
||||||
});
|
|
||||||
|
|
||||||
// these are exposed only for use by unit tests; they are not part of the API
|
|
||||||
RippleAPI._PRIVATE = {
|
|
||||||
validate: common.validate,
|
|
||||||
RangeSet: require('./common/rangeset').RangeSet,
|
|
||||||
ledgerUtils: require('./ledger/utils'),
|
|
||||||
schemaValidator: require('./common/schema-validator')
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.RippleAPI = RippleAPI;
|
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ function parseAccountTrustline(trustline: Trustline): AccountTrustline {
|
|||||||
limit: trustline.limit,
|
limit: trustline.limit,
|
||||||
currency: trustline.currency,
|
currency: trustline.currency,
|
||||||
counterparty: trustline.account,
|
counterparty: trustline.account,
|
||||||
qualityIn: trustline.quality_in || undefined,
|
qualityIn: utils.parseQuality(trustline.quality_in) || undefined,
|
||||||
qualityOut: trustline.quality_out || undefined,
|
qualityOut: utils.parseQuality(trustline.quality_out) || undefined,
|
||||||
ripplingDisabled: trustline.no_ripple || undefined,
|
ripplingDisabled: trustline.no_ripple || undefined,
|
||||||
frozen: trustline.freeze || undefined,
|
frozen: trustline.freeze || undefined,
|
||||||
authorized: trustline.authorized || undefined
|
authorized: trustline.authorized || undefined
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const utils = require('./utils');
|
const utils = require('./utils');
|
||||||
const flags = utils.txFlags.TrustSet;
|
const flags = utils.txFlags.TrustSet;
|
||||||
const BigNumber = require('bignumber.js');
|
|
||||||
|
|
||||||
function parseFlag(flagsValue, trueValue, falseValue) {
|
function parseFlag(flagsValue, trueValue, falseValue) {
|
||||||
if (flagsValue & trueValue) {
|
if (flagsValue & trueValue) {
|
||||||
@@ -15,13 +14,6 @@ function parseFlag(flagsValue, trueValue, falseValue) {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseQuality(quality?: number) {
|
|
||||||
if (typeof quality === 'number') {
|
|
||||||
return (new BigNumber(quality)).shift(-9).toNumber();
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
function parseTrustline(tx: Object): Object {
|
function parseTrustline(tx: Object): Object {
|
||||||
assert(tx.TransactionType === 'TrustSet');
|
assert(tx.TransactionType === 'TrustSet');
|
||||||
|
|
||||||
@@ -29,8 +21,8 @@ function parseTrustline(tx: Object): Object {
|
|||||||
limit: tx.LimitAmount.value,
|
limit: tx.LimitAmount.value,
|
||||||
currency: tx.LimitAmount.currency,
|
currency: tx.LimitAmount.currency,
|
||||||
counterparty: tx.LimitAmount.issuer,
|
counterparty: tx.LimitAmount.issuer,
|
||||||
qualityIn: parseQuality(tx.QualityIn),
|
qualityIn: utils.parseQuality(tx.QualityIn),
|
||||||
qualityOut: parseQuality(tx.QualityOut),
|
qualityOut: utils.parseQuality(tx.QualityOut),
|
||||||
ripplingDisabled: parseFlag(
|
ripplingDisabled: parseFlag(
|
||||||
tx.Flags, flags.SetNoRipple, flags.ClearNoRipple),
|
tx.Flags, flags.SetNoRipple, flags.ClearNoRipple),
|
||||||
frozen: parseFlag(tx.Flags, flags.SetFreeze, flags.ClearFreeze),
|
frozen: parseFlag(tx.Flags, flags.SetFreeze, flags.ClearFreeze),
|
||||||
|
|||||||
@@ -17,6 +17,13 @@ function adjustQualityForXRP(
|
|||||||
(new BigNumber(quality)).shift(shift).toString();
|
(new BigNumber(quality)).shift(shift).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function parseQuality(quality: ?number) {
|
||||||
|
if (typeof quality === 'number') {
|
||||||
|
return (new BigNumber(quality)).shift(-9).toNumber();
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
function parseTimestamp(rippleTime: number): string | void {
|
function parseTimestamp(rippleTime: number): string | void {
|
||||||
return rippleTime ? utils.common.rippleTimeToISO8601(rippleTime) : undefined;
|
return rippleTime ? utils.common.rippleTimeToISO8601(rippleTime) : undefined;
|
||||||
}
|
}
|
||||||
@@ -80,6 +87,7 @@ function parseMemos(tx: Object): ?Array<Object> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
parseQuality,
|
||||||
parseOutcome,
|
parseOutcome,
|
||||||
parseMemos,
|
parseMemos,
|
||||||
hexToString,
|
hexToString,
|
||||||
|
|||||||
@@ -47,9 +47,6 @@ function parseAccountTxTransaction(tx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function counterpartyFilter(filters, tx: TransactionType) {
|
function counterpartyFilter(filters, tx: TransactionType) {
|
||||||
if (!filters.counterparty) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (tx.address === filters.counterparty || (
|
if (tx.address === filters.counterparty || (
|
||||||
tx.specification && (
|
tx.specification && (
|
||||||
(tx.specification.destination &&
|
(tx.specification.destination &&
|
||||||
@@ -173,11 +170,11 @@ function getTransactions(address: string, options: TransactionsOptions = {}
|
|||||||
const ledgerVersion = tx.outcome.ledgerVersion;
|
const ledgerVersion = tx.outcome.ledgerVersion;
|
||||||
const bound = options.earliestFirst ?
|
const bound = options.earliestFirst ?
|
||||||
{minLedgerVersion: ledgerVersion} : {maxLedgerVersion: ledgerVersion};
|
{minLedgerVersion: ledgerVersion} : {maxLedgerVersion: ledgerVersion};
|
||||||
const newOptions = _.assign(defaults, options, {startTx: tx}, bound);
|
const newOptions = _.assign({}, defaults, options, {startTx: tx}, bound);
|
||||||
return getTransactionsInternal(this.connection, address, newOptions);
|
return getTransactionsInternal(this.connection, address, newOptions);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const newOptions = _.assign(defaults, options);
|
const newOptions = _.assign({}, defaults, options);
|
||||||
return getTransactionsInternal(this.connection, address, newOptions);
|
return getTransactionsInternal(this.connection, address, newOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
24
src/offline/generate-address.js
Normal file
24
src/offline/generate-address.js
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
'use strict';
|
||||||
|
const keypairs = require('ripple-keypairs');
|
||||||
|
const common = require('../common');
|
||||||
|
const {errors, validate} = common;
|
||||||
|
|
||||||
|
function generateAddress(options?: Object): Object {
|
||||||
|
const secret = keypairs.generateSeed(options);
|
||||||
|
const keypair = keypairs.deriveKeypair(secret);
|
||||||
|
const address = keypairs.deriveAddress(keypair.publicKey);
|
||||||
|
return {secret, address};
|
||||||
|
}
|
||||||
|
|
||||||
|
function generateAddressAPI(options?: Object): Object {
|
||||||
|
validate.generateAddress({options});
|
||||||
|
try {
|
||||||
|
return generateAddress(options);
|
||||||
|
} catch (error) {
|
||||||
|
throw new errors.UnexpectedError(error.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
generateAddressAPI
|
||||||
|
};
|
||||||
@@ -30,13 +30,12 @@ function getFee(): Promise<number> {
|
|||||||
|
|
||||||
function formatLedgerClose(ledgerClose: Object): Object {
|
function formatLedgerClose(ledgerClose: Object): Object {
|
||||||
return {
|
return {
|
||||||
feeBase: ledgerClose.fee_base,
|
baseFeeXRP: common.dropsToXrp(ledgerClose.fee_base),
|
||||||
feeReference: ledgerClose.fee_ref,
|
|
||||||
ledgerHash: ledgerClose.ledger_hash,
|
ledgerHash: ledgerClose.ledger_hash,
|
||||||
ledgerVersion: ledgerClose.ledger_index,
|
ledgerVersion: ledgerClose.ledger_index,
|
||||||
ledgerTimestamp: common.rippleTimeToISO8601(ledgerClose.ledger_time),
|
ledgerTimestamp: common.rippleTimeToISO8601(ledgerClose.ledger_time),
|
||||||
reserveBase: ledgerClose.reserve_base,
|
reserveBaseXRP: common.dropsToXrp(ledgerClose.reserve_base),
|
||||||
reserveIncrement: ledgerClose.reserve_inc,
|
reserveIncrementXRP: common.dropsToXrp(ledgerClose.reserve_inc),
|
||||||
transactionCount: ledgerClose.txn_count,
|
transactionCount: ledgerClose.txn_count,
|
||||||
validatedLedgerVersions: ledgerClose.validated_ledgers
|
validatedLedgerVersions: ledgerClose.validated_ledgers
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
const _ = require('lodash');
|
||||||
const utils = require('./utils');
|
const utils = require('./utils');
|
||||||
const offerFlags = utils.common.txFlags.OfferCreate;
|
const offerFlags = utils.common.txFlags.OfferCreate;
|
||||||
const {validate, iso8601ToRippleTime} = utils.common;
|
const {validate, iso8601ToRippleTime} = utils.common;
|
||||||
@@ -34,6 +35,9 @@ function createOrderTransaction(account: string, order: Order): Object {
|
|||||||
if (order.expirationTime !== undefined) {
|
if (order.expirationTime !== undefined) {
|
||||||
txJSON.Expiration = iso8601ToRippleTime(order.expirationTime);
|
txJSON.Expiration = iso8601ToRippleTime(order.expirationTime);
|
||||||
}
|
}
|
||||||
|
if (order.memos !== undefined) {
|
||||||
|
txJSON.Memos = _.map(order.memos, utils.convertMemo);
|
||||||
|
}
|
||||||
return txJSON;
|
return txJSON;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,24 +1,29 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
const _ = require('lodash');
|
||||||
const utils = require('./utils');
|
const utils = require('./utils');
|
||||||
const validate = utils.common.validate;
|
const validate = utils.common.validate;
|
||||||
import type {Instructions, Prepare} from './types.js';
|
import type {Instructions, Prepare} from './types.js';
|
||||||
|
|
||||||
function createOrderCancellationTransaction(account: string,
|
function createOrderCancellationTransaction(account: string,
|
||||||
sequence: number
|
orderCancellation: Object
|
||||||
): Object {
|
): Object {
|
||||||
return {
|
const txJSON: Object = {
|
||||||
TransactionType: 'OfferCancel',
|
TransactionType: 'OfferCancel',
|
||||||
Account: account,
|
Account: account,
|
||||||
OfferSequence: sequence
|
OfferSequence: orderCancellation.orderSequence
|
||||||
};
|
};
|
||||||
|
if (orderCancellation.memos !== undefined) {
|
||||||
|
txJSON.Memos = _.map(orderCancellation.memos, utils.convertMemo);
|
||||||
|
}
|
||||||
|
return txJSON;
|
||||||
}
|
}
|
||||||
|
|
||||||
function prepareOrderCancellation(address: string, sequence: number,
|
function prepareOrderCancellation(address: string, orderCancellation: Object,
|
||||||
instructions: Instructions = {}
|
instructions: Instructions = {}
|
||||||
): Promise<Prepare> {
|
): Promise<Prepare> {
|
||||||
validate.prepareOrderCancellation({address, sequence, instructions});
|
validate.prepareOrderCancellation({address, orderCancellation, instructions});
|
||||||
const txJSON = createOrderCancellationTransaction(address, sequence);
|
const txJSON = createOrderCancellationTransaction(address, orderCancellation);
|
||||||
return utils.prepareTransaction(txJSON, this, instructions);
|
return utils.prepareTransaction(txJSON, this, instructions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,8 +33,10 @@ type Payment = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function isXRPToXRPPayment(payment: Payment): boolean {
|
function isXRPToXRPPayment(payment: Payment): boolean {
|
||||||
const sourceCurrency = _.get(payment, 'source.maxAmount.currency');
|
const sourceCurrency = _.get(payment, 'source.maxAmount.currency',
|
||||||
const destinationCurrency = _.get(payment, 'destination.amount.currency');
|
_.get(payment, 'source.amount.currency'));
|
||||||
|
const destinationCurrency = _.get(payment, 'destination.amount.currency',
|
||||||
|
_.get(payment, 'destination.minAmount.currency'));
|
||||||
return sourceCurrency === 'XRP' && destinationCurrency === 'XRP';
|
return sourceCurrency === 'XRP' && destinationCurrency === 'XRP';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,7 +64,7 @@ function createMaximalAmount(amount: Amount): Amount {
|
|||||||
const maxXRPValue = '100000000000';
|
const maxXRPValue = '100000000000';
|
||||||
const maxIOUValue = '9999999999999999e80';
|
const maxIOUValue = '9999999999999999e80';
|
||||||
const maxValue = amount.currency === 'XRP' ? maxXRPValue : maxIOUValue;
|
const maxValue = amount.currency === 'XRP' ? maxXRPValue : maxIOUValue;
|
||||||
return _.assign(amount, {value: maxValue});
|
return _.assign({}, amount, {value: maxValue});
|
||||||
}
|
}
|
||||||
|
|
||||||
function createPaymentTransaction(address: string, paymentArgument: Payment
|
function createPaymentTransaction(address: string, paymentArgument: Payment
|
||||||
|
|||||||
@@ -87,7 +87,12 @@ function createSettingsTransaction(account: string, settings: Settings
|
|||||||
TransactionType: 'AccountSet',
|
TransactionType: 'AccountSet',
|
||||||
Account: account
|
Account: account
|
||||||
};
|
};
|
||||||
setTransactionFlags(txJSON, settings);
|
|
||||||
|
if (settings.memos !== undefined) {
|
||||||
|
txJSON.Memos = _.map(settings.memos, utils.convertMemo);
|
||||||
|
}
|
||||||
|
|
||||||
|
setTransactionFlags(txJSON, _.omit(settings, 'memos'));
|
||||||
setTransactionFields(txJSON, settings);
|
setTransactionFields(txJSON, settings);
|
||||||
|
|
||||||
if (txJSON.TransferRate !== undefined) {
|
if (txJSON.TransferRate !== undefined) {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
const _ = require('lodash');
|
||||||
const utils = require('./utils');
|
const utils = require('./utils');
|
||||||
const validate = utils.common.validate;
|
const validate = utils.common.validate;
|
||||||
const trustlineFlags = utils.common.txFlags.TrustSet;
|
const trustlineFlags = utils.common.txFlags.TrustSet;
|
||||||
@@ -8,8 +9,7 @@ import type {Instructions, Prepare} from './types.js';
|
|||||||
import type {TrustLineSpecification} from '../ledger/trustlines-types.js';
|
import type {TrustLineSpecification} from '../ledger/trustlines-types.js';
|
||||||
|
|
||||||
function convertQuality(quality) {
|
function convertQuality(quality) {
|
||||||
return quality === undefined ? undefined :
|
return (new BigNumber(quality)).shift(9).truncated().toNumber();
|
||||||
(new BigNumber(quality)).shift(9).truncated().toNumber();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function createTrustlineTransaction(account: string,
|
function createTrustlineTransaction(account: string,
|
||||||
@@ -44,6 +44,9 @@ function createTrustlineTransaction(account: string,
|
|||||||
txJSON.Flags |= trustline.frozen ?
|
txJSON.Flags |= trustline.frozen ?
|
||||||
trustlineFlags.SetFreeze : trustlineFlags.ClearFreeze;
|
trustlineFlags.SetFreeze : trustlineFlags.ClearFreeze;
|
||||||
}
|
}
|
||||||
|
if (trustline.memos !== undefined) {
|
||||||
|
txJSON.Memos = _.map(trustline.memos, utils.convertMemo);
|
||||||
|
}
|
||||||
return txJSON;
|
return txJSON;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ function formatPrepareResponse(txJSON: Object): Object {
|
|||||||
const instructions = {
|
const instructions = {
|
||||||
fee: common.dropsToXrp(txJSON.Fee),
|
fee: common.dropsToXrp(txJSON.Fee),
|
||||||
sequence: txJSON.Sequence,
|
sequence: txJSON.Sequence,
|
||||||
maxLedgerVersion: txJSON.LastLedgerSequence
|
maxLedgerVersion: txJSON.LastLedgerSequence === undefined ?
|
||||||
|
null : txJSON.LastLedgerSequence
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
txJSON: JSON.stringify(txJSON),
|
txJSON: JSON.stringify(txJSON),
|
||||||
@@ -36,7 +37,9 @@ function prepareTransaction(txJSON: Object, api: Object,
|
|||||||
|
|
||||||
function prepareMaxLedgerVersion(): Promise<Object> {
|
function prepareMaxLedgerVersion(): Promise<Object> {
|
||||||
if (instructions.maxLedgerVersion !== undefined) {
|
if (instructions.maxLedgerVersion !== undefined) {
|
||||||
txJSON.LastLedgerSequence = instructions.maxLedgerVersion;
|
if (instructions.maxLedgerVersion !== null) {
|
||||||
|
txJSON.LastLedgerSequence = instructions.maxLedgerVersion;
|
||||||
|
}
|
||||||
return Promise.resolve(txJSON);
|
return Promise.resolve(txJSON);
|
||||||
}
|
}
|
||||||
const offset = instructions.maxLedgerVersionOffset !== undefined ?
|
const offset = instructions.maxLedgerVersionOffset !== undefined ?
|
||||||
|
|||||||
525
test/api-test.js
525
test/api-test.js
@@ -14,6 +14,10 @@ const address = addresses.ACCOUNT;
|
|||||||
const utils = RippleAPI._PRIVATE.ledgerUtils;
|
const utils = RippleAPI._PRIVATE.ledgerUtils;
|
||||||
const ledgerClosed = require('./fixtures/rippled/ledger-close-newer');
|
const ledgerClosed = require('./fixtures/rippled/ledger-close-newer');
|
||||||
const schemaValidator = RippleAPI._PRIVATE.schemaValidator;
|
const schemaValidator = RippleAPI._PRIVATE.schemaValidator;
|
||||||
|
assert.options.strict = true;
|
||||||
|
|
||||||
|
function unused() {
|
||||||
|
}
|
||||||
|
|
||||||
function closeLedger(connection) {
|
function closeLedger(connection) {
|
||||||
connection._ws.emit('message', JSON.stringify(ledgerClosed));
|
connection._ws.emit('message', JSON.stringify(ledgerClosed));
|
||||||
@@ -31,49 +35,95 @@ function checkResult(expected, schemaName, response) {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
describe('RippleAPI', function() {
|
describe('RippleAPI', function() {
|
||||||
const instructions = {maxLedgerVersionOffset: 100};
|
const instructions = {maxLedgerVersionOffset: 100};
|
||||||
beforeEach(setupAPI.setup);
|
beforeEach(setupAPI.setup);
|
||||||
afterEach(setupAPI.teardown);
|
afterEach(setupAPI.teardown);
|
||||||
|
|
||||||
it('preparePayment', function() {
|
it('error inspect', function() {
|
||||||
const localInstructions = _.defaults({
|
const error = new this.api.errors.RippleError('mess', {data: 1});
|
||||||
maxFee: '0.000012'
|
assert.strictEqual(error.inspect(), '[RippleError(mess, { data: 1 })]');
|
||||||
}, instructions);
|
|
||||||
return this.api.preparePayment(
|
|
||||||
address, requests.preparePayment, localInstructions).then(
|
|
||||||
_.partial(checkResult, responses.preparePayment.normal, 'prepare'));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('preparePayment with all options specified', function() {
|
describe('preparePayment', function() {
|
||||||
return this.api.getLedgerVersion().then((ver) => {
|
|
||||||
const localInstructions = {
|
it('normal', function() {
|
||||||
maxLedgerVersion: ver + 100,
|
const localInstructions = _.defaults({
|
||||||
fee: '0.000012'
|
maxFee: '0.000012'
|
||||||
};
|
}, instructions);
|
||||||
return this.api.preparePayment(
|
return this.api.preparePayment(
|
||||||
address, requests.preparePaymentAllOptions, localInstructions).then(
|
address, requests.preparePayment.normal, localInstructions).then(
|
||||||
_.partial(checkResult, responses.preparePayment.allOptions, 'prepare'));
|
_.partial(checkResult, responses.preparePayment.normal, 'prepare'));
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
it('preparePayment without counterparty set', function() {
|
it('preparePayment - min amount xrp', function() {
|
||||||
const localInstructions = _.defaults({sequence: 23}, instructions);
|
const localInstructions = _.defaults({
|
||||||
return this.api.preparePayment(
|
maxFee: '0.000012'
|
||||||
address, requests.preparePaymentNoCounterparty, localInstructions).then(
|
}, instructions);
|
||||||
_.partial(checkResult, responses.preparePayment.noCounterparty,
|
return this.api.preparePayment(
|
||||||
'prepare'));
|
address, requests.preparePayment.minAmountXRP, localInstructions).then(
|
||||||
});
|
_.partial(checkResult,
|
||||||
|
responses.preparePayment.minAmountXRP, 'prepare'));
|
||||||
|
});
|
||||||
|
|
||||||
it('preparePayment - destination.minAmount', function() {
|
it('preparePayment - min amount xrp2xrp', function() {
|
||||||
return this.api.preparePayment(address, responses.getPaths.sendAll[0],
|
return this.api.preparePayment(
|
||||||
instructions).then(_.partial(checkResult,
|
address, requests.preparePayment.minAmount, instructions).then(
|
||||||
responses.preparePayment.minAmount, 'prepare'));
|
_.partial(checkResult,
|
||||||
|
responses.preparePayment.minAmountXRPXRP, 'prepare'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('preparePayment - XRP to XRP no partial', function() {
|
||||||
|
assert.throws(() => {
|
||||||
|
this.api.preparePayment(address, requests.preparePayment.wrongPartial);
|
||||||
|
}, /XRP to XRP payments cannot be partial payments/);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('preparePayment - address must match payment.source.address', function(
|
||||||
|
) {
|
||||||
|
assert.throws(() => {
|
||||||
|
this.api.preparePayment(address, requests.preparePayment.wrongAddress);
|
||||||
|
}, /address must match payment.source.address/);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('preparePayment - wrong amount', function() {
|
||||||
|
assert.throws(() => {
|
||||||
|
this.api.preparePayment(address, requests.preparePayment.wrongAmount);
|
||||||
|
}, this.api.errors.ValidationError);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('preparePayment with all options specified', function() {
|
||||||
|
return this.api.getLedgerVersion().then((ver) => {
|
||||||
|
const localInstructions = {
|
||||||
|
maxLedgerVersion: ver + 100,
|
||||||
|
fee: '0.000012'
|
||||||
|
};
|
||||||
|
return this.api.preparePayment(
|
||||||
|
address, requests.preparePayment.allOptions, localInstructions).then(
|
||||||
|
_.partial(checkResult,
|
||||||
|
responses.preparePayment.allOptions, 'prepare'));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('preparePayment without counterparty set', function() {
|
||||||
|
const localInstructions = _.defaults({sequence: 23}, instructions);
|
||||||
|
return this.api.preparePayment(
|
||||||
|
address, requests.preparePayment.noCounterparty, localInstructions)
|
||||||
|
.then(_.partial(checkResult, responses.preparePayment.noCounterparty,
|
||||||
|
'prepare'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('preparePayment - destination.minAmount', function() {
|
||||||
|
return this.api.preparePayment(address, responses.getPaths.sendAll[0],
|
||||||
|
instructions).then(_.partial(checkResult,
|
||||||
|
responses.preparePayment.minAmount, 'prepare'));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('prepareOrder - buy order', function() {
|
it('prepareOrder - buy order', function() {
|
||||||
const request = requests.prepareOrder.buy;
|
const request = requests.prepareOrder.buy;
|
||||||
return this.api.prepareOrder(address, request, instructions)
|
return this.api.prepareOrder(address, request)
|
||||||
.then(_.partial(checkResult, responses.prepareOrder.buy, 'prepare'));
|
.then(_.partial(checkResult, responses.prepareOrder.buy, 'prepare'));
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -91,9 +141,25 @@ describe('RippleAPI', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('prepareOrderCancellation', function() {
|
it('prepareOrderCancellation', function() {
|
||||||
const request = requests.prepareOrderCancellation;
|
const request = requests.prepareOrderCancellation.simple;
|
||||||
return this.api.prepareOrderCancellation(address, request, instructions)
|
return this.api.prepareOrderCancellation(address, request, instructions)
|
||||||
.then(_.partial(checkResult, responses.prepareOrderCancellation,
|
.then(_.partial(checkResult, responses.prepareOrderCancellation.normal,
|
||||||
|
'prepare'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('prepareOrderCancellation - no instructions', function() {
|
||||||
|
const request = requests.prepareOrderCancellation.simple;
|
||||||
|
return this.api.prepareOrderCancellation(address, request)
|
||||||
|
.then(_.partial(checkResult,
|
||||||
|
responses.prepareOrderCancellation.noInstructions,
|
||||||
|
'prepare'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('prepareOrderCancellation - with memos', function() {
|
||||||
|
const request = requests.prepareOrderCancellation.withMemos;
|
||||||
|
return this.api.prepareOrderCancellation(address, request)
|
||||||
|
.then(_.partial(checkResult,
|
||||||
|
responses.prepareOrderCancellation.withMemos,
|
||||||
'prepare'));
|
'prepare'));
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -103,6 +169,12 @@ describe('RippleAPI', function() {
|
|||||||
_.partial(checkResult, responses.prepareTrustline.simple, 'prepare'));
|
_.partial(checkResult, responses.prepareTrustline.simple, 'prepare'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('prepareTrustline - frozen', function() {
|
||||||
|
return this.api.prepareTrustline(
|
||||||
|
address, requests.prepareTrustline.frozen).then(
|
||||||
|
_.partial(checkResult, responses.prepareTrustline.frozen, 'prepare'));
|
||||||
|
});
|
||||||
|
|
||||||
it('prepareTrustline - complex', function() {
|
it('prepareTrustline - complex', function() {
|
||||||
return this.api.prepareTrustline(
|
return this.api.prepareTrustline(
|
||||||
address, requests.prepareTrustline.complex, instructions).then(
|
address, requests.prepareTrustline.complex, instructions).then(
|
||||||
@@ -115,6 +187,22 @@ describe('RippleAPI', function() {
|
|||||||
_.partial(checkResult, responses.prepareSettings.flags, 'prepare'));
|
_.partial(checkResult, responses.prepareSettings.flags, 'prepare'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('prepareSettings - no maxLedgerVersion', function() {
|
||||||
|
return this.api.prepareSettings(
|
||||||
|
address, requests.prepareSettings, {maxLedgerVersion: null}).then(
|
||||||
|
_.partial(checkResult, responses.prepareSettings.noMaxLedgerVersion,
|
||||||
|
'prepare'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('prepareSettings - no instructions', function() {
|
||||||
|
return this.api.prepareSettings(
|
||||||
|
address, requests.prepareSettings).then(
|
||||||
|
_.partial(
|
||||||
|
checkResult,
|
||||||
|
responses.prepareSettings.noInstructions,
|
||||||
|
'prepare'));
|
||||||
|
});
|
||||||
|
|
||||||
it('prepareSettings - regularKey', function() {
|
it('prepareSettings - regularKey', function() {
|
||||||
const regularKey = {regularKey: 'rAR8rR8sUkBoCZFawhkWzY4Y5YoyuznwD'};
|
const regularKey = {regularKey: 'rAR8rR8sUkBoCZFawhkWzY4Y5YoyuznwD'};
|
||||||
return this.api.prepareSettings(address, regularKey, instructions).then(
|
return this.api.prepareSettings(address, regularKey, instructions).then(
|
||||||
@@ -161,42 +249,71 @@ describe('RippleAPI', function() {
|
|||||||
maxFee: '0.000012'
|
maxFee: '0.000012'
|
||||||
}, instructions);
|
}, instructions);
|
||||||
return this.api.prepareSuspendedPaymentCreation(
|
return this.api.prepareSuspendedPaymentCreation(
|
||||||
address, requests.prepareSuspendedPaymentCreation,
|
address, requests.prepareSuspendedPaymentCreation.normal,
|
||||||
localInstructions).then(
|
localInstructions).then(
|
||||||
_.partial(checkResult, responses.prepareSuspendedPaymentCreation,
|
_.partial(checkResult, responses.prepareSuspendedPaymentCreation.normal,
|
||||||
|
'prepare'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('prepareSuspendedPaymentCreation full', function() {
|
||||||
|
return this.api.prepareSuspendedPaymentCreation(
|
||||||
|
address, requests.prepareSuspendedPaymentCreation.full).then(
|
||||||
|
_.partial(checkResult, responses.prepareSuspendedPaymentCreation.full,
|
||||||
'prepare'));
|
'prepare'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('prepareSuspendedPaymentExecution', function() {
|
it('prepareSuspendedPaymentExecution', function() {
|
||||||
return this.api.prepareSuspendedPaymentExecution(
|
return this.api.prepareSuspendedPaymentExecution(
|
||||||
address, requests.prepareSuspendedPaymentExecution, instructions).then(
|
address,
|
||||||
_.partial(checkResult, responses.prepareSuspendedPaymentExecution,
|
requests.prepareSuspendedPaymentExecution.normal, instructions).then(
|
||||||
'prepare'));
|
_.partial(checkResult,
|
||||||
|
responses.prepareSuspendedPaymentExecution.normal,
|
||||||
|
'prepare'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('prepareSuspendedPaymentExecution - simple', function() {
|
||||||
|
return this.api.prepareSuspendedPaymentExecution(
|
||||||
|
address,
|
||||||
|
requests.prepareSuspendedPaymentExecution.simple).then(
|
||||||
|
_.partial(checkResult,
|
||||||
|
responses.prepareSuspendedPaymentExecution.simple,
|
||||||
|
'prepare'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('prepareSuspendedPaymentCancellation', function() {
|
it('prepareSuspendedPaymentCancellation', function() {
|
||||||
return this.api.prepareSuspendedPaymentCancellation(
|
return this.api.prepareSuspendedPaymentCancellation(
|
||||||
address, requests.prepareSuspendedPaymentCancellation, instructions).then(
|
address,
|
||||||
_.partial(checkResult, responses.prepareSuspendedPaymentCancellation,
|
requests.prepareSuspendedPaymentCancellation.normal, instructions).then(
|
||||||
'prepare'));
|
_.partial(checkResult,
|
||||||
|
responses.prepareSuspendedPaymentCancellation.normal,
|
||||||
|
'prepare'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('prepareSuspendedPaymentCancellation with memos', function() {
|
||||||
|
return this.api.prepareSuspendedPaymentCancellation(
|
||||||
|
address,
|
||||||
|
requests.prepareSuspendedPaymentCancellation.memos).then(
|
||||||
|
_.partial(checkResult,
|
||||||
|
responses.prepareSuspendedPaymentCancellation.memos,
|
||||||
|
'prepare'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sign', function() {
|
it('sign', function() {
|
||||||
const secret = 'shsWGZcmZz6YsWWmcnpfr6fLTdtFV';
|
const secret = 'shsWGZcmZz6YsWWmcnpfr6fLTdtFV';
|
||||||
const result = this.api.sign(requests.sign.txJSON, secret);
|
const result = this.api.sign(requests.sign.normal.txJSON, secret);
|
||||||
assert.deepEqual(result, responses.sign);
|
assert.deepEqual(result, responses.sign.normal);
|
||||||
schemaValidator.schemaValidate('sign', result);
|
schemaValidator.schemaValidate('sign', result);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sign - SuspendedPaymentExecution', function() {
|
it('sign - SuspendedPaymentExecution', function() {
|
||||||
const secret = 'snoPBrXtMeMyMHUVTgbuqAfg1SUTb';
|
const secret = 'snoPBrXtMeMyMHUVTgbuqAfg1SUTb';
|
||||||
const result = this.api.sign(requests.signSuspended.txJSON, secret);
|
const result = this.api.sign(requests.sign.suspended.txJSON, secret);
|
||||||
assert.deepEqual(result, responses.signSuspended);
|
assert.deepEqual(result, responses.sign.suspended);
|
||||||
schemaValidator.schemaValidate('sign', result);
|
schemaValidator.schemaValidate('sign', result);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('submit', function() {
|
it('submit', function() {
|
||||||
return this.api.submit(responses.sign.signedTransaction).then(
|
return this.api.submit(responses.sign.normal.signedTransaction).then(
|
||||||
_.partial(checkResult, responses.submit, 'submit'));
|
_.partial(checkResult, responses.submit, 'submit'));
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -218,7 +335,8 @@ describe('RippleAPI', function() {
|
|||||||
|
|
||||||
it('getBalances - limit', function() {
|
it('getBalances - limit', function() {
|
||||||
const options = {
|
const options = {
|
||||||
limit: 3
|
limit: 3,
|
||||||
|
ledgerVersion: 123456
|
||||||
};
|
};
|
||||||
const expectedResponse = responses.getBalances.slice(0, 3);
|
const expectedResponse = responses.getBalances.slice(0, 3);
|
||||||
return this.api.getBalances(address, options).then(
|
return this.api.getBalances(address, options).then(
|
||||||
@@ -255,6 +373,18 @@ describe('RippleAPI', function() {
|
|||||||
_.partial(checkResult, responses.getBalanceSheet, 'getBalanceSheet'));
|
_.partial(checkResult, responses.getBalanceSheet, 'getBalanceSheet'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('getBalanceSheet - invalid options', function() {
|
||||||
|
assert.throws(() => {
|
||||||
|
this.api.getBalanceSheet(address, {invalid: 'options'});
|
||||||
|
}, this.api.errors.ValidationError);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('getBalanceSheet - empty', function() {
|
||||||
|
const options = {ledgerVersion: 123456};
|
||||||
|
return this.api.getBalanceSheet(address, options).then(
|
||||||
|
_.partial(checkResult, {}, 'getBalanceSheet'));
|
||||||
|
});
|
||||||
|
|
||||||
describe('getTransaction', () => {
|
describe('getTransaction', () => {
|
||||||
it('getTransaction - payment', function() {
|
it('getTransaction - payment', function() {
|
||||||
return this.api.getTransaction(hashes.VALID_TRANSACTION_HASH).then(
|
return this.api.getTransaction(hashes.VALID_TRANSACTION_HASH).then(
|
||||||
@@ -279,6 +409,15 @@ describe('RippleAPI', function() {
|
|||||||
'getTransaction'));
|
'getTransaction'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('getTransaction - sell order', function() {
|
||||||
|
const hash =
|
||||||
|
'458101D51051230B1D56E9ACAFAA34451BF65FA000F95DF6F0FF5B3A62D83FC2';
|
||||||
|
closeLedger(this.api.connection);
|
||||||
|
return this.api.getTransaction(hash).then(
|
||||||
|
_.partial(checkResult, responses.getTransaction.orderSell,
|
||||||
|
'getTransaction'));
|
||||||
|
});
|
||||||
|
|
||||||
it('getTransaction - order cancellation', function() {
|
it('getTransaction - order cancellation', function() {
|
||||||
const hash =
|
const hash =
|
||||||
'809335DD3B0B333865096217AA2F55A4DF168E0198080B3A090D12D88880FF0E';
|
'809335DD3B0B333865096217AA2F55A4DF168E0198080B3A090D12D88880FF0E';
|
||||||
@@ -456,6 +595,15 @@ describe('RippleAPI', function() {
|
|||||||
'getTransaction'));
|
'getTransaction'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('getTransaction - SuspendedPaymentCreation iou', function() {
|
||||||
|
const hash =
|
||||||
|
'144F272380BDB4F1BD92329A2178BABB70C20F59042C495E10BF72EBFB408EE2';
|
||||||
|
return this.api.getTransaction(hash).then(
|
||||||
|
_.partial(checkResult,
|
||||||
|
responses.getTransaction.SuspendedPaymentCreationIOU,
|
||||||
|
'getTransaction'));
|
||||||
|
});
|
||||||
|
|
||||||
it('getTransaction - SuspendedPaymentCancellation', function() {
|
it('getTransaction - SuspendedPaymentCancellation', function() {
|
||||||
const hash =
|
const hash =
|
||||||
'F346E542FFB7A8398C30A87B952668DAB48B7D421094F8B71776DA19775A3B22';
|
'F346E542FFB7A8398C30A87B952668DAB48B7D421094F8B71776DA19775A3B22';
|
||||||
@@ -466,20 +614,52 @@ describe('RippleAPI', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('getTransaction - SuspendedPaymentExecution', function() {
|
it('getTransaction - SuspendedPaymentExecution', function() {
|
||||||
|
const options = {
|
||||||
|
minLedgerVersion: 10,
|
||||||
|
maxLedgerVersion: 15
|
||||||
|
};
|
||||||
const hash =
|
const hash =
|
||||||
'CC5277137B3F25EE8B86259C83CB0EAADE818505E4E9BCBF19B1AC6FD136993B';
|
'CC5277137B3F25EE8B86259C83CB0EAADE818505E4E9BCBF19B1AC6FD136993B';
|
||||||
return this.api.getTransaction(hash).then(
|
return this.api.getTransaction(hash, options).then(
|
||||||
_.partial(checkResult,
|
_.partial(checkResult,
|
||||||
responses.getTransaction.suspendedPaymentExecution,
|
responses.getTransaction.suspendedPaymentExecution,
|
||||||
'getTransaction'));
|
'getTransaction'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('getTransaction - SuspendedPaymentExecution simple', function() {
|
||||||
|
const hash =
|
||||||
|
'CC5277137B3F25EE8B86259C83CB0EAADE818505E4E9BCBF19B1AC6FD1369931';
|
||||||
|
return this.api.getTransaction(hash).then(
|
||||||
|
_.partial(checkResult,
|
||||||
|
responses.getTransaction.suspendedPaymentExecutionSimple,
|
||||||
|
'getTransaction'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('getTransaction - no Meta', function() {
|
||||||
|
const hash =
|
||||||
|
'AFB3ADF22F3C605E23FAEFAA185F3BD763C4692CAC490D9819D117CD33BFAA1B';
|
||||||
|
return this.api.getTransaction(hash).then(result => {
|
||||||
|
assert.deepEqual(result, responses.getTransaction.noMeta);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('getTransaction - Unrecognized transaction type', function() {
|
||||||
|
const hash =
|
||||||
|
'AFB3ADF22F3C605E23FAEFAA185F3BD763C4692CAC490D9819D117CD33BFAA11';
|
||||||
|
closeLedger(this.api.connection);
|
||||||
|
return this.api.getTransaction(hash).then(() => {
|
||||||
|
assert(false, 'Unrecognized transaction type');
|
||||||
|
}).catch(error => {
|
||||||
|
assert.strictEqual(error.message, 'Unrecognized transaction type');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('getTransactions', function() {
|
it('getTransactions', function() {
|
||||||
const options = {types: ['payment', 'order'], initiated: true, limit: 2};
|
const options = {types: ['payment', 'order'], initiated: true, limit: 2};
|
||||||
return this.api.getTransactions(address, options).then(
|
return this.api.getTransactions(address, options).then(
|
||||||
_.partial(checkResult, responses.getTransactions,
|
_.partial(checkResult, responses.getTransactions.normal,
|
||||||
'getTransactions'));
|
'getTransactions'));
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -487,12 +667,13 @@ describe('RippleAPI', function() {
|
|||||||
const options = {types: ['payment', 'order'], initiated: true, limit: 2,
|
const options = {types: ['payment', 'order'], initiated: true, limit: 2,
|
||||||
earliestFirst: true
|
earliestFirst: true
|
||||||
};
|
};
|
||||||
const expected = _.cloneDeep(responses.getTransactions)
|
const expected = _.cloneDeep(responses.getTransactions.normal)
|
||||||
.sort(utils.compareTransactions);
|
.sort(utils.compareTransactions);
|
||||||
return this.api.getTransactions(address, options).then(
|
return this.api.getTransactions(address, options).then(
|
||||||
_.partial(checkResult, expected, 'getTransactions'));
|
_.partial(checkResult, expected, 'getTransactions'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('getTransactions - earliest first with start option', function() {
|
it('getTransactions - earliest first with start option', function() {
|
||||||
const options = {types: ['payment', 'order'], initiated: true, limit: 2,
|
const options = {types: ['payment', 'order'], initiated: true, limit: 2,
|
||||||
start: hashes.VALID_TRANSACTION_HASH,
|
start: hashes.VALID_TRANSACTION_HASH,
|
||||||
@@ -569,13 +750,35 @@ describe('RippleAPI', function() {
|
|||||||
limit: 2
|
limit: 2
|
||||||
};
|
};
|
||||||
return this.api.getTransactions(address, options).then(
|
return this.api.getTransactions(address, options).then(
|
||||||
_.partial(checkResult, responses.getTransactions, 'getTransactions'));
|
_.partial(checkResult, responses.getTransactions.normal,
|
||||||
|
'getTransactions'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('getTrustlines', function() {
|
it('getTransactions - start transaction with zero ledger version', function(
|
||||||
|
) {
|
||||||
|
const options = {
|
||||||
|
start: '4FB3ADF22F3C605E23FAEFAA185F3BD763C4692CAC490D9819D117CD33BFAA13',
|
||||||
|
limit: 1
|
||||||
|
};
|
||||||
|
return this.api.getTransactions(address, options).then(
|
||||||
|
_.partial(checkResult, [], 'getTransactions'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('getTransactions - no options', function() {
|
||||||
|
return this.api.getTransactions(addresses.OTHER_ACCOUNT).then(
|
||||||
|
_.partial(checkResult, responses.getTransactions.one, 'getTransactions'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('getTrustlines - filtered', function() {
|
||||||
const options = {currency: 'USD'};
|
const options = {currency: 'USD'};
|
||||||
return this.api.getTrustlines(address, options).then(
|
return this.api.getTrustlines(address, options).then(
|
||||||
_.partial(checkResult, responses.getTrustlines, 'getTrustlines'));
|
_.partial(checkResult,
|
||||||
|
responses.getTrustlines.filtered, 'getTrustlines'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('getTrustlines - no options', function() {
|
||||||
|
return this.api.getTrustlines(address).then(
|
||||||
|
_.partial(checkResult, responses.getTrustlines.all, 'getTrustlines'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('generateAddress', function() {
|
it('generateAddress', function() {
|
||||||
@@ -586,61 +789,123 @@ describe('RippleAPI', function() {
|
|||||||
responses.generateAddress);
|
responses.generateAddress);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('generateAddress invalid', function() {
|
||||||
|
assert.throws(() => {
|
||||||
|
function random() {
|
||||||
|
return _.fill(Array(1), 0);
|
||||||
|
}
|
||||||
|
this.api.generateAddress({entropy: random()});
|
||||||
|
}, this.api.errors.UnexpectedError);
|
||||||
|
});
|
||||||
|
|
||||||
it('getSettings', function() {
|
it('getSettings', function() {
|
||||||
return this.api.getSettings(address).then(
|
return this.api.getSettings(address).then(
|
||||||
_.partial(checkResult, responses.getSettings, 'getSettings'));
|
_.partial(checkResult, responses.getSettings, 'getSettings'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('getSettings - options undefined', function() {
|
||||||
|
return this.api.getSettings(address, undefined).then(
|
||||||
|
_.partial(checkResult, responses.getSettings, 'getSettings'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('getSettings - invalid options', function() {
|
||||||
|
assert.throws(() => {
|
||||||
|
this.api.getSettings(address, {invalid: 'options'});
|
||||||
|
}, this.api.errors.ValidationError);
|
||||||
|
});
|
||||||
|
|
||||||
it('getAccountInfo', function() {
|
it('getAccountInfo', function() {
|
||||||
return this.api.getAccountInfo(address).then(
|
return this.api.getAccountInfo(address).then(
|
||||||
_.partial(checkResult, responses.getAccountInfo, 'getAccountInfo'));
|
_.partial(checkResult, responses.getAccountInfo, 'getAccountInfo'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('getAccountInfo - options undefined', function() {
|
||||||
|
return this.api.getAccountInfo(address, undefined).then(
|
||||||
|
_.partial(checkResult, responses.getAccountInfo, 'getAccountInfo'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('getAccountInfo - invalid options', function() {
|
||||||
|
assert.throws(() => {
|
||||||
|
this.api.getAccountInfo(address, {invalid: 'options'});
|
||||||
|
}, this.api.errors.ValidationError);
|
||||||
|
});
|
||||||
|
|
||||||
it('getOrders', function() {
|
it('getOrders', function() {
|
||||||
return this.api.getOrders(address).then(
|
return this.api.getOrders(address).then(
|
||||||
_.partial(checkResult, responses.getOrders, 'getOrders'));
|
_.partial(checkResult, responses.getOrders, 'getOrders'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('getOrderbook', function() {
|
it('getOrders', function() {
|
||||||
return this.api.getOrderbook(address, requests.getOrderbook).then(
|
return this.api.getOrders(address, undefined).then(
|
||||||
_.partial(checkResult, responses.getOrderbook, 'getOrderbook'));
|
_.partial(checkResult, responses.getOrders, 'getOrders'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('getOrderbook - sorted so that best deals come first', function() {
|
it('getOrders - invalid options', function() {
|
||||||
return this.api.getOrderbook(address, requests.getOrderbook)
|
assert.throws(() => {
|
||||||
.then(data => {
|
this.api.getOrders(address, {invalid: 'options'});
|
||||||
const bidRates = data.bids.map(bid => bid.properties.makerExchangeRate);
|
}, this.api.errors.ValidationError);
|
||||||
const askRates = data.asks.map(ask => ask.properties.makerExchangeRate);
|
});
|
||||||
// makerExchangeRate = quality = takerPays.value/takerGets.value
|
|
||||||
// so the best deal for the taker is the lowest makerExchangeRate
|
describe('getOrderbook', function() {
|
||||||
// bids and asks should be sorted so that the best deals come first
|
|
||||||
assert.deepEqual(_.sortBy(bidRates, x => Number(x)), bidRates);
|
it('normal', function() {
|
||||||
assert.deepEqual(_.sortBy(askRates, x => Number(x)), askRates);
|
return this.api.getOrderbook(address,
|
||||||
|
requests.getOrderbook.normal, undefined).then(
|
||||||
|
_.partial(checkResult,
|
||||||
|
responses.getOrderbook.normal, 'getOrderbook'));
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
it('getOrderbook - currency & counterparty are correct', function() {
|
it('invalid options', function() {
|
||||||
return this.api.getOrderbook(address, requests.getOrderbook)
|
assert.throws(() => {
|
||||||
.then(data => {
|
this.api.getOrderbook(address, requests.getOrderbook.normal,
|
||||||
const orders = _.flatten([data.bids, data.asks]);
|
{invalid: 'options'});
|
||||||
_.forEach(orders, order => {
|
}, this.api.errors.ValidationError);
|
||||||
const quantity = order.specification.quantity;
|
});
|
||||||
const totalPrice = order.specification.totalPrice;
|
|
||||||
const {base, counter} = requests.getOrderbook;
|
it('with XRP', function() {
|
||||||
assert.strictEqual(quantity.currency, base.currency);
|
return this.api.getOrderbook(address, requests.getOrderbook.withXRP).then(
|
||||||
assert.strictEqual(quantity.counterparty, base.counterparty);
|
_.partial(checkResult, responses.getOrderbook.withXRP, 'getOrderbook'));
|
||||||
assert.strictEqual(totalPrice.currency, counter.currency);
|
});
|
||||||
assert.strictEqual(totalPrice.counterparty, counter.counterparty);
|
|
||||||
|
it('sorted so that best deals come first', function() {
|
||||||
|
return this.api.getOrderbook(address, requests.getOrderbook.normal)
|
||||||
|
.then(data => {
|
||||||
|
const bidRates = data.bids.map(bid => bid.properties.makerExchangeRate);
|
||||||
|
const askRates = data.asks.map(ask => ask.properties.makerExchangeRate);
|
||||||
|
// makerExchangeRate = quality = takerPays.value/takerGets.value
|
||||||
|
// so the best deal for the taker is the lowest makerExchangeRate
|
||||||
|
// bids and asks should be sorted so that the best deals come first
|
||||||
|
assert.deepEqual(_.sortBy(bidRates, x => Number(x)), bidRates);
|
||||||
|
assert.deepEqual(_.sortBy(askRates, x => Number(x)), askRates);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
it('getOrderbook - direction is correct for bids and asks', function() {
|
it('currency & counterparty are correct', function() {
|
||||||
return this.api.getOrderbook(address, requests.getOrderbook)
|
return this.api.getOrderbook(address, requests.getOrderbook.normal)
|
||||||
.then(data => {
|
.then(data => {
|
||||||
assert(_.every(data.bids, bid => bid.specification.direction === 'buy'));
|
const orders = _.flatten([data.bids, data.asks]);
|
||||||
assert(_.every(data.asks, ask => ask.specification.direction === 'sell'));
|
_.forEach(orders, order => {
|
||||||
|
const quantity = order.specification.quantity;
|
||||||
|
const totalPrice = order.specification.totalPrice;
|
||||||
|
const {base, counter} = requests.getOrderbook.normal;
|
||||||
|
assert.strictEqual(quantity.currency, base.currency);
|
||||||
|
assert.strictEqual(quantity.counterparty, base.counterparty);
|
||||||
|
assert.strictEqual(totalPrice.currency, counter.currency);
|
||||||
|
assert.strictEqual(totalPrice.counterparty, counter.counterparty);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('direction is correct for bids and asks', function() {
|
||||||
|
return this.api.getOrderbook(address, requests.getOrderbook.normal)
|
||||||
|
.then(data => {
|
||||||
|
assert(
|
||||||
|
_.every(data.bids, bid => bid.specification.direction === 'buy'));
|
||||||
|
assert(
|
||||||
|
_.every(data.asks, ask => ask.specification.direction === 'sell'));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('getServerInfo', function() {
|
it('getServerInfo', function() {
|
||||||
@@ -664,6 +929,13 @@ describe('RippleAPI', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('getFee default', function() {
|
||||||
|
this.api._feeCushion = undefined;
|
||||||
|
return this.api.getFee().then(fee => {
|
||||||
|
assert.strictEqual(fee, '0.000012');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('disconnect & isConnected', function() {
|
it('disconnect & isConnected', function() {
|
||||||
assert.strictEqual(this.api.isConnected(), true);
|
assert.strictEqual(this.api.isConnected(), true);
|
||||||
return this.api.disconnect().then(() => {
|
return this.api.disconnect().then(() => {
|
||||||
@@ -702,6 +974,14 @@ describe('RippleAPI', function() {
|
|||||||
_.partial(checkResult, responses.getPaths.XrpToXrp, 'getPaths'));
|
_.partial(checkResult, responses.getPaths.XrpToXrp, 'getPaths'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('getPaths - source with issuer', function() {
|
||||||
|
return this.api.getPaths(requests.getPaths.issuer).then(() => {
|
||||||
|
assert(false, 'Should throw NotFoundError');
|
||||||
|
}).catch(error => {
|
||||||
|
assert(error instanceof this.api.errors.NotFoundError);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('getPaths - XRP 2 XRP - not enough', function() {
|
it('getPaths - XRP 2 XRP - not enough', function() {
|
||||||
return this.api.getPaths(requests.getPaths.XrpToXrpNotEnough).then(() => {
|
return this.api.getPaths(requests.getPaths.XrpToXrpNotEnough).then(() => {
|
||||||
assert(false, 'Should throw NotFoundError');
|
assert(false, 'Should throw NotFoundError');
|
||||||
@@ -710,6 +990,12 @@ describe('RippleAPI', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('getPaths - invalid PathFind', function() {
|
||||||
|
assert.throws(() => {
|
||||||
|
this.api.getPaths(requests.getPaths.invalid);
|
||||||
|
}, /Cannot specify both source.amount/);
|
||||||
|
});
|
||||||
|
|
||||||
it('getPaths - does not accept currency', function() {
|
it('getPaths - does not accept currency', function() {
|
||||||
return this.api.getPaths(requests.getPaths.NotAcceptCurrency).then(() => {
|
return this.api.getPaths(requests.getPaths.NotAcceptCurrency).then(() => {
|
||||||
assert(false, 'Should throw NotFoundError');
|
assert(false, 'Should throw NotFoundError');
|
||||||
@@ -768,6 +1054,18 @@ describe('RippleAPI', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('getLedger - with state as hashes', function() {
|
||||||
|
const request = {
|
||||||
|
includeTransactions: true,
|
||||||
|
includeAllData: false,
|
||||||
|
includeState: true,
|
||||||
|
ledgerVersion: 6
|
||||||
|
};
|
||||||
|
return this.api.getLedger(request).then(
|
||||||
|
_.partial(checkResult, responses.getLedger.withStateAsHashes,
|
||||||
|
'getLedger'));
|
||||||
|
});
|
||||||
|
|
||||||
it('getLedger - with settings transaction', function() {
|
it('getLedger - with settings transaction', function() {
|
||||||
const request = {
|
const request = {
|
||||||
includeTransactions: true,
|
includeTransactions: true,
|
||||||
@@ -796,7 +1094,55 @@ describe('RippleAPI', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('computeLedgerHash - wrong hash', function() {
|
||||||
|
const request = {
|
||||||
|
includeTransactions: true,
|
||||||
|
includeState: true,
|
||||||
|
includeAllData: true,
|
||||||
|
ledgerVersion: 38129
|
||||||
|
};
|
||||||
|
return this.api.getLedger(request).then(
|
||||||
|
_.partial(checkResult, responses.getLedger.full, 'getLedger'))
|
||||||
|
.then(response => {
|
||||||
|
const ledger = _.assign({}, response, {
|
||||||
|
parentCloseTime: response.closeTime, stateHash:
|
||||||
|
'D9ABF622DA26EEEE48203085D4BC23B0F77DC6F8724AC33D975DA3CA492D2E44'});
|
||||||
|
assert.throws(() => {
|
||||||
|
const hash = this.api.computeLedgerHash(ledger);
|
||||||
|
unused(hash);
|
||||||
|
}, /does not match computed hash of state/);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('RippleError with data', function() {
|
||||||
|
const error = new this.api.errors.RippleError('_message_', '_data_');
|
||||||
|
assert.strictEqual(error.toString(),
|
||||||
|
'[RippleError(_message_, \'_data_\')]');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('NotFoundError default message', function() {
|
||||||
|
const error = new this.api.errors.NotFoundError();
|
||||||
|
assert.strictEqual(error.toString(),
|
||||||
|
'[NotFoundError(Not found)]');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('common utils - toRippledAmount', function() {
|
||||||
|
const amount = {issuer: 'is', currency: 'c', value: 'v'};
|
||||||
|
|
||||||
|
assert.deepEqual(utils.common.toRippledAmount(amount), {
|
||||||
|
issuer: 'is', currency: 'c', value: 'v'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('ledger utils - renameCounterpartyToIssuerInOrder', function() {
|
||||||
|
const order = {taker_gets: {issuer: '1'}};
|
||||||
|
const expected = {taker_gets: {issuer: '1'}};
|
||||||
|
|
||||||
|
assert.deepEqual(utils.renameCounterpartyToIssuerInOrder(order), expected);
|
||||||
|
});
|
||||||
|
|
||||||
it('ledger utils - compareTransactions', function() {
|
it('ledger utils - compareTransactions', function() {
|
||||||
|
assert.strictEqual(utils.compareTransactions({}, {}), 0);
|
||||||
let first = {outcome: {ledgerVersion: 1, indexInLedger: 100}};
|
let first = {outcome: {ledgerVersion: 1, indexInLedger: 100}};
|
||||||
let second = {outcome: {ledgerVersion: 1, indexInLedger: 200}};
|
let second = {outcome: {ledgerVersion: 1, indexInLedger: 200}};
|
||||||
|
|
||||||
@@ -896,9 +1242,9 @@ describe('RippleAPI', function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('ledgerClosed', function(done) {
|
it('ledger event', function(done) {
|
||||||
this.api.on('ledgerClosed', message => {
|
this.api.on('ledger', message => {
|
||||||
checkResult(responses.ledgerClosed, 'ledgerClosed', message);
|
checkResult(responses.ledgerEvent, 'ledgerEvent', message);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
closeLedger(this.api.connection);
|
closeLedger(this.api.connection);
|
||||||
@@ -917,7 +1263,8 @@ describe('RippleAPI - offline', function() {
|
|||||||
};
|
};
|
||||||
return api.prepareSettings(address, settings, instructions).then(data => {
|
return api.prepareSettings(address, settings, instructions).then(data => {
|
||||||
checkResult(responses.prepareSettings.flags, 'prepare', data);
|
checkResult(responses.prepareSettings.flags, 'prepare', data);
|
||||||
assert.deepEqual(api.sign(data.txJSON, secret), responses.sign);
|
assert.deepEqual(api.sign(data.txJSON, secret),
|
||||||
|
responses.prepareSettings.signed);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -961,7 +1308,7 @@ describe('RippleAPI - offline', function() {
|
|||||||
|
|
||||||
/* eslint-disable no-unused-vars */
|
/* eslint-disable no-unused-vars */
|
||||||
it('RippleAPI - implicit server port', function() {
|
it('RippleAPI - implicit server port', function() {
|
||||||
const api = new RippleAPI({servers: ['wss://s1.ripple.com']});
|
const api = new RippleAPI({server: 'wss://s1.ripple.com'});
|
||||||
});
|
});
|
||||||
/* eslint-enable no-unused-vars */
|
/* eslint-enable no-unused-vars */
|
||||||
it('RippleAPI invalid options', function() {
|
it('RippleAPI invalid options', function() {
|
||||||
@@ -969,12 +1316,12 @@ describe('RippleAPI - offline', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('RippleAPI valid options', function() {
|
it('RippleAPI valid options', function() {
|
||||||
const api = new RippleAPI({servers: ['wss://s:1']});
|
const api = new RippleAPI({server: 'wss://s:1'});
|
||||||
assert.deepEqual(api.connection._url, 'wss://s:1');
|
assert.deepEqual(api.connection._url, 'wss://s:1');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('RippleAPI invalid server uri', function() {
|
it('RippleAPI invalid server uri', function() {
|
||||||
assert.throws(() => new RippleAPI({servers: ['wss//s:1']}));
|
assert.throws(() => new RippleAPI({server: 'wss//s:1'}));
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
62
test/broadcast-api-test.js
Normal file
62
test/broadcast-api-test.js
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
/* eslint-disable max-nested-callbacks */
|
||||||
|
'use strict';
|
||||||
|
const _ = require('lodash');
|
||||||
|
const assert = require('assert-diff');
|
||||||
|
const setupAPI = require('./setup-api');
|
||||||
|
const responses = require('./fixtures').responses;
|
||||||
|
const ledgerClosed = require('./fixtures/rippled/ledger-close');
|
||||||
|
const RippleAPI = require('ripple-api').RippleAPI;
|
||||||
|
const schemaValidator = RippleAPI._PRIVATE.schemaValidator;
|
||||||
|
|
||||||
|
function checkResult(expected, schemaName, response) {
|
||||||
|
if (expected.txJSON) {
|
||||||
|
assert(response.txJSON);
|
||||||
|
assert.deepEqual(JSON.parse(response.txJSON), JSON.parse(expected.txJSON));
|
||||||
|
}
|
||||||
|
assert.deepEqual(_.omit(response, 'txJSON'), _.omit(expected, 'txJSON'));
|
||||||
|
if (schemaName) {
|
||||||
|
schemaValidator.schemaValidate(schemaName, response);
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('RippleAPIBroadcast', function() {
|
||||||
|
beforeEach(setupAPI.setupBroadcast);
|
||||||
|
afterEach(setupAPI.teardown);
|
||||||
|
|
||||||
|
it('base', function() {
|
||||||
|
const expected = {request_server_info: 1};
|
||||||
|
this.mocks.forEach(mock => mock.expect(_.assign({}, expected)));
|
||||||
|
assert(this.api.isConnected());
|
||||||
|
return this.api.getServerInfo().then(
|
||||||
|
_.partial(checkResult, responses.getServerInfo, 'getServerInfo'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('ledger', function(done) {
|
||||||
|
let gotLedger = 0;
|
||||||
|
this.api.on('ledger', () => {
|
||||||
|
gotLedger++;
|
||||||
|
});
|
||||||
|
const ledgerNext = _.assign({}, ledgerClosed);
|
||||||
|
ledgerNext.ledger_index++;
|
||||||
|
this.mocks.forEach(mock => mock.socket.send(JSON.stringify(ledgerNext)));
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
console.log('-- ledgerVersion', this.api.ledgerVersion);
|
||||||
|
assert.strictEqual(gotLedger, 1);
|
||||||
|
done();
|
||||||
|
}, 50);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
it('error propagation', function(done) {
|
||||||
|
this.api.once('error', (type, info) => {
|
||||||
|
assert.strictEqual(type, 'type');
|
||||||
|
assert.strictEqual(info, 'info');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
this.mocks[1].socket.send(
|
||||||
|
JSON.stringify({error: 'type', error_message: 'info'}));
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
264
test/connection-test.js
Normal file
264
test/connection-test.js
Normal file
@@ -0,0 +1,264 @@
|
|||||||
|
/* eslint-disable max-nested-callbacks */
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const _ = require('lodash');
|
||||||
|
const net = require('net');
|
||||||
|
const assert = require('assert-diff');
|
||||||
|
const setupAPI = require('./setup-api');
|
||||||
|
const RippleAPI = require('ripple-api').RippleAPI;
|
||||||
|
const utils = RippleAPI._PRIVATE.ledgerUtils;
|
||||||
|
|
||||||
|
|
||||||
|
function unused() {
|
||||||
|
}
|
||||||
|
|
||||||
|
function createServer() {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const server = net.createServer();
|
||||||
|
server.on('listening', function() {
|
||||||
|
resolve(server);
|
||||||
|
});
|
||||||
|
server.on('error', function(error) {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
server.listen(0, '0.0.0.0');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('Connection', function() {
|
||||||
|
beforeEach(setupAPI.setup);
|
||||||
|
afterEach(setupAPI.teardown);
|
||||||
|
|
||||||
|
it('default options', function() {
|
||||||
|
const connection = new utils.common.Connection('url');
|
||||||
|
assert.strictEqual(connection._url, 'url');
|
||||||
|
assert(_.isUndefined(connection._proxyURL));
|
||||||
|
assert(_.isUndefined(connection._authorization));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('trace', function() {
|
||||||
|
const connection = new utils.common.Connection('url', {trace: true});
|
||||||
|
const message1 = '{"type": "transaction"}';
|
||||||
|
const message2 = '{"type": "path_find"}';
|
||||||
|
const messages = [];
|
||||||
|
connection._console = {
|
||||||
|
log: function(message) {
|
||||||
|
messages.push(message);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
connection._onMessage(message1);
|
||||||
|
connection._send(message2);
|
||||||
|
|
||||||
|
assert.deepEqual(messages, [message1, message2]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('with proxy', function(done) {
|
||||||
|
createServer().then((server) => {
|
||||||
|
const port = server.address().port;
|
||||||
|
const expect = 'CONNECT localhost';
|
||||||
|
server.on('connection', (socket) => {
|
||||||
|
socket.on('data', (data) => {
|
||||||
|
const got = data.toString('ascii', 0, expect.length);
|
||||||
|
assert.strictEqual(got, expect);
|
||||||
|
server.close();
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
proxy: 'ws://localhost:' + port,
|
||||||
|
authorization: 'authorization',
|
||||||
|
trustedCertificates: ['path/to/pem']
|
||||||
|
};
|
||||||
|
const connection =
|
||||||
|
new utils.common.Connection(this.api.connection._url, options);
|
||||||
|
connection.connect().catch(done);
|
||||||
|
connection.connect().catch(done);
|
||||||
|
}, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Multiply disconnect calls', function() {
|
||||||
|
this.api.disconnect();
|
||||||
|
return this.api.disconnect();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('reconnect', function() {
|
||||||
|
return this.api.connection.reconnect();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('NotConnectedError', function() {
|
||||||
|
const connection = new utils.common.Connection('url');
|
||||||
|
return connection.getLedgerVersion().then(() => {
|
||||||
|
assert(false, 'Should throw NotConnectedError');
|
||||||
|
}).catch(error => {
|
||||||
|
assert(error instanceof this.api.errors.NotConnectedError);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('DisconnectedError', function() {
|
||||||
|
this.api.connection._send = function() {
|
||||||
|
this._ws.close();
|
||||||
|
};
|
||||||
|
return this.api.getServerInfo().then(() => {
|
||||||
|
assert(false, 'Should throw DisconnectedError');
|
||||||
|
}).catch(error => {
|
||||||
|
assert(error instanceof this.api.errors.DisconnectedError);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('TimeoutError', function() {
|
||||||
|
this.api.connection._send = function() {
|
||||||
|
return Promise.resolve({});
|
||||||
|
};
|
||||||
|
const request = {command: 'server_info'};
|
||||||
|
return this.api.connection.request(request, 1).then(() => {
|
||||||
|
assert(false, 'Should throw TimeoutError');
|
||||||
|
}).catch(error => {
|
||||||
|
assert(error instanceof this.api.errors.TimeoutError);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('DisconnectedError on send', function() {
|
||||||
|
this.api.connection._ws.send = function(message, options, callback) {
|
||||||
|
unused(message, options);
|
||||||
|
callback({message: 'not connected'});
|
||||||
|
};
|
||||||
|
return this.api.getServerInfo().then(() => {
|
||||||
|
assert(false, 'Should throw DisconnectedError');
|
||||||
|
}).catch(error => {
|
||||||
|
assert(error instanceof this.api.errors.DisconnectedError);
|
||||||
|
assert.strictEqual(error.message, 'not connected');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('ResponseFormatError', function() {
|
||||||
|
this.api.connection._send = function(message) {
|
||||||
|
const parsed = JSON.parse(message);
|
||||||
|
setTimeout(() => {
|
||||||
|
this._ws.emit('message', JSON.stringify({
|
||||||
|
id: parsed.id,
|
||||||
|
type: 'response',
|
||||||
|
status: 'unrecognized'
|
||||||
|
}));
|
||||||
|
}, 2);
|
||||||
|
return new Promise(() => {});
|
||||||
|
};
|
||||||
|
return this.api.getServerInfo().then(() => {
|
||||||
|
assert(false, 'Should throw ResponseFormatError');
|
||||||
|
}).catch(error => {
|
||||||
|
assert(error instanceof this.api.errors.ResponseFormatError);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('reconnect on unexpected close ', function(done) {
|
||||||
|
this.api.connection.on('connected', () => {
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
this.api.connection._ws.close();
|
||||||
|
}, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Multiply connect calls', function() {
|
||||||
|
return this.api.connect().then(() => {
|
||||||
|
return this.api.connect();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('hasLedgerVersion', function() {
|
||||||
|
return this.api.connection.hasLedgerVersion(8819951).then((result) => {
|
||||||
|
assert(result);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Cannot connect because no server', function() {
|
||||||
|
const connection = new utils.common.Connection();
|
||||||
|
return connection.connect().then(() => {
|
||||||
|
assert(false, 'Should throw ConnectionError');
|
||||||
|
}).catch(error => {
|
||||||
|
assert(error instanceof this.api.errors.ConnectionError);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('connect multiserver error', function() {
|
||||||
|
const options = {
|
||||||
|
servers: ['wss://server1.com', 'wss://server2.com']
|
||||||
|
};
|
||||||
|
assert.throws(function() {
|
||||||
|
const api = new RippleAPI(options);
|
||||||
|
unused(api);
|
||||||
|
}, this.api.errors.RippleError);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('connect throws error', function(done) {
|
||||||
|
this.api.once('error', (type, info) => {
|
||||||
|
assert.strictEqual(type, 'type');
|
||||||
|
assert.strictEqual(info, 'info');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
this.api.connection.emit('error', 'type', 'info');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('emit stream messages', function(done) {
|
||||||
|
let transactionCount = 0;
|
||||||
|
let pathFindCount = 0;
|
||||||
|
this.api.connection.on('transaction', () => {
|
||||||
|
transactionCount++;
|
||||||
|
});
|
||||||
|
this.api.connection.on('path_find', () => {
|
||||||
|
pathFindCount++;
|
||||||
|
});
|
||||||
|
this.api.connection.on('1', () => {
|
||||||
|
assert.strictEqual(transactionCount, 1);
|
||||||
|
assert.strictEqual(pathFindCount, 1);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
this.api.connection._onMessage(JSON.stringify({
|
||||||
|
type: 'transaction'
|
||||||
|
}));
|
||||||
|
this.api.connection._onMessage(JSON.stringify({
|
||||||
|
type: 'path_find'
|
||||||
|
}));
|
||||||
|
this.api.connection._onMessage(JSON.stringify({
|
||||||
|
type: 'response', id: 1
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('invalid message id', function(done) {
|
||||||
|
this.api.on('error', (errorCode, errorMessage, message) => {
|
||||||
|
assert.strictEqual(errorCode, 'badMessage');
|
||||||
|
assert.strictEqual(errorMessage, 'valid id not found in response');
|
||||||
|
assert.strictEqual(message,
|
||||||
|
'{"type":"response","id":"must be integer"}');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
this.api.connection._onMessage(JSON.stringify({
|
||||||
|
type: 'response', id: 'must be integer'
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('propagate error message', function(done) {
|
||||||
|
this.api.on('error', (errorCode, errorMessage, data) => {
|
||||||
|
assert.strictEqual(errorCode, 'slowDown');
|
||||||
|
assert.strictEqual(errorMessage, 'slow down');
|
||||||
|
assert.deepEqual(data, {error: 'slowDown', error_message: 'slow down'});
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
this.api.connection._onMessage(JSON.stringify({
|
||||||
|
error: 'slowDown', error_message: 'slow down'
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('unrecognized message type', function(done) {
|
||||||
|
this.api.on('error', (errorCode, errorMessage, message) => {
|
||||||
|
assert.strictEqual(errorCode, 'badMessage');
|
||||||
|
assert.strictEqual(errorMessage, 'unrecognized message type: unknown');
|
||||||
|
assert.strictEqual(message, '{"type":"unknown"}');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
this.api.connection._onMessage(JSON.stringify({type: 'unknown'}));
|
||||||
|
});
|
||||||
|
});
|
||||||
9
test/fixtures/requests/get-orderbook-with-xrp.json
vendored
Normal file
9
test/fixtures/requests/get-orderbook-with-xrp.json
vendored
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"base": {
|
||||||
|
"currency": "USD",
|
||||||
|
"counterparty": "rp8rJYTpodf8qbSCHVTNacf8nSW8mRakFw"
|
||||||
|
},
|
||||||
|
"counter": {
|
||||||
|
"currency": "XRP"
|
||||||
|
}
|
||||||
|
}
|
||||||
16
test/fixtures/requests/getpaths/invalid.json
vendored
Normal file
16
test/fixtures/requests/getpaths/invalid.json
vendored
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"source": {
|
||||||
|
"address": "rwBYyfufTzk77zUSKEu4MvixfarC35av1J",
|
||||||
|
"amount": {
|
||||||
|
"value": "1000002",
|
||||||
|
"currency": "USD"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"destination": {
|
||||||
|
"address": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
||||||
|
"amount": {
|
||||||
|
"value": "1000002",
|
||||||
|
"currency": "USD"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
16
test/fixtures/requests/getpaths/issuer.json
vendored
Normal file
16
test/fixtures/requests/getpaths/issuer.json
vendored
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"source": {
|
||||||
|
"address": "rwBYyfufTzk77zUSKEu4MvixfarC35av1J",
|
||||||
|
"amount": {
|
||||||
|
"value": "1000002",
|
||||||
|
"currency": "USD",
|
||||||
|
"counterparty": "rwBYyfufTzk77zUSKEu4MvixfarC35av1J"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"destination": {
|
||||||
|
"address": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
||||||
|
"amount": {
|
||||||
|
"currency": "USD"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
54
test/fixtures/requests/index.js
vendored
54
test/fixtures/requests/index.js
vendored
@@ -6,23 +6,42 @@ module.exports = {
|
|||||||
sell: require('./prepare-order-sell'),
|
sell: require('./prepare-order-sell'),
|
||||||
expiration: require('./prepare-order-expiration')
|
expiration: require('./prepare-order-expiration')
|
||||||
},
|
},
|
||||||
prepareOrderCancellation: require('./prepare-order-cancellation'),
|
prepareOrderCancellation: {
|
||||||
preparePayment: require('./prepare-payment'),
|
simple: require('./prepare-order-cancellation'),
|
||||||
preparePaymentAllOptions: require('./prepare-payment-all-options'),
|
withMemos: require('./prepare-order-cancellation-memos')
|
||||||
preparePaymentNoCounterparty: require('./prepare-payment-no-counterparty'),
|
},
|
||||||
|
preparePayment: {
|
||||||
|
normal: require('./prepare-payment'),
|
||||||
|
minAmountXRP: require('./prepare-payment-min-xrp'),
|
||||||
|
minAmount: require('./prepare-payment-min'),
|
||||||
|
wrongAddress: require('./prepare-payment-wrong-address'),
|
||||||
|
wrongAmount: require('./prepare-payment-wrong-amount'),
|
||||||
|
wrongPartial: require('./prepare-payment-wrong-partial'),
|
||||||
|
allOptions: require('./prepare-payment-all-options'),
|
||||||
|
noCounterparty: require('./prepare-payment-no-counterparty')
|
||||||
|
},
|
||||||
prepareSettings: require('./prepare-settings'),
|
prepareSettings: require('./prepare-settings'),
|
||||||
prepareSuspendedPaymentCreation:
|
prepareSuspendedPaymentCreation: {
|
||||||
require('./prepare-suspended-payment-creation'),
|
normal: require('./prepare-suspended-payment-creation'),
|
||||||
prepareSuspendedPaymentExecution:
|
full: require('./prepare-suspended-payment-creation-full')
|
||||||
require('./prepare-suspended-payment-execution'),
|
},
|
||||||
prepareSuspendedPaymentCancellation:
|
prepareSuspendedPaymentExecution: {
|
||||||
require('./prepare-suspended-payment-cancellation'),
|
normal: require('./prepare-suspended-payment-execution'),
|
||||||
|
simple: require('./prepare-suspended-payment-execution-simple')
|
||||||
|
},
|
||||||
|
prepareSuspendedPaymentCancellation: {
|
||||||
|
normal: require('./prepare-suspended-payment-cancellation'),
|
||||||
|
memos: require('./prepare-suspended-payment-cancellation-memos')
|
||||||
|
},
|
||||||
prepareTrustline: {
|
prepareTrustline: {
|
||||||
simple: require('./prepare-trustline-simple'),
|
simple: require('./prepare-trustline-simple'),
|
||||||
complex: require('./prepare-trustline')
|
complex: require('./prepare-trustline'),
|
||||||
|
frozen: require('./prepare-trustline-frozen.json')
|
||||||
|
},
|
||||||
|
sign: {
|
||||||
|
normal: require('./sign'),
|
||||||
|
suspended: require('./sign-suspended.json')
|
||||||
},
|
},
|
||||||
sign: require('./sign'),
|
|
||||||
signSuspended: require('./sign-suspended.json'),
|
|
||||||
getPaths: {
|
getPaths: {
|
||||||
normal: require('./getpaths/normal'),
|
normal: require('./getpaths/normal'),
|
||||||
UsdToUsd: require('./getpaths/usd2usd'),
|
UsdToUsd: require('./getpaths/usd2usd'),
|
||||||
@@ -31,9 +50,14 @@ module.exports = {
|
|||||||
NotAcceptCurrency: require('./getpaths/not-accept-currency'),
|
NotAcceptCurrency: require('./getpaths/not-accept-currency'),
|
||||||
NoPaths: require('./getpaths/no-paths'),
|
NoPaths: require('./getpaths/no-paths'),
|
||||||
NoPathsWithCurrencies: require('./getpaths/no-paths-with-currencies'),
|
NoPathsWithCurrencies: require('./getpaths/no-paths-with-currencies'),
|
||||||
sendAll: require('./getpaths/send-all')
|
sendAll: require('./getpaths/send-all'),
|
||||||
|
invalid: require('./getpaths/invalid'),
|
||||||
|
issuer: require('./getpaths/issuer')
|
||||||
|
},
|
||||||
|
getOrderbook: {
|
||||||
|
normal: require('./get-orderbook'),
|
||||||
|
withXRP: require('./get-orderbook-with-xrp')
|
||||||
},
|
},
|
||||||
getOrderbook: require('./get-orderbook'),
|
|
||||||
computeLedgerHash: {
|
computeLedgerHash: {
|
||||||
header: require('./compute-ledger-hash'),
|
header: require('./compute-ledger-hash'),
|
||||||
transactions: require('./compute-ledger-hash-transactions')
|
transactions: require('./compute-ledger-hash-transactions')
|
||||||
|
|||||||
10
test/fixtures/requests/prepare-order-cancellation-memos.json
vendored
Normal file
10
test/fixtures/requests/prepare-order-cancellation-memos.json
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"orderSequence": 23,
|
||||||
|
"memos": [
|
||||||
|
{
|
||||||
|
"type": "test",
|
||||||
|
"format": "plain/text",
|
||||||
|
"data": "texted data"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -1 +1,3 @@
|
|||||||
23
|
{
|
||||||
|
"orderSequence": 23
|
||||||
|
}
|
||||||
|
|||||||
@@ -9,5 +9,12 @@
|
|||||||
"currency": "XRP",
|
"currency": "XRP",
|
||||||
"value": "2"
|
"value": "2"
|
||||||
},
|
},
|
||||||
"immediateOrCancel": true
|
"immediateOrCancel": true,
|
||||||
|
"memos": [
|
||||||
|
{
|
||||||
|
"type": "test",
|
||||||
|
"format": "plain/text",
|
||||||
|
"data": "texted data"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
3
test/fixtures/requests/prepare-order.json
vendored
3
test/fixtures/requests/prepare-order.json
vendored
@@ -9,5 +9,6 @@
|
|||||||
"currency": "XRP",
|
"currency": "XRP",
|
||||||
"value": "2"
|
"value": "2"
|
||||||
},
|
},
|
||||||
"immediateOrCancel": true
|
"passive": true,
|
||||||
|
"fillOrKill": true
|
||||||
}
|
}
|
||||||
|
|||||||
17
test/fixtures/requests/prepare-payment-min-xrp.json
vendored
Normal file
17
test/fixtures/requests/prepare-payment-min-xrp.json
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"source": {
|
||||||
|
"address": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
||||||
|
"amount": {
|
||||||
|
"value": "0.01",
|
||||||
|
"currency": "USD",
|
||||||
|
"counterparty": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"destination": {
|
||||||
|
"address": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
|
||||||
|
"minAmount": {
|
||||||
|
"value": "0.01",
|
||||||
|
"currency": "XRP"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
17
test/fixtures/requests/prepare-payment-min.json
vendored
Normal file
17
test/fixtures/requests/prepare-payment-min.json
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"source": {
|
||||||
|
"address": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
||||||
|
"amount": {
|
||||||
|
"value": "0.01",
|
||||||
|
"currency": "XRP",
|
||||||
|
"counterparty": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"destination": {
|
||||||
|
"address": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
|
||||||
|
"minAmount": {
|
||||||
|
"value": "0.01",
|
||||||
|
"currency": "XRP"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
17
test/fixtures/requests/prepare-payment-wrong-address.json
vendored
Normal file
17
test/fixtures/requests/prepare-payment-wrong-address.json
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"source": {
|
||||||
|
"address": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM",
|
||||||
|
"amount": {
|
||||||
|
"value": "0.01",
|
||||||
|
"currency": "USD",
|
||||||
|
"counterparty": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"destination": {
|
||||||
|
"address": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
|
||||||
|
"minAmount": {
|
||||||
|
"value": "0.01",
|
||||||
|
"currency": "XRP"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
17
test/fixtures/requests/prepare-payment-wrong-amount.json
vendored
Normal file
17
test/fixtures/requests/prepare-payment-wrong-amount.json
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"source": {
|
||||||
|
"address": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
||||||
|
"maxAmount": {
|
||||||
|
"value": "0.01",
|
||||||
|
"currency": "USD",
|
||||||
|
"counterparty": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"destination": {
|
||||||
|
"address": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
|
||||||
|
"minAmount": {
|
||||||
|
"value": "0.01",
|
||||||
|
"currency": "XRP"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
17
test/fixtures/requests/prepare-payment-wrong-partial.json
vendored
Normal file
17
test/fixtures/requests/prepare-payment-wrong-partial.json
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"source": {
|
||||||
|
"address": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
||||||
|
"amount": {
|
||||||
|
"value": "0.01",
|
||||||
|
"currency": "XRP"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"destination": {
|
||||||
|
"address": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
|
||||||
|
"minAmount": {
|
||||||
|
"value": "0.01",
|
||||||
|
"currency": "XRP"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"allowPartialPayment": true
|
||||||
|
}
|
||||||
9
test/fixtures/requests/prepare-settings.json
vendored
9
test/fixtures/requests/prepare-settings.json
vendored
@@ -1,3 +1,10 @@
|
|||||||
{
|
{
|
||||||
"domain": "ripple.com"
|
"domain": "ripple.com",
|
||||||
|
"memos": [
|
||||||
|
{
|
||||||
|
"type": "test",
|
||||||
|
"format": "plain/text",
|
||||||
|
"data": "texted data"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
11
test/fixtures/requests/prepare-suspended-payment-cancellation-memos.json
vendored
Normal file
11
test/fixtures/requests/prepare-suspended-payment-cancellation-memos.json
vendored
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"owner": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
||||||
|
"suspensionSequence": 1234,
|
||||||
|
"memos": [
|
||||||
|
{
|
||||||
|
"type": "test",
|
||||||
|
"format": "plain/text",
|
||||||
|
"data": "texted data"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
28
test/fixtures/requests/prepare-suspended-payment-creation-full.json
vendored
Normal file
28
test/fixtures/requests/prepare-suspended-payment-creation-full.json
vendored
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
"source": {
|
||||||
|
"address": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
||||||
|
"maxAmount": {
|
||||||
|
"value": "0.01",
|
||||||
|
"currency": "USD",
|
||||||
|
"counterparty": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM"
|
||||||
|
},
|
||||||
|
"tag": 1
|
||||||
|
},
|
||||||
|
"destination": {
|
||||||
|
"address": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
|
||||||
|
"amount": {
|
||||||
|
"value": "0.01",
|
||||||
|
"currency": "USD",
|
||||||
|
"counterparty": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM"
|
||||||
|
},
|
||||||
|
"tag": 2
|
||||||
|
},
|
||||||
|
"digest": "8F434346648F6B96DF89DDA901C5176B10A6D83961DD3C1AC88B59B2DC327AA4",
|
||||||
|
"allowExecuteAfter": "2014-09-24T21:21:50.000Z",
|
||||||
|
"memos": [
|
||||||
|
{
|
||||||
|
"type": "test",
|
||||||
|
"data": "texted data"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
11
test/fixtures/requests/prepare-suspended-payment-execution-simple.json
vendored
Normal file
11
test/fixtures/requests/prepare-suspended-payment-execution-simple.json
vendored
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"owner": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
||||||
|
"suspensionSequence": 1234,
|
||||||
|
"memos": [
|
||||||
|
{
|
||||||
|
"type": "test",
|
||||||
|
"format": "plain/text",
|
||||||
|
"data": "texted data"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
8
test/fixtures/requests/prepare-trustline-frozen.json
vendored
Normal file
8
test/fixtures/requests/prepare-trustline-frozen.json
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"currency": "BTC",
|
||||||
|
"counterparty": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM",
|
||||||
|
"limit": "0.1",
|
||||||
|
"authorized": true,
|
||||||
|
"ripplingDisabled": false,
|
||||||
|
"frozen": true
|
||||||
|
}
|
||||||
@@ -5,5 +5,12 @@
|
|||||||
"qualityIn": 0.91,
|
"qualityIn": 0.91,
|
||||||
"qualityOut": 0.87,
|
"qualityOut": 0.87,
|
||||||
"ripplingDisabled": true,
|
"ripplingDisabled": true,
|
||||||
"frozen": false
|
"frozen": false,
|
||||||
|
"memos": [
|
||||||
|
{
|
||||||
|
"type": "test",
|
||||||
|
"format": "plain/text",
|
||||||
|
"data": "texted data"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
2
test/fixtures/requests/sign.json
vendored
2
test/fixtures/requests/sign.json
vendored
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"txJSON": "{\"Flags\":2147483648,\"TransactionType\":\"AccountSet\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Domain\":\"726970706C652E636F6D\",\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
|
"txJSON": "{\"Flags\":2147483648,\"TransactionType\":\"AccountSet\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Domain\":\"726970706C652E636F6D\",\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23,\"SigningPubKey\":\"02F89EAEC7667B30F33D0687BBA86C3FE2A08CCA40A9186C5BDE2DAA6FA97A37D8\"}",
|
||||||
"instructions": {
|
"instructions": {
|
||||||
"fee": "0.000012",
|
"fee": "0.000012",
|
||||||
"sequence": 23,
|
"sequence": 23,
|
||||||
|
|||||||
@@ -33,5 +33,5 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"rawTransactions": "[{\"Account\":\"rEGy9CxMTFGXFgUHUMreTy2FbqArabGy38\",\"Fee\":\"10\",\"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\"}}]"
|
"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\"}}]"
|
||||||
}
|
}
|
||||||
|
|||||||
20
test/fixtures/responses/get-ledger-with-state-as-hashes.json
vendored
Normal file
20
test/fixtures/responses/get-ledger-with-state-as-hashes.json
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"stateHash": "8DBB7FA4036704D96AD32A4573BEE461FDDBDCB1B6F62CB17EDB5182F52AE9F1",
|
||||||
|
"closeTime": "2015-11-18T11:00:30.000Z",
|
||||||
|
"closeTimeResolution": 30,
|
||||||
|
"closeFlags": 0,
|
||||||
|
"ledgerHash": "3D7115EDB5EC72FEF4ADDF46CA5B7770CBDECEAB3A97EA210BCC04E8C54A7CEE",
|
||||||
|
"ledgerVersion": 6,
|
||||||
|
"parentLedgerHash": "6D36AEFD3639EE22A27DDE0FA6C57525D103941F11D7FD6D91AC8D439DE2B3EE",
|
||||||
|
"parentCloseTime": "2015-11-18T07:53:01.000Z",
|
||||||
|
"totalDrops": "99999999999999964",
|
||||||
|
"transactionHash": "B8D716B82BFFF4186BBBE7B7341AE0E1CBD2558952408B96E925EC0A51A6AEC2",
|
||||||
|
"transactionHashes": [
|
||||||
|
"B22E27F35F3F7679F76A474E4FF8E71EFA21B313DF2FC6678037A053A00FD084"
|
||||||
|
],
|
||||||
|
"stateHashes": [
|
||||||
|
"2B6AC232AA4C4BE41BF49D2459FA4A0347E1B543A4C92FCEE0821C0201E2E9A8",
|
||||||
|
"8B24E55376A65D68542C17F3BF446231AC7062CB43BED28817570128A1849819",
|
||||||
|
"B4979A36CDC7F3D3D5C31A4EAE2AC7D7209DDA877588B9AFC66799692AB0D66B"
|
||||||
|
]
|
||||||
|
}
|
||||||
44
test/fixtures/responses/get-orderbook-with-xrp.json
vendored
Normal file
44
test/fixtures/responses/get-orderbook-with-xrp.json
vendored
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
{
|
||||||
|
"bids": [
|
||||||
|
{
|
||||||
|
"specification": {
|
||||||
|
"direction": "buy",
|
||||||
|
"quantity": {
|
||||||
|
"currency": "USD",
|
||||||
|
"value": "10.1",
|
||||||
|
"counterparty": "rp8rJYTpodf8qbSCHVTNacf8nSW8mRakFw"
|
||||||
|
},
|
||||||
|
"totalPrice": {
|
||||||
|
"currency": "XRP",
|
||||||
|
"value": "254391353"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"maker": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
|
||||||
|
"sequence": 5,
|
||||||
|
"makerExchangeRate": "3.970260734451929e-8"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"asks": [
|
||||||
|
{
|
||||||
|
"specification": {
|
||||||
|
"direction": "sell",
|
||||||
|
"quantity": {
|
||||||
|
"currency": "USD",
|
||||||
|
"value": "10453252347.1",
|
||||||
|
"counterparty": "rp8rJYTpodf8qbSCHVTNacf8nSW8mRakFw"
|
||||||
|
},
|
||||||
|
"totalPrice": {
|
||||||
|
"currency": "XRP",
|
||||||
|
"value": "134"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"maker": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
|
||||||
|
"sequence": 6,
|
||||||
|
"makerExchangeRate": "0.0000780093458738806"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
6
test/fixtures/responses/get-server-info.json
vendored
6
test/fixtures/responses/get-server-info.json
vendored
@@ -13,10 +13,10 @@
|
|||||||
"serverState": "full",
|
"serverState": "full",
|
||||||
"validatedLedger": {
|
"validatedLedger": {
|
||||||
"age": 5,
|
"age": 5,
|
||||||
"baseFeeXRP": 0.00001,
|
"baseFeeXRP": "0.00001",
|
||||||
"hash": "4482DEE5362332F54A4036ED57EE1767C9F33CF7CE5A6670355C16CECE381D46",
|
"hash": "4482DEE5362332F54A4036ED57EE1767C9F33CF7CE5A6670355C16CECE381D46",
|
||||||
"reserveBaseXRP": 20,
|
"reserveBaseXRP": "20",
|
||||||
"reserveIncrementXRP": 5,
|
"reserveIncrementXRP": "5",
|
||||||
"ledgerVersion": 6595042
|
"ledgerVersion": 6595042
|
||||||
},
|
},
|
||||||
"validationQuorum": 3
|
"validationQuorum": 3
|
||||||
|
|||||||
23
test/fixtures/responses/get-transaction-no-meta.json
vendored
Normal file
23
test/fixtures/responses/get-transaction-no-meta.json
vendored
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"type": "payment",
|
||||||
|
"address": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
||||||
|
"sequence": 4,
|
||||||
|
"id": "AFB3ADF22F3C605E23FAEFAA185F3BD763C4692CAC490D9819D117CD33BFAA1B",
|
||||||
|
"specification": {
|
||||||
|
"source": {
|
||||||
|
"address": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
||||||
|
"maxAmount": {
|
||||||
|
"currency": "XRP",
|
||||||
|
"value": "1.112209"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"destination": {
|
||||||
|
"address": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM",
|
||||||
|
"amount": {
|
||||||
|
"currency": "USD",
|
||||||
|
"value": "0.001"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"paths": "[[{\"currency\":\"USD\",\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"type\":48,\"type_hex\":\"0000000000000030\"},{\"account\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"currency\":\"USD\",\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"type\":49,\"type_hex\":\"0000000000000031\"}]]"
|
||||||
|
}
|
||||||
|
}
|
||||||
34
test/fixtures/responses/get-transaction-order-sell.json
vendored
Normal file
34
test/fixtures/responses/get-transaction-order-sell.json
vendored
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
{
|
||||||
|
"type": "order",
|
||||||
|
"address": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
|
||||||
|
"sequence": 2,
|
||||||
|
"id": "458101D51051230B1D56E9ACAFAA34451BF65FA000F95DF6F0FF5B3A62D83FC2",
|
||||||
|
"specification": {
|
||||||
|
"direction": "sell",
|
||||||
|
"quantity": {
|
||||||
|
"currency": "USD",
|
||||||
|
"value": "10.1",
|
||||||
|
"counterparty": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM"
|
||||||
|
},
|
||||||
|
"totalPrice": {
|
||||||
|
"currency": "XRP",
|
||||||
|
"value": "254391353"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outcome": {
|
||||||
|
"result": "tecUNFUNDED_OFFER",
|
||||||
|
"timestamp": "2015-11-18T20:56:30.000Z",
|
||||||
|
"fee": "0.000012",
|
||||||
|
"balanceChanges": {
|
||||||
|
"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh": [
|
||||||
|
{
|
||||||
|
"currency": "XRP",
|
||||||
|
"value": "-0.000012"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"orderbookChanges": {},
|
||||||
|
"ledgerVersion": 6,
|
||||||
|
"indexInLedger": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
51
test/fixtures/responses/get-transaction-suspended-payment-create-iou.json
vendored
Normal file
51
test/fixtures/responses/get-transaction-suspended-payment-create-iou.json
vendored
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
{
|
||||||
|
"type": "suspendedPaymentCreation",
|
||||||
|
"address": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
|
||||||
|
"sequence": 10,
|
||||||
|
"id": "144F272380BDB4F1BD92329A2178BABB70C20F59042C495E10BF72EBFB408EE2",
|
||||||
|
"specification": {
|
||||||
|
"source": {
|
||||||
|
"address": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
|
||||||
|
"maxAmount": {
|
||||||
|
"currency": "USD",
|
||||||
|
"value": "2"
|
||||||
|
},
|
||||||
|
"tag": 1
|
||||||
|
},
|
||||||
|
"destination": {
|
||||||
|
"address": "rp8rJYTpodf8qbSCHVTNacf8nSW8mRakFw",
|
||||||
|
"amount": {
|
||||||
|
"currency": "USD",
|
||||||
|
"value": "2",
|
||||||
|
"counterparty": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
|
||||||
|
},
|
||||||
|
"tag": 2
|
||||||
|
},
|
||||||
|
"memos": [
|
||||||
|
{
|
||||||
|
"type": "x2",
|
||||||
|
"format": "text/plain",
|
||||||
|
"data": "mema data"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"digest": "8F434346648F6B96DF89DDA901C5176B10A6D83961DD3C1AC88B59B2DC327AA4",
|
||||||
|
"allowCancelAfter": "2015-11-16T06:53:42.000Z",
|
||||||
|
"allowExecuteAfter": "2015-11-16T06:47:42.000Z"
|
||||||
|
},
|
||||||
|
"outcome": {
|
||||||
|
"result": "tesSUCCESS",
|
||||||
|
"timestamp": "2015-11-16T06:43:00.000Z",
|
||||||
|
"fee": "0.000012",
|
||||||
|
"balanceChanges": {
|
||||||
|
"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh": [
|
||||||
|
{
|
||||||
|
"currency": "XRP",
|
||||||
|
"value": "-0.000014"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"orderbookChanges": {},
|
||||||
|
"ledgerVersion": 15,
|
||||||
|
"indexInLedger": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
34
test/fixtures/responses/get-transaction-suspended-payment-execution-simple.json
vendored
Normal file
34
test/fixtures/responses/get-transaction-suspended-payment-execution-simple.json
vendored
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
{
|
||||||
|
"type": "suspendedPaymentExecution",
|
||||||
|
"address": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
|
||||||
|
"sequence": 6,
|
||||||
|
"id": "CC5277137B3F25EE8B86259C83CB0EAADE818505E4E9BCBF19B1AC6FD1369931",
|
||||||
|
"specification": {
|
||||||
|
"owner": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
|
||||||
|
"suspensionSequence": 5,
|
||||||
|
"method": 1,
|
||||||
|
"digest": "632F2F3E437AE720C397994A985B5D21FE186DE61523A9CA3E8709CC581671A1"
|
||||||
|
},
|
||||||
|
"outcome": {
|
||||||
|
"result": "tesSUCCESS",
|
||||||
|
"timestamp": "2015-11-17T01:47:40.000Z",
|
||||||
|
"fee": "0.000012",
|
||||||
|
"balanceChanges": {
|
||||||
|
"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh": [
|
||||||
|
{
|
||||||
|
"currency": "XRP",
|
||||||
|
"value": "-0.000012"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"rp8rJYTpodf8qbSCHVTNacf8nSW8mRakFw": [
|
||||||
|
{
|
||||||
|
"currency": "XRP",
|
||||||
|
"value": "10.000043"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"orderbookChanges": {},
|
||||||
|
"ledgerVersion": 14,
|
||||||
|
"indexInLedger": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
27
test/fixtures/responses/get-transactions-one.json
vendored
Normal file
27
test/fixtures/responses/get-transactions-one.json
vendored
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"type": "settings",
|
||||||
|
"address": "r9UHu5CWni1qRY7Q4CfFZLGvXo2pGQy96b",
|
||||||
|
"sequence": 491,
|
||||||
|
"id": "D868CFF0DF8C8AAF205404460EA764ACB3B8862527FA414BC8C1CA9A45B1F276",
|
||||||
|
"specification": {
|
||||||
|
"domain": "ripple.com"
|
||||||
|
},
|
||||||
|
"outcome": {
|
||||||
|
"result": "tesSUCCESS",
|
||||||
|
"timestamp": "2015-10-23T02:07:00.000Z",
|
||||||
|
"fee": "0.012",
|
||||||
|
"balanceChanges": {
|
||||||
|
"r9UHu5CWni1qRY7Q4CfFZLGvXo2pGQy96b": [
|
||||||
|
{
|
||||||
|
"currency": "XRP",
|
||||||
|
"value": "-0.012"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"orderbookChanges": {},
|
||||||
|
"ledgerVersion": 16635149,
|
||||||
|
"indexInLedger": 4
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
334
test/fixtures/responses/get-trustlines-all.json
vendored
Normal file
334
test/fixtures/responses/get-trustlines-all.json
vendored
Normal file
@@ -0,0 +1,334 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"specification": {
|
||||||
|
"limit": "0",
|
||||||
|
"currency": "ASP",
|
||||||
|
"counterparty": "r3vi7mWxru9rJCxETCyA1CHvzL96eZWx5z",
|
||||||
|
"qualityIn": 1
|
||||||
|
},
|
||||||
|
"counterparty": {
|
||||||
|
"limit": "10"
|
||||||
|
},
|
||||||
|
"state": {
|
||||||
|
"balance": "0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specification": {
|
||||||
|
"limit": "0",
|
||||||
|
"currency": "XAU",
|
||||||
|
"counterparty": "r3vi7mWxru9rJCxETCyA1CHvzL96eZWx5z",
|
||||||
|
"ripplingDisabled": true,
|
||||||
|
"frozen": true
|
||||||
|
},
|
||||||
|
"counterparty": {
|
||||||
|
"limit": "0",
|
||||||
|
"ripplingDisabled": true
|
||||||
|
},
|
||||||
|
"state": {
|
||||||
|
"balance": "0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specification": {
|
||||||
|
"limit": "5",
|
||||||
|
"currency": "USD",
|
||||||
|
"counterparty": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
|
||||||
|
"ripplingDisabled": true,
|
||||||
|
"frozen": true
|
||||||
|
},
|
||||||
|
"counterparty": {
|
||||||
|
"limit": "0"
|
||||||
|
},
|
||||||
|
"state": {
|
||||||
|
"balance": "2.497605752725159"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specification": {
|
||||||
|
"limit": "1000",
|
||||||
|
"currency": "MXN",
|
||||||
|
"counterparty": "rHpXfibHgSb64n8kK9QWDpdbfqSpYbM9a4"
|
||||||
|
},
|
||||||
|
"counterparty": {
|
||||||
|
"limit": "0"
|
||||||
|
},
|
||||||
|
"state": {
|
||||||
|
"balance": "481.992867407479"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specification": {
|
||||||
|
"limit": "1",
|
||||||
|
"currency": "EUR",
|
||||||
|
"counterparty": "rLEsXccBGNR3UPuPu2hUXPjziKC3qKSBun",
|
||||||
|
"ripplingDisabled": true
|
||||||
|
},
|
||||||
|
"counterparty": {
|
||||||
|
"limit": "0"
|
||||||
|
},
|
||||||
|
"state": {
|
||||||
|
"balance": "0.793598266778297"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specification": {
|
||||||
|
"limit": "3",
|
||||||
|
"currency": "CNY",
|
||||||
|
"counterparty": "rnuF96W4SZoCJmbHYBFoJZpR8eCaxNvekK",
|
||||||
|
"ripplingDisabled": true
|
||||||
|
},
|
||||||
|
"counterparty": {
|
||||||
|
"limit": "0"
|
||||||
|
},
|
||||||
|
"state": {
|
||||||
|
"balance": "0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specification": {
|
||||||
|
"limit": "3",
|
||||||
|
"currency": "DYM",
|
||||||
|
"counterparty": "rGwUWgN5BEg3QGNY3RX2HfYowjUTZdid3E"
|
||||||
|
},
|
||||||
|
"counterparty": {
|
||||||
|
"limit": "0"
|
||||||
|
},
|
||||||
|
"state": {
|
||||||
|
"balance": "1.294889190631542"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specification": {
|
||||||
|
"limit": "0",
|
||||||
|
"currency": "CHF",
|
||||||
|
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
|
||||||
|
},
|
||||||
|
"counterparty": {
|
||||||
|
"limit": "0"
|
||||||
|
},
|
||||||
|
"state": {
|
||||||
|
"balance": "0.3488146605801446"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specification": {
|
||||||
|
"limit": "3",
|
||||||
|
"currency": "BTC",
|
||||||
|
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
|
||||||
|
},
|
||||||
|
"counterparty": {
|
||||||
|
"limit": "0"
|
||||||
|
},
|
||||||
|
"state": {
|
||||||
|
"balance": "2.114103174931847"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specification": {
|
||||||
|
"limit": "5000",
|
||||||
|
"currency": "USD",
|
||||||
|
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
|
||||||
|
},
|
||||||
|
"counterparty": {
|
||||||
|
"limit": "0"
|
||||||
|
},
|
||||||
|
"state": {
|
||||||
|
"balance": "0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specification": {
|
||||||
|
"limit": "0",
|
||||||
|
"currency": "BTC",
|
||||||
|
"counterparty": "rpgKWEmNqSDAGFhy5WDnsyPqfQxbWxKeVd"
|
||||||
|
},
|
||||||
|
"counterparty": {
|
||||||
|
"limit": "10"
|
||||||
|
},
|
||||||
|
"state": {
|
||||||
|
"balance": "-0.00111"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specification": {
|
||||||
|
"limit": "0",
|
||||||
|
"currency": "BTC",
|
||||||
|
"counterparty": "rBJ3YjwXi2MGbg7GVLuTXUWQ8DjL7tDXh4"
|
||||||
|
},
|
||||||
|
"counterparty": {
|
||||||
|
"limit": "10"
|
||||||
|
},
|
||||||
|
"state": {
|
||||||
|
"balance": "-0.1010780000080207"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specification": {
|
||||||
|
"limit": "1",
|
||||||
|
"currency": "USD",
|
||||||
|
"counterparty": "rLEsXccBGNR3UPuPu2hUXPjziKC3qKSBun"
|
||||||
|
},
|
||||||
|
"counterparty": {
|
||||||
|
"limit": "0"
|
||||||
|
},
|
||||||
|
"state": {
|
||||||
|
"balance": "1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specification": {
|
||||||
|
"limit": "100",
|
||||||
|
"currency": "CNY",
|
||||||
|
"counterparty": "razqQKzJRdB4UxFPWf5NEpEG3WMkmwgcXA",
|
||||||
|
"ripplingDisabled": true
|
||||||
|
},
|
||||||
|
"counterparty": {
|
||||||
|
"limit": "0"
|
||||||
|
},
|
||||||
|
"state": {
|
||||||
|
"balance": "8.07619790068559"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specification": {
|
||||||
|
"limit": "0",
|
||||||
|
"currency": "JPY",
|
||||||
|
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
|
||||||
|
"ripplingDisabled": true
|
||||||
|
},
|
||||||
|
"counterparty": {
|
||||||
|
"limit": "0"
|
||||||
|
},
|
||||||
|
"state": {
|
||||||
|
"balance": "7.292695098901099"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specification": {
|
||||||
|
"limit": "0",
|
||||||
|
"currency": "AUX",
|
||||||
|
"counterparty": "r3vi7mWxru9rJCxETCyA1CHvzL96eZWx5z",
|
||||||
|
"ripplingDisabled": true
|
||||||
|
},
|
||||||
|
"counterparty": {
|
||||||
|
"limit": "0",
|
||||||
|
"ripplingDisabled": true
|
||||||
|
},
|
||||||
|
"state": {
|
||||||
|
"balance": "0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specification": {
|
||||||
|
"limit": "1",
|
||||||
|
"currency": "USD",
|
||||||
|
"counterparty": "r9vbV3EHvXWjSkeQ6CAcYVPGeq7TuiXY2X",
|
||||||
|
"ripplingDisabled": true
|
||||||
|
},
|
||||||
|
"counterparty": {
|
||||||
|
"limit": "0"
|
||||||
|
},
|
||||||
|
"state": {
|
||||||
|
"balance": "0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specification": {
|
||||||
|
"limit": "100",
|
||||||
|
"currency": "EUR",
|
||||||
|
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
|
||||||
|
"ripplingDisabled": true
|
||||||
|
},
|
||||||
|
"counterparty": {
|
||||||
|
"limit": "0"
|
||||||
|
},
|
||||||
|
"state": {
|
||||||
|
"balance": "12.41688780720394"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specification": {
|
||||||
|
"limit": "500",
|
||||||
|
"currency": "USD",
|
||||||
|
"counterparty": "rfF3PNkwkq1DygW2wum2HK3RGfgkJjdPVD",
|
||||||
|
"ripplingDisabled": true
|
||||||
|
},
|
||||||
|
"counterparty": {
|
||||||
|
"limit": "0"
|
||||||
|
},
|
||||||
|
"state": {
|
||||||
|
"balance": "35"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specification": {
|
||||||
|
"limit": "0",
|
||||||
|
"currency": "JOE",
|
||||||
|
"counterparty": "rwUVoVMSURqNyvocPCcvLu3ygJzZyw8qwp"
|
||||||
|
},
|
||||||
|
"counterparty": {
|
||||||
|
"limit": "50",
|
||||||
|
"ripplingDisabled": true
|
||||||
|
},
|
||||||
|
"state": {
|
||||||
|
"balance": "-5"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specification": {
|
||||||
|
"limit": "0",
|
||||||
|
"currency": "USD",
|
||||||
|
"counterparty": "rE6R3DWF9fBD7CyiQciePF9SqK58Ubp8o2"
|
||||||
|
},
|
||||||
|
"counterparty": {
|
||||||
|
"limit": "100",
|
||||||
|
"ripplingDisabled": true
|
||||||
|
},
|
||||||
|
"state": {
|
||||||
|
"balance": "0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specification": {
|
||||||
|
"limit": "0",
|
||||||
|
"currency": "JOE",
|
||||||
|
"counterparty": "rE6R3DWF9fBD7CyiQciePF9SqK58Ubp8o2"
|
||||||
|
},
|
||||||
|
"counterparty": {
|
||||||
|
"limit": "100",
|
||||||
|
"ripplingDisabled": true
|
||||||
|
},
|
||||||
|
"state": {
|
||||||
|
"balance": "0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specification": {
|
||||||
|
"limit": "10.01037626125837",
|
||||||
|
"currency": "015841551A748AD2C1F76FF6ECB0CCCD00000000",
|
||||||
|
"counterparty": "rs9M85karFkCRjvc6KMWn8Coigm9cbcgcx",
|
||||||
|
"ripplingDisabled": true
|
||||||
|
},
|
||||||
|
"counterparty": {
|
||||||
|
"limit": "0"
|
||||||
|
},
|
||||||
|
"state": {
|
||||||
|
"balance": "0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specification": {
|
||||||
|
"limit": "0",
|
||||||
|
"currency": "USD",
|
||||||
|
"counterparty": "rEhDDUUNxpXgEHVJtC2cjXAgyx5VCFxdMF",
|
||||||
|
"frozen": true
|
||||||
|
},
|
||||||
|
"counterparty": {
|
||||||
|
"limit": "1"
|
||||||
|
},
|
||||||
|
"state": {
|
||||||
|
"balance": "0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
66
test/fixtures/responses/index.js
vendored
66
test/fixtures/responses/index.js
vendored
@@ -5,7 +5,10 @@ module.exports = {
|
|||||||
getAccountInfo: require('./get-account-info.json'),
|
getAccountInfo: require('./get-account-info.json'),
|
||||||
getBalances: require('./get-balances.json'),
|
getBalances: require('./get-balances.json'),
|
||||||
getBalanceSheet: require('./get-balance-sheet.json'),
|
getBalanceSheet: require('./get-balance-sheet.json'),
|
||||||
getOrderbook: require('./get-orderbook.json'),
|
getOrderbook: {
|
||||||
|
normal: require('./get-orderbook.json'),
|
||||||
|
withXRP: require('./get-orderbook-with-xrp.json')
|
||||||
|
},
|
||||||
getOrders: require('./get-orders.json'),
|
getOrders: require('./get-orders.json'),
|
||||||
getPaths: {
|
getPaths: {
|
||||||
XrpToUsd: require('./get-paths.json'),
|
XrpToUsd: require('./get-paths.json'),
|
||||||
@@ -20,6 +23,8 @@ module.exports = {
|
|||||||
orderWithExpirationCancellation:
|
orderWithExpirationCancellation:
|
||||||
require('./get-transaction-order-with-expiration-cancellation.json'),
|
require('./get-transaction-order-with-expiration-cancellation.json'),
|
||||||
order: require('./get-transaction-order.json'),
|
order: require('./get-transaction-order.json'),
|
||||||
|
orderSell: require('./get-transaction-order-sell.json'),
|
||||||
|
noMeta: require('./get-transaction-no-meta.json'),
|
||||||
payment: require('./get-transaction-payment.json'),
|
payment: require('./get-transaction-payment.json'),
|
||||||
settings: require('./get-transaction-settings.json'),
|
settings: require('./get-transaction-settings.json'),
|
||||||
trustline: require('./get-transaction-trustline-set.json'),
|
trustline: require('./get-transaction-trustline-set.json'),
|
||||||
@@ -31,26 +36,43 @@ module.exports = {
|
|||||||
notValidated: require('./get-transaction-not-validated.json'),
|
notValidated: require('./get-transaction-not-validated.json'),
|
||||||
suspendedPaymentCreation:
|
suspendedPaymentCreation:
|
||||||
require('./get-transaction-suspended-payment-create.json'),
|
require('./get-transaction-suspended-payment-create.json'),
|
||||||
|
SuspendedPaymentCreationIOU:
|
||||||
|
require('./get-transaction-suspended-payment-create-iou.json'),
|
||||||
suspendedPaymentCancellation:
|
suspendedPaymentCancellation:
|
||||||
require('./get-transaction-suspended-payment-cancellation.json'),
|
require('./get-transaction-suspended-payment-cancellation.json'),
|
||||||
suspendedPaymentExecution:
|
suspendedPaymentExecution:
|
||||||
require('./get-transaction-suspended-payment-execution.json')
|
require('./get-transaction-suspended-payment-execution.json'),
|
||||||
|
suspendedPaymentExecutionSimple:
|
||||||
|
require('./get-transaction-suspended-payment-execution-simple.json')
|
||||||
|
},
|
||||||
|
getTransactions: {
|
||||||
|
normal: require('./get-transactions.json'),
|
||||||
|
one: require('./get-transactions-one.json')
|
||||||
|
},
|
||||||
|
getTrustlines: {
|
||||||
|
filtered: require('./get-trustlines.json'),
|
||||||
|
all: require('./get-trustlines-all.json')
|
||||||
},
|
},
|
||||||
getTransactions: require('./get-transactions.json'),
|
|
||||||
getTrustlines: require('./get-trustlines.json'),
|
|
||||||
getLedger: {
|
getLedger: {
|
||||||
header: require('./get-ledger'),
|
header: require('./get-ledger'),
|
||||||
full: require('./get-ledger-full'),
|
full: require('./get-ledger-full'),
|
||||||
withSettingsTx: require('./get-ledger-with-settings-tx')
|
withSettingsTx: require('./get-ledger-with-settings-tx'),
|
||||||
|
withStateAsHashes: require('./get-ledger-with-state-as-hashes')
|
||||||
},
|
},
|
||||||
prepareOrderCancellation: require('./prepare-order-cancellation.json'),
|
|
||||||
prepareOrder: {
|
prepareOrder: {
|
||||||
buy: require('./prepare-order.json'),
|
buy: require('./prepare-order.json'),
|
||||||
sell: require('./prepare-order-sell.json'),
|
sell: require('./prepare-order-sell.json'),
|
||||||
expiration: require('./prepare-order-expiration')
|
expiration: require('./prepare-order-expiration')
|
||||||
},
|
},
|
||||||
|
prepareOrderCancellation: {
|
||||||
|
normal: require('./prepare-order-cancellation.json'),
|
||||||
|
withMemos: require('./prepare-order-cancellation-memos.json'),
|
||||||
|
noInstructions: require('./prepare-order-cancellation-no-instructions.json')
|
||||||
|
},
|
||||||
preparePayment: {
|
preparePayment: {
|
||||||
normal: require('./prepare-payment.json'),
|
normal: require('./prepare-payment.json'),
|
||||||
|
minAmountXRP: require('./prepare-payment-min-amount-xrp.json'),
|
||||||
|
minAmountXRPXRP: require('./prepare-payment-min-amount-xrp-xrp.json'),
|
||||||
allOptions: require('./prepare-payment-all-options.json'),
|
allOptions: require('./prepare-payment-all-options.json'),
|
||||||
noCounterparty: require('./prepare-payment-no-counterparty.json'),
|
noCounterparty: require('./prepare-payment-no-counterparty.json'),
|
||||||
minAmount: require('./prepare-payment-min-amount.json')
|
minAmount: require('./prepare-payment-min-amount.json')
|
||||||
@@ -62,20 +84,32 @@ module.exports = {
|
|||||||
flagSet: require('./prepare-settings-flag-set.json'),
|
flagSet: require('./prepare-settings-flag-set.json'),
|
||||||
flagClear: require('./prepare-settings-flag-clear.json'),
|
flagClear: require('./prepare-settings-flag-clear.json'),
|
||||||
setTransferRate: require('./prepare-settings-set-transfer-rate.json'),
|
setTransferRate: require('./prepare-settings-set-transfer-rate.json'),
|
||||||
fieldClear: require('./prepare-settings-field-clear.json')
|
fieldClear: require('./prepare-settings-field-clear.json'),
|
||||||
|
noInstructions: require('./prepare-settings-no-instructions.json'),
|
||||||
|
signed: require('./prepare-settings-signed.json'),
|
||||||
|
noMaxLedgerVersion: require('./prepare-settings-no-maxledgerversion.json')
|
||||||
|
},
|
||||||
|
prepareSuspendedPaymentCreation: {
|
||||||
|
normal: require('./prepare-suspended-payment-creation'),
|
||||||
|
full: require('./prepare-suspended-payment-creation-full')
|
||||||
|
},
|
||||||
|
prepareSuspendedPaymentExecution: {
|
||||||
|
normal: require('./prepare-suspended-payment-execution'),
|
||||||
|
simple: require('./prepare-suspended-payment-execution-simple')
|
||||||
|
},
|
||||||
|
prepareSuspendedPaymentCancellation: {
|
||||||
|
normal: require('./prepare-suspended-payment-cancellation'),
|
||||||
|
memos: require('./prepare-suspended-payment-cancellation-memos')
|
||||||
},
|
},
|
||||||
prepareSuspendedPaymentCreation:
|
|
||||||
require('./prepare-suspended-payment-creation'),
|
|
||||||
prepareSuspendedPaymentExecution:
|
|
||||||
require('./prepare-suspended-payment-execution'),
|
|
||||||
prepareSuspendedPaymentCancellation:
|
|
||||||
require('./prepare-suspended-payment-cancellation'),
|
|
||||||
prepareTrustline: {
|
prepareTrustline: {
|
||||||
simple: require('./prepare-trustline-simple.json'),
|
simple: require('./prepare-trustline-simple.json'),
|
||||||
|
frozen: require('./prepare-trustline-frozen.json'),
|
||||||
complex: require('./prepare-trustline.json')
|
complex: require('./prepare-trustline.json')
|
||||||
},
|
},
|
||||||
sign: require('./sign.json'),
|
sign: {
|
||||||
signSuspended: require('./sign-suspended.json'),
|
normal: require('./sign.json'),
|
||||||
|
suspended: require('./sign-suspended.json')
|
||||||
|
},
|
||||||
submit: require('./submit.json'),
|
submit: require('./submit.json'),
|
||||||
ledgerClosed: require('./ledger-closed.json')
|
ledgerEvent: require('./ledger-event.json')
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
{
|
{
|
||||||
"feeBase": 10,
|
"baseFeeXRP": "0.00001",
|
||||||
"feeReference": 10,
|
|
||||||
"ledgerVersion": 14804627,
|
"ledgerVersion": 14804627,
|
||||||
"ledgerHash": "9141FA171F2C0CE63E609466AF728FF66C12F7ACD4B4B50B0947A7F3409D593A",
|
"ledgerHash": "9141FA171F2C0CE63E609466AF728FF66C12F7ACD4B4B50B0947A7F3409D593A",
|
||||||
"ledgerTimestamp": "2015-07-23T05:50:40.000Z",
|
"ledgerTimestamp": "2015-07-23T05:50:40.000Z",
|
||||||
"reserveBase": 20000000,
|
"reserveBaseXRP": "20",
|
||||||
"reserveIncrement": 5000000,
|
"reserveIncrementXRP": "5",
|
||||||
"transactionCount": 19,
|
"transactionCount": 19,
|
||||||
"validatedLedgerVersions": "13983423-14804627"
|
"validatedLedgerVersions": "13983423-14804627"
|
||||||
}
|
}
|
||||||
8
test/fixtures/responses/prepare-order-cancellation-memos.json
vendored
Normal file
8
test/fixtures/responses/prepare-order-cancellation-memos.json
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"txJSON": "{\"TransactionType\":\"OfferCancel\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"OfferSequence\":23,\"Memos\":[{\"Memo\":{\"MemoData\":\"7465787465642064617461\",\"MemoType\":\"74657374\",\"MemoFormat\":\"706C61696E2F74657874\"}}],\"Flags\":2147483648,\"LastLedgerSequence\":8819954,\"Fee\":\"12\",\"Sequence\":23}",
|
||||||
|
"instructions": {
|
||||||
|
"fee": "0.000012",
|
||||||
|
"sequence": 23,
|
||||||
|
"maxLedgerVersion": 8819954
|
||||||
|
}
|
||||||
|
}
|
||||||
8
test/fixtures/responses/prepare-order-cancellation-no-instructions.json
vendored
Normal file
8
test/fixtures/responses/prepare-order-cancellation-no-instructions.json
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"txJSON": "{\"Flags\":2147483648,\"TransactionType\":\"OfferCancel\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"OfferSequence\":23,\"LastLedgerSequence\":8819954,\"Fee\":\"12\",\"Sequence\":23}",
|
||||||
|
"instructions": {
|
||||||
|
"fee": "0.000012",
|
||||||
|
"sequence": 23,
|
||||||
|
"maxLedgerVersion": 8819954
|
||||||
|
}
|
||||||
|
}
|
||||||
16
test/fixtures/responses/prepare-order-sell.json
vendored
16
test/fixtures/responses/prepare-order-sell.json
vendored
@@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"txJSON": "{\"Flags\":2148139008,\"TransactionType\":\"OfferCreate\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"TakerGets\":{\"value\":\"10.1\",\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\"},\"TakerPays\":\"2000000\",\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
|
"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}",
|
||||||
"instructions": {
|
"instructions": {
|
||||||
"fee": "0.000012",
|
"fee": "0.000012",
|
||||||
"sequence": 23,
|
"sequence": 23,
|
||||||
"maxLedgerVersion": 8820051
|
"maxLedgerVersion": 8820051
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user