Compare commits

...

46 Commits

Author SHA1 Message Date
Elliot Lee
a36e23ebfa Release 0.21.0 2018-04-11 21:33:44 -07:00
Elliot Lee
e978ef1888 Add getAccountObjects (#881)
Squashed commit of the following:

commit 361ead8cbbbe4fa25ecba614f8f11930ff679996
commit 5ff26d7d2defbbaaa7c50d6b3b5b74bf30be19ef
commit 97f5dfc86d4730082fd016197b0c025e499912e3
commit d48654098601f2a19484d9bbae7c65786e3c5dd4
commit 4790401123e7836f6bea8d03111bce60dcf95114
commit 57512f7fc000689bb8224f33173ba91221f27281
commit e75a7e95b11368b26c40e8e6e7b583d978475e95
2018-04-11 14:37:37 -07:00
Chris Yuen
9af3968508 Upgrade https-proxy-agent to version 2 (#883) 2018-04-10 12:59:24 -07:00
Elliot Lee
86ce7b707c Release 0.20.0 2018-04-09 12:03:05 -07:00
Elliot Lee
e0eb27ed8e Use jsonschema v1.2.2 and run yarn upgrade (#882)
- Fixes #880
2018-04-09 11:54:30 -07:00
amougel
2570e2a6d8 Add signWithKeypair (#769) 2018-04-03 15:33:24 -07:00
Rome Reginelli
c71540e77a Merge pull request #877 from mDuo13/add-tx-types
Improve Payment Channel documentation
2018-03-30 18:57:17 -07:00
mDuo13
8eba827d11 Improve Payment Channel documentation 2018-03-28 11:54:05 -07:00
Elliot Lee
90be539b09 Release 0.19.1 2018-03-22 14:12:22 -07:00
Fred K. Schott
43c08e5ea7 Clean up min/max adjustments (#873) 2018-03-22 12:31:44 -07:00
Fred K. Schott
3f22b12216 Add linting to travis (#872) 2018-03-20 14:30:37 -07:00
darkmemo
a72041a321 Fix Payment source & destination types (#870)
Payment `source` and `destination` are defined as intersection types, `Adjustment & MaxAdjustment` and  `Adjustment & MinAdjustment` respectively. But they should be union types instead. This problem was introduced during js to ts conversion.

Fixes #866
2018-03-20 11:26:41 -07:00
Elliot Lee
71a0c16fec Ledger object - accountState supersedes accounts (#868)
This appears to originate from a mistake in the docs.
The actual name of the field is `accountState`.

See:
9af994ceb4/src/ripple/app/ledger/impl/LedgerToJson.cpp (L167)

* Remove TODOs addressed by docs PR

https://github.com/ripple/ripple-dev-portal/pull/324
2018-03-19 14:52:18 -07:00
Elliot Lee
27ab98160a Fix link to checkCash (#871)
Fix source file for 4eaaa8188d
2018-03-19 14:41:18 -07:00
Ryan Young
4eaaa8188d Fix link to checkCash (#871)
#checkCash -- > #check-cash
2018-03-19 14:39:54 -07:00
Fred K. Schott
187154a2b0 Types cleanup + more API methods onto new request method (#857)
* major types cleanup, more formatted api methods onto new request method

- getPaymentChannel() now uses this.request()
- getSettings() now uses this.request()
- getLedger() now uses this.request()
- transaction types cleaned up a bit, but still some work left to do
2018-03-14 16:08:57 -07:00
Elliot Lee
c175e3f58e Point to types in package.json (#863) 2018-03-06 23:15:55 -08:00
Fred K. Schott
2ea22a099e Don't generate TS definitions for browser build (#864) 2018-03-06 23:15:11 -08:00
Elliot Lee
c3aa062edd Bump version to 0.19.0 and add release notes 2018-03-02 13:58:39 -08:00
Elliot Lee
0ad8c577c0 Export Check* transaction param types 2018-03-01 21:46:20 -08:00
Elliot Lee
facc513a52 Add support for Checks (#853)
- See https://github.com/ripple/rippled/pull/2245

* Add support for depositAuth flag

* Upgrade ripple-binary-codec to 0.1.13
2018-03-01 21:42:46 -08:00
Elliot Lee
df711ecb06 Import from 'server' to fix TS4029 2018-03-01 21:23:02 -08:00
Elliot Lee
144be08af0 Export types used by exported variables (#858)
Fixes TypeScript compile errors due to generating TS declaration files.

See #851
2018-03-01 17:48:28 -08:00
Fred K. Schott
c53db4844a Add .travis.yml (#859) 2018-03-01 17:32:31 -08:00
Elliot Lee
68b34f7532 Improve documentation of getTransactions params (#856)
* Improve documentation of getTransactions params

- Resolve #855
2018-02-26 17:39:06 -08:00
cryptcoin-junkey
3fe5d715a5 Generate/publish *.ts.d (#851)
For TypeScript
2018-02-24 23:52:45 -08:00
Elliot Lee
ca74cf1028 Apply automatic formatting 2018-02-23 16:50:40 -08:00
Elliot Lee
5b51ff6071 Support for the Deposit Authorization account root flag (#852)
* Add depositAuth flag tests
* Add support for depositAuth flag
2018-02-21 17:15:23 -08:00
Elliot Lee
3cad4f4aa3 Apply code formatting to API unit tests 2018-02-21 16:05:57 -08:00
Fred K. Schott
365de6d18a Add new request interface, implement first few request typings (#843)
* Add request interface & typings

- src/api: add basic implementation of request/requestAll()
- src/ledgers/account_info: refactor to simplify with request()
- src/ledgers/balances: refactor to simplify with request()
- src/ledgers/orderbook: refactor to simplify with requestAll()
- src/ledgers/orders: refactor to simplify with requestAll()
- src/ledgers/trustlines: refactor to simplify with requestAll()

* standardize on Formatted prefix
2018-02-20 11:44:36 -08:00
Elliot Lee
4a21360e37 Alphabetize properties for Settings object
- Generate docs to fix earlier typo (yarn run docgen)
2018-02-14 16:22:05 -08:00
Elliot Lee
43a3cfa010 HISTORY.md - remove broken link (404) 2018-02-14 16:00:51 -08:00
Elliot Lee
b89eae5cb1 Add test of getTrustlines with multiple pages of results (#850) 2018-02-14 15:57:35 -08:00
Elliot Lee
e311b74dac Add release notes for 0.18.2 2018-02-13 13:59:02 -08:00
Elliot Lee
e3748e070b Bump version to 0.18.2 2018-02-13 13:53:42 -08:00
Elliot Lee
0c318816cc Remove unnecessary files from npm
- `"bin/*"`, `"test/*"`, and `"Gulpfile.js"` can be removed
- See #844
2018-02-13 13:36:02 -08:00
Fred K. Schott
55e6801f4a Add build to prepublish in package.json (#849)
Continue to publish the build/ directory so that users can easily grab it from CDNs.
2018-02-12 09:47:25 -08:00
Elliot Lee
4f60fc301f Add "browser" property to package.json (#847)
* Use wswrapper shim for browserify
2018-02-11 08:52:19 -08:00
Elliot Lee
139159bf1a webpack config - include src instead of excluding node_modules 2018-02-07 14:14:35 -08:00
Elliot Lee
3ebbca0083 instructions.json - fix typo 2018-02-02 10:49:32 -08:00
Elliot Lee
51aaa75a05 Use BigNumber internally to compute fee 2018-01-30 15:29:28 -08:00
Elliot Lee
01a25f55f2 Initialize ledgerVersion to undefined 2018-01-30 14:58:59 -08:00
Fred K. Schott
94196ab268 post flow-to-ts cleanup 2018-01-29 12:11:32 -08:00
Elliot Lee
dc39343899 HISTORY.md - Add 0.18.1 2018-01-27 19:38:25 -08:00
Elliot Lee
272eabd1cd v0.18.1 2018-01-27 00:46:23 -08:00
Elliot Lee
7a653e6e63 Fix: isSameIssue() should check counterparty 2018-01-26 16:06:25 -08:00
149 changed files with 5751 additions and 1698 deletions

View File

@@ -1,3 +0,0 @@
{
"presets": ["es2015", "stage-1", "flow"]
}

View File

@@ -1,10 +0,0 @@
[ignore]
.*/ripple-lib/dist/.*
.*/ripple-lib/test/fixtures/.*
[include]
[libs]
[options]
module.system=node

10
.travis.yml Normal file
View File

@@ -0,0 +1,10 @@
language: node_js
node_js:
- 6
- 8
- 9
script:
- yarn compile
- yarn test
- yarn build
- yarn lint

View File

@@ -50,8 +50,12 @@ function getWebpackConfig(extension, overrides) {
use: 'null',
}, {
test: /\.ts$/,
use: 'ts-loader',
exclude: /node_modules/,
use: [{
loader: 'ts-loader',
options: {
compilerOptions: {declaration: false}
},
}],
}, {
test: /\.json/,
use: 'json-loader',

View File

@@ -1,5 +1,102 @@
# ripple-lib Release History
## 0.21.0 (2018-04-11)
+ [Upgrade https-proxy-agent](https://github.com/ripple/ripple-lib/pull/883)
+ [Add getAccountObjects](https://github.com/ripple/ripple-lib/pull/881)
The SHA-256 checksums for the browser version of this release can be found
below.
```
% shasum -a 256 *
3ab52209ad4a80393c8c08ef3f4aa9cfb47bc76c0ede2ee9fa7f5ca180ba4d67 ripple-0.21.0-debug.js
3b1efccded347bed5f64757098a1ea6a513bb8932d922d00af47cd24e001dc14 ripple-0.21.0-min.js
db08e5a3eab1f659b4c803543374398004d950ba720adc4b9a7658817cb5c94b ripple-0.21.0.js
```
## 0.20.0 (2018-04-09)
+ [Add support for using a keypair with sign()](https://github.com/ripple/ripple-lib/pull/769)
+ [Fix a bug caused by jsonschema v1.2.3 by pinning to v1.2.2](https://github.com/ripple/ripple-lib/pull/882)
+ [Improve Payment Channel documentation](https://github.com/ripple/ripple-lib/pull/877)
The SHA-256 checksums for the browser version of this release can be found
below.
```
% shasum -a 256 *
389811a9baa72f77e2a43d0b48045762d29a6f616ed5fd2660ba76fc12a3ecc5 ripple-0.20.0-debug.js
c1746ea0dd55318cb4e1ef3955ef14759d9d70861437c69abafc10169916f068 ripple-0.20.0-min.js
17958b0e46395d2b2a35a003693c0babdfb5382513d3cc58a62f8648ad710b0e ripple-0.20.0.js
```
## 0.19.1 (2018-03-22)
+ [Fix: Include TypeScript declarations in npm package](https://github.com/ripple/ripple-lib/pull/863)
+ [Fix: Documentation link to checkCash](https://github.com/ripple/ripple-lib/pull/871)
+ [Internal: Clean up types and migrate more APIs to new request method](https://github.com/ripple/ripple-lib/pull/857)
+ [Internal: Fix Payment source and destination types](https://github.com/ripple/ripple-lib/pull/870)
The SHA-256 checksums for the browser version of this release can be found
below.
```
% shasum -a 256 *
3ed5332aa035c07bae6c1abfdfc8ca77cdbb05cc4b88878f544f1ea4cb793f4d ripple-0.19.1-debug.js
2f5507aa00a40ab6a94de1822af87db5e927edef3885aef5d9b39ccb623ccb54 ripple-0.19.1-min.js
1e439aee1b220242d56ea687a9b55a67b8614212c1ddbd70a4fcf34503fc487a ripple-0.19.1.js
```
## 0.19.0 (2018-03-02)
+ [Add support for Checks](https://github.com/ripple/ripple-lib/pull/853)
+ [Add support for the Deposit Authorization account root flag](https://github.com/ripple/ripple-lib/pull/852)
+ [Generate .ts.d TypeScript declaration files](https://github.com/ripple/ripple-lib/pull/851)
+ [Improve documentation of getTransactions params](https://github.com/ripple/ripple-lib/pull/856)
+ [Add new request interface](https://github.com/ripple/ripple-lib/pull/843) (private for now)
The SHA-256 checksums for the browser version of this release can be found
below.
```
% shasum -a 256 *
0e7ce4594b7e455fbc57ad81f6fddc391d1e1f349a49c96ad783be50f80fdc14 ripple-0.19.0-debug.js
6d716a0357929e51e476f22136880f7a0e5458fd396ac145ce9308f278ff7cc1 ripple-0.19.0-min.js
6715db1af638f99226ab7f8f244103306aa6e04d1b8c1da47a63431053bacb84 ripple-0.19.0.js
```
## 0.18.2 (2018-02-13)
+ [Fix: Publish updated browser builds to npm so that users can easily use
CDNs](https://github.com/ripple/ripple-lib/pull/849)
+ [Fix: Browserify fails due to dependency on `ws`](https://github.com/ripple/ripple-lib/pull/847)
+ [Fix: `build` script fails when `node_modules` is in path](https://github.com/ripple/ripple-lib/pull/846)
+ [Reduce size of published npm package](https://github.com/ripple/ripple-lib/commit/0c318816ccf25c4c3932934a35ef903cc552edc1)
+ Clean up files from Flow (we migrated to TypeScript)
+ Typos and code cleanup
The SHA-256 checksums for the browser version of this release can be found
below.
```
% shasum -a 256 *
f08ab61137255be3639e9d210ded2a182b6e0388f257a70d9b372ce7e7e518a6 ripple-0.18.2-debug.js
0604835b8421391167b4314ce93a76b5994780a08bd7edf36d91eb5e8f2643a2 ripple-0.18.2-min.js
fda56ab5c8256e04355e20064877ef4053f26c87f37cfcf861340f22bf89ee40 ripple-0.18.2.js
```
## 0.18.1 (2018-01-27)
Note: The package published to npm for this version did not include updated
browser builds. If you are using a CDN that pulls from npm, please use 0.18.2 or
later.
+ [Fix: isSameIssue() should check counterparty](https://github.com/ripple/ripple-lib/pull/836). This bug caused `getOrderbook()` to return incorrect values.
The SHA-256 checksums for the browser version of this release can be found below.
```
% shasum -a 256 *
6871855a2af1dc591ef557d442c11e8c60e01c5932054e13e8cbb84a182f45e0 ripple-0.18.1-debug.js
331f0baff46af44933a8fa31f128132945ff82a147acfff0a7315adb446e3de0 ripple-0.18.1-min.js
26324bb0725d2d484fe3b6086335d49734f45dc647b07c60746e0d8619f1ed3e ripple-0.18.1.js
```
## 0.18.0 (2018-01-25)
+ [Convert from Flow to TypeScript](https://github.com/ripple/ripple-lib/pull/816)
@@ -9,14 +106,6 @@
+ [Fix type errors](https://github.com/ripple/ripple-lib/pull/811)
+ [Fix lint errors](https://github.com/ripple/ripple-lib/pull/813)
The SHA-256 checksums for the browser version of this release can be found below.
```
% shasum -a 256 *
c97e2c820863b51f9ca8c98714406afb7cb4ba6d10c7dab5443c8c8579878665 ripple-0.18.0-debug.js
9f2b69045979b76735f436c4aa3e010d195e0407de5ac9c96289b8724c35da66 ripple-0.18.0-min.js
500db0411fe66e9550a07ee42229641afd7f544481c0cdddfcc87cccdb9f070f ripple-0.18.0.js
```
## 0.17.9 (2017-11-14)
+ [Update ws dependency to 3.3.1](https://github.com/ripple/ripple-lib/pull/804)
@@ -133,7 +222,6 @@ __OTHER CHANGES__
__BREAKING CHANGES__
+ Add new RippleAPI interface and delete old API
- [RippleAPI README and samples](https://github.com/ripple/ripple-lib/tree/develop/docs/samples)
- [Method documentation](https://rawgit.com/ripple/ripple-lib/develop/docs/api.html)
__OTHER CHANGES__
+ [Removed timeout method of Request and added default timeout](https://github.com/ripple/ripple-lib/commit/634fe5683a9082e57682ff7d5c4fb9483b4af818)

View File

@@ -27,6 +27,9 @@
- [Escrow Creation](#escrow-creation)
- [Escrow Cancellation](#escrow-cancellation)
- [Escrow Execution](#escrow-execution)
- [Check Create](#check-create)
- [Check Cancel](#check-cancel)
- [Check Cash](#check-cash)
- [Payment Channel Create](#payment-channel-create)
- [Payment Channel Fund](#payment-channel-fund)
- [Payment Channel Claim](#payment-channel-claim)
@@ -47,6 +50,7 @@
- [getOrderbook](#getorderbook)
- [getSettings](#getsettings)
- [getAccountInfo](#getaccountinfo)
- [getAccountObjects](#getaccountobjects)
- [getPaymentChannel](#getpaymentchannel)
- [getLedger](#getledger)
- [preparePayment](#preparepayment)
@@ -60,6 +64,9 @@
- [preparePaymentChannelCreate](#preparepaymentchannelcreate)
- [preparePaymentChannelClaim](#preparepaymentchannelclaim)
- [preparePaymentChannelFund](#preparepaymentchannelfund)
- [prepareCheckCreate](#preparecheckcreate)
- [prepareCheckCancel](#preparecheckcancel)
- [prepareCheckCash](#preparecheckcash)
- [sign](#sign)
- [combine](#combine)
- [submit](#submit)
@@ -266,6 +273,12 @@ Type | Description
[escrowCreation](#escrow-creation) | An `escrowCreation` transaction creates an escrow on the ledger, which locks XRP until a cryptographic condition is met or it expires. It is like an escrow service where the XRP Ledger acts as the escrow agent.
[escrowCancellation](#escrow-cancellation) | An `escrowCancellation` transaction unlocks the funds in an escrow and sends them back to the creator of the escrow, but it will only work after the escrow expires.
[escrowExecution](#escrow-execution) | An `escrowExecution` transaction unlocks the funds in an escrow and sends them to the destination of the escrow, but it will only work if the cryptographic condition is provided.
[checkCreate](#check-create) | A `checkCreate` transaction creates a check on the ledger, which is a deferred payment that can be cashed by its intended destination.
[checkCancel](#check-cancel) | A `checkCancel` transaction cancels an unreedemed Check, removing it from the ledger without sending any money.
[checkCash](#check-cash) | A `checkCash` transaction redeems a Check to receive up to the amount authorized by the corresponding `checkCreate` transaction. Only the `destination` address of a Check can cash it.
[paymentChannelCreate](#payment-channel-create) | A `paymentChannelCreate` transaction opens a payment channel between two addresses with XRP set aside for asynchronous payments.
[paymentChannelFund](#payment-channel-fund) | A `paymentChannelFund` transaction adds XRP to a payment channel and optionally sets a new expiration for the channel.
[paymentChannelClaim](#payment-channel-claim) | A `paymentChannelClaim` transaction withdraws XRP from a channel and optionally requests to close it.
## Transaction Flow
@@ -280,6 +293,9 @@ Executing a transaction with `RippleAPI` requires the following four steps:
* [prepareEscrowCreation](#prepareescrowcreation)
* [prepareEscrowCancellation](#prepareescrowcancellation)
* [prepareEscrowExecution](#prepareescrowexecution)
* [prepareCheckCreate](#preparecheckcreate)
* [prepareCheckCancel](#preparecheckcancel)
* [prepareCheckCash](#preparecheckcash)
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. For multisignature transactions, the `signedTransaction` fields returned by `sign` must be collected and passed to the [combine](#combine) method.
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.
@@ -299,7 +315,8 @@ Name | Type | Description
fee | [value](#value) | *Optional* An exact fee to pay for the transaction. See [Transaction Fees](#transaction-fees) for more information.
maxFee | [value](#value) | *Optional* The maximum fee to pay for the transaction. See [Transaction Fees](#transaction-fees) for more information.
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 validated legder version to highest ledger version that the transaction can be included in.
maxLedgerVersion | string,null | *Optional* The highest ledger version that the transaction can be included in. If this option and `maxLedgerVersionOffset` are both omitted, the `maxLedgerVersion` option will default to 3 greater than the current validated ledger version (equivalent to `maxLedgerVersionOffset=3`). Use `null` to not set a maximum ledger version.
maxLedgerVersionOffset | integer | *Optional* Offset from current validated ledger version to highest ledger version that the transaction can be included in.
sequence | [sequence](#account-sequence-number) | *Optional* The initiating account's sequence number for this transaction.
signersCount | integer | *Optional* Number of signers that will be signing this transaction.
@@ -346,11 +363,11 @@ destination | object | The destination of the funds to be sent.
*destination.* tag | integer | *Optional* An arbitrary unsigned 32-bit integer that identifies a reason for payment or a non-Ripple account.
*destination.* address | [address](#address) | The address to send to.
*destination.* minAmount | [laxAmount](#amount) | The minimum amount to be delivered. (This field is exclusive with destination.amount)
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* If true, this payment should proceed even if the whole amount cannot be delivered due to a lack of liquidity or a lack of funds in the source account.
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.
memos | [memos](#transaction-memos) | *Optional* Array of memos to attach to the transaction.
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* If true and paths are specified, the sender would like the XRP Ledger to disregard any direct paths from the source account to the destination account. This may be used to take advantage of an arbitrage opportunity or by gateways wishing to issue balances from a hot wallet to a user who has mistakenly set a trustline directly to the hot wallet.
paths | string | *Optional* The paths of trustlines and orders to use in executing the payment.
### Example
@@ -479,7 +496,8 @@ See [Transaction Types](#transaction-types) for a description.
Name | Type | Description
---- | ---- | -----------
defaultRipple | boolean | *Optional* Enable [rippling](https://ripple.com/knowledge_center/understanding-the-noripple-flag/) on this accounts trust lines by default. (New in [rippled 0.27.3](https://github.com/ripple/rippled/releases/tag/0.27.3))
defaultRipple | boolean | *Optional* Enable [rippling](https://ripple.com/build/understanding-the-noripple-flag/) on this accounts trust lines by default. (New in [rippled 0.27.3](https://github.com/ripple/rippled/releases/tag/0.27.3))
depositAuth | boolean | *Optional* Enable [Deposit Authorization](https://ripple.com/build/deposit-authorization/) on this account. If set, transactions cannot send value of any kind to this account unless the sender of those transactions is the account itself. (Requires the [DepositAuth amendment](https://ripple.com/build/known-amendments/#depositauth))
disableMasterKey | boolean | *Optional* Disallows use of the master key to sign transactions for this account.
disallowIncomingXRP | boolean | *Optional* Indicates that client applications should not send XRP to this account. Not enforced by rippled.
domain | string | *Optional* The domain that owns this account, as a hexadecimal string representing the ASCII for the domain in lowercase.
@@ -592,6 +610,74 @@ memos | [memos](#transaction-memos) | *Optional* Array of memos to attach to the
```
## Check Create
See [Transaction Types](#transaction-types) for a description.
Name | Type | Description
---- | ---- | -----------
destination | [address](#address) | Address of the account that can cash the check.
sendMax | [laxAmount](#amount) | Amount of source currency the check is allowed to debit the sender, including transfer fees on non-XRP currencies.
destinationTag | integer | *Optional* Destination tag that identifies the reason for the check, or a hosted recipient to pay.
expiration | date-time string | *Optional* Time after which the check is no longer valid.
invoiceID | string | *Optional* 256-bit hash, as a 64-character hexadecimal string, representing a specific reason or identifier for this check.
### Example
```json
{
"destination": "rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW",
"sendMax": {
"currency": "XRP",
"value": "1"
}
}
```
## Check Cancel
See [Transaction Types](#transaction-types) for a description.
Name | Type | Description
---- | ---- | -----------
checkID | string | The ID of the Check ledger object to cancel, as a 64-character hexadecimal string.
### Example
```json
{
"checkID": "49647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB0"
}
```
## Check Cash
See [Transaction Types](#transaction-types) for a description.
Name | Type | Description
---- | ---- | -----------
checkID | string | The ID of the Check ledger object to cash, as a 64-character hexadecimal string.
amount | [laxAmount](#amount) | *Optional* Redeem the Check for exactly this amount, if possible. The currency must match that of the sendMax of the corresponding CheckCreate transaction. You must provide either this field or deliverMin.
deliverMin | [laxAmount](#amount) | *Optional* Redeem the Check for at least this amount and for as much as possible. The currency must match that of the sendMax of the corresponding CheckCreate transaction. You must provide either this field or amount.
### Example
```json
{
"amount": {
"currency": "XRP",
"value": "1"
},
"checkID": "838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334"
}
```
## Payment Channel Create
See [Transaction Types](#transaction-types) for a description.
@@ -601,8 +687,8 @@ Name | Type | Description
amount | [value](#value) | Amount of XRP for sender to set aside in this channel.
destination | [address](#address) | Address to receive XRP claims against this channel.
settleDelay | number | Amount of seconds the source address must wait before closing the channel if it has unclaimed XRP.
publicKey | string | Public key of the key pair the source will use to sign claims against this channel.
cancelAfter | date-time string | *Optional* Time when this channel expires.
publicKey | string | Public key of the key pair the source may use to sign claims against this channel.
cancelAfter | date-time string | *Optional* Time when this channel expires. This expiration cannot be changed after creating the channel.
destinationTag | integer | *Optional* Destination tag.
sourceTag | integer | *Optional* Source tag.
@@ -627,7 +713,7 @@ Name | Type | Description
---- | ---- | -----------
amount | [value](#value) | Amount of XRP to fund the channel with.
channel | string | 256-bit hexadecimal channel identifier.
expiration | date-time string | *Optional* New expiration for this channel.
expiration | date-time string | *Optional* New expiration for this channel. (This does not change the cancelAfter expiration, if the channel has one.) Cannot move the expiration sooner than settleDelay seconds from time of the request.
### Example
@@ -647,12 +733,12 @@ See [Transaction Types](#transaction-types) for a description.
Name | Type | Description
---- | ---- | -----------
channel | string | 256-bit hexadecimal channel identifier.
amount | [value](#value) | *Optional* XRP balance of this channel after claim is processed.
balance | [value](#value) | *Optional* Amount of XRP authorized by signature.
close | boolean | *Optional* Request to close the channel.
publicKey | string | *Optional* Public key of the channel's sender
amount | [value](#value) | *Optional* Amount of XRP authorized by this signature.
balance | [value](#value) | *Optional* Total XRP balance delivered by this channel after claim is processed.
close | boolean | *Optional* Request to close the channel. If the channel has no XRP remaining or the destination address requests it, closes the channel immediately (returning unclaimed XRP to the source address). Otherwise, sets the channel to expire after settleDelay seconds have passed.
publicKey | string | *Optional* Public key of the channel. (For verifying the signature.)
renew | boolean | *Optional* Clear the channel's expiration time.
signature | string | *Optional* Signature of this claim.
signature | string | *Optional* Signed claim authorizing withdrawal of XRP from the channel. (Required except from the channel's source address.)
### Example
@@ -864,7 +950,9 @@ Name | Type | Description
id | [id](#transaction-id) | A hash of a transaction used to identify the transaction, represented in hexadecimal.
options | object | *Optional* Options to limit the ledger versions to search.
*options.* maxLedgerVersion | integer | *Optional* The highest ledger version to search
*options.* maxLedgerVersion | string | *Optional* The highest ledger version to search
*options.* minLedgerVersion | integer | *Optional* The lowest ledger version to search.
*options.* minLedgerVersion | string | *Optional* The lowest ledger version to search.
### Return Value
@@ -891,6 +979,7 @@ outcome | object | The outcome of the transaction (what effects it had).
*outcome.orderbookChanges.\*[].* expirationTime | date-time string | *Optional* The time after which the order expires, if any.
*outcome.orderbookChanges.\*[].* makerExchangeRate | [value](#value) | *Optional* The exchange rate between the `quantity` currency and the `totalPrice` currency from the point of view of the maker.
*outcome.* ledgerVersion | integer | The ledger version that the transaction was validated in.
*outcome.* ledgerVersion | string | The ledger version that the transaction was validated in.
*outcome.* indexInLedger | integer | The ordering index of the transaction in the ledger.
*outcome.* deliveredAmount | [amount](#amount) | *Optional* For payment transactions, it is impossible to reliably compute the actual delivered amount from the balanceChanges due to fixed precision. If the payment is not a partial payment and the transaction succeeded, the deliveredAmount should always be considered to be the amount specified in the transaction.
*outcome.* timestamp | date-time string | *Optional* The timestamp when the transaction was validated. (May be missing when requesting transactions in binary mode.)
@@ -1020,8 +1109,10 @@ options | object | *Optional* Options to filter the resulting transactions.
*options.* initiated | boolean | *Optional* If true, return only transactions initiated by the account specified by `address`. If false, return only transactions not initiated by the account specified by `address`.
*options.* limit | integer | *Optional* If specified, return at most this many transactions.
*options.* maxLedgerVersion | integer | *Optional* Return only transactions in this ledger version or lower.
*options.* maxLedgerVersion | string | *Optional* Return only transactions in this ledger version or lower.
*options.* minLedgerVersion | integer | *Optional* Return only transactions in this ledger verion or higher.
*options.* start | string | *Optional* If specified, this transaction will be the first transaction in the result.
*options.* minLedgerVersion | string | *Optional* Return only transactions in this ledger verion or higher.
*options.* start | string | *Optional* If specified, this transaction will be the first transaction in the result. You cannot use `start` with `minLedgerVersion` or `maxLedgerVersion`. When `start` is specified, these ledger versions will be determined internally.
*options.* types | array\<[transactionType](#transaction-types)\> | *Optional* Only return transactions of the specified [Transaction Types](#transaction-types).
### Return Value
@@ -1253,6 +1344,7 @@ options | object | *Optional* Options to filter and determine which trustlines t
*options.* counterparty | [address](#address) | *Optional* Only return trustlines with this counterparty.
*options.* currency | [currency](#currency) | *Optional* Only return trustlines for this currency.
*options.* ledgerVersion | integer | *Optional* Return trustlines as they were in this historical ledger version.
*options.* ledgerVersion | string | *Optional* Return trustlines as they were in this historical ledger version.
*options.* limit | integer | *Optional* Return at most this many trustlines.
### Return Value
@@ -1397,6 +1489,7 @@ options | object | *Optional* Options to filter and determine which balances to
*options.* counterparty | [address](#address) | *Optional* Only return balances with this counterparty.
*options.* currency | [currency](#currency) | *Optional* Only return balances for this currency.
*options.* ledgerVersion | integer | *Optional* Return balances as they were in this historical ledger version.
*options.* ledgerVersion | string | *Optional* Return balances as they were in this historical ledger version.
*options.* limit | integer | *Optional* Return at most this many balances.
### Return Value
@@ -1562,6 +1655,7 @@ address | [address](#address) | The Ripple address of the account to get the bal
options | object | *Optional* Options to determine how the balances will be calculated.
*options.* excludeAddresses | array\<[address](#address)\> | *Optional* Addresses to exclude from the balance totals.
*options.* ledgerVersion | integer | *Optional* Get the balance sheet as of this historical ledger version.
*options.* ledgerVersion | string | *Optional* Get the balance sheet as of this historical ledger version.
### Return Value
@@ -1778,6 +1872,7 @@ Name | Type | Description
address | [address](#address) | The Ripple address of the account to get open orders for.
options | object | *Optional* Options that determine what orders will be returned.
*options.* ledgerVersion | integer | *Optional* Return orders as of this historical ledger version.
*options.* ledgerVersion | string | *Optional* Return orders as of this historical ledger version.
*options.* limit | integer | *Optional* At most this many orders will be returned.
### Return Value
@@ -2161,6 +2256,7 @@ orderbook | object | The order book to get.
*orderbook.* counter | object | A currency-counterparty pair, or just currency if it's XRP
options | object | *Optional* Options to determine what to return.
*options.* ledgerVersion | integer | *Optional* Return the order book as of this historical ledger version.
*options.* ledgerVersion | string | *Optional* Return the order book as of this historical ledger version.
*options.* limit | integer | *Optional* Return at most this many orders from the order book.
### Return Value
@@ -2711,6 +2807,7 @@ Name | Type | Description
address | [address](#address) | The address of the account to get the settings of.
options | object | *Optional* Options that affect what to return.
*options.* ledgerVersion | integer | *Optional* Get the settings as of this historical ledger version.
*options.* ledgerVersion | string | *Optional* Get the settings as of this historical ledger version.
### Return Value
@@ -2718,7 +2815,8 @@ This method returns a promise that resolves with an array of objects with the fo
Name | Type | Description
---- | ---- | -----------
defaultRipple | boolean | *Optional* Enable [rippling](https://ripple.com/knowledge_center/understanding-the-noripple-flag/) on this accounts trust lines by default. (New in [rippled 0.27.3](https://github.com/ripple/rippled/releases/tag/0.27.3))
defaultRipple | boolean | *Optional* Enable [rippling](https://ripple.com/build/understanding-the-noripple-flag/) on this accounts trust lines by default. (New in [rippled 0.27.3](https://github.com/ripple/rippled/releases/tag/0.27.3))
depositAuth | boolean | *Optional* Enable [Deposit Authorization](https://ripple.com/build/deposit-authorization/) on this account. If set, transactions cannot send value of any kind to this account unless the sender of those transactions is the account itself. (Requires the [DepositAuth amendment](https://ripple.com/build/known-amendments/#depositauth))
disableMasterKey | boolean | *Optional* Disallows use of the master key to sign transactions for this account.
disallowIncomingXRP | boolean | *Optional* Indicates that client applications should not send XRP to this account. Not enforced by rippled.
domain | string | *Optional* The domain that owns this account, as a hexadecimal string representing the ASCII for the domain in lowercase.
@@ -2788,6 +2886,7 @@ Name | Type | Description
address | [address](#address) | The address of the account to get the account info of.
options | object | *Optional* Options that affect what to return.
*options.* ledgerVersion | integer | *Optional* Get the account info as of this historical ledger version.
*options.* ledgerVersion | string | *Optional* Get the account info as of this historical ledger version.
### Return Value
@@ -2800,6 +2899,7 @@ xrpBalance | [value](#value) | The XRP balance owned by the account.
ownerCount | integer | Number of other ledger entries (specifically, trust lines and offers) attributed to this account. This is used to calculate the total reserve required to use the account.
previousAffectingTransactionID | string | Hash value representing the most recent transaction that affected this account node directly. **Note:** This does not include changes to the accounts trust lines and offers.
previousAffectingTransactionLedgerVersion | integer | The ledger version that the transaction identified by the `previousAffectingTransactionID` was validated in.
previousAffectingTransactionLedgerVersion | string | The ledger version that the transaction identified by the `previousAffectingTransactionID` was validated in.
previousInitiatedTransactionID | string | *Optional* Hash value representing the most recent transaction that was initiated by this account.
### Example
@@ -2822,6 +2922,330 @@ return api.getAccountInfo(address).then(info =>
```
## getAccountObjects
`getAccountObjects(address: string, options: object): Promise<AccountObjectsResponse>`
Returns objects owned by an account. For an account's trust lines and balances, see `getTrustlines` and `getBalances`.
### Parameters
Name | Type | Description
---- | ---- | -----------
address | [address](#address) | The address of the account to get the account objects of.
options | object | *Optional* Options that affect what to return.
*options.* ledgerHash | string | *Optional* (Optional) A 20-byte hex string for the ledger version to use.
*options.* ledgerIndex | integer | *Optional* (Optional) The sequence number of the ledger to use, or a shortcut string to choose a ledger automatically.
*options.* ledgerIndex | string | *Optional* (Optional) The sequence number of the ledger to use, or a shortcut string to choose a ledger automatically.
*options.* limit | integer | *Optional* (Optional) The maximum number of objects to include in the results.
*options.* type | string | *Optional* (Optional) Filter results to include only this type of ledger object. The valid types are: `check`, `escrow`, `offer`, `payment_channel`, `signer_list`, and `state` (trust line).
### Return Value
This method returns a promise that resolves with an object with the following structure:
Name | Type | Description
---- | ---- | -----------
account | [address](#address) | Unique address of the account this request corresponds to.
account_objects | array\<object\> | Array of objects owned by this account. Each object is in its raw ledger format.
ledger_current_index | integer | *Optional* (May be omitted) The sequence number of the ledger that was used to generate this response.
ledger_current_index | string | *Optional* (May be omitted) The sequence number of the ledger that was used to generate this response.
ledger_hash | string | *Optional* (May be omitted) The identifying hash of the ledger that was used to generate this response.
ledger_index | integer | *Optional* (May be omitted) The sequence number of the ledger that was used to generate this response.
ledger_index | string | *Optional* (May be omitted) The sequence number of the ledger that was used to generate this response.
limit | integer | *Optional* (May be omitted) The limit that was used in this request, if any.
validated | boolean | *Optional* If included and set to true, the information in this request comes from a validated ledger version. Otherwise, the information is subject to change.
The types of objects that may be returned include:
* Offer objects for orders that are currently live, unfunded, or expired but not yet removed.
* RippleState objects for trust lines where this account's side is not in the default state.
* A SignerList object if the account has multi-signing enabled.
* Escrow objects for held payments that have not yet been executed or canceled.
* PayChannel objects for open payment channels.
* Check objects for pending checks.
### Example
```javascript
const address = 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59';
return api.getAccountObjects(address: address).then(objects =>
{/* ... */});
```
```json
{
"account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
"account_objects": [
{
"Balance": {
"currency": "ASP",
"issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value": "0"
},
"Flags": 65536,
"HighLimit": {
"currency": "ASP",
"issuer": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
"value": "0"
},
"HighNode": "0000000000000000",
"LedgerEntryType": "RippleState",
"LowLimit": {
"currency": "ASP",
"issuer": "r3vi7mWxru9rJCxETCyA1CHvzL96eZWx5z",
"value": "10"
},
"LowNode": "0000000000000000",
"PreviousTxnID":
"BF7555B0F018E3C5E2A3FF9437A1A5092F32903BE246202F988181B9CED0D862",
"PreviousTxnLgrSeq": 1438879,
"index":
"2243B0B630EA6F7330B654EFA53E27A7609D9484E535AB11B7F946DF3D247CE9"
},
{
"Balance": {
"currency": "XAU",
"issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value": "0"
},
"Flags": 3342336,
"HighLimit": {
"currency": "XAU",
"issuer": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
"value": "0"
},
"HighNode": "0000000000000000",
"LedgerEntryType": "RippleState",
"LowLimit": {
"currency": "XAU",
"issuer": "r3vi7mWxru9rJCxETCyA1CHvzL96eZWx5z",
"value": "0"
},
"LowNode": "0000000000000000",
"PreviousTxnID":
"79B26D7D34B950AC2C2F91A299A6888FABB376DD76CFF79D56E805BF439F6942",
"PreviousTxnLgrSeq": 5982530,
"index":
"9ED4406351B7A511A012A9B5E7FE4059FA2F7650621379C0013492C315E25B97"
},
{
"Balance": {
"currency": "USD",
"issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value": "0"
},
"Flags": 1114112,
"HighLimit": {
"currency": "USD",
"issuer": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
"value": "0"
},
"HighNode": "0000000000000000",
"LedgerEntryType": "RippleState",
"LowLimit": {
"currency": "USD",
"issuer": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
"value": "5"
},
"LowNode": "0000000000000000",
"PreviousTxnID":
"6FE8C824364FB1195BCFEDCB368DFEE3980F7F78D3BF4DC4174BB4C86CF8C5CE",
"PreviousTxnLgrSeq": 10555014,
"index":
"2DECFAC23B77D5AEA6116C15F5C6D4669EBAEE9E7EE050A40FE2B1E47B6A9419"
},
{
"Balance": {
"currency": "MXN",
"issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value": "481.992867407479"
},
"Flags": 65536,
"HighLimit": {
"currency": "MXN",
"issuer": "rHpXfibHgSb64n8kK9QWDpdbfqSpYbM9a4",
"value": "0"
},
"HighNode": "0000000000000000",
"LedgerEntryType": "RippleState",
"LowLimit": {
"currency": "MXN",
"issuer": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
"value": "1000"
},
"LowNode": "0000000000000000",
"PreviousTxnID":
"A467BACE5F183CDE1F075F72435FE86BAD8626ED1048EDEFF7562A4CC76FD1C5",
"PreviousTxnLgrSeq": 3316170,
"index":
"EC8B9B6B364AF6CB6393A423FDD2DDBA96375EC772E6B50A3581E53BFBDFDD9A"
},
{
"Balance": {
"currency": "EUR",
"issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value": "0.793598266778297"
},
"Flags": 1114112,
"HighLimit": {
"currency": "EUR",
"issuer": "rLEsXccBGNR3UPuPu2hUXPjziKC3qKSBun",
"value": "0"
},
"HighNode": "0000000000000000",
"LedgerEntryType": "RippleState",
"LowLimit": {
"currency": "EUR",
"issuer": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
"value": "1"
},
"LowNode": "0000000000000000",
"PreviousTxnID":
"E9345D44433EA368CFE1E00D84809C8E695C87FED18859248E13662D46A0EC46",
"PreviousTxnLgrSeq": 5447146,
"index":
"4513749B30F4AF8DA11F077C448128D6486BF12854B760E4E5808714588AA915"
},
{
"Balance": {
"currency": "CNY",
"issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value": "0"
},
"Flags": 2228224,
"HighLimit": {
"currency": "CNY",
"issuer": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
"value": "3"
},
"HighNode": "0000000000000000",
"LedgerEntryType": "RippleState",
"LowLimit": {
"currency": "CNY",
"issuer": "rnuF96W4SZoCJmbHYBFoJZpR8eCaxNvekK",
"value": "0"
},
"LowNode": "0000000000000008",
"PreviousTxnID":
"2FDDC81F4394695B01A47913BEC4281AC9A283CC8F903C14ADEA970F60E57FCF",
"PreviousTxnLgrSeq": 5949673,
"index":
"578C327DA8944BDE2E10C9BA36AFA2F43E06C8D1E8819FB225D266CBBCFDE5CE"
},
{
"Balance": {
"currency": "DYM",
"issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value": "1.336889190631542"
},
"Flags": 65536,
"HighLimit": {
"currency": "DYM",
"issuer": "rGwUWgN5BEg3QGNY3RX2HfYowjUTZdid3E",
"value": "0"
},
"HighNode": "0000000000000000",
"LedgerEntryType": "RippleState",
"LowLimit": {
"currency": "DYM",
"issuer": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
"value": "3"
},
"LowNode": "0000000000000000",
"PreviousTxnID":
"6DA2BD02DFB83FA4DAFC2651860B60071156171E9C021D9E0372A61A477FFBB1",
"PreviousTxnLgrSeq": 8818732,
"index":
"5A2A5FF12E71AEE57564E624117BBA68DEF78CD564EF6259F92A011693E027C7"
},
{
"Balance": {
"currency": "CHF",
"issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value": "-0.3488146605801446"
},
"Flags": 131072,
"HighLimit": {
"currency": "CHF",
"issuer": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
"value": "0"
},
"HighNode": "0000000000000000",
"LedgerEntryType": "RippleState",
"LowLimit": {
"currency": "CHF",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0"
},
"LowNode": "000000000000008C",
"PreviousTxnID":
"722394372525A13D1EAAB005642F50F05A93CF63F7F472E0F91CDD6D38EB5869",
"PreviousTxnLgrSeq": 2687590,
"index":
"F2DBAD20072527F6AD02CE7F5A450DBC72BE2ABB91741A8A3ADD30D5AD7A99FB"
},
{
"Balance": {
"currency": "BTC",
"issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value": "0"
},
"Flags": 131072,
"HighLimit": {
"currency": "BTC",
"issuer": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
"value": "3"
},
"HighNode": "0000000000000000",
"LedgerEntryType": "RippleState",
"LowLimit": {
"currency": "BTC",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0"
},
"LowNode": "0000000000000043",
"PreviousTxnID":
"03EDF724397D2DEE70E49D512AECD619E9EA536BE6CFD48ED167AE2596055C9A",
"PreviousTxnLgrSeq": 8317037,
"index":
"767C12AF647CDF5FEB9019B37018748A79C50EDAF87E8D4C7F39F78AA7CA9765"
},
{
"Balance": {
"currency": "USD",
"issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value": "-16.00534471983042"
},
"Flags": 131072,
"HighLimit": {
"currency": "USD",
"issuer": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
"value": "5000"
},
"HighNode": "0000000000000000",
"LedgerEntryType": "RippleState",
"LowLimit": {
"currency": "USD",
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
"value": "0"
},
"LowNode": "000000000000004A",
"PreviousTxnID":
"CFFF5CFE623C9543308C6529782B6A6532207D819795AAFE85555DB8BF390FE7",
"PreviousTxnLgrSeq": 14365854,
"index":
"826CF5BFD28F3934B518D0BDF3231259CBD3FD0946E3C3CA0C97D2C75D2D1A09"
}
],
"ledger_hash":
"053DF17D2289D1C4971C22F235BC1FCA7D4B3AE966F842E5819D0749E0B8ECD3",
"ledger_index": 14378733,
"validated": true
}
```
## getPaymentChannel
`getPaymentChannel(id: string): Promise<Object>`
@@ -2847,6 +3271,7 @@ balance | [value](#value) | The total amount of XRP delivered by this channel.
settleDelay | number | Amount of seconds the source address must wait before closing the channel if it has unclaimed XRP.
previousAffectingTransactionID | string | Hash value representing the most recent transaction that affected this payment channel.
previousAffectingTransactionLedgerVersion | integer | The ledger version that the transaction identified by the `previousAffectingTransactionID` was validated in.
previousAffectingTransactionLedgerVersion | string | The ledger version that the transaction identified by the `previousAffectingTransactionID` was validated in.
cancelAfter | date-time string | *Optional* Time when this channel expires as specified at creation.
destinationTag | integer | *Optional* Destination tag.
expiration | date-time string | *Optional* Time when this channel expires.
@@ -2892,6 +3317,7 @@ options | object | *Optional* Options affecting what ledger and how much data to
*options.* includeState | boolean | *Optional* Return an array of hashes for all state data or an array of all state data in this ledger version, depending on whether `includeAllData` is set.
*options.* includeTransactions | boolean | *Optional* Return an array of hashes for each transaction or an array of all transactions that were validated in this ledger version, depending on whether `includeAllData` is set.
*options.* ledgerVersion | integer | *Optional* Get ledger data for this historical ledger version.
*options.* ledgerVersion | string | *Optional* Get ledger data for this historical ledger version.
### Return Value
@@ -2905,6 +3331,7 @@ closeTimeResolution | integer | Approximate number of seconds between closing on
closeFlags | integer | A bit-map of flags relating to the closing of this ledger. Currently, the ledger has only one flag defined for `closeFlags`: **sLCF_NoConsensusTime** (value 1). If this flag is enabled, it means that validators were in conflict regarding the correct close time for the ledger, but built otherwise the same ledger, so they declared consensus while "agreeing to disagree" on the close time. In this case, the consensus ledger contains a `closeTime` value that is 1 second after that of the previous ledger. (In this case, there is no official close time, but the actual real-world close time is probably 3-6 seconds later than the specified `closeTime`.)
ledgerHash | string | Unique identifying hash of the entire ledger.
ledgerVersion | integer | The ledger version of this ledger.
ledgerVersion | string | The ledger version of this ledger.
parentLedgerHash | string | Unique identifying hash of the ledger that came immediately before this one.
parentCloseTime | date-time string | The time at which the previous ledger was closed.
totalDrops | [value](#value) | Total number of drops (1/1,000,000th of an XRP) in the network, as a quoted integer. (This decreases as transaction fees cause XRP to be destroyed.)
@@ -2968,6 +3395,7 @@ instructions | object | The instructions for how to execute the transaction afte
*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.* maxLedgerVersion | integer,null | The highest ledger version that the transaction can be included in. Set to `null` if there is no maximum.
*instructions.* maxLedgerVersion | string,null | The highest ledger version that the transaction can be included in. Set to `null` if there is no maximum.
### Example
@@ -3037,6 +3465,7 @@ instructions | object | The instructions for how to execute the transaction afte
*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.* maxLedgerVersion | integer,null | The highest ledger version that the transaction can be included in. Set to `null` if there is no maximum.
*instructions.* maxLedgerVersion | string,null | The highest ledger version that the transaction can be included in. Set to `null` if there is no maximum.
### Example
@@ -3104,6 +3533,7 @@ instructions | object | The instructions for how to execute the transaction afte
*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.* maxLedgerVersion | integer,null | The highest ledger version that the transaction can be included in. Set to `null` if there is no maximum.
*instructions.* maxLedgerVersion | string,null | The highest ledger version that the transaction can be included in. Set to `null` if there is no maximum.
### Example
@@ -3169,6 +3599,7 @@ instructions | object | The instructions for how to execute the transaction afte
*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.* maxLedgerVersion | integer,null | The highest ledger version that the transaction can be included in. Set to `null` if there is no maximum.
*instructions.* maxLedgerVersion | string,null | The highest ledger version that the transaction can be included in. Set to `null` if there is no maximum.
### Example
@@ -3221,6 +3652,7 @@ instructions | object | The instructions for how to execute the transaction afte
*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.* maxLedgerVersion | integer,null | The highest ledger version that the transaction can be included in. Set to `null` if there is no maximum.
*instructions.* maxLedgerVersion | string,null | The highest ledger version that the transaction can be included in. Set to `null` if there is no maximum.
### Example
@@ -3284,6 +3716,7 @@ instructions | object | The instructions for how to execute the transaction afte
*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.* maxLedgerVersion | integer,null | The highest ledger version that the transaction can be included in. Set to `null` if there is no maximum.
*instructions.* maxLedgerVersion | string,null | The highest ledger version that the transaction can be included in. Set to `null` if there is no maximum.
### Example
@@ -3341,6 +3774,7 @@ instructions | object | The instructions for how to execute the transaction afte
*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.* maxLedgerVersion | integer,null | The highest ledger version that the transaction can be included in. Set to `null` if there is no maximum.
*instructions.* maxLedgerVersion | string,null | The highest ledger version that the transaction can be included in. Set to `null` if there is no maximum.
### Example
@@ -3396,6 +3830,7 @@ instructions | object | The instructions for how to execute the transaction afte
*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.* maxLedgerVersion | integer,null | The highest ledger version that the transaction can be included in. Set to `null` if there is no maximum.
*instructions.* maxLedgerVersion | string,null | The highest ledger version that the transaction can be included in. Set to `null` if there is no maximum.
### Example
@@ -3453,6 +3888,7 @@ instructions | object | The instructions for how to execute the transaction afte
*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.* maxLedgerVersion | integer,null | The highest ledger version that the transaction can be included in. Set to `null` if there is no maximum.
*instructions.* maxLedgerVersion | string,null | The highest ledger version that the transaction can be included in. Set to `null` if there is no maximum.
### Example
@@ -3510,6 +3946,7 @@ instructions | object | The instructions for how to execute the transaction afte
*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.* maxLedgerVersion | integer,null | The highest ledger version that the transaction can be included in. Set to `null` if there is no maximum.
*instructions.* maxLedgerVersion | string,null | The highest ledger version that the transaction can be included in. Set to `null` if there is no maximum.
### Example
@@ -3564,6 +4001,7 @@ instructions | object | The instructions for how to execute the transaction afte
*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.* maxLedgerVersion | integer,null | The highest ledger version that the transaction can be included in. Set to `null` if there is no maximum.
*instructions.* maxLedgerVersion | string,null | The highest ledger version that the transaction can be included in. Set to `null` if there is no maximum.
### Example
@@ -3590,9 +4028,185 @@ return api.preparePaymentChannelFund(address, paymentChannelFund).then(prepared
```
## prepareCheckCreate
`prepareCheckCreate(address: string, checkCreate: Object, instructions: Object): Promise<Object>`
Prepare a Check creation transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
### Parameters
Name | Type | Description
---- | ---- | -----------
address | [address](#address) | The address of the account that is creating the transaction.
checkCreate | [checkCreate](#check-create) | The specification of the Check create creation to prepare.
instructions | [instructions](#transaction-instructions) | *Optional* Instructions for executing the transaction
### Return Value
This method returns a promise that resolves with an object with the following structure:
<aside class="notice">
All "prepare*" methods have the same return type.
</aside>
Name | Type | Description
---- | ---- | -----------
txJSON | string | The prepared transaction in rippled JSON format.
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.* sequence | [sequence](#account-sequence-number) | The initiating account's sequence number for this transaction.
*instructions.* maxLedgerVersion | integer,null | The highest ledger version that the transaction can be included in. Set to `null` if there is no maximum.
*instructions.* maxLedgerVersion | string,null | The highest ledger version that the transaction can be included in. Set to `null` if there is no maximum.
### Example
```javascript
const address = 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59';
const checkCreate = {
"destination": "rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW",
"sendMax": {
"currency": "XRP",
"value": "1"
}
};
return api.prepareCheckCreate(address, checkCreate).then(prepared =>
{/* ... */});
```
```json
{
"txJSON": "{\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"TransactionType\":\"CheckCreate\",\"Destination\":\"rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW\",\"SendMax\":\"1000000\",\"Flags\":2147483648,\"LastLedgerSequence\":8820051,\"Sequence\":23,\"Fee\":\"12\"}",
"instructions": {
"fee": "0.000012",
"sequence": 23,
"maxLedgerVersion": 8820051
}
}
```
## prepareCheckCancel
`prepareCheckCancel(address: string, checkCancel: Object, instructions: Object): Promise<Object>`
Prepare a Check cancellation transaction. This cancels an unredeemed Check, removing it from the ledger without sending any money. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
### Parameters
Name | Type | Description
---- | ---- | -----------
address | [address](#address) | The address of the account that is creating the transaction.
checkCancel | [checkCancel](#check-cancel) | The specification of the Check cancellation to prepare.
instructions | [instructions](#transaction-instructions) | *Optional* Instructions for executing the transaction
### Return Value
This method returns a promise that resolves with an object with the following structure:
<aside class="notice">
All "prepare*" methods have the same return type.
</aside>
Name | Type | Description
---- | ---- | -----------
txJSON | string | The prepared transaction in rippled JSON format.
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.* sequence | [sequence](#account-sequence-number) | The initiating account's sequence number for this transaction.
*instructions.* maxLedgerVersion | integer,null | The highest ledger version that the transaction can be included in. Set to `null` if there is no maximum.
*instructions.* maxLedgerVersion | string,null | The highest ledger version that the transaction can be included in. Set to `null` if there is no maximum.
### Example
```javascript
const address = 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59';
const checkCancel = {
"checkID": "49647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB0"
};
return api.prepareCheckCancel(address, checkCancel).then(prepared =>
{/* ... */});
```
```json
{
"txJSON": "{\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"TransactionType\":\"CheckCancel\",\"CheckID\":\"49647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB0\",\"Flags\":2147483648,\"LastLedgerSequence\":8819954,\"Fee\":\"12\",\"Sequence\":23}",
"instructions": {
"fee": "0.000012",
"sequence": 23,
"maxLedgerVersion": 8819954
}
}
```
## prepareCheckCash
`prepareCheckCash(address: string, checkCash: Object, instructions: Object): Promise<Object>`
Prepare a Check cashing transaction. This redeems a Check to receive up to the amount authorized by the corresponding CheckCreate transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
### Parameters
Name | Type | Description
---- | ---- | -----------
address | [address](#address) | The address of the account that is creating the transaction.
checkCash | [checkCash](#check-cash) | The specification of the Check cash to prepare.
instructions | [instructions](#transaction-instructions) | *Optional* Instructions for executing the transaction
### Return Value
This method returns a promise that resolves with an object with the following structure:
<aside class="notice">
All "prepare*" methods have the same return type.
</aside>
Name | Type | Description
---- | ---- | -----------
txJSON | string | The prepared transaction in rippled JSON format.
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.* sequence | [sequence](#account-sequence-number) | The initiating account's sequence number for this transaction.
*instructions.* maxLedgerVersion | integer,null | The highest ledger version that the transaction can be included in. Set to `null` if there is no maximum.
*instructions.* maxLedgerVersion | string,null | The highest ledger version that the transaction can be included in. Set to `null` if there is no maximum.
### Example
```javascript
const address = 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59';
const checkCash = {
"amount": {
"currency": "XRP",
"value": "1"
},
"checkID": "838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334"
};
return api.prepareCheckCash(address, checkCash).then(prepared =>
{/* ... */});
```
```json
{
"txJSON": "{\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"TransactionType\":\"CheckCash\",\"CheckID\":\"838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334\",\"Amount\":\"1000000\",\"Flags\":2147483648,\"LastLedgerSequence\":8819954,\"Sequence\":23,\"Fee\":\"12\"}",
"instructions": {
"fee": "0.000012",
"sequence": 23,
"maxLedgerVersion": 8819954
}
}
```
## sign
`sign(txJSON: string, secret: string, options: Object): {signedTransaction: string, id: string}`
```
sign(txJSON: string, secret: string, options: Object): {signedTransaction: string, id: string}
sign(txJSON: string, keypair: Object, options: Object): {signedTransaction: string, id: string}
```
Sign a prepared transaction. The signed transaction must subsequently be [submitted](#submit).
@@ -3601,9 +4215,12 @@ Sign a prepared transaction. The signed transaction must subsequently be [submit
Name | Type | Description
---- | ---- | -----------
txJSON | string | Transaction represented as a JSON string in rippled format.
secret | secret string | The secret of the account that is initiating the transaction.
keypair | object | *Optional* The private and public key of the account that is initiating the transaction. (This field is exclusive with secret).
*keypair.* privateKey | privateKey | The uppercase hexadecimal representation of the secp256k1 or Ed25519 private key.
*keypair.* publicKey | publicKey | The uppercase hexadecimal representation of the secp256k1 or Ed25519 public key.
options | object | *Optional* Options that control the type of signature that will be generated.
*options.* signAs | [address](#address) | *Optional* The account that the signature should count for in multisigning.
secret | secret string | *Optional* The secret of the account that is initiating the transaction. (This field is exclusive with keypair).
### Return Value
@@ -3619,7 +4236,8 @@ id | [id](#transaction-id) | The [Transaction ID](#transaction-id) of the signed
```javascript
const txJSON = '{"Flags":2147483648,"TransactionType":"AccountSet","Account":"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59","Domain":"726970706C652E636F6D","LastLedgerSequence":8820051,"Fee":"12","Sequence":23}';
const secret = 'shsWGZcmZz6YsWWmcnpfr6fLTdtFV';
return api.sign(txJSON, secret);
const keypair = { privateKey: '00ACCD3309DB14D1A4FC9B1DAE608031F4408C85C73EE05E035B7DC8B25840107A', publicKey: '02F89EAEC7667B30F33D0687BBA86C3FE2A08CCA40A9186C5BDE2DAA6FA97A37D8' };
return api.sign(txJSON, secret); // or: api.sign(txJSON, keypair);
```
@@ -3844,6 +4462,7 @@ ledger | object | The ledger header to hash.
*ledger.* closeFlags | integer | A bit-map of flags relating to the closing of this ledger. Currently, the ledger has only one flag defined for `closeFlags`: **sLCF_NoConsensusTime** (value 1). If this flag is enabled, it means that validators were in conflict regarding the correct close time for the ledger, but built otherwise the same ledger, so they declared consensus while "agreeing to disagree" on the close time. In this case, the consensus ledger contains a `closeTime` value that is 1 second after that of the previous ledger. (In this case, there is no official close time, but the actual real-world close time is probably 3-6 seconds later than the specified `closeTime`.)
*ledger.* ledgerHash | string | Unique identifying hash of the entire ledger.
*ledger.* ledgerVersion | integer | The ledger version of this ledger.
*ledger.* ledgerVersion | string | The ledger version of this ledger.
*ledger.* parentLedgerHash | string | Unique identifying hash of the ledger that came immediately before this one.
*ledger.* parentCloseTime | date-time string | The time at which the previous ledger was closed.
*ledger.* totalDrops | [value](#value) | Total number of drops (1/1,000,000th of an XRP) in the network, as a quoted integer. (This decreases as transaction fees cause XRP to be destroyed.)
@@ -3896,6 +4515,7 @@ reserveBaseXRP | [value](#value) | The minimum reserve, in XRP, that is required
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.
ledgerVersion | integer | Ledger version of the ledger that closed.
ledgerVersion | string | Ledger version of the ledger that closed.
validatedLedgerVersions | string | Range of ledgers that the server has available. This may be discontiguous.
### Example

View File

@@ -0,0 +1,33 @@
## getAccountObjects
`getAccountObjects(address: string, options: object): Promise<AccountObjectsResponse>`
Returns objects owned by an account. For an account's trust lines and balances, see `getTrustlines` and `getBalances`.
### Parameters
<%- renderSchema('input/get-account-objects.json') %>
### Return Value
This method returns a promise that resolves with an object with the following structure:
<%- renderSchema('output/get-account-objects.json') %>
The types of objects that may be returned include:
* Offer objects for orders that are currently live, unfunded, or expired but not yet removed.
* RippleState objects for trust lines where this account's side is not in the default state.
* A SignerList object if the account has multi-signing enabled.
* Escrow objects for held payments that have not yet been executed or canceled.
* PayChannel objects for open payment channels.
* Check objects for pending checks.
### Example
```javascript
const address = 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59';
return api.getAccountObjects(address: address).then(objects =>
{/* ... */});
```
<%- renderFixture('responses/get-account-objects.json') %>

View File

@@ -21,6 +21,7 @@
<% include getOrderbook.md.ejs %>
<% include getSettings.md.ejs %>
<% include getAccountInfo.md.ejs %>
<% include getAccountObjects.md.ejs %>
<% include getPaymentChannel.md.ejs %>
<% include getLedger.md.ejs %>
<% include preparePayment.md.ejs %>
@@ -34,6 +35,9 @@
<% include preparePaymentChannelCreate.md.ejs %>
<% include preparePaymentChannelClaim.md.ejs %>
<% include preparePaymentChannelFund.md.ejs %>
<% include prepareCheckCreate.md.ejs %>
<% include prepareCheckCancel.md.ejs %>
<% include prepareCheckCash.md.ejs %>
<% include sign.md.ejs %>
<% include combine.md.ejs %>
<% include submit.md.ejs %>

View File

@@ -0,0 +1,30 @@
## prepareCheckCancel
`prepareCheckCancel(address: string, checkCancel: Object, instructions: Object): Promise<Object>`
Prepare a Check cancellation transaction. This cancels an unredeemed Check, removing it from the ledger without sending any money. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
### Parameters
<%- renderSchema('input/prepare-check-cancel.json') %>
### Return Value
This method returns a promise that resolves with an object with the following structure:
<aside class="notice">
All "prepare*" methods have the same return type.
</aside>
<%- renderSchema('output/prepare.json') %>
### Example
```javascript
const address = 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59';
const checkCancel = <%- importFile('test/fixtures/requests/prepare-check-cancel.json') %>;
return api.prepareCheckCancel(address, checkCancel).then(prepared =>
{/* ... */});
```
<%- renderFixture('responses/prepare-check-cancel.json') %>

View File

@@ -0,0 +1,30 @@
## prepareCheckCash
`prepareCheckCash(address: string, checkCash: Object, instructions: Object): Promise<Object>`
Prepare a Check cashing transaction. This redeems a Check to receive up to the amount authorized by the corresponding CheckCreate transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
### Parameters
<%- renderSchema('input/prepare-check-cash.json') %>
### Return Value
This method returns a promise that resolves with an object with the following structure:
<aside class="notice">
All "prepare*" methods have the same return type.
</aside>
<%- renderSchema('output/prepare.json') %>
### Example
```javascript
const address = 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59';
const checkCash = <%- importFile('test/fixtures/requests/prepare-check-cash-amount.json') %>;
return api.prepareCheckCash(address, checkCash).then(prepared =>
{/* ... */});
```
<%- renderFixture('responses/prepare-check-cash-amount.json') %>

View File

@@ -0,0 +1,30 @@
## prepareCheckCreate
`prepareCheckCreate(address: string, checkCreate: Object, instructions: Object): Promise<Object>`
Prepare a Check creation transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
### Parameters
<%- renderSchema('input/prepare-check-create.json') %>
### Return Value
This method returns a promise that resolves with an object with the following structure:
<aside class="notice">
All "prepare*" methods have the same return type.
</aside>
<%- renderSchema('output/prepare.json') %>
### Example
```javascript
const address = 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59';
const checkCreate = <%- importFile('test/fixtures/requests/prepare-check-create.json') %>;
return api.prepareCheckCreate(address, checkCreate).then(prepared =>
{/* ... */});
```
<%- renderFixture('responses/prepare-check-create.json') %>

View File

@@ -1,6 +1,9 @@
## sign
`sign(txJSON: string, secret: string, options: Object): {signedTransaction: string, id: string}`
```
sign(txJSON: string, secret: string, options: Object): {signedTransaction: string, id: string}
sign(txJSON: string, keypair: Object, options: Object): {signedTransaction: string, id: string}
```
Sign a prepared transaction. The signed transaction must subsequently be [submitted](#submit).
@@ -19,7 +22,8 @@ This method returns an object with the following structure:
```javascript
const txJSON = '{"Flags":2147483648,"TransactionType":"AccountSet","Account":"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59","Domain":"726970706C652E636F6D","LastLedgerSequence":8820051,"Fee":"12","Sequence":23}';
const secret = 'shsWGZcmZz6YsWWmcnpfr6fLTdtFV';
return api.sign(txJSON, secret);
const keypair = { privateKey: '00ACCD3309DB14D1A4FC9B1DAE608031F4408C85C73EE05E035B7DC8B25840107A', publicKey: '02F89EAEC7667B30F33D0687BBA86C3FE2A08CCA40A9186C5BDE2DAA6FA97A37D8' };
return api.sign(txJSON, secret); // or: api.sign(txJSON, keypair);
```
<%- renderFixture("responses/sign.json") %>

View File

@@ -82,6 +82,36 @@ See [Transaction Types](#transaction-types) for a description.
<%- renderFixture('requests/prepare-escrow-execution.json') %>
## Check Create
See [Transaction Types](#transaction-types) for a description.
<%- renderSchema('specifications/check-create.json') %>
### Example
<%- renderFixture('requests/prepare-check-create.json') %>
## Check Cancel
See [Transaction Types](#transaction-types) for a description.
<%- renderSchema('specifications/check-cancel.json') %>
### Example
<%- renderFixture('requests/prepare-check-cancel.json') %>
## Check Cash
See [Transaction Types](#transaction-types) for a description.
<%- renderSchema('specifications/check-cash.json') %>
### Example
<%- renderFixture('requests/prepare-check-cash-amount.json') %>
## Payment Channel Create
See [Transaction Types](#transaction-types) for a description.

View File

@@ -14,6 +14,12 @@ Type | Description
[escrowCreation](#escrow-creation) | An `escrowCreation` transaction creates an escrow on the ledger, which locks XRP until a cryptographic condition is met or it expires. It is like an escrow service where the XRP Ledger acts as the escrow agent.
[escrowCancellation](#escrow-cancellation) | An `escrowCancellation` transaction unlocks the funds in an escrow and sends them back to the creator of the escrow, but it will only work after the escrow expires.
[escrowExecution](#escrow-execution) | An `escrowExecution` transaction unlocks the funds in an escrow and sends them to the destination of the escrow, but it will only work if the cryptographic condition is provided.
[checkCreate](#check-create) | A `checkCreate` transaction creates a check on the ledger, which is a deferred payment that can be cashed by its intended destination.
[checkCancel](#check-cancel) | A `checkCancel` transaction cancels an unreedemed Check, removing it from the ledger without sending any money.
[checkCash](#check-cash) | A `checkCash` transaction redeems a Check to receive up to the amount authorized by the corresponding `checkCreate` transaction. Only the `destination` address of a Check can cash it.
[paymentChannelCreate](#payment-channel-create) | A `paymentChannelCreate` transaction opens a payment channel between two addresses with XRP set aside for asynchronous payments.
[paymentChannelFund](#payment-channel-fund) | A `paymentChannelFund` transaction adds XRP to a payment channel and optionally sets a new expiration for the channel.
[paymentChannelClaim](#payment-channel-claim) | A `paymentChannelClaim` transaction withdraws XRP from a channel and optionally requests to close it.
## Transaction Flow
@@ -28,6 +34,9 @@ Executing a transaction with `RippleAPI` requires the following four steps:
* [prepareEscrowCreation](#prepareescrowcreation)
* [prepareEscrowCancellation](#prepareescrowcancellation)
* [prepareEscrowExecution](#prepareescrowexecution)
* [prepareCheckCreate](#preparecheckcreate)
* [prepareCheckCancel](#preparecheckcancel)
* [prepareCheckCash](#preparecheckcash)
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. For multisignature transactions, the `signedTransaction` fields returned by `sign` must be collected and passed to the [combine](#combine) method.
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.

View File

@@ -1,16 +1,17 @@
{
"name": "ripple-lib",
"version": "0.18.0",
"version": "0.21.0",
"license": "ISC",
"description": "A JavaScript API for interacting with Ripple in Node.js and the browser",
"files": [
"dist/npm/*",
"bin/*",
"build/*",
"test/*",
"Gulpfile.js"
"build/*"
],
"main": "dist/npm/",
"types": "dist/npm/index.d.ts",
"browser": {
"ws": "./dist/npm/common/wswrapper.js"
},
"directories": {
"test": "test"
},
@@ -18,11 +19,11 @@
"@types/lodash": "^4.14.85",
"@types/ws": "^3.2.0",
"bignumber.js": "^4.1.0",
"https-proxy-agent": "^1.0.0",
"jsonschema": "^1.1.1",
"https-proxy-agent": "2.2.1",
"jsonschema": "1.2.2",
"lodash": "^4.17.4",
"ripple-address-codec": "^2.0.1",
"ripple-binary-codec": "^0.1.10",
"ripple-binary-codec": "^0.1.13",
"ripple-hashes": "^0.3.1",
"ripple-keypairs": "^0.10.1",
"ripple-lib-transactionparser": "^0.6.2",
@@ -46,9 +47,9 @@
"mocha-in-sauce": "^0.0.1",
"mocha-junit-reporter": "^1.9.1",
"null-loader": "^0.1.1",
"ts-loader": "^3.2.0",
"nyc": "^11.3.0",
"source-map-support": "^0.5.0",
"ts-loader": "^3.2.0",
"ts-node": "^3.3.0",
"tslint": "^5.8.0",
"tslint-eslint-rules": "^4.1.1",
@@ -64,14 +65,13 @@
"clean": "rm -rf dist/npm",
"compile": "mkdir -p dist/npm/common && cp -r src/common/schemas dist/npm/common/ && tsc",
"watch": "tsc -w",
"compile-with-source-maps": "babel -D --optional runtime -s -t -d dist/npm/ src/",
"prepublish": "npm run clean && npm run compile",
"prepublish": "npm run clean && npm run compile && npm run build",
"test": "nyc mocha",
"coveralls": "cat ./coverage/lcov.info | coveralls",
"lint": "tslint -p ./",
"perf": "./scripts/perf_test.sh",
"start": "babel-node scripts/http.js",
"sauce": "babel-node scripts/sauce-runner.js"
"start": "node scripts/http.js",
"sauce": "node scripts/sauce-runner.js"
},
"repository": {
"type": "git",
@@ -79,6 +79,6 @@
},
"readmeFilename": "README.md",
"engines": {
"node": ">=0.12.0"
"node": ">=6.12.3"
}
}

View File

@@ -1,6 +1,6 @@
'use strict';
const createHTTPServer = require('../src/http').createHTTPServer;
const createHTTPServer = require('../dist/npm/http').createHTTPServer;
const port = 5990;
const serverUrl = 'wss://s1.ripple.com';

View File

@@ -1,13 +1,15 @@
import * as _ from 'lodash'
import {EventEmitter} from 'events'
import {Connection, errors, validate} from './common'
import * as server from './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
import {
connect,
disconnect,
isConnected,
getServerInfo,
getFee,
getLedgerVersion,
formatLedgerClose
} from './server/server'
import getTransaction from './ledger/transaction'
import getTransactions from './ledger/transactions'
import getTrustlines from './ledger/trustlines'
@@ -18,6 +20,7 @@ import getOrders from './ledger/orders'
import getOrderbook from './ledger/orderbook'
import getSettings from './ledger/settings'
import getAccountInfo from './ledger/accountinfo'
import getAccountObjects from './ledger/accountobjects'
import getPaymentChannel from './ledger/payment-channel'
import preparePayment from './transaction/payment'
import prepareTrustline from './transaction/trustline'
@@ -29,6 +32,9 @@ import prepareEscrowCancellation from './transaction/escrow-cancellation'
import preparePaymentChannelCreate from './transaction/payment-channel-create'
import preparePaymentChannelFund from './transaction/payment-channel-fund'
import preparePaymentChannelClaim from './transaction/payment-channel-claim'
import prepareCheckCreate from './transaction/check-create'
import prepareCheckCancel from './transaction/check-cancel'
import prepareCheckCash from './transaction/check-cash'
import prepareSettings from './transaction/settings'
import sign from './transaction/sign'
import combine from './transaction/combine'
@@ -39,12 +45,24 @@ import signPaymentChannelClaim from './offline/sign-payment-channel-claim'
import verifyPaymentChannelClaim from './offline/verify-payment-channel-claim'
import getLedger from './ledger/ledger'
import {
AccountObjectsRequest, AccountObjectsResponse,
AccountOffersRequest, AccountOffersResponse,
AccountInfoRequest, AccountInfoResponse,
AccountLinesRequest, AccountLinesResponse,
BookOffersRequest, BookOffersResponse,
GatewayBalancesRequest, GatewayBalancesResponse,
LedgerRequest, LedgerResponse,
LedgerEntryRequest, LedgerEntryResponse
} from './common/types/commands'
import RangeSet from './common/rangeset'
import * as ledgerUtils from './ledger/utils'
import * as schemaValidator from './common/schema-validator'
import {clamp} from './ledger/utils'
type APIOptions = {
export type APIOptions = {
server?: string,
feeCushion?: number,
trace?: boolean,
@@ -52,8 +70,25 @@ type APIOptions = {
timeout?: number
}
/**
* Get the response key / property name that contains the listed data for a
* command. This varies from command to command, but we need to know it to
* properly count across many requests.
*/
function getCollectKeyFromCommand(command: string): string|undefined {
switch (command) {
case 'account_offers':
case 'book_offers':
return 'offers'
case 'account_lines':
return 'lines'
default:
return undefined
}
}
// prevent access to non-validated ledger versions
class RestrictedConnection extends Connection {
export class RestrictedConnection extends Connection {
request(request: any, timeout?: number) {
const ledger_index = request.ledger_index
if (ledger_index !== undefined && ledger_index !== 'validated') {
@@ -88,7 +123,7 @@ class RippleAPI extends EventEmitter {
if (serverURL !== undefined) {
this.connection = new RestrictedConnection(serverURL, options)
this.connection.on('ledgerClosed', message => {
this.emit('ledger', server.formatLedgerClose(message))
this.emit('ledger', formatLedgerClose(message))
})
this.connection.on('error', (errorCode, errorMessage, data) => {
this.emit('error', errorCode, errorMessage, data)
@@ -106,6 +141,106 @@ class RippleAPI extends EventEmitter {
}
}
async _request(command: 'account_info', params: AccountInfoRequest):
Promise<AccountInfoResponse>
async _request(command: 'account_lines', params: AccountLinesRequest):
Promise<AccountLinesResponse>
/**
* Returns objects owned by an account.
* For an account's trust lines and balances,
* see `getTrustlines` and `getBalances`.
*/
async _request(command: 'account_objects', params: AccountObjectsRequest):
Promise<AccountObjectsResponse>
async _request(command: 'account_offers', params: AccountOffersRequest):
Promise<AccountOffersResponse>
async _request(command: 'book_offers', params: BookOffersRequest):
Promise<BookOffersResponse>
async _request(command: 'gateway_balances', params: GatewayBalancesRequest):
Promise<GatewayBalancesResponse>
async _request(command: 'ledger', params: LedgerRequest):
Promise<LedgerResponse>
async _request(command: 'ledger_entry', params: LedgerEntryRequest):
Promise<LedgerEntryResponse>
/**
* Makes a request to the API with the given command and
* additional request body parameters.
*
* NOTE: This command is under development.
*/
async _request(command: string, params: object = {}) {
return this.connection.request({
...params,
command
})
}
/**
* Makes multiple paged requests to the API to return a given number of
* resources. _requestAll() will make multiple requests until the `limit`
* number of resources is reached (if no `limit` is provided, a single request
* will be made).
*
* If the command is unknown, an additional `collect` property is required to
* know which response key contains the array of resources.
*
* NOTE: This command is under development and should not yet be relied
* on by external consumers.
*/
async _requestAll(command: 'account_offers', params: AccountOffersRequest):
Promise<AccountOffersResponse[]>
async _requestAll(command: 'book_offers', params: BookOffersRequest):
Promise<BookOffersResponse[]>
async _requestAll(command: 'account_lines', params: AccountLinesRequest):
Promise<AccountLinesResponse[]>
async _requestAll(
command: string,
params: any = {},
options: {collect?: string} = {}): Promise<any[]> {
// The data under collection is keyed based on the command. Fail if command
// not recognized and collection key not provided.
const collectKey = options.collect || getCollectKeyFromCommand(command)
if (!collectKey) {
throw new errors.ValidationError(`no collect key for command ${command}`)
}
// If limit is not provided, fetches all data over multiple requests.
// NOTE: This may return much more than needed. Set limit when possible.
const countTo: number =
(params.limit !== undefined) ? params.limit : Infinity
let count: number = 0
let marker: string = params.marker
let lastBatchLength: number
const results = []
do {
const countRemaining = clamp(countTo - count, 10, 400)
const repeatProps = {
...params,
limit: countRemaining,
marker
}
// NOTE: We have to generalize the `this._request()` function signature
// here until we add support for unknown commands (since command is some
// unknown string).
const singleResult = await (<Function>this._request)(command, repeatProps)
const collectedData = singleResult[collectKey]
marker = singleResult.marker
results.push(singleResult)
// Make sure we handle when no data (not even an empty array) is returned.
const isExpectedFormat = Array.isArray(collectedData)
if (isExpectedFormat) {
count += collectedData.length
lastBatchLength = collectedData.length
} else {
lastBatchLength = 0
}
} while(!!marker && count < countTo && lastBatchLength !== 0)
return results
}
connect = connect
disconnect = disconnect
isConnected = isConnected
@@ -123,6 +258,7 @@ class RippleAPI extends EventEmitter {
getOrderbook = getOrderbook
getSettings = getSettings
getAccountInfo = getAccountInfo
getAccountObjects = getAccountObjects
getPaymentChannel = getPaymentChannel
getLedger = getLedger
@@ -136,6 +272,9 @@ class RippleAPI extends EventEmitter {
preparePaymentChannelCreate = preparePaymentChannelCreate
preparePaymentChannelFund = preparePaymentChannelFund
preparePaymentChannelClaim = preparePaymentChannelClaim
prepareCheckCreate = prepareCheckCreate
prepareCheckCash = prepareCheckCash
prepareCheckCancel = prepareCheckCancel
prepareSettings = prepareSettings
sign = sign
combine = combine

View File

@@ -4,8 +4,7 @@ import {RippleAPI} from './api'
class RippleAPIBroadcast extends RippleAPI {
// TODO: Should this default to 0, or null/undefined?
ledgerVersion: number = 0
ledgerVersion: number | undefined = undefined
private _apis: RippleAPI[]
constructor(servers, options) {
@@ -50,7 +49,8 @@ class RippleAPIBroadcast extends RippleAPI {
}
onLedgerEvent(ledger) {
if (ledger.ledgerVersion > this.ledgerVersion) {
if (ledger.ledgerVersion > this.ledgerVersion ||
this.ledgerVersion === undefined) {
this.ledgerVersion = ledger.ledgerVersion
this.emit('ledger', ledger)
}

View File

@@ -13,7 +13,7 @@ function isStreamMessageType(type) {
type === 'path_find'
}
interface ConnectionOptions {
export interface ConnectionOptions {
trace?: boolean,
proxy?: string
proxyAuthorization?: string

View File

@@ -4,7 +4,8 @@ import {txFlagIndices} from './txflags'
const accountRootFlags = {
PasswordSpent: 0x00010000, // password set fee is spent
RequireDestTag: 0x00020000, // require a DestinationTag for payments
RequireAuth: 0x00040000, // require a authorization to hold IOUs
RequireAuth: 0x00040000, // require authorization to hold IOUs
DepositAuth: 0x01000000, // require account to auth deposits
DisallowXRP: 0x00080000, // disallow sending XRP
DisableMaster: 0x00100000, // force regular key
NoFreeze: 0x00200000, // permanently disallowed freezing trustlines
@@ -16,6 +17,7 @@ const AccountFlags = {
passwordSpent: accountRootFlags.PasswordSpent,
requireDestinationTag: accountRootFlags.RequireDestTag,
requireAuthorization: accountRootFlags.RequireAuth,
depositAuth: accountRootFlags.DepositAuth,
disallowIncomingXRP: accountRootFlags.DisallowXRP,
disableMasterKey: accountRootFlags.DisableMaster,
noFreeze: accountRootFlags.NoFreeze,
@@ -26,6 +28,7 @@ const AccountFlags = {
const AccountFlagIndices = {
requireDestinationTag: txFlagIndices.AccountSet.asfRequireDest,
requireAuthorization: txFlagIndices.AccountSet.asfRequireAuth,
depositAuth: txFlagIndices.AccountSet.asfDepositAuth,
disallowIncomingXRP: txFlagIndices.AccountSet.asfDisallowXRP,
disableMasterKey: txFlagIndices.AccountSet.asfDisableMaster,
enableTransactionIDTracking: txFlagIndices.AccountSet.asfAccountTxnID,

View File

@@ -29,7 +29,7 @@ class RippleError extends Error {
}
/* console.log in node uses util.inspect on object, and util.inspect allows
us to cutomize its output:
us to customize its output:
https://nodejs.org/api/util.html#util_custom_inspect_function_on_objects */
inspect() {
return this.toString()

View File

@@ -20,6 +20,7 @@ function loadSchemas() {
require('./schemas/objects/memo.json'),
require('./schemas/objects/memos.json'),
require('./schemas/objects/public-key.json'),
require('./schemas/objects/private-key.json'),
require('./schemas/objects/uint32.json'),
require('./schemas/objects/value.json'),
require('./schemas/objects/source-adjustment.json'),
@@ -53,10 +54,14 @@ function loadSchemas() {
require('./schemas/specifications/payment-channel-create.json'),
require('./schemas/specifications/payment-channel-fund.json'),
require('./schemas/specifications/payment-channel-claim.json'),
require('./schemas/specifications/check-create.json'),
require('./schemas/specifications/check-cash.json'),
require('./schemas/specifications/check-cancel.json'),
require('./schemas/specifications/trustline.json'),
require('./schemas/output/sign.json'),
require('./schemas/output/submit.json'),
require('./schemas/output/get-account-info.json'),
require('./schemas/output/get-account-objects.json'),
require('./schemas/output/get-balances.json'),
require('./schemas/output/get-balance-sheet.json'),
require('./schemas/output/get-ledger.json'),
@@ -86,6 +91,7 @@ function loadSchemas() {
require('./schemas/input/api-options.json'),
require('./schemas/input/get-settings.json'),
require('./schemas/input/get-account-info.json'),
require('./schemas/input/get-account-objects.json'),
require('./schemas/input/get-transaction.json'),
require('./schemas/input/get-transactions.json'),
require('./schemas/input/get-trustlines.json'),
@@ -100,6 +106,9 @@ function loadSchemas() {
require('./schemas/input/prepare-payment-channel-create.json'),
require('./schemas/input/prepare-payment-channel-fund.json'),
require('./schemas/input/prepare-payment-channel-claim.json'),
require('./schemas/input/prepare-check-create.json'),
require('./schemas/input/prepare-check-cash.json'),
require('./schemas/input/prepare-check-cancel.json'),
require('./schemas/input/compute-ledger-hash.json'),
require('./schemas/input/sign.json'),
require('./schemas/input/submit.json'),

View File

@@ -0,0 +1,56 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "getAccountObjectsOptions",
"description": "Request options for getAccountObjects",
"type": "object",
"properties": {
"address": {
"$ref": "address",
"description": "The address of the account to get the account objects of."
},
"options": {
"description": "Options that affect what to return.",
"properties": {
"type": {
"type": "string",
"enum": [
"check",
"escrow",
"offer",
"payment_channel",
"signer_list",
"state"
],
"description":
"(Optional) Filter results to include only this type of ledger object. The valid types are: `check`, `escrow`, `offer`, `payment_channel`, `signer_list`, and `state` (trust line)."
},
"ledgerHash": {
"type": "string",
"description":
"(Optional) A 20-byte hex string for the ledger version to use."
},
"ledgerIndex": {
"oneOf": [
{
"$ref": "ledgerVersion"
},
{
"type": "string"
}
],
"description":
"(Optional) The sequence number of the ledger to use, or a shortcut string to choose a ledger automatically."
},
"limit": {
"type": "integer",
"minimum": 1,
"description":
"(Optional) The maximum number of objects to include in the results."
}
},
"additionalProperties": false
}
},
"required": ["address"],
"additionalProperties": false
}

View File

@@ -13,7 +13,7 @@
"properties": {
"start": {
"$ref": "hash256",
"description": "If specified, this transaction will be the first transaction in the result."
"description": "If specified, this transaction will be the first transaction in the result. You cannot use `start` with `minLedgerVersion` or `maxLedgerVersion`. When `start` is specified, these ledger versions will be determined internally."
},
"limit": {
"type": "integer",

View File

@@ -0,0 +1,18 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "prepareCheckCancelParameters",
"type": "object",
"properties": {
"address": {
"$ref": "address",
"description": "The address of the account that is creating the transaction."
},
"checkCancel": {
"$ref": "checkCancel",
"description": "The specification of the Check cancellation to prepare."
},
"instructions": {"$ref": "instructions"}
},
"additionalProperties": false,
"required": ["address", "checkCancel"]
}

View File

@@ -0,0 +1,18 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "prepareCheckCashParameters",
"type": "object",
"properties": {
"address": {
"$ref": "address",
"description": "The address of the account that is creating the transaction."
},
"checkCash": {
"$ref": "checkCash",
"description": "The specification of the Check cash to prepare."
},
"instructions": {"$ref": "instructions"}
},
"additionalProperties": false,
"required": ["address", "checkCash"]
}

View File

@@ -0,0 +1,18 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "prepareCheckCreateParameters",
"type": "object",
"properties": {
"address": {
"$ref": "address",
"description": "The address of the account that is creating the transaction."
},
"checkCreate": {
"$ref": "checkCreate",
"description": "The specification of the Check create creation to prepare."
},
"instructions": {"$ref": "instructions"}
},
"additionalProperties": false,
"required": ["address", "checkCreate"]
}

View File

@@ -10,7 +10,23 @@
"secret": {
"type": "string",
"format": "secret",
"description": "The secret of the account that is initiating the transaction."
"description": "The secret of the account that is initiating the transaction. (This field is exclusive with keypair)."
},
"keypair": {
"type": "object",
"properties": {
"privateKey": {
"type": "privateKey",
"description": "The uppercase hexadecimal representation of the secp256k1 or Ed25519 private key."
},
"publicKey": {
"type": "publicKey",
"description": "The uppercase hexadecimal representation of the secp256k1 or Ed25519 public key."
}
},
"description": "The private and public key of the account that is initiating the transaction. (This field is exclusive with secret).",
"required": ["privateKey", "publicKey"],
"additionalProperties": false
},
"options": {
"type": "object",
@@ -25,5 +41,15 @@
}
},
"additionalProperties": false,
"required": ["txJSON", "secret"]
"required": ["txJSON"],
"oneOf": [
{
"required": ["secret"],
"not": {"required": ["keypair"]}
},
{
"required": ["keypair"],
"not": {"required": ["secret"]}
}
]
}

View File

@@ -25,7 +25,7 @@
]
},
"maxLedgerVersionOffset": {
"description": "Offset from current validated legder version to highest ledger version that the transaction can be included in.",
"description": "Offset from current validated ledger version to highest ledger version that the transaction can be included in.",
"type": "integer",
"minimum": 0
},

View File

@@ -2,6 +2,14 @@
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "ledgerVersion",
"description": "A ledger version number",
"type": "integer",
"minimum": 1
"oneOf": [
{
"type": "integer",
"minimum": 1
},
{
"type": "string",
"enum": ["validated", "closed", "current"]
}
]
}

View File

@@ -0,0 +1,7 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "privateKey",
"description": "The hexadecimal representation of a secp256k1 or Ed25519 private key.",
"type": "string",
"pattern": "^[A-F0-9]+$"
}

View File

@@ -3,41 +3,25 @@
"title": "settingsPlusMemos",
"type": "object",
"properties": {
"passwordSpent": {
"defaultRipple": {
"type": "boolean",
"description": "Indicates that the account has used its free SetRegularKey transaction."
"description": "Enable [rippling](https://ripple.com/build/understanding-the-noripple-flag/) on this accounts trust lines by default. (New in [rippled 0.27.3](https://github.com/ripple/rippled/releases/tag/0.27.3))"
},
"requireDestinationTag": {
"depositAuth": {
"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 accounts issuances."
},
"disallowIncomingXRP": {
"type": "boolean",
"description": "Indicates that client applications should not send XRP to this account. Not enforced by rippled."
"description": "Enable [Deposit Authorization](https://ripple.com/build/deposit-authorization/) on this account. If set, transactions cannot send value of any kind to this account unless the sender of those transactions is the account itself. (Requires the [DepositAuth amendment](https://ripple.com/build/known-amendments/#depositauth))"
},
"disableMasterKey": {
"type": "boolean",
"description": "Disallows use of the master key to sign transactions for this account."
},
"enableTransactionIDTracking": {
"disallowIncomingXRP": {
"type": "boolean",
"description": "Track the ID of this accounts most recent transaction."
"description": "Indicates that client applications should not send XRP to this account. Not enforced by rippled."
},
"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 accounts trust lines by default. (New in [rippled 0.27.3](https://github.com/ripple/rippled/releases/tag/0.27.3))"
"domain": {
"type": "string",
"description": " The domain that owns this account, as a hexadecimal string representing the ASCII for the domain in lowercase."
},
"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.",
@@ -46,20 +30,26 @@
{"$ref": "hash128"}
]
},
"enableTransactionIDTracking": {
"type": "boolean",
"description": "Track the ID of this accounts most recent transaction."
},
"globalFreeze": {
"type": "boolean",
"description": "Freeze all assets issued by this account."
},
"memos": {"$ref": "memos"},
"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."
"noFreeze": {
"type": "boolean",
"description": "Permanently give up the ability to freeze individual trust lines. This flag can never be disabled after being enabled."
},
"transferRate": {
"description": " The fee to charge when users transfer this accounts issuances, as the decimal amount that must be sent to deliver 1 unit. Has precision up to 9 digits beyond the decimal point. Use `null` to set no fee.",
"oneOf": [
{"type": "null"},
{"type": "number", "minimum": 1, "maximum": 4.294967295}
]
"passwordSpent": {
"type": "boolean",
"description": "Indicates that the account has used its free SetRegularKey transaction."
},
"regularKey": {
"oneOf": [
@@ -68,6 +58,14 @@
],
"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."
},
"requireAuthorization": {
"type": "boolean",
"description": "If set, this account must individually approve other users in order for those users to hold this accounts issuances."
},
"requireDestinationTag": {
"type": "boolean",
"description": "Requires incoming payments to specify a destination tag."
},
"signers": {
"type": "object",
"description": "Settings that determine what sets of accounts can be used to sign a transaction on behalf of this account using multisigning.",
@@ -97,7 +95,13 @@
}
}
},
"memos": {"$ref": "memos"}
"transferRate": {
"description": " The fee to charge when users transfer this accounts issuances, as the decimal amount that must be sent to deliver 1 unit. Has precision up to 9 digits beyond the decimal point. Use `null` to set no fee.",
"oneOf": [
{"type": "null"},
{"type": "number", "minimum": 1, "maximum": 4.294967295}
]
}
},
"additionalProperties": false
}

View File

@@ -4,8 +4,20 @@
"link": "transaction-types",
"description": "The type of the transaction.",
"type": "string",
"enum": ["payment", "order", "orderCancellation", "trustline", "settings",
"escrowCreation", "escrowCancellation",
"escrowExecution", "paymentChannelCreate",
"paymentChannelFund", "paymentChannelClaim"]
"enum": [
"payment",
"order",
"orderCancellation",
"trustline",
"settings",
"escrowCreation",
"escrowCancellation",
"escrowExecution",
"paymentChannelCreate",
"paymentChannelFund",
"paymentChannelClaim",
"checkCreate",
"checkCancel",
"checkCash"
]
}

View File

@@ -0,0 +1,48 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "AccountObjectsResponse",
"description": "Response format for account_objects",
"type": "object",
"properties": {
"account": {
"$ref": "address",
"description":
"Unique address of the account this request corresponds to."
},
"account_objects": {
"type": "array",
"items": {
"type": "object"
},
"description":
"Array of objects owned by this account. Each object is in its raw ledger format."
},
"ledger_hash": {
"type": "string",
"description":
"(May be omitted) The identifying hash of the ledger that was used to generate this response."
},
"ledger_index": {
"$ref": "ledgerVersion",
"description":
"(May be omitted) The sequence number of the ledger that was used to generate this response."
},
"ledger_current_index": {
"$ref": "ledgerVersion",
"description":
"(May be omitted) The sequence number of the ledger that was used to generate this response."
},
"limit": {
"type": "integer",
"description":
"(May be omitted) The limit that was used in this request, if any."
},
"validated": {
"type": "boolean",
"description":
"If included and set to true, the information in this request comes from a validated ledger version. Otherwise, the information is subject to change."
}
},
"required": ["account", "account_objects"],
"additionalProperties": false
}

View File

@@ -3,7 +3,9 @@
"title": "getTransaction",
"link": "gettransaction",
"properties": {
"type": {"$ref": "transactionType"},
"type": {
"$ref": "transactionType"
},
"specification": {
"description": "A specification that would produce the same outcome as this transaction. The structure of the specification depends on the value of the `type` field (see [Transaction Types](#transaction-types) for details). *Note:* This is **not** necessarily the same as the original specification."
},
@@ -24,73 +26,182 @@
"description": "The account sequence number of the transaction for the account that initiated it."
}
},
"required": ["id", "address", "sequence", "type", "specification", "outcome"],
"required": [
"id",
"address",
"sequence",
"type",
"specification",
"outcome"
],
"additionalProperties": false,
"oneOf": [
{
"properties": {
"type": {"enum": ["payment"]},
"specification": {"$ref": "payment"}
"type": {
"enum": [
"payment"
]
},
"specification": {
"$ref": "payment"
}
}
},
{
"properties": {
"type": {"enum": ["order"]},
"specification": {"$ref": "order"}
"type": {
"enum": [
"order"
]
},
"specification": {
"$ref": "order"
}
}
},
{
"properties": {
"type": {"enum": ["orderCancellation"]},
"specification": {"$ref": "orderCancellation"}
"type": {
"enum": [
"orderCancellation"
]
},
"specification": {
"$ref": "orderCancellation"
}
}
},
{
"properties": {
"type": {"enum": ["trustline"]},
"specification": {"$ref": "trustline"}
"type": {
"enum": [
"trustline"
]
},
"specification": {
"$ref": "trustline"
}
}
},
{
"properties": {
"type": {"enum": ["settings"]},
"specification": {"$ref": "getSettings"}
"type": {
"enum": [
"settings"
]
},
"specification": {
"$ref": "getSettings"
}
}
},
{
"properties": {
"type": {"enum": ["escrowCreation"]},
"specification": {"$ref": "escrowCreation"}
"type": {
"enum": [
"checkCreate"
]
},
"specification": {
"$ref": "checkCreate"
}
}
},
{
"properties": {
"type": {"enum": ["escrowCancellation"]},
"specification": {"$ref": "escrowCancellation"}
"type": {
"enum": [
"checkCancel"
]
},
"specification": {
"$ref": "checkCancel"
}
}
},
{
"properties": {
"type": {"enum": ["escrowExecution"]},
"specification": {"$ref": "escrowExecution"}
"type": {
"enum": [
"checkCash"
]
},
"specification": {
"$ref": "checkCash"
}
}
},
{
"properties": {
"type": {"enum": ["paymentChannelCreate"]},
"specification": {"$ref": "paymentChannelCreate"}
"type": {
"enum": [
"escrowCreation"
]
},
"specification": {
"$ref": "escrowCreation"
}
}
},
{
"properties": {
"type": {"enum": ["paymentChannelFund"]},
"specification": {"$ref": "paymentChannelFund"}
"type": {
"enum": [
"escrowCancellation"
]
},
"specification": {
"$ref": "escrowCancellation"
}
}
},
{
"properties": {
"type": {"enum": ["paymentChannelClaim"]},
"specification": {"$ref": "paymentChannelClaim"}
"type": {
"enum": [
"escrowExecution"
]
},
"specification": {
"$ref": "escrowExecution"
}
}
},
{
"properties": {
"type": {
"enum": [
"paymentChannelCreate"
]
},
"specification": {
"$ref": "paymentChannelCreate"
}
}
},
{
"properties": {
"type": {
"enum": [
"paymentChannelFund"
]
},
"specification": {
"$ref": "paymentChannelFund"
}
}
},
{
"properties": {
"type": {
"enum": [
"paymentChannelClaim"
]
},
"specification": {
"$ref": "paymentChannelClaim"
}
}
}
]

View File

@@ -2,5 +2,7 @@
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "getTransactions",
"type": "array",
"items": {"$ref": "getTransaction"}
"items": {
"$ref": "getTransaction"
}
}

View File

@@ -0,0 +1,14 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "checkCancel",
"link": "check-cancel",
"type": "object",
"properties": {
"checkID": {
"$ref": "hash256",
"description": "The ID of the Check ledger object to cancel, as a 64-character hexadecimal string."
}
},
"required": ["checkID"],
"additionalProperties": false
}

View File

@@ -0,0 +1,26 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "checkCash",
"link": "check-cash",
"type": "object",
"properties": {
"checkID": {
"$ref": "hash256",
"description": "The ID of the Check ledger object to cash, as a 64-character hexadecimal string."
},
"amount": {
"$ref": "laxAmount",
"description": "Redeem the Check for exactly this amount, if possible. The currency must match that of the sendMax of the corresponding CheckCreate transaction. You must provide either this field or deliverMin."
},
"deliverMin": {
"$ref": "laxAmount",
"description": "Redeem the Check for at least this amount and for as much as possible. The currency must match that of the sendMax of the corresponding CheckCreate transaction. You must provide either this field or amount."
}
},
"required": ["checkID"],
"oneOf": [
{"required": ["amount"]},
{"required": ["deliverMin"]}
],
"additionalProperties": false
}

View File

@@ -0,0 +1,31 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "checkCreate",
"link": "check-create",
"type": "object",
"properties": {
"destination": {
"$ref": "address",
"description": "Address of the account that can cash the check."
},
"sendMax": {
"$ref": "laxAmount",
"description": "Amount of source currency the check is allowed to debit the sender, including transfer fees on non-XRP currencies."
},
"destinationTag": {
"$ref": "tag",
"description": "Destination tag that identifies the reason for the check, or a hosted recipient to pay."
},
"expiration": {
"type": "string",
"format": "date-time",
"description": "Time after which the check is no longer valid."
},
"invoiceID": {
"$ref": "hash256",
"description": "256-bit hash, as a 64-character hexadecimal string, representing a specific reason or identifier for this check."
}
},
"required": ["destination", "sendMax"],
"additionalProperties": false
}

View File

@@ -10,19 +10,19 @@
},
"amount": {
"$ref": "value",
"description": "XRP balance of this channel after claim is processed."
"description": "Amount of XRP authorized by this signature."
},
"balance": {
"$ref": "value",
"description": "Amount of XRP authorized by signature."
"description": "Total XRP balance delivered by this channel after claim is processed."
},
"signature": {
"$ref": "signature",
"description": "Signature of this claim."
"description": "Signed claim authorizing withdrawal of XRP from the channel. (Required except from the channel's source address.)"
},
"publicKey": {
"$ref": "publicKey",
"description": "Public key of the channel's sender"
"description": "Public key of the channel. (For verifying the signature.)"
},
"renew": {
"type": "boolean",
@@ -30,7 +30,7 @@
},
"close": {
"type": "boolean",
"description": "Request to close the channel."
"description": "Request to close the channel. If the channel has no XRP remaining or the destination address requests it, closes the channel immediately (returning unclaimed XRP to the source address). Otherwise, sets the channel to expire after settleDelay seconds have passed."
}
},
"required": ["channel"],

View File

@@ -18,12 +18,12 @@
},
"publicKey": {
"$ref": "publicKey",
"description": "Public key of the key pair the source will use to sign claims against this channel."
"description": "Public key of the key pair the source may use to sign claims against this channel."
},
"cancelAfter": {
"type": "string",
"format": "date-time",
"description": "Time when this channel expires."
"description": "Time when this channel expires. This expiration cannot be changed after creating the channel."
},
"sourceTag": {
"$ref": "tag",

View File

@@ -15,7 +15,7 @@
"expiration": {
"type": "string",
"format": "date-time",
"description": "New expiration for this channel."
"description": "New expiration for this channel. (This does not change the cancelAfter expiration, if the channel has one.) Cannot move the expiration sooner than settleDelay seconds from time of the request."
}
},
"required": ["amount", "channel"],

View File

@@ -22,11 +22,11 @@
"$ref": "hash256"
},
"allowPartialPayment": {
"description": "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",
"description": "If true, this payment should proceed even if the whole amount cannot be delivered due to a lack of liquidity or a lack of funds in the source account.",
"type": "boolean"
},
"noDirectRipple": {
"description": "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",
"description": "If true and paths are specified, the sender would like the XRP Ledger to disregard any direct paths from the source account to the destination account. This may be used to take advantage of an arbitrage opportunity or by gateways wishing to issue balances from a hot wallet to a user who has mistakenly set a trustline directly to the hot wallet.",
"type": "boolean"
},
"limitQuality": {

View File

@@ -1,6 +1,7 @@
import * as _ from 'lodash'
import {convertKeysFromSnakeCaseToCamelCase} from './utils'
import Connection from './connection'
import BigNumber from 'bignumber.js'
export type GetServerInfoResponse = {
buildVersion: string,
@@ -60,13 +61,12 @@ function getServerInfo(connection: Connection): Promise<GetServerInfoResponse> {
})
}
// TODO: This was originally annotated to return a number, but actually
// returned a toString'ed number. Should this actually be returning a number?
function computeFeeFromServerInfo(cushion: number,
serverInfo: GetServerInfoResponse
): string {
return (Number(serverInfo.validatedLedger.baseFeeXRP)
* Number(serverInfo.loadFactor) * cushion).toString()
return (new BigNumber(serverInfo.validatedLedger.baseFeeXRP)).
times(serverInfo.loadFactor).
times(cushion).toString()
}
function getFee(connection: Connection, cushion: number): Promise<string> {

View File

@@ -55,7 +55,8 @@ const txFlagIndices = {
asfAccountTxnID: 5,
asfNoFreeze: 6,
asfGlobalFreeze: 7,
asfDefaultRipple: 8
asfDefaultRipple: 8,
asfDepositAuth: 9
}
}

View File

@@ -1,63 +0,0 @@
export type RippledAmountIOU = {
currency: string,
value: string,
issuer?: string
}
export type RippledAmount = string | RippledAmountIOU
export type Amount = {
value: string,
currency: string,
issuer?: string,
counterparty?: string
}
// Amount where counterparty and value are optional
export type LaxLaxAmount = {
currency: string,
value?: string,
issuer?: string,
counterparty?: string
}
// A currency-counterparty pair, or just currency if it's XRP
export type Issue = {
currency: string,
issuer?: string,
counterparty?: string
}
export type Adjustment = {
address: string,
amount: Amount,
tag?: number
}
export type MaxAdjustment = {
address: string,
maxAmount: Amount,
tag?: number
}
export type MinAdjustment = {
address: string,
minAmount: Amount,
tag?: number
}
export type Memo = {
type?: string,
format?: string,
data?: string
}
export type ApiMemo = {
MemoData?: string,
MemoType?: string,
MemoFormat?: string
}

View File

@@ -0,0 +1,23 @@
import {
AccountRootLedgerEntry,
SignerListLedgerEntry,
QueueData
} from '../objects'
export interface AccountInfoRequest {
account: string,
strict?: boolean,
queue?: boolean,
ledger_hash?: string,
ledger_index?: number | ('validated' | 'closed' | 'current'),
signer_lists?: boolean
}
export interface AccountInfoResponse {
account_data: AccountRootLedgerEntry,
signer_lists?: SignerListLedgerEntry[],
ledger_current_index?: number,
ledger_index?: number,
queue_data?: QueueData,
validated?: boolean
}

View File

@@ -0,0 +1,19 @@
import {Trustline} from '../objects'
export interface AccountLinesRequest {
account: string,
ledger_hash?: string,
ledger_index?: number | ('validated' | 'closed' | 'current'),
peer?: string,
limit?: number,
marker?: any,
}
export interface AccountLinesResponse {
account: string,
lines: Trustline[],
ledger_current_index?: number,
ledger_index?: number,
ledger_hash?: string,
marker?: any,
}

View File

@@ -0,0 +1,72 @@
import {CheckLedgerEntry} from '../objects'
export interface GetAccountObjectsOptions {
type?: string | (
'check' |
'escrow' |
'offer' |
'payment_channel' |
'signer_list' |
'state'
),
ledgerHash?: string,
ledgerIndex?: number | ('validated' | 'closed' | 'current'),
limit?: number,
marker?: string
}
export interface AccountObjectsRequest {
account: string,
// (Optional) Filter results to include only this type of ledger object.
type?: string | (
'check' |
'escrow' |
'offer' |
'payment_channel' |
'signer_list' |
'state'
),
// (Optional) A 20-byte hex string for the ledger version to use.
ledger_hash?: string,
// (Optional) The sequence number of the ledger to use,
// or a shortcut string to choose a ledger automatically.
ledger_index?: number | ('validated' | 'closed' | 'current'),
limit?: number,
marker?: string
}
export interface AccountObjectsResponse {
account: string,
// Array of objects owned by this account.
account_objects: CheckLedgerEntry | object,
// (May be omitted) The identifying hash of the ledger
// that was used to generate this response.
ledger_hash?: string,
// (May be omitted) The sequence number of the ledger version
// that was used to generate this response.
ledger_index?: number,
// (May be omitted) The sequence number of the current in-progress ledger
// version that was used to generate this response.
ledger_current_index?: number,
// The limit that was used in this request, if any.
limit?: number,
// Server-defined value indicating the response is paginated. Pass this
// to the next call to resume where this call left off. Omitted when there
// are no additional pages after this one.
marker?: string,
// If true, this information comes from a ledger version
// that has been validated by consensus.
validated?: boolean
}

View File

@@ -0,0 +1,27 @@
import {RippledAmount} from '../objects'
export interface AccountOffersRequest {
account: string,
ledger_hash?: string,
ledger_index?: number | ('validated' | 'closed' | 'current'),
limit?: number,
marker?: any,
}
export interface AccountOffersResponse {
account: string,
ledger_hash?: string,
ledger_current_index?: number,
ledger_index?: number,
marker?: any,
offers?: AccountOffer[],
}
export interface AccountOffer {
seq: number,
flags: number,
taker_gets: RippledAmount,
taker_pays: RippledAmount,
quality: string,
expiration?: number
}

View File

@@ -0,0 +1,30 @@
import {
TakerRequestAmount,
RippledAmount,
OfferCreateTransaction
} from '../objects'
export interface BookOffersRequest {
taker?: string,
taker_gets: TakerRequestAmount,
taker_pays: TakerRequestAmount,
ledger_hash?: string,
ledger_index?: number | ('validated' | 'closed' | 'current'),
limit?: number,
marker?: any
}
export interface BookOffersResponse {
offers: BookOffer[],
ledger_hash?: string,
ledger_current_index?: number,
ledger_index?: number,
marker?: any
}
export interface BookOffer extends OfferCreateTransaction {
quality?: string
owner_funds?: string,
taker_gets_funded?: RippledAmount,
taker_pays_funded?: RippledAmount
}

View File

@@ -0,0 +1,19 @@
import {Amount} from '../objects'
export interface GatewayBalancesRequest {
account: string,
strict?: boolean,
hotwallet: string|Array<string>,
ledger_hash?: string,
ledger_index?: number | ('validated' | 'closed' | 'current')
}
export interface GatewayBalancesResponse {
account: string,
obligations?: {[currency: string]: string},
balances?: {[address: string]: Amount[]},
assets?: {[address: string]: Amount[]},
ledger_hash?: string,
ledger_current_index?: number,
ledger_index?: number
}

View File

@@ -0,0 +1,8 @@
export * from './account_info'
export * from './account_lines'
export * from './account_objects'
export * from './account_offers'
export * from './book_offers'
export * from './gateway_balances'
export * from './ledger'
export * from './ledger_entry'

View File

@@ -0,0 +1,20 @@
import {Ledger, QueueData} from '../objects'
export interface LedgerRequest {
ledger_hash?: string
ledger_index?: number | ('validated' | 'closed' | 'current')
full?: boolean
accounts?: boolean
transactions?: boolean
expand?: boolean
owner_funds?: boolean
binary?: boolean
queue?: boolean
}
export interface LedgerResponse {
ledger_index: number
ledger_hash: string
ledger: Ledger
queue_data?: QueueData
}

View File

@@ -0,0 +1,31 @@
import {LedgerEntry} from '../objects'
export interface LedgerEntryRequest {
ledger_hash?: string
ledger_index?: number | ('validated' | 'closed' | 'current')
index?: string,
account_root?: string,
directory?: string | {
sub_index?: number,
dir_root: string
} | {
sub_index?: number,
owner: string
},
offer?: string | {
account: string,
seq: number
},
ripple_state?: {
accounts: [string, string],
currency: string
},
binary?: boolean
}
export interface LedgerEntryResponse {
index: string,
ledger_index: number,
node_binary?: string,
node?: LedgerEntry,
}

View File

@@ -0,0 +1,19 @@
import {Amount} from './amounts'
export type Adjustment = {
address: string,
amount: Amount,
tag?: number
}
export type MaxAdjustment = {
address: string,
maxAmount: Amount,
tag?: number
}
export type MinAdjustment = {
address: string,
minAmount: Amount,
tag?: number
}

View File

@@ -0,0 +1,28 @@
export type Amount = {
value: string,
currency: string,
issuer?: string,
counterparty?: string
}
export type RippledAmount = string | Amount
/**
* Specification of which currency the account taking the offer would pay/
* receive, as an object with currency and issuer fields (omit issuer for XRP).
* Similar to currency amounts.
*/
export interface TakerRequestAmount {
currency: string
issuer?: string
}
/**
* A currency-counterparty pair, or just currency if it's XRP.
*/
export type Issue = {
currency: string,
issuer?: string,
counterparty?: string
}

View File

@@ -0,0 +1,11 @@
export * from './adjustments'
export * from './amounts'
export * from './ledger'
export * from './ledger_entries'
export * from './memos'
export * from './orders'
export * from './queue_data'
export * from './settings'
export * from './signers'
export * from './transactions'
export * from './trustlines'

View File

@@ -0,0 +1,22 @@
export interface Ledger {
account_hash: string,
close_time: number,
close_time_human: string,
close_time_resolution: number,
closed: boolean,
ledger_hash: string,
ledger_index: string,
parent_hash: string,
total_coins: string,
transaction_hash: string,
transactions: string[] | object[],
// @deprecated
seqNum?: string,
// @deprecated
totalCoins?: string,
// @deprecated
hash?: string,
close_flags?: number,
parent_close_time?: number,
accountState?: any[]
}

View File

@@ -0,0 +1,83 @@
import {SignerEntry} from './index'
export interface AccountRootLedgerEntry {
LedgerEntryType: 'AccountRoot',
Account: string,
Balance: string,
Flags: number,
OwnerCount: number,
PreviousTxnID: string,
PreviousTxnLgrSeq: number,
Sequence: number,
AccountTxnID?: string,
Domain?: string,
EmailHash?: string,
MessageKey?: string
RegularKey?: string,
TickSize?: number,
TransferRate?: number,
WalletLocator?: string, // DEPRECATED
WalletSize?: number // DEPRECATED
}
export interface AmendmentsLedgerEntry {
LedgerEntryType: 'Amendments',
Amendments?: string[],
Majorities?: any[],
Flags: 0
}
export interface CheckLedgerEntry {
LedgerEntryType: 'Check',
Account: string,
Destination, string,
Flags: 0,
OwnerNode: string,
PreviousTxnID: string,
PreviousTxnLgrSeq: number,
SendMax: string | object,
Sequence: number,
DestinationNode: string,
DestinationTag: number,
Expiration: number,
InvoiceID: string,
SourceTag: number
}
export interface PayChannelLedgerEntry {
LedgerEntryType: 'PayChannel',
Sequence: number,
Account: string,
Amount: string,
Balance: string,
PublicKey: string,
Destination: string,
SettleDelay: number,
Expiration?: number,
CancelAfter?: number,
SourceTag?: number,
DestinationTag?: number,
OwnerNode: string,
PreviousTxnID: string,
PreviousTxnLgrSeq: number,
index: string
}
export interface SignerListLedgerEntry {
LedgerEntryType: 'SignerList',
OwnerNode: string,
SignerQuorum: number,
SignerEntries: SignerEntry[],
SignerListID: number,
PreviousTxnID: string,
PreviousTxnLgrSeq: number
}
// TODO: Add the other ledger entry types, then remove the `any` fallback
// see https://ripple.com/build/ledger-format/#ledger-object-types
export type LedgerEntry =
AccountRootLedgerEntry |
AmendmentsLedgerEntry |
PayChannelLedgerEntry |
SignerListLedgerEntry |
any

View File

@@ -0,0 +1,6 @@
export type Memo = {
type?: string,
format?: string,
data?: string
}

View File

@@ -0,0 +1,17 @@
import {Amount} from './amounts'
import {Memo} from './memos'
export type FormattedOrderSpecification = {
direction: string,
quantity: Amount,
totalPrice: Amount,
immediateOrCancel?: boolean,
fillOrKill?: boolean,
expirationTime?: string,
orderToReplace?: number,
memos?: Memo[],
// 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
}

View File

@@ -0,0 +1,16 @@
export interface QueueTransaction {
auth_change: boolean,
fee: string,
fee_level: string,
max_spend_drops: string,
seq: number
}
export interface QueueData {
txn_count: number,
auth_change_queued?: boolean,
lowest_sequence?: number,
highest_sequence?: number,
max_spend_drops_total?: string,
transactions?: QueueTransaction[]
}

View File

@@ -0,0 +1,30 @@
import {Memo} from './memos'
export type WeightedSigner = {
address: string,
weight: number
}
export type Signers = {
threshold?: number,
weights: WeightedSigner[]
}
export type FormattedSettings = {
passwordSpent?: boolean,
requireDestinationTag?: boolean,
requireAuthorization?: boolean,
disallowIncomingXRP?: boolean,
disableMasterKey?: boolean,
enableTransactionIDTracking?: boolean,
noFreeze?: boolean,
globalFreeze?: boolean,
defaultRipple?: boolean,
emailHash?: string|null,
messageKey?: string,
domain?: string,
transferRate?: number|null,
regularKey?: string,
signers?: Signers,
memos?: Memo[]
}

View File

@@ -0,0 +1,4 @@
export interface SignerEntry {
Account: string,
SignerWeight: number
}

View File

@@ -0,0 +1,22 @@
import {RippledAmount} from './amounts'
import {Memo} from './memos'
export interface OfferCreateTransaction {
TransactionType: 'OfferCreate',
Account: string,
AccountTxnID?: string,
Fee: string,
Field: any,
Flags: number,
LastLedgerSequence?: number,
Sequence: number,
Signers: any[],
SigningPubKey: string,
SourceTag?: number,
TakerGets: RippledAmount,
TakerPays: RippledAmount,
TxnSignature: string,
Expiration?: number,
Memos?: Memo[],
OfferSequence?: number,
}

View File

@@ -0,0 +1,42 @@
import {Memo} from './memos'
export interface Trustline {
account: string,
balance: string,
currency: string,
limit: string,
limit_peer: string,
quality_in: number,
quality_out: number,
no_ripple?: boolean,
no_ripple_peer?: boolean,
freeze?: boolean,
freeze_peer?: boolean,
authorized?: boolean,
peer_authorized?: boolean,
}
export type FormattedTrustlineSpecification = {
currency: string,
counterparty: string,
limit: string,
qualityIn?: number,
qualityOut?: number,
ripplingDisabled?: boolean,
authorized?: boolean,
frozen?: boolean,
memos?: Memo[]
}
export type FormattedTrustline = {
specification: FormattedTrustlineSpecification,
counterparty: {
limit: string,
ripplingDisabled?: boolean,
frozen?: boolean,
authorized?: boolean
},
state: {
balance: string
}
}

View File

@@ -2,7 +2,7 @@ import * as _ from 'lodash'
import BigNumber from 'bignumber.js'
const {deriveKeypair} = require('ripple-keypairs')
import {Amount, RippledAmount} from './types'
import {Amount, RippledAmount} from './types/objects'
function isValidSecret(secret: string): boolean {
try {

View File

@@ -89,6 +89,15 @@ _.partial(schemaValidate, 'preparePaymentChannelFundParameters')
export const preparePaymentChannelClaim =
_.partial(schemaValidate, 'preparePaymentChannelClaimParameters')
export const prepareCheckCreate =
_.partial(schemaValidate, 'prepareCheckCreateParameters')
export const prepareCheckCash =
_.partial(schemaValidate, 'prepareCheckCashParameters')
export const prepareCheckCancel =
_.partial(schemaValidate, 'prepareCheckCancelParameters')
export const sign =
_.partial(schemaValidate, 'signParameters')

View File

@@ -2,7 +2,7 @@
import * as assert from 'assert'
import * as _ from 'lodash'
import jayson from 'jayson'
import * as jayson from 'jayson'
import {RippleAPI} from './api'

View File

@@ -1,31 +1,12 @@
import {validate, removeUndefined, dropsToXrp} from '../common'
import {RippleAPI} from '../api'
import {AccountInfoResponse} from '../common/types/commands/account_info'
type AccountData = {
Sequence: number,
Account: string,
Balance: string,
Flags: number,
LedgerEntryType: string,
OwnerCount: number,
PreviousTxnID: string,
AccountTxnID?: string,
PreviousTxnLgrSeq: number,
index: string
}
type AccountDataResponse = {
account_data: AccountData,
ledger_current_index?: number,
ledger_hash?: string,
ledger_index: number,
validated: boolean
}
type AccountInfoOptions = {
export type GetAccountInfoOptions = {
ledgerVersion?: number
}
type AccountInfoResponse = {
export type FormattedGetAccountInfoResponse = {
sequence: number,
xrpBalance: string,
ownerCount: number,
@@ -34,7 +15,9 @@ type AccountInfoResponse = {
previousAffectingTransactionLedgerVersion: number
}
function formatAccountInfo(response: AccountDataResponse) {
function formatAccountInfo(
response: AccountInfoResponse
): FormattedGetAccountInfoResponse {
const data = response.account_data
return removeUndefined({
sequence: data.Sequence,
@@ -46,17 +29,16 @@ function formatAccountInfo(response: AccountDataResponse) {
})
}
function getAccountInfo(address: string, options: AccountInfoOptions = {}
): Promise<AccountInfoResponse> {
export default async function getAccountInfo(
this: RippleAPI, address: string, options: GetAccountInfoOptions = {}
): Promise<FormattedGetAccountInfoResponse> {
// 1. Validate
validate.getAccountInfo({address, options})
const request = {
command: 'account_info',
// 2. Make Request
const response = await this._request('account_info', {
account: address,
ledger_index: options.ledgerVersion || 'validated'
}
return this.connection.request(request).then(formatAccountInfo)
})
// 3. Return Formatted Response
return formatAccountInfo(response)
}
export default getAccountInfo

View File

@@ -0,0 +1,27 @@
import {removeUndefined} from '../common'
import {RippleAPI} from '../api'
import {
GetAccountObjectsOptions,
AccountObjectsResponse
} from '../common/types/commands/account_objects'
export default async function getAccountObjects(
this: RippleAPI,
address: string,
options: GetAccountObjectsOptions = {}
): Promise<AccountObjectsResponse> {
// Don't validate the options so that new types can be passed
// through to rippled. rippled validates requests.
// Make Request
const response = await this._request('account_objects', removeUndefined({
account: address,
type: options.type,
ledger_hash: options.ledgerHash,
ledger_index: options.ledgerIndex,
limit: options.limit,
marker: options.marker
}))
// Return Response
return response
}

View File

@@ -1,14 +1,15 @@
import * as _ from 'lodash'
import * as utils from './utils'
import {validate} from '../common'
import {Amount} from '../common/types'
import {Amount} from '../common/types/objects'
import {ensureLedgerVersion} from './utils'
import {RippleAPI} from '../api'
type BalanceSheetOptions = {
export type BalanceSheetOptions = {
excludeAddresses?: Array<string>,
ledgerVersion?: number
}
type GetBalanceSheet = {
export type GetBalanceSheet = {
balances?: Array<Amount>,
assets?: Array<Amount>,
obligations?: Array<{
@@ -46,21 +47,21 @@ function formatBalanceSheet(balanceSheet): GetBalanceSheet {
return result
}
function getBalanceSheet(address: string, options: BalanceSheetOptions = {}
async function getBalanceSheet(
this: RippleAPI, address: string, options: BalanceSheetOptions = {}
): Promise<GetBalanceSheet> {
// 1. Validate
validate.getBalanceSheet({address, options})
return utils.ensureLedgerVersion.call(this, options).then(_options => {
const request = {
command: 'gateway_balances',
account: address,
strict: true,
hotwallet: _options.excludeAddresses,
ledger_index: _options.ledgerVersion
}
return this.connection.request(request).then(formatBalanceSheet)
options = await ensureLedgerVersion.call(this, options)
// 2. Make Request
const response = await this._request('gateway_balances', {
account: address,
strict: true,
hotwallet: options.excludeAddresses,
ledger_index: options.ledgerVersion
})
// 3. Return Formatted Response
return formatBalanceSheet(response)
}
export default getBalanceSheet

View File

@@ -1,18 +1,19 @@
import * as utils from './utils'
import {validate} from '../common'
import {Connection} from '../common'
import {TrustlinesOptions, Trustline} from './trustlines-types'
import {GetTrustlinesOptions} from './trustlines'
import {FormattedTrustline} from '../common/types/objects/trustlines'
type Balance = {
export type Balance = {
value: string,
currency: string,
counterparty?: string
}
type GetBalances = Array<Balance>
export type GetBalances = Array<Balance>
function getTrustlineBalanceAmount(trustline: Trustline) {
function getTrustlineBalanceAmount(trustline: FormattedTrustline) {
return {
currency: trustline.specification.currency,
counterparty: trustline.specification.counterparty,
@@ -46,7 +47,7 @@ function getLedgerVersionHelper(connection: Connection, optionValue?: number
return connection.getLedgerVersion()
}
function getBalances(address: string, options: TrustlinesOptions = {}
function getBalances(address: string, options: GetTrustlinesOptions = {}
): Promise<GetBalances> {
validate.getTrustlines({address, options})

View File

@@ -1,28 +1,29 @@
import {validate} from '../common'
import parseLedger from './parse/ledger'
import {GetLedger} from './types'
import {FormattedLedger, parseLedger} from './parse/ledger'
import {RippleAPI} from '../api'
type LedgerOptions = {
export type GetLedgerOptions = {
ledgerVersion?: number,
includeAllData?: boolean,
includeTransactions?: boolean,
includeState?: boolean
}
function getLedger(options: LedgerOptions = {}): Promise<GetLedger> {
async function getLedger(
this: RippleAPI, options: GetLedgerOptions = {}
): Promise<FormattedLedger> {
// 1. Validate
validate.getLedger({options})
const request = {
command: 'ledger',
// 2. Make Request
const response = await this._request('ledger', {
ledger_index: options.ledgerVersion || 'validated',
expand: options.includeAllData,
transactions: options.includeTransactions,
accounts: options.includeState
}
return this.connection.request(request).then(response =>
parseLedger(response.ledger))
})
// 3. Return Formatted Response
return parseLedger(response.ledger)
}
export default getLedger

View File

@@ -1,65 +1,28 @@
import * as _ from 'lodash'
import * as utils from './utils'
import parseOrderbookOrder from './parse/orderbook-order'
import {
parseOrderbookOrder,
FormattedOrderbookOrder
} from './parse/orderbook-order'
import {validate} from '../common'
import {Connection} from '../common'
import {OrdersOptions, OrderSpecification} from './types'
import {Amount, Issue} from '../common/types'
import {Amount, Issue} from '../common/types/objects'
import {BookOffer} from '../common/types/commands'
import {RippleAPI} from '../api'
type Orderbook = {
base: Issue,
counter: Issue
}
type OrderbookItem = {
specification: OrderSpecification,
properties: {
maker: string,
sequence: number,
makerExchangeRate: string
},
state?: {
fundedAmount: Amount,
priceOfFundedAmount: Amount
}
}
type OrderbookOrders = Array<OrderbookItem>
type GetOrderbook = {
bids: OrderbookOrders,
asks: OrderbookOrders
}
// account is to specify a "perspective", which affects which unfunded offers
// are returned
function getBookOffers(connection: Connection, account: string,
ledgerVersion: number|undefined, limit: number|undefined, takerGets: Issue,
takerPays: Issue
): Promise<Object[]> {
const orderData = utils.renameCounterpartyToIssuerInOrder({
taker_gets: takerGets,
taker_pays: takerPays
})
return connection.request({
command: 'book_offers',
taker_gets: orderData.taker_gets,
taker_pays: orderData.taker_pays,
ledger_index: ledgerVersion || 'validated',
limit: limit,
taker: account
}).then(data => data.offers)
export type FormattedOrderbook = {
bids: FormattedOrderbookOrder[],
asks: FormattedOrderbookOrder[]
}
function isSameIssue(a: Amount, b: Amount) {
return a.currency === b.currency && a.issuer === b.issuer
return a.currency === b.currency && a.counterparty === b.counterparty
}
function directionFilter(direction: string, order: OrderbookItem) {
function directionFilter(direction: string, order: FormattedOrderbookOrder) {
return order.specification.direction === direction
}
function flipOrder(order: OrderbookItem) {
function flipOrder(order: FormattedOrderbookOrder) {
const specification = order.specification
const flippedSpecification = {
quantity: specification.totalPrice,
@@ -70,12 +33,13 @@ function flipOrder(order: OrderbookItem) {
return _.merge({}, order, {specification: newSpecification})
}
function alignOrder(base: Amount, order: OrderbookItem) {
function alignOrder(base: Amount, order: FormattedOrderbookOrder) {
const quantity = order.specification.quantity
return isSameIssue(quantity, base) ? order : flipOrder(order)
}
function formatBidsAndAsks(orderbook: Orderbook, offers) {
function formatBidsAndAsks(
orderbook: OrderbookInfo, offers: BookOffer[]) {
// the "base" currency is the currency that you are buying or selling
// the "counter" is the currency that the "base" is priced in
// a "bid"/"ask" is an order to buy/sell the base, respectively
@@ -93,17 +57,53 @@ function formatBidsAndAsks(orderbook: Orderbook, offers) {
return {bids, asks}
}
function getOrderbook(address: string, orderbook: Orderbook,
options: OrdersOptions = {}
): Promise<GetOrderbook> {
validate.getOrderbook({address, orderbook, options})
const getter = _.partial(getBookOffers, this.connection, address,
options.ledgerVersion, options.limit)
const getOffers = _.partial(getter, orderbook.base, orderbook.counter)
const getReverseOffers = _.partial(getter, orderbook.counter, orderbook.base)
return Promise.all([getOffers(), getReverseOffers()]).then(data =>
formatBidsAndAsks(orderbook, _.flatten(data)))
// account is to specify a "perspective", which affects which unfunded offers
// are returned
async function makeRequest(
api: RippleAPI, taker: string, options: GetOrderbookOptions,
takerGets: Issue, takerPays: Issue
) {
const orderData = utils.renameCounterpartyToIssuerInOrder({
taker_gets: takerGets,
taker_pays: takerPays
})
return api._requestAll('book_offers', {
taker_gets: orderData.taker_gets,
taker_pays: orderData.taker_pays,
ledger_index: options.ledgerVersion || 'validated',
limit: options.limit,
taker
})
}
export default getOrderbook
export type GetOrderbookOptions = {
limit?: number,
ledgerVersion?: number
}
export type OrderbookInfo = {
base: Issue,
counter: Issue
}
export default async function getOrderbook(
this: RippleAPI,
address: string,
orderbook: OrderbookInfo,
options: GetOrderbookOptions = {}
): Promise<FormattedOrderbook> {
// 1. Validate
validate.getOrderbook({address, orderbook, options})
// 2. Make Request
const [directOfferResults, reverseOfferResults] = await Promise.all([
makeRequest(this, address, options, orderbook.base, orderbook.counter),
makeRequest(this, address, options, orderbook.counter, orderbook.base)
])
// 3. Return Formatted Response
const directOffers = _.flatMap(directOfferResults,
directOfferResult => directOfferResult.offers)
const reverseOffers = _.flatMap(reverseOfferResults,
reverseOfferResult => reverseOfferResult.offers)
return formatBidsAndAsks(orderbook, [...directOffers, ...reverseOffers])
}

View File

@@ -1,37 +1,38 @@
import * as _ from 'lodash'
import * as utils from './utils'
import {validate} from '../common'
import {Connection} from '../common'
import parseAccountOrder from './parse/account-order'
import {OrdersOptions, Order} from './types'
import {FormattedAccountOrder, parseAccountOrder} from './parse/account-order'
import {RippleAPI} from '../api'
import {AccountOffersResponse} from '../common/types/commands'
type GetOrders = Array<Order>
function requestAccountOffers(connection: Connection, address: string,
ledgerVersion: number, marker: string, limit: number
): Promise<Object> {
return connection.request({
command: 'account_offers',
account: address,
marker: marker,
limit: utils.clamp(limit, 10, 400),
ledger_index: ledgerVersion
}).then(data => ({
marker: data.marker,
results: data.offers.map(_.partial(parseAccountOrder, address))
}))
export type GetOrdersOptions = {
limit?: number,
ledgerVersion?: number
}
function getOrders(address: string, options: OrdersOptions = {}
): Promise<GetOrders> {
function formatResponse(
address: string, responses: AccountOffersResponse[]
): FormattedAccountOrder[] {
let orders: FormattedAccountOrder[] = []
for (const response of responses) {
const offers = response.offers.map(offer => {
return parseAccountOrder(address, offer)
})
orders = orders.concat(offers)
}
return _.sortBy(orders, order => order.properties.sequence)
}
export default async function getOrders(
this: RippleAPI, address: string, options: GetOrdersOptions = {}
): Promise<FormattedAccountOrder[]> {
// 1. Validate
validate.getOrders({address, options})
return utils.ensureLedgerVersion.call(this, options).then(_options => {
const getter = _.partial(requestAccountOffers, this.connection, address,
_options.ledgerVersion)
return utils.getRecursive(getter, _options.limit).then(orders =>
_.sortBy(orders, order => order.properties.sequence))
// 2. Make Request
const responses = await this._requestAll('account_offers', {
account: address,
ledger_index: options.ledgerVersion || await this.getLedgerVersion(),
limit: options.limit
})
// 3. Return Formatted Response
return formatResponse(address, responses)
}
export default getOrders

View File

@@ -3,6 +3,16 @@ import parseAmount from './amount'
import {parseTimestamp, adjustQualityForXRP} from './utils'
import {removeUndefined} from '../../common'
import {orderFlags} from './flags'
import {FormattedOrderSpecification} from '../../common/types/objects'
export type FormattedAccountOrder = {
specification: FormattedOrderSpecification,
properties: {
maker: string,
sequence: number,
makerExchangeRate: string
}
}
// TODO: remove this function once rippled provides quality directly
function computeQuality(takerGets, takerPays) {
@@ -12,7 +22,9 @@ function computeQuality(takerGets, takerPays) {
// rippled 'account_offers' returns a different format for orders than 'tx'
// the flags are also different
function parseAccountOrder(address: string, order: any): Object {
export function parseAccountOrder(
address: string, order: any
): FormattedAccountOrder {
const direction = (order.flags & orderFlags.Sell) === 0 ? 'buy' : 'sell'
const takerGetsAmount = parseAmount(order.taker_gets)
const takerPaysAmount = parseAmount(order.taker_pays)
@@ -42,5 +54,3 @@ function parseAccountOrder(address: string, order: any): Object {
return {specification, properties}
}
export default parseAccountOrder

View File

@@ -1,24 +1,13 @@
import {parseQuality} from './utils'
import {removeUndefined} from '../../common'
type Trustline = {
account: string, limit: number, currency: string, quality_in: number|null,
quality_out: number|null, no_ripple: boolean, freeze: boolean,
authorized: boolean, limit_peer: string, no_ripple_peer: boolean,
freeze_peer: boolean, peer_authorized: boolean, balance: any
}
type TrustlineSpecification = {}
type TrustlineCounterParty = {}
type TrustlineState = {balance: number}
type AccountTrustline = {
specification: TrustlineSpecification, counterparty: TrustlineCounterParty,
state: TrustlineState
}
import {
Trustline,
FormattedTrustline
} from '../../common/types/objects/trustlines'
// rippled 'account_lines' returns a different format for
// trustlines than 'tx'
function parseAccountTrustline(trustline: Trustline): AccountTrustline {
function parseAccountTrustline(trustline: Trustline): FormattedTrustline {
const specification = removeUndefined({
limit: trustline.limit,
currency: trustline.currency,

View File

@@ -1,5 +1,5 @@
import * as common from '../../common'
import {Amount, RippledAmount} from '../../common/types'
import {Amount, RippledAmount} from '../../common/types/objects'
function parseAmount(amount: RippledAmount): Amount {

View File

@@ -0,0 +1,18 @@
import * as assert from 'assert'
import {removeUndefined} from '../../common'
export type FormattedCheckCancel = {
// ID of the Check ledger object to cancel.
checkID: string
}
function parseCheckCancel(tx: any): FormattedCheckCancel {
assert(tx.TransactionType === 'CheckCancel')
return removeUndefined({
checkID: tx.CheckID
})
}
export default parseCheckCancel

View File

@@ -0,0 +1,35 @@
import * as assert from 'assert'
import {removeUndefined} from '../../common'
import parseAmount from './amount'
import {Amount} from '../../common/types/objects'
export type FormattedCheckCash = {
// ID of the Check ledger object to cash.
checkID: string,
// (Optional) redeem the Check for exactly this amount, if possible.
// The currency must match that of the `SendMax` of the corresponding
// `CheckCreate` transaction.
amount: Amount,
// (Optional) redeem the Check for at least this amount and
// for as much as possible.
// The currency must match that of the `SendMax` of the corresponding
// `CheckCreate` transaction.
deliverMin: Amount
// *must* include either Amount or DeliverMin, but not both.
}
function parseCheckCash(tx: any): FormattedCheckCash {
assert(tx.TransactionType === 'CheckCash')
return removeUndefined({
checkID: tx.CheckID,
amount: tx.Amount && parseAmount(tx.Amount),
deliverMin: tx.DeliverMin && parseAmount(tx.DeliverMin)
})
}
export default parseCheckCash

View File

@@ -0,0 +1,38 @@
import * as assert from 'assert'
import {parseTimestamp} from './utils'
import {removeUndefined} from '../../common'
import parseAmount from './amount'
import {Amount} from '../../common/types/objects'
export type FormattedCheckCreate = {
// account that can cash the check.
destination: string,
// amount the check is allowed to debit the sender,
// including transfer fees on non-XRP currencies.
sendMax: Amount,
// (Optional) identifies the reason for the check, or a hosted recipient.
destinationTag?: string,
// (Optional) time in seconds since the Ripple Epoch.
expiration?: string,
// (Optional) 256-bit hash representing a specific reason or identifier.
invoiceID?: string
}
function parseCheckCreate(tx: any): FormattedCheckCreate {
assert(tx.TransactionType === 'CheckCreate')
return removeUndefined({
destination: tx.Destination,
sendMax: parseAmount(tx.SendMax),
destinationTag: tx.DestinationTag,
expiration: tx.Expiration && parseTimestamp(tx.Expiration),
invoiceID: tx.InvoiceID
})
}
export default parseCheckCreate

View File

@@ -1,7 +1,28 @@
import * as _ from 'lodash'
import {removeUndefined, rippleTimeToISO8601} from '../../common'
import parseTransaction from './transaction'
import {GetLedger} from '../types'
import {Ledger} from '../../common/types/objects'
export type FormattedLedger = {
// TODO: properties in type don't match response object. Fix!
// accepted: boolean,
// closed: boolean,
stateHash: string,
closeTime: string,
closeTimeResolution: number,
closeFlags: number,
ledgerHash: string,
ledgerVersion: number,
parentLedgerHash: string,
parentCloseTime: string,
totalDrops: string,
transactionHash: string,
transactions?: Array<Object>,
rawTransactions?: string,
transactionHashes?: Array<string>,
rawState?: string,
stateHashes?: Array<string>
}
function parseTransactionWrapper(ledgerVersion, tx) {
const transaction = _.assign({}, _.omit(tx, 'metaData'), {
@@ -39,7 +60,7 @@ function parseState(state) {
return {rawState: JSON.stringify(state)}
}
function parseLedger(ledger: any): GetLedger {
export function parseLedger(ledger: Ledger): FormattedLedger {
const ledgerVersion = parseInt(ledger.ledger_index || ledger.seqNum, 10)
return removeUndefined(Object.assign({
stateHash: ledger.account_hash,
@@ -57,5 +78,3 @@ function parseLedger(ledger: any): GetLedger {
parseState(ledger.accountState)
))
}
export default parseLedger

View File

@@ -2,9 +2,14 @@ import * as assert from 'assert'
import {parseTimestamp} from './utils'
import parseAmount from './amount'
import {removeUndefined, txFlags} from '../../common'
import {
FormattedOrderSpecification,
OfferCreateTransaction
} from '../../common/types/objects/index'
const flags = txFlags.OfferCreate
function parseOrder(tx: any): Object {
function parseOrder(tx: OfferCreateTransaction): FormattedOrderSpecification {
assert(tx.TransactionType === 'OfferCreate')
const direction = (tx.Flags & flags.Sell) === 0 ? 'buy' : 'sell'

View File

@@ -4,8 +4,25 @@ import {removeUndefined} from '../../common'
import {orderFlags} from './flags'
import parseAmount from './amount'
import {BookOffer} from '../../common/types/commands'
import {Amount, FormattedOrderSpecification} from '../../common/types/objects'
function parseOrderbookOrder(order: any): Object {
export type FormattedOrderbookOrder = {
specification: FormattedOrderSpecification,
properties: {
maker: string,
sequence: number,
makerExchangeRate: string
},
state?: {
fundedAmount: Amount,
priceOfFundedAmount: Amount
}
}
export function parseOrderbookOrder(
order: BookOffer
): FormattedOrderbookOrder {
const direction = (order.Flags & orderFlags.Sell) === 0 ? 'buy' : 'sell'
const takerGetsAmount = parseAmount(order.TakerGets)
const takerPaysAmount = parseAmount(order.TakerPays)
@@ -14,7 +31,7 @@ function parseOrderbookOrder(order: any): Object {
// note: immediateOrCancel and fillOrKill orders cannot enter the order book
// so we can omit those flags here
const specification = removeUndefined({
const specification: FormattedOrderSpecification = removeUndefined({
direction: direction,
quantity: quantity,
totalPrice: totalPrice,
@@ -40,5 +57,3 @@ function parseOrderbookOrder(order: any): Object {
const state = _.isEmpty(available) ? undefined : available
return removeUndefined({specification, properties, state})
}
export default parseOrderbookOrder

View File

@@ -1,6 +1,6 @@
import * as _ from 'lodash'
import parseAmount from './amount'
import {Amount, RippledAmount} from '../../common/types'
import {Amount, RippledAmount} from '../../common/types/objects'
import {Path, GetPaths, RippledPathsResponse} from '../pathfind-types'
function parsePaths(paths) {

View File

@@ -1,35 +1,8 @@
import {parseTimestamp} from './utils'
import {removeUndefined, dropsToXrp} from '../../common'
import {PayChannelLedgerEntry} from '../../common/types/objects'
export type PaymentChannel = {
Sequence: number,
Account: string,
Amount: string,
Balance: string,
PublicKey: string,
Destination: string,
SettleDelay: number,
Expiration?: number,
CancelAfter?: number,
SourceTag?: number,
DestinationTag?: number,
OwnerNode: string,
LedgerEntryType: string,
PreviousTxnID: string,
PreviousTxnLgrSeq: number,
index: string
}
export type LedgerEntryResponse = {
node: PaymentChannel,
ledger_current_index?: number,
ledger_hash?: string,
ledger_index: number,
validated: boolean
}
type PaymentChannelResponse = {
export type FormattedPaymentChannel = {
account: string,
balance: string,
publicKey: string,
@@ -43,7 +16,9 @@ type PaymentChannelResponse = {
previousAffectingTransactionLedgerVersion: number
}
function parsePaymentChannel(data: PaymentChannel): PaymentChannelResponse {
export function parsePaymentChannel(
data: PayChannelLedgerEntry
): FormattedPaymentChannel {
return removeUndefined({
account: data.Account,
amount: dropsToXrp(data.Amount),
@@ -59,5 +34,3 @@ function parsePaymentChannel(data: PaymentChannel): PaymentChannelResponse {
previousAffectingTransactionLedgerVersion: data.PreviousTxnLgrSeq
})
}
export default parsePaymentChannel

View File

@@ -9,6 +9,9 @@ import parseSettings from './settings'
import parseEscrowCreation from './escrow-creation'
import parseEscrowExecution from './escrow-execution'
import parseEscrowCancellation from './escrow-cancellation'
import parseCheckCreate from './check-create'
import parseCheckCash from './check-cash'
import parseCheckCancel from './check-cancel'
import parsePaymentChannelCreate from './payment-channel-create'
import parsePaymentChannelFund from './payment-channel-fund'
import parsePaymentChannelClaim from './payment-channel-claim'
@@ -26,6 +29,9 @@ function parseTransactionType(type) {
EscrowCreate: 'escrowCreation',
EscrowFinish: 'escrowExecution',
EscrowCancel: 'escrowCancellation',
CheckCreate: 'checkCreate',
CheckCash: 'checkCash',
CheckCancel: 'checkCancel',
PaymentChannelCreate: 'paymentChannelCreate',
PaymentChannelFund: 'paymentChannelFund',
PaymentChannelClaim: 'paymentChannelClaim',
@@ -47,6 +53,9 @@ function parseTransaction(tx: any): any {
'escrowCreation': parseEscrowCreation,
'escrowExecution': parseEscrowExecution,
'escrowCancellation': parseEscrowCancellation,
'checkCreate': parseCheckCreate,
'checkCash': parseCheckCash,
'checkCancel': parseCheckCancel,
'paymentChannelCreate': parsePaymentChannelCreate,
'paymentChannelFund': parsePaymentChannelFund,
'paymentChannelClaim': parsePaymentChannelClaim,

View File

@@ -4,7 +4,7 @@ import BigNumber from 'bignumber.js'
import * as common from '../../common'
import parseAmount from './amount'
import {Amount, Memo} from '../../common/types'
import {Amount, Memo} from '../../common/types/objects'
function adjustQualityForXRP(
quality: string, takerGetsCurrency: string, takerPaysCurrency: string

View File

@@ -1,7 +1,14 @@
import {Amount, LaxLaxAmount, RippledAmount, Adjustment, MaxAdjustment,
MinAdjustment} from '../common/types'
import {Amount, RippledAmount, Adjustment, MaxAdjustment,
MinAdjustment} from '../common/types/objects'
// Amount where counterparty and value are optional
export type LaxLaxAmount = {
currency: string,
value?: string,
issuer?: string,
counterparty?: string
}
export type Path = {
source: Adjustment | MaxAdjustment,

View File

@@ -4,7 +4,7 @@ import {getXRPBalance, renameCounterpartyToIssuer} from './utils'
import {validate, toRippledAmount, errors} from '../common'
import {Connection} from '../common'
import parsePathfind from './parse/pathfind'
import {RippledAmount, Amount} from '../common/types'
import {RippledAmount, Amount} from '../common/types/objects'
import {
GetPaths, PathFind, RippledPathsResponse, PathFindRequest
} from './pathfind-types'

View File

@@ -1,29 +1,35 @@
import parsePaymentChannel, {
LedgerEntryResponse, PaymentChannel
import {
parsePaymentChannel,
FormattedPaymentChannel
} from './parse/payment-channel'
import {validate, errors} from '../common'
import {RippleAPI} from '../api'
import {LedgerEntryResponse} from '../common/types/commands'
const NotFoundError = errors.NotFoundError
function formatResponse(response: LedgerEntryResponse) {
if (response.node !== undefined &&
response.node.LedgerEntryType === 'PayChannel') {
return parsePaymentChannel(response.node)
} else {
function formatResponse(
response: LedgerEntryResponse
): FormattedPaymentChannel {
if (response.node === undefined ||
response.node.LedgerEntryType !== 'PayChannel') {
throw new NotFoundError('Payment channel ledger entry not found')
}
return parsePaymentChannel(response.node)
}
function getPaymentChannel(id: string): Promise<PaymentChannel> {
async function getPaymentChannel(
this: RippleAPI, id: string
): Promise<FormattedPaymentChannel> {
// 1. Validate
validate.getPaymentChannel({id})
const request = {
command: 'ledger_entry',
// 2. Make Request
const response = await this._request('ledger_entry', {
index: id,
binary: false,
ledger_index: 'validated'
}
return this.connection.request(request).then(formatResponse)
})
// 3. Return Formatted Response
return formatResponse(response)
}
export default getPaymentChannel

View File

@@ -1,30 +1,15 @@
import * as _ from 'lodash'
import parseFields from './parse/fields'
import {validate, constants} from '../common'
import {FormattedSettings} from '../common/types/objects'
import {AccountInfoResponse} from '../common/types/commands'
import {RippleAPI} from '../api'
const AccountFlags = constants.AccountFlags
type SettingsOptions = {
export type SettingsOptions = {
ledgerVersion?: number
}
type GetSettings = {
passwordSpent?: boolean,
requireDestinationTag?: boolean,
requireAuthorization?: boolean,
disallowIncomingXRP?: boolean,
disableMasterKey?: boolean,
enableTransactionIDTracking?: boolean,
noFreeze?: boolean,
globalFreeze?: boolean,
defaultRipple?: boolean,
emailHash?: string|null,
messageKey?: string,
domain?: string,
transferRate?: number|null,
regularKey?: string
}
function parseFlags(value) {
const settings = {}
for (const flagName in AccountFlags) {
@@ -35,25 +20,26 @@ function parseFlags(value) {
return settings
}
function formatSettings(response) {
function formatSettings(response: AccountInfoResponse) {
const data = response.account_data
const parsedFlags = parseFlags(data.Flags)
const parsedFields = parseFields(data)
return _.assign({}, parsedFlags, parsedFields)
}
function getSettings(address: string, options: SettingsOptions = {}
): Promise<GetSettings> {
async function getSettings(
this: RippleAPI, address: string, options: SettingsOptions = {}
): Promise<FormattedSettings> {
// 1. Validate
validate.getSettings({address, options})
const request = {
command: 'account_info',
// 2. Make Request
const response = await this._request('account_info', {
account: address,
ledger_index: options.ledgerVersion || 'validated',
signer_lists: true
}
return this.connection.request(request).then(formatSettings)
})
// 3. Return Formatted Response
return formatSettings(response)
}
export default getSettings

View File

@@ -1,143 +0,0 @@
import {Amount, Memo} from '../common/types'
type Outcome = {
result: string,
ledgerVersion: number,
indexInLedger: number,
fee: string,
balanceChanges: {
[key: string]: [{
currency: string,
counterparty?: string,
value: string
}]
},
orderbookChanges: Object,
timestamp?: string
}
type Adjustment = {
address: string,
amount: {
currency: string,
counterparty?: string,
value: string
},
tag?: number
}
type Trustline = {
currency: string,
counterparty: string,
limit: string,
qualityIn?: number,
qualityOut?: number,
ripplingDisabled?: boolean,
authorized?: boolean,
frozen?: boolean
}
type Settings = {
passwordSpent?: boolean,
requireDestinationTag?: boolean,
requireAuthorization?: boolean,
disallowIncomingXRP?: boolean,
disableMasterKey?: boolean,
enableTransactionIDTracking?: boolean,
noFreeze?: boolean,
globalFreeze?: boolean,
defaultRipple?: boolean,
emailHash?: string,
messageKey?: string,
domain?: string,
transferRate?: number,
regularKey?: string
}
type OrderCancellation = {
orderSequence: number
}
type Payment = {
source: Adjustment,
destination: Adjustment,
paths?: string,
memos?: Array<Memo>,
invoiceID?: string,
allowPartialPayment?: boolean,
noDirectRipple?: boolean,
limitQuality?: boolean
}
type PaymentTransaction = {
type: string,
specification: Payment,
outcome: Outcome,
id: string,
address: string,
sequence: number
}
export type Order = {
direction: string,
quantity: Amount,
totalPrice: Amount,
immediateOrCancel?: boolean,
fillOrKill?: boolean,
passive?: boolean,
expirationTime?: string,
orderToReplace?: number,
memos?: Memo[]
}
type OrderTransaction = {
type: string,
specification: Order,
outcome: Outcome,
id: string,
address: string,
sequence: number
}
type OrderCancellationTransaction = {
type: string,
specification: OrderCancellation,
outcome: Outcome,
id: string,
address: string,
sequence: number
}
type TrustlineTransaction = {
type: string,
specification: Trustline,
outcome: Outcome,
id: string,
address: string,
sequence: number
}
type SettingsTransaction = {
type: string,
specification: Settings,
outcome: Outcome,
id: string,
address: string,
sequence: number
}
export type TransactionOptions = {
minLedgerVersion?: number,
maxLedgerVersion?: number
}
export type TransactionType = PaymentTransaction | OrderTransaction |
OrderCancellationTransaction | TrustlineTransaction | SettingsTransaction
export type TransactionResponse = TransactionType & {
hash: string,
ledger_index: number,
meta: any,
validated?: boolean
}

View File

@@ -3,12 +3,22 @@ import * as utils from './utils'
import parseTransaction from './parse/transaction'
import {validate, errors} from '../common'
import {Connection} from '../common'
import {
TransactionType, TransactionResponse, TransactionOptions
} from './transaction-types'
import {FormattedTransactionType} from '../transaction/types'
export type TransactionOptions = {
minLedgerVersion?: number,
maxLedgerVersion?: number
}
type TransactionResponse = FormattedTransactionType & {
hash: string,
ledger_index: number,
meta: any,
validated?: boolean
}
function attachTransactionDate(connection: Connection, tx: any
): Promise<TransactionType> {
): Promise<FormattedTransactionType> {
if (tx.date) {
return Promise.resolve(tx)
}
@@ -71,7 +81,7 @@ function convertError(connection: Connection, options: TransactionOptions,
}
function formatResponse(options: TransactionOptions, tx: TransactionResponse
): TransactionType {
): FormattedTransactionType {
if (tx.validated !== true || !isTransactionInRange(tx, options)) {
throw new errors.NotFoundError('Transaction not found')
}
@@ -79,7 +89,7 @@ function formatResponse(options: TransactionOptions, tx: TransactionResponse
}
function getTransaction(id: string, options: TransactionOptions = {}
): Promise<TransactionType> {
): Promise<FormattedTransactionType> {
validate.getTransaction({id, options})
const request = {

View File

@@ -4,12 +4,11 @@ const {computeTransactionHash} = require('ripple-hashes')
import * as utils from './utils'
import parseTransaction from './parse/transaction'
import getTransaction from './transaction'
import {validate, errors} from '../common'
import {Connection} from '../common'
import {TransactionType} from './transaction-types'
import {validate, errors, Connection} from '../common'
import {FormattedTransactionType} from '../transaction/types'
type TransactionsOptions = {
export type TransactionsOptions = {
start?: string,
limit?: number,
minLedgerVersion?: number,
@@ -20,10 +19,10 @@ type TransactionsOptions = {
counterparty?: string,
types?: Array<string>,
binary?: boolean,
startTx?: TransactionType
startTx?: FormattedTransactionType
}
type GetTransactionsResponse = Array<TransactionType>
export type GetTransactionsResponse = Array<FormattedTransactionType>
function parseBinaryTransaction(transaction) {
const tx = binary.decode(transaction.tx_blob)
@@ -43,7 +42,7 @@ function parseAccountTxTransaction(tx) {
{meta: _tx.meta, validated: _tx.validated}))
}
function counterpartyFilter(filters, tx: TransactionType) {
function counterpartyFilter(filters, tx: FormattedTransactionType) {
if (tx.address === filters.counterparty) {
return true
}
@@ -57,7 +56,7 @@ function counterpartyFilter(filters, tx: TransactionType) {
}
function transactionFilter(address: string, filters: TransactionsOptions,
tx: TransactionType
tx: FormattedTransactionType
) {
if (filters.excludeFailures && tx.outcome.result !== 'tesSUCCESS') {
return false
@@ -77,7 +76,9 @@ function transactionFilter(address: string, filters: TransactionsOptions,
return true
}
function orderFilter(options: TransactionsOptions, tx: TransactionType) {
function orderFilter(
options: TransactionsOptions, tx: FormattedTransactionType
) {
return !options.startTx || (options.earliestFirst ?
utils.compareTransactions(tx, options.startTx) > 0 :
utils.compareTransactions(tx, options.startTx) < 0)

View File

@@ -1,33 +0,0 @@
import {Memo} from '../common/types'
export type TrustLineSpecification = {
currency: string,
counterparty: string,
limit: string,
qualityIn?: number,
qualityOut?: number,
ripplingDisabled?: boolean,
authorized?: boolean,
frozen?: boolean,
memos?: Memo[]
}
export type Trustline = {
specification: TrustLineSpecification,
counterparty: {
limit: string,
ripplingDisabled?: boolean,
frozen?: boolean,
authorized?: boolean
},
state: {
balance: string
}
}
export type TrustlinesOptions = {
counterparty?: string,
currency?: string,
limit?: number,
ledgerVersion?: number
}

View File

@@ -1,53 +1,37 @@
import * as _ from 'lodash'
import * as utils from './utils'
import {validate} from '../common'
import {Connection} from '../common'
import parseAccountTrustline from './parse/account-trustline'
import {TrustlinesOptions, Trustline} from './trustlines-types'
import {RippleAPI} from '../api'
import {FormattedTrustline} from '../common/types/objects/trustlines'
type GetTrustlinesResponse = Array<Trustline>
interface GetAccountLinesResponse {
marker?: any,
results: Trustline[]
export type GetTrustlinesOptions = {
counterparty?: string,
currency?: string,
limit?: number,
ledgerVersion?: number
}
function currencyFilter(currency: string, trustline: Trustline) {
function currencyFilter(currency: string, trustline: FormattedTrustline) {
return currency === null || trustline.specification.currency === currency
}
function formatResponse(options: TrustlinesOptions, data: any) {
return {
marker: data.marker,
results: data.lines.map(parseAccountTrustline)
.filter(_.partial(currencyFilter, options.currency || null))
}
}
function getAccountLines(connection: Connection, address: string,
ledgerVersion: number, options: TrustlinesOptions, marker: string,
limit: number
): Promise<GetAccountLinesResponse> {
const request = {
command: 'account_lines',
async function getTrustlines(
this: RippleAPI, address: string, options: GetTrustlinesOptions = {}
): Promise<FormattedTrustline[]> {
// 1. Validate
validate.getTrustlines({address, options})
const ledgerVersion = await this.getLedgerVersion()
// 2. Make Request
const responses = await this._requestAll('account_lines', {
account: address,
ledger_index: ledgerVersion,
marker: marker,
limit: utils.clamp(limit, 10, 400),
limit: options.limit,
peer: options.counterparty
}
return connection.request(request).then(_.partial(formatResponse, options))
}
function getTrustlines(address: string, options: TrustlinesOptions = {}
): Promise<GetTrustlinesResponse> {
validate.getTrustlines({address, options})
return this.getLedgerVersion().then(ledgerVersion => {
const getter = _.partial(getAccountLines, this.connection, address,
options.ledgerVersion || ledgerVersion, options)
return utils.getRecursive(getter, options.limit)
})
// 3. Return Formatted Response
const trustlines = _.flatMap(responses, response => response.lines)
return trustlines.map(parseAccountTrustline).filter(trustline => {
return currencyFilter(options.currency || null, trustline)
})
}

View File

@@ -1,49 +0,0 @@
import {Amount} from '../common/types'
export type OrdersOptions = {
limit?: number,
ledgerVersion?: number
}
export type OrderSpecification = {
direction: string,
quantity: Amount,
totalPrice: Amount,
immediateOrCancel?: boolean,
fillOrKill?: boolean,
// 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
}
export type Order = {
specification: OrderSpecification,
properties: {
maker: string,
sequence: number,
makerExchangeRate: string
}
}
export type GetLedger = {
// TODO: properties in type don't match response object. Fix!
// accepted: boolean,
// closed: boolean,
stateHash: string,
closeTime: string,
closeTimeResolution: number,
closeFlags: number,
ledgerHash: string,
ledgerVersion: number,
parentLedgerHash: string,
parentCloseTime: string,
totalDrops: string,
transactionHash: string,
transactions?: Array<Object>,
rawTransactions?: string,
transactionHashes?: Array<string>,
rawState?: string,
stateHashes?: Array<string>
}

Some files were not shown because too many files have changed in this diff Show More