Compare commits

...

557 Commits

Author SHA1 Message Date
Elliot Lee
f785605db8 Release 1.0.1 2018-09-27 19:01:38 -07:00
Elliot Lee
01ad30ab07 Fix typos in ledger_entries.ts 2018-09-19 14:24:02 -07:00
Cory Perkins
e08d507462 Add remaining LedgerEntry types (#943)
* Replaced the union with 'any' in the LedgerEntry type
* Added DepositPreauthLedgerEntry (new in rippled 1.1.0)
2018-09-19 14:21:52 -07:00
wudanjs
4c23bd5ad3 Include memos when parsing trustlines (#949) 2018-09-19 14:17:38 -07:00
Scott M Sunarto
b15abd5376 Update server regex to accommodate UDS (#944) 2018-09-18 11:47:46 -07:00
Elliot Lee
79971f906b Update release notes 2018-09-11 18:45:52 -07:00
Elliot Lee
9eec98778f Expose validation methods (#932)
Merge branch 'movitto-expose_validation_methods' into develop
2018-09-11 18:33:55 -07:00
Elliot Lee
dcd0e14142 Add test of deriveKeypair with ed25519 secret 2018-09-11 18:33:07 -07:00
Elliot Lee
cfcbc9aab7 Update checksums for 1.0.0 2018-09-10 14:52:14 -07:00
Mo Morsi
a80de5658a Move deriveKeypair and deriveAddress to offline module 2018-09-09 09:39:25 -04:00
Mo Morsi
34215eb309 Add docs for newly exposed API methods 2018-09-09 09:39:25 -04:00
Mo Morsi
9458005d7f Add tests for newly exposed API methods 2018-09-09 09:39:25 -04:00
Mo Morsi
5f36df0172 Expose deriveKeypair, deriveAddress, isValidAddress, and isValidSecret to the public API 2018-09-09 09:39:25 -04:00
Elliot Lee
3ff4929a49 Fix PendingLedgerVersionError message and export FormattedTransactionType (#941) 2018-09-04 18:31:24 -07:00
Elliot Lee
4bea69d647 Release 1.0.0 2018-08-30 14:30:57 -07:00
Elliot Lee
09541dae86 docs: rippled APIs use issuer 2018-08-30 14:12:45 -07:00
Elliot Lee
bcbcc53c87 No `--coverage' option anymore with nyc
See https://github.com/istanbuljs/nyc
2018-08-30 13:41:52 -07:00
Elliot Lee
76f120bec9 Merge branch 'getLedger-includeRawTransaction-2' into develop 2018-08-30 13:30:18 -07:00
Elliot Lee
f8bf28876d if statements must be braced 2018-08-30 13:29:50 -07:00
wilsonianb
b03795df09 Add hidden computeTreeHashes option 2018-08-30 13:29:50 -07:00
Elliot Lee
dbe20d6574 getLedger: include raw transaction with each transaction
computeLedgerHash: support new getLedger response by using
rawTransaction

BREAKING CHANGES:

* Remove the `rawTransactions` field and replace it with a new `rawTransaction` field in each transaction.
* Rename the `metaData` field (in each raw transaction) to `meta` (for consistency with rippled's `tx` method).
* Add `ledger_index` to each raw transaction.
2018-08-30 13:28:52 -07:00
Elliot Lee
0550fab73e Update escrowCreation error message and docs (#934)
Fix #933
2018-08-29 19:03:33 -07:00
Elliot Lee
3f2d9d198e computeLedgerHash - add requireRawTransactions option 2018-08-28 17:31:12 -07:00
Elliot Lee
b9c953fce6 Fix getPaths (#930)
* getPaths:
  * Filter paths correctly
  * Use correct value when XRP is the destination currency
2018-08-23 17:37:02 -07:00
Elliot Lee
181cfd69de Prevent 'amount' from being misinterpreted (#924)
The 'amount' field should almost never be used.
With partial payments, the field can show an amount that is
significantly less than the amount that the transaction actually
delivered. This change sets amount to 0 XRP when it may be misleading.

This change omits the `amount` when parsing payment transactions.
See `HISTORY.md` for recommended alternatives.
2018-08-23 16:17:23 -07:00
Elliot Lee
569766b8f8 Rename json schemas (#931)
Rename files for consistency with their titles:

* Rename amount-base to amountbase
* Rename tx-hash to transaction-hash
* Rename id to transactionHash
* Rename objects/settings.json to objects/settings-plus-memos.json
* Rename ledgerversion to ledger-version
2018-08-22 14:41:41 -07:00
Elliot Lee
53a232ebdc Update docs 2018-08-14 20:05:50 -07:00
Elliot Lee
4c9a2ff538 Improve Order docs. Fix #776 2018-08-14 19:27:50 -07:00
Elliot Lee
dc623cd049 Release 1.0.0-beta.5 2018-08-11 01:38:36 -07:00
Elliot Lee
7cd517268b Fix error TS2307: Cannot find module 2018-08-11 01:35:47 -07:00
Elliot Lee
2438295e70 Release 1.0.0-beta.4 2018-08-10 14:58:19 -07:00
Elliot Lee
f5e1a4a588 Revert "Expose validation methods in public api"
This reverts commit 9e9a0a7d9b.

We should move methods like deriveKeypair and deriveAddress
off of the schemaValidator object.
2018-08-10 14:54:01 -07:00
Mo Morsi
9e9a0a7d9b Expose validation methods in public api
Updated to fix tests
2018-08-06 16:09:04 -07:00
Elliot Lee
1c68283d1e ES6: omit property value since it matches the variable name 2018-07-28 00:42:37 -07:00
Elliot Lee
28796d37cb Update TypeScript to 2.9.2 2018-07-28 00:18:58 -07:00
Elliot Lee
067bc48d4e Add prepareTransaction() (#898)
* Export iso8601ToRippleTime(), txFlags, convertStringToHex()

* Fix a bug that caused fees exceeding 999 to throw an error

e.g. '1,000' would not be recognized as a valid number.
To use 6 decimal places, toFixed should be used instead of toFormat.
2018-07-26 12:24:29 -07:00
Fred K. Schott
b94698df0b Update some API methods to use api.request() internally (#896)
* use any instead of object
2018-07-26 12:23:07 -07:00
Elliot Lee
4f40b5cb6d Update README.md - How to build ripple-lib (#837) 2018-07-25 12:09:55 -07:00
Elliot Lee
14704eee6b Add more tests of getFee (#897) 2018-07-25 01:53:27 -07:00
Elliot Lee
860f6a6cd8 Release 1.0.0-beta.3 2018-07-17 22:39:00 -07:00
Elliot Lee
7a928804ec feat: add payment channel details to tx (2) (#920)
* Bump transactionparser to v0.7.1 and update output schema
* yarn docgen for required `threshold` and `weights`
2018-07-17 22:22:07 -07:00
adrianhopebailie
14444bea3f feat: add payment channel details to tx 2018-07-17 22:20:47 -07:00
Rome Reginelli
47a139fdff Fix text/plain MIMETYPE in examples with memos (#914) 2018-07-03 17:18:46 -07:00
Brandon Wilson
4e30b9b2fa Require threshold and weights in signers settings (#909)
Fixes #908
2018-07-02 16:27:03 -07:00
Elliot Lee
2112d4c0b3 Round XRP fee to 6 decimal places (#912)
* Round XRP fee to 6 decimal places

Fix #911
2018-06-28 17:59:00 -07:00
Elliot Lee
1d1132b7fa Release 1.0.0-beta.2 2018-06-08 08:11:00 -07:00
Elliot Lee
e07fa11923 Maximum fee values (#902)
* Add maxFeeXRP (default 2 XRP) as an optional RippleAPI constructor parameter
  - No calculated or specified fee can exceed this value
  - If the fee exceeds 2 XRP, throw a ValidationError
* sign() - throw ValidationError when Fee exceeds maxFeeXRP
* Document getFee parameters
* Explain new fee limits in HISTORY.md
* Deprecate `maxFee`
2018-06-07 23:29:24 -07:00
Elliot Lee
7c92adbf45 Release 1.0.0-beta.1 2018-05-24 20:13:26 -07:00
Elliot Lee
d55aa2339f Improve docs (raw order data) 2018-05-24 20:02:45 -07:00
Elliot Lee
95e39153da Bump node version to v8 2018-05-24 19:29:09 -07:00
Daniel Davis
65d8260908 Updated yarn command (#900)
`yarn install` deprecated in favor of `yarn add`
2018-05-23 23:05:09 -07:00
Elliot Lee
1aa9feda71 Allow specifying amounts in drops (#892)
* Accept "drops" in lieu of "XRP"
* Export xrpToDrops() and dropsToXrp()
* Throw our own validation errors instead of BigNumber Errors
2018-05-21 13:19:18 -07:00
Fred K. Schott
2e5b435b11 add server_info request typing (#895) 2018-05-17 16:37:17 -07:00
Elliot Lee
54f12862dc Improve errors (#893)
- `RippledError`: Include the full response from the `rippled` server.
- A new test ensures correct behavior when `streams` is not an array.
- `NotConnectedError` may be thrown with a different message than before.
2018-05-12 09:38:49 -07:00
Elliot Lee
226ef862ae Link to mailing lists 2018-05-10 16:25:05 -07:00
Elliot Lee
4a0d675726 Release 1.0.0-beta.0 2018-05-10 15:56:23 -07:00
Elliot Lee
b2b6715ac0 Add request(), hasNextPage(), and requestNextPage() (#887)
* Add support for all rippled APIs, including subscriptions.
* Add support for arbitrary stream message types.
* Note that rippled APIs take amounts in drops.
* request() will be available in ripple-lib version 1.0.0+
2018-05-10 15:43:56 -07:00
Elliot Lee
823d93b86c Add checksums for 0.22.0 2018-05-10 15:26:43 -07:00
Elliot Lee
7a42db99c9 Bump version to 0.22.0 2018-05-10 00:33:20 -07:00
Elliot Lee
f28ec27614 getOrderbook - return raw order data (#886)
Fix #799
2018-05-08 15:05:41 -07:00
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
Elliot Lee
994a6d5e76 Add SHA-256 checksums for 0.18.0 release 2018-01-25 15:36:02 -08:00
Elliot Lee
3db72716b4 HISTORY.md - Add release date for 0.18.0 2018-01-25 15:30:02 -08:00
Elliot Lee
6d39e072f8 Docs: getFee() returns a string 2018-01-23 16:13:27 -08:00
Elliot Lee
b7d636d157 Rerun docgen to update docs 2018-01-23 16:11:35 -08:00
Elliot Lee
e8ac4f3d40 Set PublicKey type to string 2018-01-23 16:08:40 -08:00
Elliot Lee
ae2ccd9887 Add SHA-256 checksums 2018-01-23 15:24:18 -08:00
Elliot Lee
4fff85096c Bump version to 0.18.0 and update HISTORY.md 2018-01-17 16:03:57 -08:00
Elliot Lee
b4d8684740 Update escrow creation response fixture
- Request fixture was changed by #820
- Add an ExecuteAfter (aka FinishAfter) timestamp
2018-01-17 15:50:34 -08:00
Fred K. Schott
d3fb4b6260 Add TypeScript linting (#827)
* add tslint, create tslint.json ruleset from .eslintrc

* remove leftover rules

* fix up meta files
2018-01-17 14:41:24 -08:00
Nicolás López Jullian
19eaedf50d Change yarn install to yarn add 2018-01-16 23:18:17 -08:00
Elliot Lee
c56e6a6c08 Update yarn.lock 2018-01-16 23:16:22 -08:00
Fred K. Schott
01ecfb0a07 update istanbul to nyc (their new cli) to get typescript coverage 2018-01-11 17:20:44 -08:00
Elliot Lee
e1630e1693 HISTORY - Add SHA checksums for 0.17.9 2017-12-29 01:52:24 -08:00
Elliot Lee
526d87c1fc Update HISTORY.md 2017-12-24 00:44:14 -08:00
Fred K. Schott
8204f6c648 Convert from Flow to Typescript (#816)
* convert to typescript
* add docs for custom node typing
* update webpack, gulpfile
2017-12-24 00:39:18 -08:00
Rome Reginelli
5979ff6197 Merge pull request #820 from mDuo13/fix-escrow-example
[Docs] Improve escrow creation example to have ExecuteAfter date
2017-12-20 12:15:24 -08:00
mDuo13
d22828b222 [Docs] Improve escrow creation example to have ExecuteAfter date 2017-12-18 10:23:54 -08:00
Fred K. Schott
7e5b9948a8 convert common.js modules to new standard esm module syntax (#815) 2017-12-04 11:21:56 -08:00
Fred K. Schott
7ece43e2e2 fix whitespace (lint errors) (#813) 2017-11-27 10:54:40 -08:00
Fred K. Schott
f90617eac4 fix flow type errors (#811) 2017-11-21 16:52:48 -08:00
Fred K. Schott
2469fb2307 Update package.json 2017-11-16 14:37:46 -08:00
Fred K. Schott
a051e6fd71 fix and update flow to get typechecker running again 2017-11-16 14:37:46 -08:00
Elliot Lee
cabe029861 Release 0.17.9 2017-11-14 13:45:55 -08:00
Elliot Lee
1ac4ad2076 Update HISTORY.md for 0.17.9 2017-11-14 13:41:53 -08:00
Fred K. Schott
44119ddf2d remove unneccessary double-polyfills from runtime 2017-11-12 23:40:29 -08:00
Fred K. Schott
567036f382 fix lint errors and configure eslintrc to automatically work /w tooling 2017-11-12 12:46:50 -08:00
Elliot Lee
27aa0247e7 yarn.lock: Update ripple-keypairs to 0.10.1 2017-11-10 15:22:54 -08:00
Elliot Lee
0fc10b302f Update ripple-keypairs to 0.10.1 (#805) 2017-11-10 15:21:57 -08:00
Elliot Lee
0bc51a869d Merge pull request #786 from ripple/escrow-execution-ValidationError
escrow-execution - Add reference to ValidationError
2017-11-10 14:57:38 -08:00
Elliot Lee
a3dff0dcf7 Update HISTORY.md 2017-11-08 22:51:53 -08:00
Elliot Lee
048fc7ce71 Merge branch 'bsclifton-develop' into develop 2017-11-08 22:49:58 -08:00
Elliot Lee
6265e81afb Update yarn.lock for ws 3.3.1 2017-11-08 22:49:01 -08:00
Brian Clifton
38ca96a938 Update ws dependency >= 3.3.1 per https://nodesecurity.io/advisories/550 2017-11-08 21:42:23 -07:00
wilsonianb
8ed5f764fa Add missing condition or fulfillment test 2017-11-06 13:49:38 -06:00
Elliot Lee
227ea82a29 escrow-execution - Add reference to ValidationError 2017-11-06 11:08:06 -08:00
Elliot Lee
0e2a5e36c6 Add 0.17.8 release date 2017-11-06 10:13:23 -08:00
Elliot Lee
332b656860 Merge pull request #802 from ripple/update-bignumber
Update bignumber.js, ripple-hashes, ripple-lib-transactionparser
2017-11-06 08:58:27 -08:00
Elliot Lee
0230b963c1 Update HISTORY.md 2017-11-06 08:54:49 -08:00
Waldir Pimenta
48e2ea9ff2 LICENSE: add title (#803) 2017-11-04 18:18:55 -07:00
Elliot Lee
b6f1394c61 Update HISTORY.md 2017-11-03 23:44:17 -07:00
Elliot Lee
560e43b1a6 Update scripts/ci.sh to use yarn 2017-11-03 23:43:33 -07:00
Elliot Lee
cc1ab7ae97 Update references of npm to yarn 2017-11-03 15:30:41 -07:00
Elliot Lee
4886561f7d Add yarn lockfile
Use yarn to ensure that we always get the same dependencies each time
2017-11-03 14:20:00 -07:00
Elliot Lee
658d8a182e Update bignumber.js, ripple-hashes, ripple-lib-transactionparser 2017-11-03 14:20:00 -07:00
wilsonianb
2a90f9b134 Include signers in getSettings 2017-10-10 19:10:26 -05:00
Elliot Lee
f42dafd304 Merge branch 'update-lodash' into develop 2017-09-27 15:47:51 -07:00
Elliot Lee
ec2100094a Docs: Specify Node 6.11.3
- Add .nvmrc and update HISTORY.md
2017-09-27 15:45:50 -07:00
Elliot Lee
ecd6347859 Update to lodash 4
- Update ripple-lib-transactionparser
2017-09-27 10:25:53 -07:00
Elliot Lee
ab17b19ff0 Update for CircleCI
- circle.yml - use node 6
- Fix eslint errors
- Update coveralls and add path to babel
2017-09-27 10:25:08 -07:00
Elliot Lee
a9e5ac6290 Fix typos
Thanks @seelabs
2017-09-06 23:53:20 -07:00
Elliot Lee
4974f73f26 Clean up release history
- Fix some typos
- Improve consistency of formatting
2017-09-06 00:55:26 -07:00
Rome Reginelli
e6d71471e2 Merge pull request #791 from ripple/rr-xrp-ledger-rebranding
Fix case-sensitive broken link for preparePaymentChannelClaim
2017-09-01 15:16:58 -07:00
mDuo13
50db68dff7 Fix case-sensitive broken link for preparePaymentChannelClaim 2017-09-01 15:12:58 -07:00
Rome Reginelli
c8eb5b6a70 Merge pull request #790 from ripple/rr-xrp-ledger-rebranding
Fix 'Paymment' typo
2017-09-01 15:06:11 -07:00
mDuo13
c61a15e4f3 Fix 'Paymment' typo 2017-09-01 14:50:02 -07:00
Rome Reginelli
c151ff2d66 Merge pull request #788 from ripple/rr-xrp-ledger-rebranding
Docs: fix broken links
2017-09-01 14:45:56 -07:00
mDuo13
393b2f9d78 Docs: fix broken links 2017-09-01 12:45:03 -07:00
Rome Reginelli
bf36cf03d6 Merge pull request #785 from ripple/rr-xrp-ledger-rebranding
Rebrand 'Ripple Consensus Ledger' to 'XRP Ledger'
2017-08-31 14:47:52 -07:00
mDuo13
d3332e0db9 README updates for rebranding 2017-07-31 17:17:30 -07:00
mDuo13
ed62b20645 Rebrand 'Ripple Consensus Ledger' to 'XRP Ledger' 2017-07-31 14:05:40 -07:00
Rome Reginelli
5f2c5e27f1 Merge pull request #771 from xasos/develop
Fix readme syntax
2017-07-31 11:53:20 -07:00
Abraham Tom
ff702b85e2 Merge pull request #760 from mDuo13/doc_nodever_update
Docs: Require Node 6.9.0, update boilerplate to avoid destructuring assign
2017-07-28 12:04:23 -07:00
Niraj Pant
f91eb68556 Fix readme syntax 2017-06-09 11:12:42 -07:00
mDuo13
469fefee92 Docs: Require Node 6.9.0, update boilerplate to avoid destructuring assign 2017-05-09 15:51:45 -07:00
Matthew Fettig
de47263087 0.17.7 2017-05-08 15:10:26 -07:00
Matthew Fettig
3b9679a673 Merge pull request #759 from bachase/jsonschema
Switch to jsonschema
2017-05-08 15:09:04 -07:00
Brad Chase
f175966816 Make http server dev only 2017-05-05 14:59:15 -04:00
Brad Chase
f1f5364d07 Switch to jsonschema 2017-05-03 20:34:24 -04:00
Matthew Fettig
1b8b0c76ac Merge pull request #757 from ripple/fix-condition
Fix escrow condition and fulfillment descriptions
2017-04-13 19:39:27 -07:00
Matthew Fettig
1a8096ab18 Merge pull request #756 from ripple/sign-claim
Payment channel lookup and claim signing & verification
2017-04-13 19:38:45 -07:00
wilsonianb
f177771c67 Update ripple-binary-codec version 2017-04-13 17:39:27 -07:00
wilsonianb
081fcbfa32 Fix escrow condition and fulfillment descriptions 2017-04-12 15:16:01 -07:00
wilsonianb
0a5e4e2155 Update docs for escrow and paychan activation 2017-04-07 13:04:32 -07:00
wilsonianb
19eb88a00e Add getPaymentChannel 2017-04-07 13:04:21 -07:00
wilsonianb
c8f2967de0 Sign and verify payment channel claim 2017-04-07 13:01:58 -07:00
Matthew Fettig
b5564330f6 Merge pull request #755 from ripple/develop
0.17.6
2017-03-30 21:49:59 -07:00
Matthew Fettig
43ccb83f73 0.17.6 2017-03-30 21:33:09 -07:00
Brandon Wilson
e2d92126c0 Merge pull request #745 from ripple/feat/bs-paychan
Add transactions for payment channels
2017-03-30 21:26:13 -07:00
Ben Sharafian
8c8eef45d5 Add docs for payment channels 2017-03-30 21:19:31 -07:00
Ben Sharafian
a574e1158a Add transactions for payment channels 2017-03-30 21:19:31 -07:00
Matthew Fettig
af687a6aed Merge pull request #754 from ripple/escrowcreate
Simplify EscrowCreate parameters
2017-03-30 21:18:33 -07:00
wilsonianb
016e82ab5d Simplify EscrowCreate parameters 2017-03-30 19:01:58 -07:00
Matthew Fettig
f300a412d7 Merge pull request #753 from ripple/feature/dependancy-update
update ripple-hashes and ripple-binary-codec
2017-03-30 15:21:27 -07:00
Matthew Fettig
75e2249cf3 update ripple-hashes and ripple-binary-codec 2017-03-30 15:12:09 -07:00
Matthew Fettig
1942bcb971 Merge pull request #752 from ripple/rm-escrow-iou
Disallow escrow of IOU
2017-03-30 14:53:29 -07:00
wilsonianb
9393adf66f Disallow escrow of IOU 2017-03-30 10:10:00 -07:00
Matthew Fettig
917aae9bf3 Merge pull request #751 from ripple/feature/escrow
Replace suspended payments with escrow
2017-03-29 17:38:32 -07:00
wilsonianb
da36457d5c Update condition and fulfillment for escrow
Calculate escrowFinish fulfillment fee
2017-03-29 10:27:34 -07:00
wilsonianb
15a0ededc8 Replace suspended payments with escrow 2017-03-24 12:35:22 -07:00
wilsonianb
68d7864f93 Rename suspended payment files as escrow 2017-03-24 12:32:17 -07:00
Matthew Fettig
1eddbf995f 0.17.5 2017-03-24 12:31:10 -07:00
Matthew Fettig
592385ac73 Merge pull request #750 from ripple/feature/dependancy-update
update ripple-binary-codec to version 0.1.8
2017-03-24 12:26:35 -07:00
Matthew Fettig
56d626f5b1 Merge pull request #744 from choiip/develop
Added .json in missing require()
2017-03-24 10:53:42 -07:00
Matthew Fettig
7a14300409 update ripple-binary-codec to version 0.1.8 2017-03-24 10:40:19 -07:00
alex.choi
30fa8d658e Added .json in missing require() 2017-02-15 18:51:49 +08:00
Chris Clark
c0101cb5e7 Merge pull request #740 from wilsonianb/shamapv2
Check SHAMapV2 ledger close flag
2016-12-02 12:31:46 -08:00
wilsonianb
fd640cd65e Check SHAMapV2 ledger close flag 2016-12-02 12:25:32 -08:00
Chris Clark
11528eff92 Merge pull request #741 from wilsonianb/fix-lint-errors
Fix eslint errors
2016-12-02 11:55:21 -08:00
wilsonianb
3c9175459d Fix eslint errors 2016-12-02 08:16:16 -08:00
Chris Clark
bd4e0e01e2 Merge pull request #739 from clark800/develop
Update ripple-binary-codec and ripple-hashes dependencies
2016-11-30 14:59:52 -08:00
Chris Clark
cfcf6e473c Update ripple-binary-codec and ripple-hashes dependencies 2016-11-30 14:49:40 -08:00
Chris Clark
50c6af3158 Merge pull request #734 from clark800/bump-codec
Bump version to 0.17.3 and bump ripple-binary-codec to 0.1.4
2016-09-29 11:24:04 -07:00
Chris Clark
1d4310cd3a Disable flow type checking in CircleCI 2016-09-29 11:19:46 -07:00
Chris Clark
2191596e68 Bump version to 0.17.3 and bump ripple-binary-codec to 0.1.4 2016-09-29 11:19:32 -07:00
Chris Clark
acf8f87a88 Merge pull request #727 from clark800/order-seq
Add orderToReplace option
2016-08-01 14:34:27 -07:00
Chris Clark
cfac146620 Add orderToReplace option 2016-08-01 14:27:08 -07:00
Chris Clark
f3234ad853 Merge pull request #726 from clark800/doc-typos
Fix typos in docs
2016-08-01 14:24:22 -07:00
Chris Clark
b65fee3d85 Merge pull request #725 from shekenahglory/develop
update parseDeliveredAmount for cases where delivered_amount is not p…
2016-08-01 14:21:43 -07:00
Chris Clark
82b294bc7d Update flow 2016-08-01 14:13:00 -07:00
Chris Clark
2a58573823 Fix typos in docs 2016-08-01 11:53:46 -07:00
Matthew Fettig
a96f71b7fd fix missing deliveredAmount data from getLedger requests 2016-07-19 21:29:50 -07:00
Chris Clark
077f4a4c79 Merge pull request #723 from clark800/fix-coverage
Fix code coverage tool
2016-07-08 15:04:38 -07:00
Chris Clark
9a495467fb Disable sauce tests because they usually timeout 2016-07-08 11:45:27 -07:00
Chris Clark
db2e62b219 Fix code coverage tool 2016-07-08 11:28:10 -07:00
Alan Cohen
2fafa493a2 Version 0.17.2 2016-06-24 10:59:04 -07:00
Alan Cohen
7617c3005c Merge pull request #721 from mDuo13/fix_transferrate_docs
[DOC] fix transferRate description
2016-06-22 11:13:14 -07:00
mDuo13
5cdbb71277 [DOC] fix transferRate description 2016-06-16 15:11:08 -07:00
Chris Clark
f9339c36bf Merge pull request #720 from clark800/update-binary-codec
0.17.1
2016-05-11 18:20:29 -07:00
Chris Clark
67dc57e9d0 Disable PhantomJS tests due to issue downloading from bitbucket 2016-05-11 17:49:57 -07:00
Chris Clark
757f3190d1 0.17.1 2016-05-11 17:49:54 -07:00
Chris Clark
0d94a15ee7 0.17.0 2016-05-05 18:35:13 -07:00
Chris Clark
7f1c80da1b Merge pull request #718 from clark800/pseudo
Add support for parsing SetFee and EnableAmendment pseudo-transactions
2016-05-05 16:15:32 -07:00
Chris Clark
f74e11bce0 Add support for parsing SetFee and EnableAmendment pseudo-transactions 2016-05-05 15:37:23 -07:00
Chris Clark
d4c843e8e3 Merge pull request #714 from darkdarkdragon/remove_tej
[FIX] remove check for `tej` class of errors.
2016-04-05 15:15:42 -07:00
Ivan Tivonenko
bae190b282 [FIX] remove check for tej class of errors. 2016-04-05 23:50:41 +03:00
Chris Clark
d2cbd70da8 Merge pull request #712 from darkdarkdragon/reconnect_fix_browser
[FIX] on reconnect wait for server to be synced
2016-03-30 15:50:58 -07:00
Ivan Tivonenko
5da78ce583 [FIX] handle websocket errors in browsers
emit not RippledNotInitializedError if server doesn't have any
completed ledgers on connect
2016-03-31 00:46:00 +03:00
Chris Clark
14bbe3e30b Merge pull request #680 from ripple/sublimator-patch-1
Fix typo in docs
2016-03-29 10:27:34 -07:00
Nicholas Dudfield
e52e2bbc68 Fix IOU Amount precision related typo in docs 2016-03-29 13:51:30 +07:00
Alan Cohen
b56752e45b 0.16.10 2016-03-24 14:52:36 -07:00
Chris Clark
4632f511ab Merge pull request #711 from darkdarkdragon/reconnect_fix2
[FIX] on connect return error if server doesn't have validated ledgers
2016-03-24 14:27:50 -07:00
Ivan Tivonenko
e17b6f172d [FIX] on connect return error if server doesn't have validated ledgers 2016-03-24 22:26:33 +02:00
Alan Cohen
eb04e878ba 0.16.9 2016-03-22 18:39:33 -07:00
Chris Clark
c71febd116 Merge pull request #709 from darkdarkdragon/reconnect_fix
Reconnection fix
2016-03-22 18:12:28 -07:00
Ivan Tivonenko
69c1ccbb6b [TASK] emit connected and disconnected events from api 2016-03-23 02:05:07 +02:00
Ivan Tivonenko
499b8c8d8b [FIX] fix multiple reconnections issue 2016-03-23 01:18:08 +02:00
Chris Clark
ea009f9a84 Merge pull request #708 from clark800/fix-maker-exchange-rate
Fix makerExchangeRate for getOrders when rippled provides quality
2016-03-22 14:14:23 -07:00
Chris Clark
dc784d4567 Fix makerExchangeRate for getOrders when rippled provides quality 2016-03-22 13:21:26 -07:00
Alan Cohen
9ffc8a2c0b Merge pull request #707 from ripple/fix/filter-source-amount
FIX: Filtering source_amount pathfind correctly
2016-03-21 14:48:37 -07:00
Alan Cohen
5b20fe573e FIX: Filtering source_amount pathfind correctly
Bug:

```js
api.connect().then(() => {
  const pathfind = {
    source: {
      address: USDCold,
      amount: {
        currency: 'USD',
        value: '1.00' // <<<< Rippled response has "1" not "1.00"
      }
    },
    destination: {
      address: EURCold,
      amount: {currency: 'EUR'}
    }
  };
  return api.getPaths(pathfind).then(paths => {
    console.log('PATHS: \n', JSON.stringify(paths, null, 2));
  });
}).catch(console.log);

```
2016-03-21 11:44:55 -07:00
Chris Clark
7e466bb80f Merge pull request #705 from darkdarkdragon/code_comment
[FIX] add small code comment
2016-03-15 12:14:05 -07:00
Ivan Tivonenko
1f8418b447 [FIX] add small code comment 2016-03-15 20:58:22 +02:00
Alan Cohen
ccfc57fc62 Merge pull request #704 from darkdarkdragon/fix_edge_test
[FIX] fix test hang in microsoft edge
2016-03-15 10:27:01 -07:00
Ivan Tivonenko
1d31fccd72 [FIX] fix test hang in microsoft edge 2016-03-15 05:04:47 +02:00
Alan Cohen
9ac1a89e48 0.16.8 2016-03-09 12:30:10 -08:00
Chris Clark
bfc0696324 Merge pull request #701 from h0vhannes/develop
Documentation fixes
2016-03-09 12:24:55 -08:00
Hovhannes Kuloghlyan
e33e782f9e [DOC] Fix transaction spelling in getTransaction description 2016-03-09 22:14:09 +04:00
Hovhannes Kuloghlyan
f2b591d1b2 [DOC] Fix transaction responses link in submit() description 2016-03-09 22:07:54 +04:00
Chris Clark
fe9af5153d Merge pull request #699 from darkdarkdragon/develop_connection_error
[FIX] fix connection error handling
2016-02-24 14:12:12 -08:00
Ivan Tivonenko
0dfdd0a601 [FIX] change eslint version to 2.1 2016-02-24 23:08:49 +02:00
Ivan Tivonenko
4acc42e1b6 [FIX] fix connection error handling
if connection to server can't be established, reject Promise of `connect()` method caller,
instead of throwing error event on base object.
2016-02-24 23:08:47 +02:00
Alan Cohen
7c9a179865 Merge pull request #698 from h0vhannes/develop
[FIX] Fix typo in PrepareTrustline description
2016-02-23 08:44:43 -07:00
Hovhannes Kuloghlyan
c6296a4918 [FIX] Modify PrepareTrustline doc source to pass tests 2016-02-23 16:45:32 +04:00
Hovhannes Kuloghlyan
cc399f1164 [FIX] Fix typo in PrepareTrustline description 2016-02-21 17:02:27 +03:00
Alan Cohen
e4ffb96646 Update version to 0.16.7 2016-02-12 11:38:51 -08:00
Chris Clark
8d34428dac Merge pull request #694 from lumberj/add-deliveredAmount
Add deliveredAmount to payment outcome
2016-02-12 11:25:01 -08:00
Alan Cohen
353637a0c0 Add TODO comment for fixing workaround for rippled bug 2016-02-12 10:56:35 -08:00
Alan Cohen
00713d8ec1 Update version to 0.16.6 2016-02-11 17:02:18 -08:00
Alan Cohen
d949881e9f Merge pull request #695 from lumberj/fix-typo
Fix typo in common/connection.js
2016-02-11 16:30:23 -08:00
Alan Cohen
5075441a69 Fix lint error 2016-02-11 13:39:35 -08:00
Alan Cohen
94a852cb8b Fix typo in common/connection.js 2016-02-11 13:36:12 -08:00
Alan Cohen
06f847c2d0 Fix lint errors 2016-02-10 19:45:51 -08:00
Alan Cohen
0c2f9d0e62 Add deliveredAmount to payment outcome
It is impossible to reliably compute the delivered amount from the metadata due
to fixed precision. If the partial payment flag is not set and the transaction
succeeded, the delivered amount should always be considered to be the amount
specified in the transaction.
2016-02-10 17:25:27 -08:00
Chris Clark
11ed6b124f Merge pull request #692 from darkdarkdragon/develop-minify
fixes for minified version
2016-02-08 17:22:14 -08:00
Ivan Tivonenko
8767fc0068 fixes for minified version test minified version in SauceLabs 2016-02-09 03:08:23 +02:00
Chris Clark
66b07623b0 Merge pull request #691 from darkdarkdragon/develop-sauce
add SauceLabs testing
2016-02-05 10:10:37 -08:00
Ivan Tivonenko
4f3635eef0 add SauceLabs testing 2016-02-05 07:59:34 +02:00
Chris Clark
f638833759 Merge pull request #686 from darkdarkdragon/develop-RLJS-565
switch from Babel 5 to Babel 6
2016-01-21 15:42:00 -08:00
Ivan Tivonenko
ab9d1936d9 fix reconnect error - in case of connection was unexpectedly closed before it was open,
resolve first promise that was returned from call to connect
2016-01-21 18:35:59 +02:00
Ivan Tivonenko
0fefb2bd2c do not pack lodash inside browser version 2016-01-16 01:12:48 +02:00
Ivan Tivonenko
6740eee495 combine with different transaction test
test for trying to sign already signed transaction
ignore http server in coverage
2016-01-16 01:12:46 +02:00
Ivan Tivonenko
aa6020e00d switch from Babel 5 to Babel 6
use of isparta for coverage reporting
2016-01-16 01:12:43 +02:00
Alan Cohen
7bfe4a6cd8 Update version to 0.16.5 2016-01-15 14:44:05 -08:00
Chris Clark
aa467681e4 Merge pull request #688 from lumberj/source-amount-paths
Filter insufficient source funds paths from pathfind results
2016-01-15 13:47:17 -08:00
Alan Cohen
6b8cd6151d Filter insufficient source funds paths from pathfind results
When pathfinding with source amount, we need to filter out paths where source
amount is not equal to the specified source amount. This is due to the behavior
of rippled when specifying a source amount during pathfinding.

Example:

 {
  "command": "ripple_path_find",
  "source_account": "rhFQQ4ATC6MDF9ghTq3qAoCsGbGtjnhcXF",
  "destination_account": "rp91GUd5R3Rk3ipqW7XBdtrUJcX8epzGyb",
  "destination_amount": {
    "currency": "EUR",
    "issuer": "rp91GUd5R3Rk3ipqW7XBdtrUJcX8epzGyb",
    "value": -1
  },
  "send_max": {
    "currency": "USD",
    "issuer": "rhFQQ4ATC6MDF9ghTq3qAoCsGbGtjnhcXF",
    "value": "1234567891"
  },
  "id": 2
}
{
  "id": 2,
  "result": {
    "alternatives": [
      {
        "destination_amount": {
          "currency": "EUR",
          "issuer": "rp91GUd5R3Rk3ipqW7XBdtrUJcX8epzGyb",
          "value": "3999889.62127857"
        },
        "paths_canonical": [],
        "paths_computed": [
          [
            {
              "account": "rcsxQxEqU2qquAKp3tBUJy8Z2t19ioQPJ",
              "type": 1,
              "type_hex": "0000000000000001"
            },
            {
              "currency": "EUR",
              "issuer": "rp91GUd5R3Rk3ipqW7XBdtrUJcX8epzGyb",
              "type": 48,
              "type_hex": "0000000000000030"
            }
          ]
        ],
        "source_amount": {
          "currency": "USD",
          "issuer": "rhFQQ4ATC6MDF9ghTq3qAoCsGbGtjnhcXF",
          "value": "4170759.906037564"
        }
      }
    ],
    "destination_account": "rp91GUd5R3Rk3ipqW7XBdtrUJcX8epzGyb",
    "destination_amount": {
      "currency": "EUR",
      "issuer": "rp91GUd5R3Rk3ipqW7XBdtrUJcX8epzGyb",
      "value": "-1"
    },
    "destination_currencies": [
      "EUR",
      "XRP"
    ],
    "full_reply": true,
    "id": 2,
    "source_account": "rhFQQ4ATC6MDF9ghTq3qAoCsGbGtjnhcXF",
    "status": "success"
  },
  "status": "success",
  "type": "response"
}
2016-01-15 13:38:57 -08:00
Chris Clark
0d6aaee12a Merge pull request #681 from darkdarkdragon/develop-RLJS-564
fix for browser
2016-01-13 11:31:14 -08:00
Ivan Tivonenko
dc03c6e0ac fix to work in browser
run unit tests and integration tests in PhantomJS
add JUnit reporter to unit test so CircleCI can show results
2016-01-13 07:11:39 +02:00
Alan Cohen
0f4d957d14 Update version to 0.16.4 2016-01-04 19:48:59 -08:00
Alan Cohen
71a13224a1 Merge branch 'develop' into release
* develop:
  Update ws to 1.0.1
  run integration tests using standalone server
  Add multisignature support
  Add sample code to cancel all orders for a specified account
  Remove references to browser support
  add check for windows eol on commit removes windows eols from some files
  Fix error on ledger subscription message without validated_ledgers
2016-01-04 19:47:24 -08:00
Alan Cohen
8097ed60ba Update version to 0.16.3 2016-01-04 19:45:47 -08:00
Alan Cohen
408bb74214 Merge pull request #682 from lumberj/update-ws
Update ws to 1.0.1
2016-01-04 19:12:11 -08:00
Alan Cohen
9433b43873 Update ws to 1.0.1
Also, addresses remote memory disclosure vulnerability
https://nodesecurity.io/advisories/67
2016-01-04 19:06:30 -08:00
Chris Clark
896bf48c79 Merge pull request #672 from darkdarkdragon/develop-RLJS-558
testing circleci standalone integration
2015-12-18 16:11:13 -08:00
Ivan Tivonenko
3dd21a7e11 run integration tests using standalone server 2015-12-19 02:04:05 +02:00
Chris Clark
ed79a04018 Merge pull request #679 from clark800/multisign
Add multisignature support
2015-12-17 13:27:52 -08:00
Chris Clark
ebfe20defb Add multisignature support 2015-12-17 11:45:08 -08:00
Chris Clark
28b148348d Merge pull request #678 from clark800/cancel-all
Add sample code to cancel all orders for a specified account
2015-12-16 12:05:09 -08:00
Chris Clark
fe099f2c8b Add sample code to cancel all orders for a specified account 2015-12-16 11:40:39 -08:00
Chris Clark
107c8c9f0f Merge pull request #677 from lumberj/no-browser
Remove references to browser support
2015-12-16 11:35:33 -08:00
Alan Cohen
39e818b3e5 Remove references to browser support 2015-12-16 10:34:57 -08:00
Chris Clark
588ffa3d5c Merge pull request #674 from darkdarkdragon/develop-eol
add check for windows eol
2015-12-14 12:57:57 -08:00
Ivan Tivonenko
691e4dd114 add check for windows eol on commit
removes windows eols from some files
2015-12-14 22:15:30 +02:00
Chris Clark
55bc42725f Merge pull request #675 from clark800/fix-validated-ledgers
Fix error on ledger subscription message without validated_ledgers
2015-12-14 11:30:35 -08:00
Chris Clark
cce55b9361 Fix error on ledger subscription message without validated_ledgers 2015-12-14 11:07:58 -08:00
Chris Clark
c23c6e4fc9 Bump version to 0.16.2 2015-12-10 14:41:45 -08:00
Chris Clark
afdd60efe8 Merge pull request #671 from clark800/bump-binary
Bump ripple-binary-codec dependency version to 0.1.1 to fix issue wit…
2015-12-10 14:38:11 -08:00
Chris Clark
8f6ea573ff Bump ripple-binary-codec dependency version to 0.1.1 to fix issue with computeLedgerHash for transactions with DeliverMin 2015-12-10 14:29:28 -08:00
Alan Cohen
3271b544ef Bump version to 0.16.1 2015-12-09 16:51:26 -08:00
Alan Cohen
6e83130754 Merge pull request #669 from lumberj/fix-assertdiff
FIX: Use assert not assert-diff
2015-12-09 16:49:36 -08:00
Alan Cohen
f6ebe32519 FIX: Use assert not assert-diff 2015-12-09 16:45:08 -08:00
Chris Clark
3caed3c761 Bump version to 0.16.0 2015-12-09 13:17:04 -08:00
Chris Clark
ce1c55427a Merge pull request #668 from clark800/fix-ws-error
BREAKING CHANGE: Change error event format and fix crash due to error event on websocket
2015-12-09 13:06:45 -08:00
Chris Clark
9cd72595f0 BREAKING CHANGE: Change error event format and fix crash due to error event on websocket 2015-12-09 12:56:45 -08:00
Chris Clark
ad1d3e135f Merge pull request #663 from darkdarkdragon/develop-http-server
http server example
2015-12-09 11:15:52 -08:00
Ivan Tivonenko
76866ab901 http server example
allows to use both positional and named parameters
2015-12-09 21:00:47 +02:00
Chris Clark
20b647dfbf Merge pull request #667 from clark800/fix-server-info
BREAKING CHANGE: Fix types of XRP values in getServerInfo response
2015-12-07 17:03:09 -08:00
Chris Clark
99d08065e4 BREAKING CHANGE: Fix types of XRP values in getServerInfo response 2015-12-07 16:47:56 -08:00
Chris Clark
261fba3d21 Merge pull request #666 from clark800/fix-deliver-min
Fix DeliverMin value when specifying minAmount
2015-12-04 15:35:30 -08:00
Chris Clark
e1d9de7b1f Fix DeliverMin value when specifying minAmount 2015-12-04 15:18:03 -08:00
Chris Clark
391b2f3622 Merge pull request #665 from clark800/fix-quality
Fix parsing of quality for getTrustlines
2015-12-04 13:55:46 -08:00
Chris Clark
86ff315ef2 Fix parsing of quality for getTrustlines 2015-12-04 13:40:59 -08:00
Chris Clark
8d8a850864 Merge pull request #662 from lumberj/doc-fix
getFee returns a string not float
2015-12-02 13:32:11 -08:00
Alan Cohen
7bf2da6014 getFee returns a string not float
> api.connect().then(() => api.getFee().then(fee => console.log(typeof fee)));
> string
2015-12-02 13:17:35 -08:00
Chris Clark
7eae3ce709 Merge pull request #661 from clark800/client-cert
Add support for client certificates
2015-11-30 16:48:52 -08:00
Chris Clark
5f5e48e414 Add support for client certificates 2015-11-30 16:26:27 -08:00
Chris Clark
4f6a37f7b1 Merge pull request #660 from clark800/null-max
Allow setting maxLedgerVersion to null to specify no maximum
2015-11-30 16:13:41 -08:00
Chris Clark
82613e7e8b Allow setting maxLedgerVersion to null to specify no maximum 2015-11-30 15:52:36 -08:00
Chris Clark
588aa382a1 Merge pull request #659 from clark800/doc-fixes
Fix generateAddress docs and add error event listener to boilerplate
2015-11-30 15:32:02 -08:00
Chris Clark
809d981987 Fix generateAddress docs and add error event listener to boilerplate 2015-11-30 15:16:37 -08:00
Chris Clark
cfc21fde8c Bump version to 0.15.2 2015-11-25 13:13:53 -08:00
Geert Weening
5c06ef547b Merge pull request #658 from clark800/fix-proxy-auth
Fix support for proxy credentials in proxy URL and fix error when the…
2015-11-25 13:11:42 -08:00
Chris Clark
0990ad4a6f Fix support for proxy credentials in proxy URL and fix error when there are more than 10 outstanding requests 2015-11-25 12:53:50 -08:00
Chris Clark
d8f967d2b8 Bump version to 0.15.1 2015-11-25 11:46:33 -08:00
Geert Weening
fe1c3e7130 Merge pull request #657 from clark800/fix-polyfill
Fix babel-polyfill require
2015-11-25 11:38:52 -08:00
Chris Clark
062148674c Fix babel-polyfill require 2015-11-25 11:31:32 -08:00
Chris Clark
11320693fd Merge pull request #656 from clark800/fix-samples
Fix samples
2015-11-25 11:08:39 -08:00
Chris Clark
7af7eaccb4 Merge pull request #655 from darkdarkdragon/develop-RLJS-549-3
add unit tests for RippleAPIBroadcast
2015-11-25 11:04:55 -08:00
Chris Clark
5d5cf868a2 Fix samples 2015-11-25 10:26:30 -08:00
Ivan Tivonenko
ddf8fe5b1a add unit tests for RippleAPIBroadcast 2015-11-25 05:58:48 +02:00
Chris Clark
dc24f6afe0 Bump version to 0.15.0 2015-11-24 17:53:53 -08:00
Chris Clark
f7dac6ab25 Merge pull request #654 from clark800/mDuo13-docs-patch-3
Docs: SusPay warnings, offline mode, and other tweaks
2015-11-24 17:49:01 -08:00
mDuo13
4b4fc36ebd Docs: SusPay warnings, offline mode, and other tweaks 2015-11-24 17:37:52 -08:00
Chris Clark
7626ea5ed8 Merge pull request #653 from clark800/multi
BREAKING CHANGE: "servers" parameter changed to single "server" and a…
2015-11-24 17:08:58 -08:00
Chris Clark
7061e9afe4 BREAKING CHANGE: "servers" parameter changed to single "server" and added a new broadcast wrapper class for multiple servers 2015-11-24 16:47:12 -08:00
Chris Clark
a124635c2c Merge pull request #652 from darkdarkdragon/develop-RLJS-549-2
fix handling memos in prepareSettings
2015-11-24 16:33:43 -08:00
Ivan Tivonenko
c9704137b7 fix handling memos in prepareSettings
boost coverage back to 99.88%
move connection tests to separate file
group test fixtures into namespaces
2015-11-25 02:10:54 +02:00
Chris Clark
ab8d75d3cc Merge pull request #650 from clark800/cancel-doc-fix
Fix prepareOrderCancellation documentation
2015-11-24 14:32:24 -08:00
Chris Clark
5e720891f5 Fix prepareOrderCancellation documentation 2015-11-23 18:24:19 -08:00
Chris Clark
27ed1aadd5 Bump version to 0.14.0 2015-11-23 17:36:16 -08:00
Chris Clark
001f203983 Merge pull request #648 from clark800/memos
Allow memos on all transaction types
2015-11-23 17:25:09 -08:00
Chris Clark
515047d2dc Merge pull request #649 from clark800/darkdarkdragon-develop-RLJS-549
boost coverage to almost 100%
2015-11-23 17:24:46 -08:00
Ivan Tivonenko
995606b1e6 boost coverage to almost 100% 2015-11-23 17:06:55 -08:00
Chris Clark
b5081344da Allow memos on all transaction types 2015-11-23 14:12:32 -08:00
Chris Clark
4f86691fb8 Merge pull request #647 from clark800/cancellation-spec
BREAKING CHANGE: prepareOrderCancellation now takes orderCancellation specification instead of sequence
2015-11-23 13:14:00 -08:00
Chris Clark
45aca016d4 Merge pull request #646 from clark800/api-options-doc
Add documentation for RippleAPI options
2015-11-23 12:47:43 -08:00
Chris Clark
7f33d8a71e BREAKING CHANGE: prepareOrderCancellation now takes orderCancellation specification instead of sequence 2015-11-23 12:45:44 -08:00
Chris Clark
af620755c5 Fix trace option 2015-11-23 12:01:28 -08:00
Chris Clark
a76b554cad Add documentation for RippleAPI options 2015-11-23 12:01:28 -08:00
Chris Clark
ef1e9e1b70 Merge pull request #644 from mDuo13/patch-1
Docs: more on basic types, tx types
2015-11-23 10:23:38 -08:00
mDuo13
fdbac63f46 Docs: more on basic types, tx types 2015-11-20 18:49:03 -08:00
Chris Clark
377f1dbfa1 Merge pull request #643 from clark800/proxy-auth
Fix proxy support and add support for proxy authorization
2015-11-20 16:32:53 -08:00
Chris Clark
14b840f3fe Fix proxy support and add support for proxy authorization 2015-11-20 15:23:56 -08:00
Chris Clark
beb1cc0cde Merge pull request #642 from mDuo13/patch-1
Doc introduction changes
2015-11-20 14:30:05 -08:00
Rome Reginelli
ef2515507d Docs: revised introductory material 2015-11-20 14:15:40 -08:00
Chris Clark
a271b9e816 Merge pull request #641 from clark800/ledger-event
BREAKING CHANGE: Rename "ledgerClosed" event to "ledger" and convert drops amounts to XRP
2015-11-20 11:30:35 -08:00
Chris Clark
8a3d4a64db BREAKING CHANGE: Rename "ledgerClosed" event to "ledger" and convert drops amounts to XRP 2015-11-20 11:23:19 -08:00
Alan Cohen
9cd8beb778 Bump version to 0.13.2 2015-11-20 10:54:01 -08:00
Chris Clark
aaa165a0f3 Merge pull request #640 from lumberj/fix-pathfind
Fix: Specify send_max when pathfinding with a source amount
2015-11-20 10:48:39 -08:00
Alan Cohen
7514213918 Fix: Specify send_max when pathfinding with a source amount
When specifying a fixed sending amount during a pathfind request, the source
amount is specified as a `send_max` field. This fixes a bug where the amount was
specified as `source_amount`. Leading to strange pathfinding behavior.

Example bad behavior (rippled pathfind request/response):

```
 {
  "command": "ripple_path_find",
  "source_account": "rM21sWyMAJY1oqzgnweDatURxGMurBs7Kf",
  "destination_account": "raDjTrcEtyMqZT6s3PyKGcikUJqYNXUPPv",
  "destination_amount": {
    "currency": "EUR",
    "issuer": "raDjTrcEtyMqZT6s3PyKGcikUJqYNXUPPv",
    "value": -1
  },
  "source_amount": {
    "currency": "USD",
    "issuer": "rM21sWyMAJY1oqzgnweDatURxGMurBs7Kf",
    "value": "9.9"
  },
  "id": 2
}
{
  "id": 2,
  "result": {
    "alternatives": [
      {
        "destination_amount": {
          "currency": "EUR",
          "issuer": "raDjTrcEtyMqZT6s3PyKGcikUJqYNXUPPv",
          "value": "147520.7583553951"
        },
        "paths_canonical": [],
        "paths_computed": [
          [
            {
              "account": "r9HqF3wexBb1vtu2DfZKiFuyy3HoTAwUnH",
              "type": 1,
              "type_hex": "0000000000000001"
            },
            {
              "currency": "EUR",
              "issuer": "raDjTrcEtyMqZT6s3PyKGcikUJqYNXUPPv",
              "type": 48,
              "type_hex": "0000000000000030"
            }
          ]
        ],
        "source_amount": {
          "currency": "USD",
          "issuer": "rM21sWyMAJY1oqzgnweDatURxGMurBs7Kf",
          "value": "160510.6025237665"
        }
      }
    ],
    "destination_account": "raDjTrcEtyMqZT6s3PyKGcikUJqYNXUPPv",
    "destination_currencies": [
      "EUR",
      "XRP"
    ],
    "ledger_current_index": 2771044,
    "validated": false
  },
  "status": "success",
  "type": "response"
}
```

https://ripple.com/build/rippled-apis/#ripple-path-find
2015-11-20 10:44:21 -08:00
Alan Cohen
849ba999cb Bump version to 0.13.1 2015-11-19 18:00:22 -08:00
Chris Clark
10eb08095a Merge pull request #639 from lumberj/babel-polyfill
Add babel-polyfill
2015-11-19 17:46:54 -08:00
Chris Clark
23eb4c90fd Merge pull request #636 from clark800/events-doc
Add documentation for API events
2015-11-19 17:45:00 -08:00
Alan Cohen
12e5765c64 Bump version on ripple-hashes 2015-11-19 17:42:54 -08:00
Alan Cohen
8a53abc32f Add babel-polyfill
» node
> ripple = require('ripple-lib')
Error: Cannot find module 'babel-core/polyfill'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/Users/alan/Projects/ripple-connect/node_modules/ripple-lib/dist/npm/index.js:23:3)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
2015-11-19 17:31:52 -08:00
Chris Clark
25d1ac0c5f Add documentation for API events 2015-11-19 15:40:35 -08:00
Chris Clark
f534bafb79 Merge branch 'develop' 2015-11-19 12:48:08 -08:00
Alan Cohen
f5fa1e6c2a Merge pull request #635 from clark800/docs
Bump version to 0.13.0
2015-11-19 12:34:42 -08:00
Chris Clark
60842540cb Bump version to 0.13.0 2015-11-19 12:26:24 -08:00
Chris Clark
0fb04cdcb4 Merge pull request #634 from clark800/docs
Add table of contents to docs
2015-11-19 11:29:43 -08:00
Chris Clark
5fb8d9214f Add table of contents to docs 2015-11-19 11:19:35 -08:00
Chris Clark
f7f2de291f Merge pull request #633 from clark800/docs
Add documentation and documentation testing
2015-11-18 17:51:36 -08:00
Chris Clark
0c27a13a00 Fix ci.sh error detection 2015-11-18 16:54:13 -08:00
Chris Clark
02a887776f Add documentation and documentation testing 2015-11-18 16:54:10 -08:00
Alan Cohen
f8c885c0a9 Bump version to 0.13.0-rc16 2015-11-18 14:43:50 -08:00
Chris Clark
327ee2b8dd Merge pull request #632 from clark800/error-message
Add resultCode and resultMessage to submit failure RippledError
2015-11-17 17:46:00 -08:00
Chris Clark
4f90bbd931 Add resultCode and resultMessage to submit failure RippledError 2015-11-17 17:33:36 -08:00
Chris Clark
f196304a56 Merge pull request #630 from darkdarkdragon/develop-RLJS-540
add test case for get transaction of types
2015-11-17 16:27:57 -08:00
Ivan Tivonenko
f146ea05c7 add test case for get transaction of types
suspendedPaymentExecution, suspendedPaymentCancellation, suspendedPaymentCreation
2015-11-17 23:43:01 +02:00
Chris Clark
a602d4d73d Merge pull request #631 from clark800/fix-todos
Fix TODOs in schemas and update README for RippleAPI
2015-11-17 13:02:59 -08:00
Chris Clark
2422b9a30b Update README for RippleAPI 2015-11-17 11:30:26 -08:00
Chris Clark
ef72c9fe02 Fix TODOs in schemas 2015-11-16 16:59:27 -08:00
Chris Clark
ee12a214d3 Merge pull request #629 from clark800/remove-closed
Miscellaneous cleanup
2015-11-16 14:17:55 -08:00
Chris Clark
83a85a4549 Remove walletLocator and walletSize from settings 2015-11-16 13:07:25 -08:00
Chris Clark
420413268d Rename server info response fields 2015-11-16 13:07:25 -08:00
Chris Clark
c1bf1fd211 Rename "paymentSequence" to "suspensionSequence" in suspended payments 2015-11-16 13:07:25 -08:00
Chris Clark
9af20f9176 Simplify "submit" response 2015-11-16 13:07:22 -08:00
Chris Clark
230a80852a Remove "closed" from getLedger response 2015-11-16 11:44:15 -08:00
Chris Clark
ff9474b2f9 Merge pull request #628 from clark800/remove-regular-key
Support removing RegularKey
2015-11-16 10:58:49 -08:00
Chris Clark
ed8f1e4111 Support removing RegularKey 2015-11-16 10:24:02 -08:00
Chris Clark
c7eb625ac0 Merge pull request #627 from clark800/docprep
Add descriptions to JSON schemas and organize for documentation generation
2015-11-13 16:22:48 -08:00
Chris Clark
5a8e4be9df Add descriptions to JSON schemas and organize for documentation generation 2015-11-13 15:05:53 -08:00
Chris Clark
e267e4131b Merge pull request #625 from clark800/json-schemas
Organize JSON schemas for documentation generation
2015-11-06 12:50:10 -08:00
Chris Clark
782adc6a1a Organize JSON schemas for documentation generation 2015-11-06 11:57:33 -08:00
Chris Clark
dce8b2d61a Merge pull request #624 from clark800/misc
Better error message when using methods that require a connection when servers are not provided
2015-11-03 11:05:21 -08:00
Chris Clark
8074baa3b5 Better error message when using methods that require a connection when servers are not provided 2015-11-02 14:50:38 -08:00
Chris Clark
c104a51458 Merge pull request #623 from clark800/ledgerclose
BREAKING CHANGE: Specify ledger close time and suspended payment timestamps in ISO 8601 format
2015-11-02 14:17:14 -08:00
Chris Clark
6cc8c5a0f4 BREAKING CHANGE: Specify ledger close time and suspended payment timestamps in ISO 8601 format 2015-11-02 12:34:50 -08:00
Geert Weening
90c928205a Merge pull request #621 from clark800/schemas
Fix and reorganize schemas and switch to ajv validator
2015-11-02 21:34:01 +01:00
Geert Weening
7c1831ef38 Merge pull request #622 from clark800/fix-samples
Fix samples
2015-11-02 20:08:27 +01:00
Chris Clark
f722514ecf Fix samples 2015-10-30 15:22:42 -07:00
Chris Clark
c7b021c7be Fix and reorganize schemas and switch to ajv validator 2015-10-30 14:28:50 -07:00
Chris Clark
2aa1695b74 Delete obsolete files and update LICENSE file 2015-10-30 14:25:33 -07:00
Chris Clark
7bc242bcd0 Merge pull request #620 from clark800/expiration
Add support for order expiration
2015-10-29 17:59:49 -07:00
Chris Clark
665f5f9664 Add support for order expiration 2015-10-29 17:25:52 -07:00
sublimator
36806e4724 Merge pull request #619 from clark800/current-error
Expose computeLedgerHash and prevent access to non-validated ledgers
2015-10-29 11:29:59 +07:00
Chris Clark
6c2fad508a Expose computeLedgerHash and prevent access to non-validated ledgers 2015-10-28 15:39:43 -07:00
Chris Clark
252b99db18 Merge pull request #618 from clark800/cleanup
Emit Connection errors on RippleAPI, remove unused exports, use ripple-hashes in sign
2015-10-28 12:39:50 -07:00
Chris Clark
c238596a81 Emit Connection errors on RippleAPI, remove unused exports, use ripple-hashes in sign 2015-10-28 11:33:51 -07:00
Chris Clark
85c1a3cc42 Merge pull request #615 from clark800/cleanup-errors
Cleanup error classes
2015-10-28 10:08:11 -07:00
sublimator
b6e8dc4c8d Merge pull request #616 from clark800/proxy
Add proxy and authorization support to Connection class
2015-10-28 13:24:07 +07:00
Chris Clark
ba95514d8d Add proxy and authorization support to Connection class 2015-10-27 17:41:46 -07:00
Chris Clark
87dac75919 Cleanup error classes 2015-10-27 17:14:23 -07:00
Chris Clark
37178eeb0b Merge pull request #614 from clark800/api-class
Delete core
2015-10-27 13:27:15 -07:00
Chris Clark
97747deed9 Delete core, move "api" directory up to "src", and remove unused dependencies 2015-10-27 12:37:07 -07:00
Chris Clark
88b1c7e6eb Convert RippleAPI to ES6 class 2015-10-27 12:13:45 -07:00
Chris Clark
29c933e31b Merge pull request #612 from clark800/delete-core
BREAKING CHANGE: Remove dependency of src/api on src/core, removes multiserver support
2015-10-27 11:54:29 -07:00
Chris Clark
b224d4d1c4 Use Promise.resolve 2015-10-27 10:49:59 -07:00
Chris Clark
6db2a72eb8 Use Promise.resolve 2015-10-27 10:39:18 -07:00
Chris Clark
cd5eedff84 Rename toTimestamp/fromTimestamp 2015-10-26 17:46:57 -07:00
Chris Clark
75a427ab27 Avoid catching listener exceptions in Connection class 2015-10-26 17:39:21 -07:00
Chris Clark
ae439afaa4 Remove unnecessary server_info request 2015-10-26 17:29:32 -07:00
Chris Clark
1a99a2fddb BREAKING CHANGE: Remove dependency of src/api on src/core, removes multiserver support 2015-10-26 16:28:43 -07:00
sublimator
c867f2a29a Merge pull request #603 from wltsmrz/add-basic-auth
Add basic auth
2015-10-24 10:18:56 +07:00
Chris Clark
ce65d83cc3 Merge pull request #610 from darkdarkdragon/develop-RLJS-534
fix error in remote.createPathFind
2015-10-23 14:28:31 -07:00
Chris Clark
38dc1c29d6 Merge pull request #611 from darkdarkdragon/develop-RLJS-535
add timeout logic to Remote.getLedgerSequence
2015-10-23 14:28:12 -07:00
Ivan Tivonenko
eeb62ff85e add timeout logic to Remote.getLedgerSequence 2015-10-24 00:20:06 +03:00
Ivan Tivonenko
1dca40c1c9 fix error in remote.createPathFind
add toString method on RippleError
2015-10-24 00:03:53 +03:00
Chris Clark
7e1f2b99b1 Merge pull request #609 from clark800/ripple-path-find
Switch back to ripple_path_find
2015-10-23 13:32:59 -07:00
wltsmrz
f65b673451 Add basic auth 2015-10-22 23:03:48 -07:00
Chris Clark
391a9fd260 Switch back to ripple_path_find 2015-10-22 17:51:16 -07:00
Chris Clark
9a759e7ef1 Merge pull request #608 from clark800/decouple-remote
BREAKING CHANGE: getFee returns promise, express fee in XRP in instru…
2015-10-22 16:37:24 -07:00
Chris Clark
3de0030d07 Add ledger version range checking to Connection class 2015-10-22 14:34:44 -07:00
Chris Clark
cd17d6940f BREAKING CHANGE: getFee returns promise, express fee in XRP in instructions response, use rawRequest to start decoupling Remote from API 2015-10-22 14:34:42 -07:00
Chris Clark
5aa212471c Merge pull request #606 from clark800/decouple-transaction
Decouple core.Transaction from API
2015-10-22 11:16:29 -07:00
Chris Clark
c324682ca3 Decouple core.Transaction from API 2015-10-21 11:48:40 -07:00
Chris Clark
33565d8b96 Merge pull request #604 from shekenahglory/develop
rename metaData to meta
2015-10-21 11:13:35 -07:00
Matthew Fettig
aeb56dee17 rename metaData to meta on getLedger 2015-10-21 10:00:07 -07:00
Chris Clark
98422e4153 Merge pull request #605 from clark800/replace-transaction
Set FullyCanoncialSig flag and fix integration tests
2015-10-20 15:51:44 -07:00
Chris Clark
2c7ce4a107 Run integration tests in CI 2015-10-20 15:49:06 -07:00
Chris Clark
3fbde86548 Set FullyCanoncialSig flag and fix integration tests 2015-10-20 15:49:03 -07:00
Chris Clark
01ecd197ce Merge pull request #601 from clark800/replace-core
Add Connection class
2015-10-20 10:38:00 -07:00
Chris Clark
15eb4c290a Add Connection class 2015-10-19 17:32:45 -07:00
wltsmrz
5fa20dc1f7 Merge pull request #593 from clark800/remove-rsign
Remove rsign.js
2015-10-19 13:45:52 -07:00
Alan Cohen
3df64091dd Bump version to 0.13.0-rc15 2015-10-19 08:51:44 -07:00
Chris Clark
de5d9335d1 Merge pull request #598 from clark800/remove-currency
Remove Currency class
2015-10-16 11:51:20 -07:00
Chris Clark
88a65f08d8 Merge pull request #596 from darkdarkdragon/develop-RLJS-520
getBalances fixes:
2015-10-16 10:54:16 -07:00
Chris Clark
a505354363 Remove bin scripts 2015-10-16 10:52:11 -07:00
Chris Clark
837f7e6e9b Remove Currency class 2015-10-16 10:48:09 -07:00
Ivan Tivonenko
4faa857330 getBalances fixes:
obey limit, do not return XRP if currency or issuer specified
2015-10-16 20:46:52 +03:00
Alan Cohen
9c7b0cb889 Merge '0.13.0-rc11.1' into develop
Bump version to 0.13.0-rc11.1
  Add proxy support to schema
2015-10-15 18:28:27 -07:00
Alan Cohen
a11abcc016 Bump version to 0.13.0-rc11.1 2015-10-15 18:22:20 -07:00
Alan Cohen
dd693fdc5f Add proxy support to schema 2015-10-15 18:14:22 -07:00
Chris Clark
5ac2576fcf Merge pull request #597 from clark800/remove-ieee754
Remove demurrage
2015-10-15 12:18:21 -07:00
Chris Clark
512817a2db Remove demurrage 2015-10-15 11:56:39 -07:00
Chris Clark
1f8c8d88fa Merge pull request #595 from clark800/ripple-hashes
Use ripple-hashes
2015-10-15 10:51:06 -07:00
Chris Clark
044ed53935 Merge pull request #582 from darkdarkdragon/develop-flow-annotate-4
add more flow annotations to RippleApi
2015-10-15 10:32:32 -07:00
Ivan Tivonenko
d47bb2749a add more flow annotations to RippleApi 2015-10-15 03:51:45 +03:00
Chris Clark
0dc000839b Use ripple-hashes 2015-10-14 15:48:40 -07:00
Chris Clark
462e440d5b Merge pull request #594 from clark800/hex-sign
Update ripple-keypairs
2015-10-14 14:12:23 -07:00
Chris Clark
1891fe0afd Update ripple-keypairs 2015-10-14 13:24:13 -07:00
Geert Weening
8cec60c4b0 Merge pull request #592 from clark800/remote-serial
Delete serialization code
2015-10-14 11:28:11 -07:00
Chris Clark
7419244b39 Delete serialization code 2015-10-13 18:24:21 -07:00
Chris Clark
eb9a48d2d6 Merge pull request #589 from wltsmrz/multisign-update
Fix Transaction.complete() for multisigned transactions
2015-10-13 16:18:01 -07:00
Chris Clark
e44d36b4af Merge pull request #591 from clark800/ledger-hashes
Decouple ledger.js and serialization code
2015-10-13 16:15:40 -07:00
Chris Clark
9a5d05f198 Decouple ledger.js and serialization code 2015-10-13 14:51:04 -07:00
Chris Clark
d7a20a5d53 Merge pull request #588 from darkdarkdragon/develop-broadcast-fix
fix Request.broadcast logic
2015-10-13 14:06:31 -07:00
Ivan Tivonenko
b56680e24e fix Request.broadcast logic
Add default timeout to Request.broadcas
Add default timeout to Remote.createPathFind
Handle 'slowDown' error in many places
2015-10-13 22:40:02 +03:00
Chris Clark
886e80ff6d Merge pull request #590 from FrRichard/patch-4
Update REFERENCE.md
2015-10-13 10:51:57 -07:00
FrRichard
142187b024 Update REFERENCE.md
Changed the way you are setting the request callback.
Previous documentation didn't work, ie, the callback was never called (probably old way to set the callback).
2015-10-10 19:52:55 +02:00
wltsmrz
72f3237aba Fix Transaction.complete() for multisigned transactions 2015-10-09 10:50:54 -07:00
Chris Clark
a2406ac163 Merge pull request #587 from clark800/serialize-quality
Use ripple-binary-codec
2015-10-08 15:51:15 -07:00
Chris Clark
91a64137fe BREAKING CHANGE: Use ripple-binary-codec 2015-10-08 15:48:23 -07:00
Geert Weening
57ecbc58f8 bump version to 0.13.0-rc14 2015-10-07 11:42:08 -07:00
Geert Weening
ea4d1007b8 Merge branch 'release' into develop 2015-10-07 11:17:36 -07:00
Geert Weening
16bc7b986b Bump version to 0.13.0-rc13 2015-10-07 11:14:39 -07:00
Geert Weening
115f95fa96 update release notes 2015-10-07 11:14:01 -07:00
Chris Clark
b77b76ebb5 Merge pull request #586 from darkdarkdragon/develop-log-fix
get back lost argument in debug logger
2015-10-07 10:20:01 -07:00
Ivan Tivonenko
f516298a84 get back lost argument in debug logger 2015-10-07 11:43:17 +03:00
Chris Clark
edb31a0c9c Merge pull request #584 from darkdarkdragon/develop-RLJS-521
Add Remote.closeCurrentPathFind function, so current pathfind can be …
2015-10-06 18:40:25 -07:00
Ivan Tivonenko
e99010f363 Add Remote.closeCurrentPathFind function, so current pathfind can be properly closed,
so new can be created without adding to queue
2015-10-07 04:10:13 +03:00
Chris Clark
fa865f8409 Merge pull request #580 from FrRichard/patch-1
Update REFERENCE.md
2015-10-06 17:43:47 -07:00
FrRichard
40b613b7a2 Update REFERENCE.md
Update REFERENCE.md

Update REFERENCE.md
2015-10-07 02:29:17 +02:00
Chris Clark
786c371acd Merge pull request #585 from shekenahglory/master
fix orderbook subscription bug
2015-10-06 16:24:48 -07:00
Matthew Fettig
c4920f474d fix orderbook subscription bug 2015-10-06 15:56:10 -07:00
Chris Clark
a79b010572 Merge pull request #576 from shekenahglory/develop
allow offers request on orderbook subscribe when disconnected
2015-10-06 14:09:25 -07:00
Matthew Fettig
7404795dc6 fix bugs in orderbook subscription 2015-10-06 13:59:21 -07:00
Chris Clark
47a9fb5803 Merge pull request #583 from clark800/fix-merge-error
Fix merge error
2015-10-06 12:54:41 -07:00
Chris Clark
701d4c5722 Fix merge error 2015-10-06 12:47:26 -07:00
Chris Clark
d8d6f945ec Merge pull request #581 from clark800/binary-codec
Decouple UInt from non-serialization code
2015-10-05 16:39:17 -07:00
Geert Weening
a6821bb8ab Fix bower version regex 2015-10-05 15:58:49 -07:00
Geert Weening
ed40eec711 Bump version to 0.13.0-rc12 2015-10-05 15:38:20 -07:00
Chris Clark
2f163c3b6e Decouple UInt from non-serialization code 2015-10-05 15:27:43 -07:00
Geert Weening
43488c55f1 Update release notes 2015-10-05 15:07:31 -07:00
Geert Weening
2f727b553c Merge branch 'develop' into release 2015-10-05 15:04:18 -07:00
Chris Clark
29c37aa6da Merge pull request #579 from wltsmrz/balance-sheet
Balance sheet
2015-10-05 13:41:24 -07:00
wltsmrz
64baef431d Use amount schema 2015-10-05 13:37:55 -07:00
Chris Clark
634fe5683a Merge pull request #577 from darkdarkdragon/develop-reconnect-2
remove Request resubmit logic
2015-10-05 13:28:47 -07:00
Ivan Tivonenko
225ca3f852 BREAKING CHANGE: removed 'timeout' method of Request
added default timeout to Request - will emit 'timeout' event
and RippleError('tejTimeout') to callback
2015-10-05 23:22:32 +03:00
wltsmrz
ff2ac6c3cd Format balancesheet schema 2015-10-05 13:09:04 -07:00
wltsmrz
607777f2a3 Lint 2015-10-05 12:30:41 -07:00
wltsmrz
78eeb40322 Change rippled test fixture name 2015-10-05 12:23:22 -07:00
wltsmrz
772f79ae21 Update schema 2015-10-05 12:16:25 -07:00
wltsmrz
806a4e823f Add getBalanceSheet() to RippleAPI 2015-10-02 17:30:13 -07:00
wltsmrz
323e402e0c Add requestGatewayBalances() to core 2015-10-02 17:30:04 -07:00
Chris Clark
9ebb59580d Merge pull request #575 from clark800/get-paths-source-amount
Support source.amount in getPaths and destination.minAmount in preparePayment
2015-10-02 13:30:04 -07:00
wltsmrz
bafab6eb18 Merge pull request #574 from clark800/fix-ratio-human
Fix bug in Amount.ratio_human
2015-10-01 15:18:20 -07:00
Chris Clark
35acbb62c3 Support source.amount in getPaths and destination.minAmount in preparePayment 2015-10-01 14:55:11 -07:00
Chris Clark
4676ade4ee Fix bug in Amount.ratio_human 2015-10-01 11:58:09 -07:00
Geert Weening
61afca2337 bump to 0.12.9 2015-09-30 16:05:29 -07:00
Geert Weening
47251bd38b update release notes 2015-09-30 15:44:38 -07:00
wltsmrz
8edc3b1f36 Merge pull request #572 from darkdarkdragon/develop-request-once
throw error if Request.request called more than once
2015-09-30 12:00:06 -07:00
Chris Clark
8acfb1a537 Merge pull request #546 from darkdarkdragon/develop-async
make Remote.getLedgerSequence asynchronous
2015-09-30 11:18:49 -07:00
Ivan Tivonenko
ac78171099 make orderbook use Remote.getLedgerSequenceSync
fix some variables naming in src/api
2015-09-30 07:46:30 +03:00
Ivan Tivonenko
d573c5746b refactor getLedgerVersionHelper 2015-09-30 07:07:46 +03:00
Ivan Tivonenko
51e8f9a87a make Remote.getLedgerSequence asynchronous 2015-09-30 07:05:39 +03:00
Ivan Tivonenko
bfe590d96d copy message from Error instance into RippleError 2015-09-30 06:34:58 +03:00
Ivan Tivonenko
60e2d10775 throw error if Request.request called more than once 2015-09-30 06:29:07 +03:00
Chris Clark
2f432cef62 Merge pull request #571 from clark800/fix-pathfind-queue
Fix pathfind queuing and add unit test
2015-09-29 15:22:38 -07:00
Chris Clark
5217b66396 Fix pathfind queuing and add unit test 2015-09-29 12:54:23 -07:00
Chris Clark
b8bb191d24 Merge pull request #566 from clark800/refactor
Decouple UInt160 from account.js and amount.js
2015-09-28 14:15:50 -07:00
Chris Clark
8070a52dc7 Merge pull request #568 from ripple/revert-max-ledger
Revert "Set default maxLedgerVersion to last closed ledger when reque…
2015-09-28 13:27:57 -07:00
wltsmrz
3205f3cf8c Merge pull request #570 from darkdarkdragon/develop-before-once
make sure that 'before' event emitted from Request only once
2015-09-28 12:06:15 -07:00
Alan Cohen
e0cdd610dd Set default max ledger to -1 when requesting account_tx
-1 means up to the most recent available _validated_ ledger for ledger_index_max

account_tx operates only on valided ledgers
2015-09-28 10:35:33 -07:00
Ivan Tivonenko
ed3b04ed6f make sure that 'before' event emitted from Request only once 2015-09-28 03:00:59 +03:00
Alan Cohen
62a2d2ae39 Revert "Set default maxLedgerVersion to last closed ledger when requesting account_tx"
This reverts commit 90b53002aa.

account_tx operates against validated ledgers only
2015-09-25 20:18:36 -07:00
Geert Weening
e2c853e40d Bump version to 0.13.0-rc11 2015-09-25 17:05:22 -07:00
Geert Weening
b9b5a71869 Update release notes 2015-09-25 17:01:58 -07:00
Geert Weening
87fdbc932f Merge pull request #567 from clark800/fix-crash
Fix crash due to rippled slowDown error
2015-09-25 16:59:42 -07:00
Chris Clark
84838b2e9f Fix crash due to rippled slowDown error 2015-09-25 16:41:37 -07:00
Chris Clark
c2ca37a790 Fix lint errors in meta.js and serializedtypes.js 2015-09-25 12:42:13 -07:00
Chris Clark
c6805b9f0d Decouple UInt160 from amount.js 2015-09-25 12:42:13 -07:00
Chris Clark
b1dbdc03dd Decouple UInt160 from account.js 2015-09-25 12:42:10 -07:00
Chris Clark
88a3f3d43b Merge pull request #565 from clark800/value
Use ripple-lib-value package and update ripple-lib-transactionparser dependency
2015-09-25 12:39:03 -07:00
Chris Clark
5f8dcd71a5 Merge pull request #564 from darkdarkdragon/develop-master-merge-2
Merge branch 'master' into develop
2015-09-24 13:58:11 -07:00
Ivan Tivonenko
45db95da79 put back UInt160 in AutobridgeCalculator
fix lint issues
2015-09-24 23:49:32 +03:00
Chris Clark
c79b12b27f Use ripple-lib-value package and update ripple-lib-transactionparser dependency 2015-09-24 12:32:15 -07:00
Chris Clark
135da6108d Merge pull request #563 from clark800/keypairs
Move to new ripple-keypairs API
2015-09-24 11:53:20 -07:00
Ivan Tivonenko
0d6dda579f Merge branch 'master' into develop 2015-09-24 20:04:18 +03:00
Chris Clark
e641a347db Merge pull request #561 from darkdarkdragon/master-performance-2
more OrderBook performance optimizations
2015-09-23 17:14:44 -07:00
Ivan Tivonenko
3e17d91edf more OrderBook performance optimizations
OrderBook: emit 'model' event only after last transaction in closed ledger
run AutobridgeCalculator only once in a ledger
2015-09-24 02:50:48 +03:00
Chris Clark
715c648d52 Move to new ripple-keypairs API 2015-09-23 14:30:56 -07:00
Geert Weening
d0ebed9822 bump version to 0.12.8 2015-09-23 11:51:42 -07:00
Geert Weening
a3775f18ba update release notes 2015-09-23 11:51:29 -07:00
wltsmrz
7b5d6e9fc5 Merge pull request #562 from wltsmrz/add-reconnect-test
Add test for Server automatic reconnection
2015-09-22 21:52:11 -07:00
wltsmrz
368ac0b9e0 Merge pull request #560 from wltsmrz/fix-connect-when-already-connected
Always call Remote.connect() callback
2015-09-22 21:51:30 -07:00
wltsmrz
0448696bd8 Merge pull request #552 from wltsmrz/update-multisigning
Autofill LastLedgerSequence for multisigned transactions
2015-09-22 21:50:53 -07:00
wltsmrz
deb75ed0d7 Add test for Server automatic reconnection 2015-09-22 19:48:25 -07:00
wltsmrz
1c023c4377 Always call Remote.connect() callback
Fixes non-resolving Promise in RippleAPI.connect()
2015-09-22 18:22:28 -07:00
wltsmrz
de67570230 Autofill LastLedgerSequence for multisigned transactions 2015-09-21 10:26:00 -07:00
Geert Weening
f282585c3f Bump version to 0.12.7
bump dependencies and regenerate shrinkwrap
2015-09-17 10:30:23 -07:00
Geert Weening
ae5ff31c96 Update release notes 2015-09-17 10:20:52 -07:00
801 changed files with 36983 additions and 45242 deletions

View File

@@ -1,14 +0,0 @@
[ignore]
.*/src/api/.*
.*/src/core/.*
.*/dist/.*
.*/test/fixtures/.*
.*/node_modules/flow-bin/.*
[include]
./node_modules/
[libs]
[options]
module.system=node

10
.gitignore vendored
View File

@@ -51,13 +51,13 @@ test/config.js
# Ignore npm-debug
npm-debug.log
# Ignore dist folder, build for bower
# Ignore dist folder, built from tsc
dist/
# Ignore flow output directory
out/
# Ignore perf test cache
scripts/cache
eslintrc
.eslintrc
# nyc (istanbul)
.nyc_output

1
.nvmrc Normal file
View File

@@ -0,0 +1 @@
v8

10
.nycrc Normal file
View File

@@ -0,0 +1,10 @@
{
"include": ["src/**/*.ts"],
"exclude": ["src/**/*.d.ts"],
"extension": [".ts"],
"require": ["ts-node/register"],
"reporter": ["text-summary", "html"],
"sourceMap": true,
"instrument": true,
"cache": true
}

View File

@@ -1,9 +1,10 @@
sudo: false # use faster docker containers
language: node_js
node_js:
- "0.12"
before_script:
- sh -c "git log | head -12"
script: bin/ci.sh
notifications:
email: false
- 6
- 8
- 9
script:
- yarn compile
- yarn test
- yarn build
- yarn lint

View File

@@ -1,61 +1,148 @@
/* eslint-disable no-var, no-param-reassign */
/* these eslint rules are disabled because gulp does not support babel yet */
'use strict';
var _ = require('lodash');
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var webpack = require('webpack');
var bump = require('gulp-bump');
var argv = require('yargs').argv;
const _ = require('lodash');
const fs = require('fs');
const path = require('path');
const assert = require('assert');
const gulp = require('gulp');
const rename = require('gulp-rename');
const webpack = require('webpack');
const bump = require('gulp-bump');
const argv = require('yargs').argv;
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
var pkg = require('./package.json');
function webpackConfig(extension, overrides) {
var uglifyOptions = {
mangle: {
reserved: ['_', 'RippleError', 'RippledError', 'UnexpectedError',
'LedgerVersionError', 'ConnectionError', 'NotConnectedError',
'DisconnectedError', 'TimeoutError', 'ResponseFormatError',
'ValidationError', 'NotFoundError', 'MissingLedgerHistoryError',
'PendingLedgerVersionError'
]
}
};
function getWebpackConfig(extension, overrides) {
overrides = overrides || {};
var defaults = {
let defaults = {
cache: true,
entry: './src/index.js',
externals: [{
'lodash': '_'
}],
entry: './src/index.ts',
output: {
library: 'ripple',
path: './build/',
path: path.join(__dirname, 'build/'),
filename: ['ripple-', extension].join(pkg.version)
},
plugins: [
new webpack.NormalModuleReplacementPlugin(/^ws$/, './wswrapper'),
new webpack.NormalModuleReplacementPlugin(/^\.\/wallet$/, './wallet-web'),
new webpack.NormalModuleReplacementPlugin(/^.*setup-api$/,
'./setup-api-web')
],
module: {
loaders: [{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader?optional=runtime'
rules: [{
test: /jayson/,
use: 'null',
}, {
test: /\.ts$/,
use: [{
loader: 'ts-loader',
options: {
compilerOptions: {declaration: false}
},
}],
}, {
test: /\.json/,
loader: 'json-loader'
use: 'json-loader',
}]
}
},
resolve: {
extensions: [ '.ts', '.js' ]
},
};
return _.assign({}, defaults, overrides);
}
gulp.task('build', function(callback) {
webpack(webpackConfig('.js'), callback);
function webpackConfigForWebTest(testFileName, path) {
var match = testFileName.match(/\/?([^\/]*)-test.js$/);
if (!match) {
assert(false, 'wrong filename:' + testFileName);
}
var configOverrides = {
externals: [{
'lodash': '_',
'ripple-api': 'ripple',
'net': 'null'
}],
entry: testFileName,
output: {
library: match[1].replace(/-/g, '_'),
path: './test-compiled-for-web/' + (path ? path : ''),
filename: match[1] + '-test.js'
}
};
return getWebpackConfig('.js', configOverrides);
}
gulp.task('build-tests', function(callback) {
var times = 0;
function done() {
if (++times >= 5) {
callback();
}
}
webpack(webpackConfigForWebTest('./test/rangeset-test.js'), done);
webpack(webpackConfigForWebTest('./test/connection-test.js'), done);
webpack(webpackConfigForWebTest('./test/api-test.js'), done);
webpack(webpackConfigForWebTest('./test/broadcast-api-test.js'), done);
webpack(webpackConfigForWebTest('./test/integration/integration-test.js',
'integration/'), done);
});
gulp.task('build-min', ['build'], function() {
return gulp.src(['./build/ripple-', '.js'].join(pkg.version))
.pipe(uglify())
.pipe(rename(['ripple-', '-min.js'].join(pkg.version)))
.pipe(gulp.dest('./build/'));
function createLink(from, to) {
if (fs.existsSync(to)) {
fs.unlinkSync(to);
}
fs.linkSync(from, to);
}
function createBuildLink(callback) {
return function(err, res) {
createLink('./build/ripple-' + pkg.version + '.js',
'./build/ripple-latest.js');
callback(err, res);
};
}
gulp.task('build', function(callback) {
webpack(getWebpackConfig('.js'), createBuildLink(callback));
});
gulp.task('build-min', function(callback) {
const webpackConfig = getWebpackConfig('-min.js');
webpackConfig.plugins.push(new UglifyJsPlugin({uglifyOptions}));
webpack(webpackConfig, function() {
createLink('./build/ripple-' + pkg.version + '-min.js',
'./build/ripple-latest-min.js');
callback();
});
});
gulp.task('build-debug', function(callback) {
var configOverrides = {debug: true, devtool: 'eval'};
webpack(webpackConfig('-debug.js', configOverrides), callback);
const webpackConfig = getWebpackConfig('-debug.js', {devtool: 'eval'});
webpackConfig.plugins.unshift(new webpack.LoaderOptionsPlugin({debug: true}));
webpack(webpackConfig, callback);
});
/**
* Generate a WebPack external for a given unavailable module which replaces
* that module's constructor with an error-thrower
*/
function buildUseError(cons) {
return ('var {<CONS>:function(){throw new Error('
+ '"Class is unavailable in this build: <CONS>")}}')
@@ -65,7 +152,7 @@ function buildUseError(cons) {
gulp.task('build-core', function(callback) {
var configOverrides = {
cache: false,
entry: './src/remote.js',
entry: './src/remote.ts',
externals: [{
'./transaction': buildUseError('Transaction'),
'./orderbook': buildUseError('OrderBook'),
@@ -73,10 +160,10 @@ gulp.task('build-core', function(callback) {
'./serializedobject': buildUseError('SerializedObject')
}],
plugins: [
new webpack.optimize.UglifyJsPlugin()
new UglifyJsPlugin()
]
};
webpack(webpackConfig('-core.js', configOverrides), callback);
webpack(getWebpackConfig('-core.js', configOverrides), callback);
});
gulp.task('bower-build', ['build'], function() {

View File

@@ -1,116 +1,524 @@
##0.13.0 (release candidate)
# ripple-lib Release History
## 1.0.1 (2018-09-27)
+ Add address/secret/key validation and derivation methods ([#932](https://github.com/ripple/ripple-lib/pull/932))
+ `isValidAddress(address: string) : boolean`: Checks if the specified string contains a valid address.
+ `isValidSecret(secret: string): boolean`: Checks if the specified string contains a valid secret.
+ `deriveKeypair(seed: string): {privateKey: string, publicKey: string}`: Derive a public and private key from a seed.
+ `deriveAddress(publicKey: string): string`: Derive an XRP Ledger address from a public key.
+ To derive an address from a secret:
1. Derive the public key from the secret.
2. Derive the address from the public key.
+ Example: `const address = api.deriveAddress(api.deriveKeypair(secret).publicKey)`
+ Update server regex to accommodate UDS (#944)
+ Include memos when parsing trustlines (#949)
+ Add remaining LedgerEntry types (#943)
The SHA-256 checksums for the browser version of this release can be found
below.
```
% shasum -a 256 *
9b6408641ce83659afcd5765c256c35829a4fcb4c3244dc9ca6bf27c871a45c4 ripple-1.0.1-debug.js
7ab2b69fe59c2d4a74638116e2ba3b387155eb2d23e48a01bbf7beb72911f898 ripple-1.0.1-min.js
8bb4dcad9ce25a27003b1d73d71ddf41b8a5af02ece4ebbfeaff4aeb91f3b8c4 ripple-1.0.1.js
```
## 1.0.0 (2018-08-30)
We are pleased to announce the release of `ripple-lib` version 1.0.0.
This version features a range of changes and improvements that make the library
more capable and flexible. It includes new methods for accessing rippled APIs,
including subscriptions.
When using this version with `rippled` for online functionality, we recommend
using `rippled` version 1.0.1 or later.
Here is a summary of the changes since `ripple-lib` version 0.22.0, which was
the last non-beta version.
### New Features
+ [Add `request()`, `hasNextPage()`, and `requestNextPage()` for accessing `rippled`
APIs](https://github.com/ripple/ripple-lib/blob/09541dae86bc859bf5928ac65b2645dfaaf7f8b1/docs/index.md#rippled-apis).
+ Add `prepareTransaction()` for preparing raw `txJSON`.
+ XRP amounts can be specified in drops. Also, `xrpToDrops()` and `dropsToXrp()`
are available to make conversions.
+ `getTransaction` responses can include a new `channelChanges` property that
describes the details of a payment channel.
### Data Validation and Errors
+ [Amounts in drops and XRP are checked for
validity](https://github.com/ripple/ripple-lib/blob/develop/HISTORY.md#100-beta1-2018-05-24).
+ [A maximum fee is now
imposed](https://github.com/ripple/ripple-lib/blob/develop/HISTORY.md#100-beta2-2018-06-08). Exceeding it causes a `ValidationError` to be
thrown.
+ Errors are improved and more data validation was added.
+ Bug fix: `getPaths` now filters paths correctly and works correctly when the
destination currency is XRP.
### Breaking Changes
The following changes were introduced in 1.0.0.
+ `getTransaction()` and `getTransactions()`
+ The `specification.destination.amount` field has been removed from the parsed transaction response.
+ To determine the amount that a transaction delivered, use `outcome.deliveredAmount`.
+ If you require the provisional requested `Amount` from the original transaction:
+ Use `getTransaction`'s `includeRawTransaction` option, or
+ Use `getTransactions`'s `includeRawTransactions` option, or
+ Use the rippled APIs directly with `request`. For example, call the API methods `tx`, `account_tx`, etc.
+ `getLedger()` response object
+ The `rawTransactions` field has been removed (for consistency with `getTransaction()` and `getTransactions()`).
+ Instead, within each `transaction`, use the new `rawTransaction` JSON string.
+ The `metaData` field has been renamed to `meta` for consistency with rippled's `tx` method.
+ `ledger_index` has been added to each raw transaction.
The SHA-256 checksums for the browser version of this release can be found
below.
```
% shasum -a 256 *
06e5efcb6846ad45dedfd85cfa2ef4bdeb608b15ccbfb60b872c995d97342426 ripple-1.0.0-debug.js
cdb26b928a89ce228c727d1ff966df266eb46b2f76bd94f81cbeb0a9d75febf0 ripple-1.0.0-min.js
f74ee804e8a945a994e4e3901a0a3eb52292fbdcbff61ed30cefb8ffbcba50c3 ripple-1.0.0.js
```
## 1.0.0-beta.5 (2018-08-11)
+ [Fix a TypeScript error by importing the `Prepare` type](https://github.com/ripple/ripple-lib/commit/7cd517268bda5fe74b91dad02fedf8b51b7eae9b)
## 1.0.0-beta.4 (2018-08-10)
+ [Add `prepareTransaction()`](https://github.com/ripple/ripple-lib/pull/898)
+ Internal improvements and cleanup
## 1.0.0-beta.3 (2018-07-17)
+ For payment channel transactions, `getTransaction` includes a new
`channelChanges` property that describes the details of the payment channel.
(#920)
### Bug Fixes
+ A bug caused calculated fees to use too many decimal places. This was fixed by
rounding fees to 6 decimal places. (#912)
+ When using the Settings transaction to set up a multi-signing list, the
threshold and weights fields are required. (#909)
+ Docs: Fix the MIMETYPE in examples with memos. (#914)
The SHA-256 checksums for the browser version of this release can be found
below.
```
% shasum -a 256 *
460dbb521e24c44cb53dabc1a74feeca33d031b44d889dd5b51103ca92d51de6 ripple-1.0.0-beta.3-debug.js
cccfd24973c6b7990d9e933a589175dae26249825737fff4f2f73d8558a3f186 ripple-1.0.0-beta.3-min.js
0dc456a58fb078347d9920310621595905085595d73c2b8fe96bea73bcf35450 ripple-1.0.0-beta.3.js
```
## 1.0.0-beta.2 (2018-06-08)
### Breaking Changes
+ During transaction preparation, there is now a maximum fee. Also, when a transaction is signed, its fee is checked and an error is thrown if the fee exceeds the maximum. The default `maxFeeXRP` is `'2'` (2 XRP). Override this value in the RippleAPI constructor.
+ Attempting to prepare a transaction with an exact `fee` higher than `maxFeeXRP` causes a `ValidationError` to be thrown.
+ Attempting to sign a transaction with a fee higher than `maxFeeXRP` causes a `ValidationError` to be thrown.
+ The value returned by `getFee()` is capped at `maxFeeXRP`.
### Other Changes
+ In Transaction Instructions, the `maxFee` parameter is deprecated. Use the `maxFeeXRP` parameter in the RippleAPI constructor.
#### Overview of new fee limit
Most users of ripple-lib do not need to make any code changes to accommodate the new soft limit on fees. The limit is designed to protect against the most severe cases where an unintentionally high fee may be used.
+ When having ripple-lib provide the fee with a `prepare*` method, a maximum fee of `maxFeeXRP` (default 2 XRP) applies. You can prepare more economical transactions by setting a lower `maxFeeXRP`, or support high-priority transactions by setting a higher `maxFeeXRP` in the RippleAPI constructor.
+ When using `sign` with a Fee higher than `maxFeeXRP`, a `ValidationError` is thrown.
If you have any questions or concerns, please open an issue on GitHub.
The SHA-256 checksums for the browser version of this release can be found
below.
```
% shasum -a 256 *
ef348a2805098e61395b689b410cbf4bfd35e4d72e38c89f4ab74ec5e19793f5 ripple-1.0.0-beta.2-debug.js
ea33fd53df8c7176d5fbf52dae0b64aade7180860f26449062cdbefaf8bd4d9b ripple-1.0.0-beta.2-min.js
fe5cc6e97c9b8a1470dacb34f16a64255cd639a25381abe9db1ba79e102456f2 ripple-1.0.0-beta.2.js
```
## 1.0.0-beta.1 (2018-05-24)
### Breaking Changes
+ Amounts in drops and XRP are checked for validity. Some
methods may now throw a `BigNumber Error` or `ValidationError` if the amount
is invalid. This may include methods that previously did not throw.
+ Note that 1 drop is equivalent to 0.000001 XRP and 1 XRP is equivalent to 1,000,000 drops.
+ Using drops is recommended. All rippled APIs require XRP amounts to be
expressed in drops.
### Other Changes
+ Allow specifying amounts in drops for consistency with the `rippled`
APIs.
+ Export `xrpToDrops()` and `dropsToXrp()` functions.
+ Potentially breaking change: Improve errors. For example, `RippledError` now includes the full response from
the `rippled` server ([#687](https://github.com/ripple/ripple-lib/issues/687)). `NotConnectedError`
may be thrown with a different message than before.
The SHA-256 checksums for the browser version of this release can be found
below.
```
% shasum -a 256 *
a80ebb39e186640246306eadb2879147458c8271fd3c6cb32e6ef78d0b4b01a5 ripple-1.0.0-beta.1-debug.js
81bcc4b5fd6fd52220ed151242eaddd63eb29c4078845edc68f65b769557d126 ripple-1.0.0-beta.1-min.js
738b4d65b58cf4e3542fa396f8d319a24cd7d0b7aff5ff629a900e244f735ff4 ripple-1.0.0-beta.1.js
```
## 1.0.0-beta.0 (2018-05-10)
+ [Add `request`, `hasNextPage`, and
`requestNextPage`](https://github.com/ripple/ripple-lib/pull/887).
+ This provides support for all rippled APIs, including subscriptions.
When using rippled APIs, you must:
+ For all XRP amounts, use drops (1 drop = 0.000001 XRP).
+ Instead of `counterparty`, use `issuer`.
The SHA-256 checksums for the browser version of this release can be found
below.
```
% shasum -a 256 *
ab2094979a3d6b320c7bc22bc5946c50fa5e29af0976d352e7689b0a4d840c55 ripple-1.0.0-beta.0-debug.js
0e7f7d740606c2866ebf63776b13b41a555848e1a1419e2c8058d2e6c562d7fd ripple-1.0.0-beta.0-min.js
bd05e8806832ca4192aea7ba2d0362baa9f44605f8e8e6676acd25eb0b94b778 ripple-1.0.0-beta.0.js
```
## 0.22.0 (2018-05-10)
+ [`getOrderbook` - return raw order data](https://github.com/ripple/ripple-lib/pull/886). The full `BookOffer` data is now provided under `data`.
The SHA-256 checksums for the browser version of this release can be found
below.
```
% shasum -a 256 *
33f71b55c4adec4452826e44fe7809377364df04222b60f0fce01e7de2daff33 ripple-0.22.0-debug.js
63232888a4ea77065e8e8eb8fdaa8ebfe3a785428fe935e2667c1ea54c837f29 ripple-0.22.0-min.js
ab98026fabe296bd938297c48cb58e01dfdbe90f3c66c9617d6a3e1efd4c6b93 ripple-0.22.0.js
```
## 0.21.0 (2018-04-11)
+ [Upgrade https-proxy-agent](https://github.com/ripple/ripple-lib/pull/883)
+ [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)
+ [Use ES Module syntax](https://github.com/ripple/ripple-lib/pull/815) (Babel still compiles these to common.js modules for
distribution)
+ Docs: [Improve escrow creation example/test](https://github.com/ripple/ripple-lib/pull/820)
+ [Fix type errors](https://github.com/ripple/ripple-lib/pull/811)
+ [Fix lint errors](https://github.com/ripple/ripple-lib/pull/813)
## 0.17.9 (2017-11-14)
+ [Update ws dependency to 3.3.1](https://github.com/ripple/ripple-lib/pull/804)
+ [Remove unnecessary polyfills](https://github.com/ripple/ripple-lib/pull/807)
+ Fix lint errors ([#786](https://github.com/ripple/ripple-lib/pull/786), [#808](https://github.com/ripple/ripple-lib/pull/808))
+ [Update ripple-keypairs dependency to 0.10.1](https://github.com/ripple/ripple-lib/pull/805)
The SHA-256 checksums for the browser version of this release can be found below.
```
% shasum -a 256 *
b52f251eedac2509d72093eab1e8dba0d0f4a9fe6a28ec1cc90853cfb0fd7110 ripple-0.17.9-debug.js
d577a2bbdbdf7535c5365a1c52a2a31989d1b966e30abcba65c87133a536b9dc ripple-0.17.9-min.js
ff4c3002842fac72ec2ebbd081e9594b0de6050d4d051a8fd6c06adb9a351488 ripple-0.17.9.js
```
The SHA-1 checksums for the browser version of this release can be found below.
```
% shasum *
e1995afc34aef6accd269cfccc55a45619618a41 ripple-0.17.9-debug.js
e6ad9a9c111ab696f5637bfa372d80999e5ae362 ripple-0.17.9-min.js
4866494ec5f9095cc34bea142f1e2b8ac5f7fbf8 ripple-0.17.9.js
```
## 0.17.8 (2017-11-06)
+ Fix: Freezing in Safari 10.1 (updated bignumber.js) (closes #762)
+ [Fix: `getSettings` should include signers](https://github.com/ripple/ripple-lib/commit/2a90f9b134e168937dceb7da283d63734eac9e7c)
+ Update for Node 6
+ Update lodash dependency
+ Migrate to yarn
## 0.17.7 (2017-05-08)
+ Replace AJV with jsonschema
## 0.16.5 (2016-01-21)
+ [Filter insufficient source funds paths from pathfind results](https://github.com/ripple/ripple-lib/pull/688)
## 0.16.4
+ [Update `ws` to 1.0.1](https://github.com/ripple/ripple-lib/pull/682)
## 0.16.2
+ Bump `ripple-binary-codec` dependency version to 0.1.1 to fix issue with `computeLedgerHash` for transactions with `DeliverMin`
## 0.16.1
+ [FIX: Use assert not assert-diff](https://github.com/ripple/ripple-lib/commit/f6ebe325193e7208c5ee8d8e84a7504714f0009e)
## 0.16.0
__BREAKING CHANGES__
+ [Fix types of XRP values in `getServerInfo` response](https://github.com/ripple/ripple-lib/commit/99d08065e4bda3dda6ae1f183adbd11abc70a9b7)
+ [Change error event format and fix crash due to error event on websocket](https://github.com/ripple/ripple-lib/commit/9cd72595f0efc062d77b9d625695d6030c524cc6)
__OTHER CHANGES__
+ [Fix `generateAddress` docs and add error event listener to boilerplate](https://github.com/ripple/ripple-lib/commit/809d981987a2890fac3a73a40a05c598b9040334)
+ [Allow setting `maxLedgerVersion` to `null` to specify no maximum](https://github.com/ripple/ripple-lib/commit/82613e7e8b360d1ae1552eab4559ab4763c06d7e)
+ [Add support for client certificates](https://github.com/ripple/ripple-lib/commit/5f5e48e4140345d166b8c1a3ee0847b0d9e2d893)
+ [`getFee` returns a string not a float](https://github.com/ripple/ripple-lib/commit/7bf2da6014c87e164542e69356efeaabb575a157)
+ [Fix parsing of quality for `getTrustlines`](https://github.com/ripple/ripple-lib/commit/86ff315ef2a39dfdc2ce97e0e1c4aa73f04e363b)
+ Fix `DeliverMin` value when specifying `minAmount`
+ [http server example](https://github.com/ripple/ripple-lib/commit/76866ab901ea46a2dd73181605e0f7f4220043d4)
## 0.15.2
+ [Fix support for proxy credentials in proxy URL and fix error when there are more than 10 outstanding requests](https://github.com/ripple/ripple-lib/commit/0990ad4a6f1d59ca9d2cb859b4e2d71693f3fc4b)
## 0.15.1
+ [Fix `babel-polyfill` require](https://github.com/ripple/ripple-lib/commit/062148674c3b1293ab82c28e25615ddd530339fa)
+ [Fix samples](https://github.com/ripple/ripple-lib/commit/5d5cf868a2ddb1b1cd40e4a4f0a782d0066c2055)
+ [Add unit tests for `RippleAPIBroadcast`](https://github.com/ripple/ripple-lib/commit/ddf8fe5b1a9c750490dca98fb9ffaaf8017f87e0)
## 0.15.0
__BREAKING CHANGES__
+ ["servers" parameter changed to single "server"](https://github.com/ripple/ripple-lib/commit/7061e9afe46f0682254d098adeff3dd7157521a1)
__OTHER CHANGES__
+ [Fix handling memos in `prepareSettings`](https://github.com/ripple/ripple-lib/commit/c9704137b7b538e8dbf31c483bcdcf2dcfd7cd75)
+ [Docs: SusPay warnings, offline mode, and other tweaks](https://github.com/ripple/ripple-lib/commit/4b4fc36ebd93f1360781a65f2869bd2c4f0a5093)
+ [Fix prepareOrderCancellation documentation](https://github.com/ripple/ripple-lib/commit/5e720891f579fd73d43c64e5ec519d9121023c10)
## 0.14.0
__BREAKING CHANGES__
+ [`prepareOrderCancellation` now takes orderCancellation specification](https://github.com/ripple/ripple-lib/commit/7f33d8a71e56289e5a5e0ead1c74f75ebcde72bc)
+ [Rename "ledgerClosed" event to "ledger" and change format](https://github.com/ripple/ripple-lib/commit/8a3d4a64db5fbf560ebf87dc62e0212513c5e18a)
__OTHER CHANGES__
+ [Fix proxy support and add support for proxy authorization](https://github.com/ripple/ripple-lib/commit/14b840f3feca758e0384b746c94e36d8bf59b8c2)
+ [Fix trace option](https://github.com/ripple/ripple-lib/commit/af620755c53556c55eed12de4b0013ef5a349ce2)
+ [Allow memos on all transaction types](https://github.com/ripple/ripple-lib/commit/b5081344da8e66fbd3a5113cc3313325ef72a494)
+ [Add documentation for RippleAPI options](https://github.com/ripple/ripple-lib/commit/a76b554cadb9f9f918b06f8386bc29355682a1a4)
+ [Docs: more on basic types, tx types](https://github.com/ripple/ripple-lib/commit/fdbac63f466b4fd3be701d4878800d856692e26e)
+ [Docs: revised introductory material](https://github.com/ripple/ripple-lib/commit/ef2515507dbd3c6a426ab5b31332a1bdf72d5b2d)
+ [boost coverage to almost 100%](https://github.com/ripple/ripple-lib/commit/995606b1e6f3643af34d9fd442ccd31f320b03eb)
## 0.13.2
+ [Fix: Specify send_max when pathfinding with a source amount](https://github.com/ripple/ripple-lib/commit/75142139184625c8b9fcc480b1825d9985337813)
## 0.13.1
+ [Add documentation for API events](https://github.com/ripple/ripple-lib/commit/25d1ac0c5f95cad32ea4ceebb)
+ [Fix: Add babel-polyfill](https://github.com/ripple/ripple-lib/commit/8a53abc32f6ec6c7d50cd182492d6fb511b86704)
+ [Fix: Bump version on ripple-hashes](https://github.com/ripple/ripple-lib/commit/12e5765c64aea31b3c2fb65ff989cf01e6368f58)
## 0.13.0
__BREAKING CHANGES__
+ Add new RippleAPI interface and delete old API
- [RippleAPI README and samples](https://github.com/ripple/ripple-lib/tree/develop/docs/samples)
__OTHER CHANGES__
+ [Removed timeout method of Request and added default timeout](https://github.com/ripple/ripple-lib/commit/634fe5683a9082e57682ff7d5c4fb9483b4af818)
+ [Add Remote.closeCurrentPathFind function, so current pathfind can be properly closed](https://github.com/ripple/ripple-lib/commit/e99010f363fc7cbe7fd547d3ca5b32ea083c44e6)
+ [Implement Balance Sheet API](https://github.com/ripple/ripple-lib/pull/579)
+ [Fix bugs in orderbook subscription](https://github.com/ripple/ripple-lib/commit/7404795dc64a85216148de7bc3ca7da7b33f4490)
+ [Fix crash due to rippled slowDown error](https://github.com/ripple/ripple-lib/commit/84838b2e9f6969b593b8462a62a6b8f516ada937)
+ [Fix: Emit error events and return error on pathfind](https://github.com/ripple/ripple-lib/commit/1ccbaf677631a1944eb05d90f7afc5f3690a03dd)
+ [Deprecate core and remove snake case method copying](https://github.com/ripple/ripple-lib/commit/fb8dc44ec1d49bb05cd0cdbe6dd4ab211195868a)
+ Add new RippleAPI interface
- [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)
+ [Fix RangeSet for validated_ledger as single ledger](https://github.com/ripple/ripple-lib/commit/9f9e76f8b933201651af59307135f67cfa7d60e8)
+ [Fix bug where the paths would be set with an empty array](https://github.com/ripple/ripple-lib/commit/83874ec0962da311b76f2385623e51c68bc39035)
+ [Fix reserve calculation](https://github.com/ripple/ripple-lib/commit/52879febb92d876f01f2e4d70871baa07af631fb)
##0.12.6
## 0.12.9
+ [OrderBook performance optimizations](https://github.com/ripple/ripple-lib/commit/3e17d91edf36745f6b6c09b0ad88971b7775f6ab)
## 0.12.7 and 0.12.8
+ [Improve performance of orderbook](https://github.com/ripple/ripple-lib/commit/c745faaaf0956ca98448a754b4fe97fb50574fc7)
+ [Remove Firefox warning about prototype overwrite](https://github.com/ripple/ripple-lib/commit/0c62fa21123b220b066871e1c41a3b4fe6f51885)
+ [Fix compare bug in `Amount` class](https://github.com/ripple/ripple-lib/commit/806547dd154e1b0bf252e8a74ad3ac6aa8a97660)
## 0.12.6
+ [Fix webpack require failure due to "./" notation](https://github.com/ripple/ripple-lib/commit/8d9746d7b10be203ee613df523c2522012ff1baf)
##0.12.15
## 0.12.15
+ [Add offer autobridging](https://github.com/ripple/ripple-lib/commit/c7bbce83719c1e8c6a4fae5ca850e7515db1a4a5)
+ [Prevent crash when listening for "model" events on the OrderBook class](https://github.com/ripple/ripple-lib/commit/5824c3cb7cb6bd834d6e037f69943aebf3d83351)
+ [Fix empty order edgecase](https://github.com/ripple/ripple-lib/commit/64809d9ae23dc24f47accd4b4788b48f49880d3e)
+ [Fix AutobridgeCalculator (RT-3445)](https://github.com/ripple/ripple-lib/commit/1fff5ea6dcbcee856536df26f3b9cf1aec3c3b55)
+ [Update sjcl and delete custom ripemd160, montgomery, and jacobi](https://github.com/ripple/ripple-lib/commit/50cda426eb83599c38c0b725e1524a01fc415da2)
+ [Fix transaction summary for transactions that fail with remoteError](https://github.com/ripple/ripple-lib/commit/5e714f6143464d7912f42537acaa553b88eaf6dc)
+ [Fix serializedobject append for excessively large bytes length](https://github.com/ripple/ripple-lib/commit/e93f1ab6f4aaad347450aee75a169af0faa2121c)
+ [Switch to sjcl npm module](https://github.com/ripple/ripple-lib/commit/9a502580fd89ec6a9aa55f4e5847f6a4a2cb5bba)
+ [Add babel transpiler](https://github.com/ripple/ripple-lib/commit/398f8d001f758bf575b959537a17e79e4042d17b)
+ [Remove unused float.js and wallet.js](https://github.com/ripple/ripple-lib/commit/d4a4b5f4fbbf09677a59ce81bace35c6426a2fda)
+ [Remove config singleton to reduce global state](https://github.com/ripple/ripple-lib/commit/c655c2a20ee5d150a4b5a1b6717b9fb81f636025)
##0.12.4
## 0.12.4
+ [Improve entropy security](https://github.com/ripple/ripple-lib/commit/c7ba822320880037796f57876d1abb4e525648ed)
+ [Remove unused crypt.js file](https://github.com/ripple/ripple-lib/commit/1f68eba1461bca03a4d22872450d15ae5a185334)
##0.12.3
## 0.12.3
+ [Add getLedgerSequence to Remote](https://github.com/ripple/ripple-lib/commit/d09548d04d3238fca653d482ec1d5faa7254559a)
+ [Improve randomness when generating ECDSA signatures](https://github.com/ripple/ripple-lib/commit/fe7e30b737ead6e71adfa466f5835ba546feab31)
+ [Improve SerializedObject.append performance](https://github.com/ripple/ripple-lib/commit/f7c35b118ebba549a64bcaa1a0629385ec6dbf6f)
+ [Add `Amount.scale`. Multiply an amounts value by a scale factor](https://github.com/ripple/ripple-lib/commit/74dac97b368493056474468520f05671f458a69f)
##0.12.2
## 0.12.2
+ [Check that stack trace is available, fixes logging in browser](https://github.com/ripple/ripple-lib/commit/53cae3a66d48e88e8a6bbb96d6489ce7b9e22975)
## 0.12.1
##0.12.1
**Breaking Changes**
__BREAKING CHANGES__
+ [Removed support for parsing native amounts in floating point format](https://github.com/ripple/ripple-lib/commit/e80cd1ff55deae9cd5b0ae85be957f86856b887e)
**Changes**
__OTHER CHANGES__
+ [Fix taker pays funded calculation](https://github.com/ripple/ripple-lib/commit/5af824f5cf46c7b9caa58ee0a757bf854d26c8dc)
+ [Fix order funded amount calculation](https://github.com/ripple/ripple-lib/commit/b2cdb1a6aed968b1f306e8dadbd4b7ca37e5aa03)
+ [Fix handling of quality in order book](https://github.com/ripple/ripple-lib/commit/2a5a8b498da60df738ba18d5c265f34771e8a1af)
+ [Fix currency parsing of non-alphanumeric and no-currency currencies](https://github.com/ripple/ripple-lib/commit/2166bb2e88eae8d5f1aba77338f69e8a9edf6a6f)
+ [Add Amount.strict_mode for toggling range validation](https://github.com/ripple/ripple-lib/commit/b5ed8f59a7dab1a17491618b8d9193646c314fb4)
+ [Add filename and line number to log, use log.warn() for deprecations](https://github.com/ripple/ripple-lib/commit/90329d3d73f1a76675063655b407513e32dc048b)
+ [Add GlobalFreeze and NoFreeze flags](https://github.com/ripple/ripple-lib/commit/e2ed2bdbf6f01c7d4d690c2cf0b83fba94558dd7)
+ [Fix handling of falsy parameters in requestLedger](https://github.com/ripple/ripple-lib/commit/6023efed41b7812b3bab660a1c0dc9f0a21000b9)
+ [Fix Base:decode](https://github.com/ripple/ripple-lib/commit/719f39c01c6941d9a650aa94f95617793dd53ea0)
+ [Fix Amount: clone in ratio_human, product_human](https://github.com/ripple/ripple-lib/commit/19e17a8431550cf156b1ad669a19dedfe4e28e4a)
+ [Fix Amount.to_human for very small numbers](https://github.com/ripple/ripple-lib/commit/6abfa759aa09d68074ac558d96c4b126a7cd1719)
+ [Refactor base conversion](https://github.com/ripple/ripple-lib/commit/f2b63fa4a80663eb29472bc6bb1aea8159f1f205)
+ [Update binary transaction format](https://github.com/ripple/ripple-lib/commit/8e134918fb4c22983320a3102f955e4568bb1dfb)
+ [Add DefaultRipple account flag](https://github.com/ripple/ripple-lib/commit/3e249902c4cf25b4da5e75048c84ae391be83b10)
+ [Remove `Features` field requirement in `SetFee` transaction format](https://github.com/ripple/ripple-lib/commit/a20a649013646710c078d4ce1e210f87c7fe74fe)
+ [Remove `RegularKey` field requirement in `SetRegularKey` transaction format](https://github.com/ripple/ripple-lib/commit/c275174f27877ba8f389eb4efe969feb514d6e46)
## 0.12.0
##0.12.0
**Breaking Changes**
__BREAKING CHANGES__
+ REMOVED Remote storage interface
+ REMOVED Remote `ping` configuration
+ REMOVED Old/deprecated Remote server configuration (websocket_ip, websocket_port)
+ REMOVED browser `online` reconnect listener
- [Cleanup, deprecations - 2833a7b6](https://github.com/ripple/ripple-lib/commit/2833a7b66e696dab427464625077f9b93092d0d5)
+ Remove `jsbn` and use `bignumber.js` instead for big number math
+ The `allow_nan` flag has been removed. Results for invalid amounts will always be `NaN`
- [Refactor to use bignumber.js - d025b4a0](https://github.com/ripple/ripple-lib/commit/d025b4a0c3a98a6de27a1bee9573c85347bcd66b)
@@ -118,109 +526,76 @@
- [Check for null in isNumber - b86790c8](https://github.com/ripple/ripple-lib/commit/b86790c8543c239a532fd7697d4652829019d385)
- [Cleanup amount.js - d0fb291c](https://github.com/ripple/ripple-lib/commit/d0fb291c4e330193a244902156f1d74730da357d)
**Changes**
__OTHER CHANGES__
+ [Add deprecation warnings to request constructors. The first argument to request constructor functions should be an object containing request properties](https://github.com/ripple/ripple-lib/commit/35d76b3520934285f80059c1badd6c522539104c)
+ [Fix taker_gets_funded exceeding offer.TakerGets](https://github.com/ripple/ripple-lib/commit/b19ecb4482b589d575382b7a5d0480b963383bb1)
+ [Fix unsymmetric memo serializing](https://github.com/ripple/ripple-lib/commit/1ed36fabdbd54f4d31078c2b0eaa3becc0fe2821)
+ [Fix IOU value passed to `Amount.from_json()`](https://github.com/ripple/ripple-lib/commit/fd1b64393dffb3d1819cd40b8d43df43a4db042d)
+ [Update transaction binary parsing to account for XRP delivered amounts](https://github.com/ripple/ripple-lib/commit/35a346a674e6ee1e1e495db93700d55984efc7dd)
+ [Bumped dependencies](https://github.com/ripple/ripple-lib/commit/f9bc7cc746b44b24b61bbe260ae2e9d9617286da)
##0.11.0
## 0.11.0
+ [Track the funded status of an order based on cumulative account orders](https://github.com/ripple/ripple-lib/commit/67d39737a4d5e0fcd9d9b47b9083ee00e5a9e652) and [67d3973](https://github.com/ripple/ripple-lib/commit/b6b99dde022e1e14c4797e454b1d7fca50e49482)
+ Remove blobvault client from ripple-lib, use the [`ripple-vault-client`](https://github.com/ripple/ripple-vault-client) instead [9b3d62b7](https://github.com/ripple/ripple-lib/commit/9b3d62b765c4c25beae6eb0fa57ef3a07f2581b1)
+ [Add support for `ledger` option in requestBookOffers](https://github.com/ripple/ripple-lib/commit/34c0677c453c409ef0a5b351959abdc176d3bacb)
+ [Add support for `limit` option in requestBookOffers](https://github.com/ripple/ripple-lib/commit/d1d4452217c878d0b377d24830b4cd8b3162f6e0)
+ [Add `ledgerSelect` request constructor in `Remote`](https://github.com/ripple/ripple-lib/commit/98f40abfc3aa74dec5067a2d90002756cc8acd01)
+ [Default to binary data for commands that accept the binary flag](https://github.com/ripple/ripple-lib/commit/7cb113fcbcfc1e3e9830a999148b3e78df3387cc)
+ [Fix metadata account check](https://github.com/ripple/ripple-lib/commit/3f61598d6c87e3cc877af60e2d515f9eff73dfe1)
+ [Double check `tes` code before emitting `success`](https://github.com/ripple/ripple-lib/commit/97a8c874903eb7309d8f755955ac80872f670582)
+ [Decrease redundancy in binary account_tx parsing](https://github.com/ripple/ripple-lib/commit/0aba638e6e7f4f6e22cb6424eed3897ebad90a5a)
+ [Abort server connection on unrecoverable TLS error](https://github.com/ripple/ripple-lib/commit/000a2ea00c57157044aeca0fb3f24b37669b163c)
+ [Fix complete ledgers check on subscription that is not initial](https://github.com/ripple/ripple-lib/commit/89de91301e682a46dc60aaacc7ae152e8fe1b7c7)
##0.10.0
## 0.10.0
+ [Transaction changes](https://github.com/ripple/ripple-lib/pull/221)
+ **Important** `tef*` and `tel*` and errors will no longer be presented as
final. Rather than considering these errors final, ripple-lib will wait until
the `LastLedgerSequence` specified in the transaction is exceeded. This makes
failures more definitive, and ensures that no transaction will resubmit
indefinitely.
+ A new, final tej-class error is introduced to account for transactions that
are locally determined to have expired: `tejMaxLedger`.
+ [Allow per transaction fees to be set, `transaction.setFixedFee()`](https://github.com/ripple/ripple-lib/commit/9b22f279bcbe60ee6bcf4b7fa60a48e9c197a828)
+ [Improve memo support](https://github.com/ripple/ripple-lib/commit/1704ac4ae144c0ce54afad86f644c75a632080b1)
- Add `MemoFormat` property for memo
- Enforce `MemoFormat` and `MemoType` to be valid ASCII
- Support `text` and `json` MemoFormat
+ [Update jscl library](https://github.com/ripple/ripple-lib/commit/3204998fcb6f31d6c90532a737a4adb8a1e420f6)
+ [Update sjcl library](https://github.com/ripple/ripple-lib/commit/3204998fcb6f31d6c90532a737a4adb8a1e420f6)
- Improved entropy by taking advantage of platform crypto
- Use jscl's k256 curve instead of altering the c256 curve with k256 configuration
- **deprecated:** the c256 curve is linked to the k256 curve to provide backwards compatibility, this link will be removed in the future
- **Deprecated:** The c256 curve is linked to the k256 curve to provide backwards compatibility, this link will be removed in the future
+ [Fix empty queue check on reconnect](https://github.com/ripple/ripple-lib/commit/3c21994adcf72d1fbd87d453ceb917f9ad6df4ec)
##0.9.4
## 0.9.4
+ [Normalize offers from book_offers and transaction stream](https://github.com/ripple/ripple-lib/commit/86ed24b94cf7c8929c87db3a63e9bbea7f767e9c)
+ [Fix: Amount.to_human() precision rounding](https://github.com/ripple/ripple-lib/commit/e371cc2c3ceccb3c1cfdf18b98d80093147dd8b2)
+ [Fix: fractional drops in funded taker_pays setter](https://github.com/ripple/ripple-lib/commit/0d7fc0a573a144caac15dd13798b23eeb1f95fb4)
##0.9.3
## 0.9.3
+ [Change `presubmit` to emit immediately before transaction submit](https://github.com/ripple/ripple-lib/commit/7a1feaa89701bf861ab31ebd8ffdc8d8d1474e29)
+ [Add a "core" browser build of ripple-lib which has a subset of features and smaller file size](https://github.com/ripple/ripple-lib/pull/205)
+ [Update binformat with missing fields from rippled](https://github.com/ripple/ripple-lib/commit/cae980788efb00191bfd0988ed836d60cdf7a9a2)
+ [Wait for transaction validation before returning `tec` error](https://github.com/ripple/ripple-lib/commit/6bdd4b2670906588852fc4dda457607b4aac08e4)
+ [Change default `max_fee` on `Remote` to `1 XRP`](https://github.com/ripple/ripple-lib/commit/d6b1728c23ff85c3cc791bed6982a750641fd95f)
+ [Fix: Request ledger_accept should return the Remote](https://github.com/ripple/ripple-lib/pull/209)
##0.9.2
## 0.9.2
+ [**Breaking change**: Change accountRequest method signature](https://github.com/ripple/ripple-lib/commit/6f5d1104aa3eb440c518ec4f39e264fdce15fa15)
__BREAKING CHANGES__
+ [Change accountRequest method signature](https://github.com/ripple/ripple-lib/commit/6f5d1104aa3eb440c518ec4f39e264fdce15fa15)
__OTHER CHANGES__
+ [Add paging behavior for account requests, `account_lines` and `account_offers`](https://github.com/ripple/ripple-lib/commit/722f4e175dbbf378e51b49142d0285f87acb22d7)
+ [Add max_fee setter to transactions to set max fee the submitter is willing to pay] (https://github.com/ripple/ripple-lib/commit/24587fab9c8ad3840d7aa345a7037b48839e09d7)
+ [Fix: cap IOU Amounts to their max and min value] (https://github.com/ripple/ripple-lib/commit/f05941fbc46fdb7c6fe7ad72927af02d527ffeed)
+ [Add max_fee setter to transactions to set max fee the submitter is willing to pay](https://github.com/ripple/ripple-lib/commit/24587fab9c8ad3840d7aa345a7037b48839e09d7)
+ [Fix: cap IOU Amounts to their max and min value](https://github.com/ripple/ripple-lib/commit/f05941fbc46fdb7c6fe7ad72927af02d527ffeed)
Example on how to use paging with `account_offers`:
```
```js
// A valid `ledger_index` or `ledger_hash` is required to provide a reliable result.
// Results can change between ledger closes, so the provided ledger will be used as base.
var options = {
@@ -240,110 +615,70 @@ var request = remote.requestAccountOffers(options);
[Full working example](https://github.com/geertweening/ripple-lib-scripts/blob/master/account_offers_paging.js)
##0.9.1
## 0.9.1
+ Switch account requests to use ledgerSelect rather than ledgerChoose ([278df90](https://github.com/ripple/ripple-lib/commit/278df9025a20228de22379a53c76ca12d40fa591))
+ **Deprecated** setting `ident` and `account_index` on account requests ([278df90](https://github.com/ripple/ripple-lib/commit/278df9025a20228de22379a53c76ca12d40fa591))
+ Change initial account transaction sequence to 1 ([a3c1d06](https://github.com/ripple/ripple-lib/commit/a3c1d06eba883dc84fe2bfe700e4309795c84cac))
+ Fix: instance transaction withoute remote ([d3b6b81](https://github.com/ripple/ripple-lib/commit/d3b6b8127c7b01e416b400c25abf1719bdd008ca))
+ Fix: instance transaction without remote ([d3b6b81](https://github.com/ripple/ripple-lib/commit/d3b6b8127c7b01e416b400c25abf1719bdd008ca))
+ Fix: account root request ledger argument ([bc1f9f8](https://github.com/ripple/ripple-lib/commit/bc1f9f8a286b187d36ebaf552694e31e73742293))
+ Fix: rsign.js local signing and example ([d3b6b81](https://github.com/ripple/ripple-lib/commit/d3b6b8127c7b01e416b400c25abf1719bdd008ca) and [f1004c6](https://github.com/ripple/ripple-lib/commit/f1004c6db2a0ce59bbabbb8f2b355a9fd9995fd8))
## 0.9.0
##0.9.0
__BREAKING CHANGES__
+ Make maxLoops in seed.get_key optional. [Example use in tests](https://github.com/ripple/ripple-lib/blob/23e473b6886c457781949c825b3ff48b3984e51f/test/seed-test.js) ([23e473b](https://github.com/ripple/ripple-lib/commit/23e473b6886c457781949c825b3ff48b3984e51f))
__OTHER CHANGES__
+ Add routes to the vault client for KYC attestations ([ed2da574](https://github.com/ripple/ripple-lib/commit/ed2da57475acf5e9d2cf3373858f4274832bd83f))
+ Currency: add `show_interest` flag to show or hide interest in `Currency.to_human()` and `Currency.to_json()` [Example use in tests](https://github.com/ripple/ripple-lib/blob/947ec3edc2e7c8f1ef097e496bf552c74366e749/test/currency-test.js#L123)
+ Configurable maxAttempts for transaction submission ([d107092](https://github.com/ripple/ripple-lib/commit/d10709254061e9e4416d2cb78b5cac1ec0d7ffa5))
+ Binformat: added missing TransactionResult options ([6abed8d](https://github.com/ripple/ripple-lib/commit/6abed8dd5311765b2eb70505dadbdf5121439ca8))
+ **Breaking change:** make maxLoops in seed.get_key optional. [Example use in tests](https://github.com/ripple/ripple-lib/blob/23e473b6886c457781949c825b3ff48b3984e51f/test/seed-test.js) ([23e473b](https://github.com/ripple/ripple-lib/commit/23e473b6886c457781949c825b3ff48b3984e51f))
+ Shrinkwrap packages for dependency locking ([2dcd5f9](2dcd5f94fbc71200eb08a5044c76ef94f7971913))
+ Fix: Amount.to_human() precision bugs ([4be209e](https://github.com/ripple/ripple-lib/commit/4be209e286b5b209bec7bcd1212098985e15ff2f) and [7708c64](https://github.com/ripple/ripple-lib/commit/7708c64576e70ce3ac190442daceb30e4446aab7))
+ Fix: change handling of requestLedger options ([57b7030](https://github.com/ripple/ripple-lib/commit/57b70300f5f0c7534ede118ddbb5d8762668a4f8))
##0.8.2
## 0.8.2
+ Currency: Allow mixed letters and numbers in currencies
+ Deprecate account_tx map/reduce/filterg
+ Fix: correct requestLedger arguments
+ Fix: missing subscription on error events for some server methods
+ Fix: orderbook reset on reconnect
+ Fix: ripple-lib crashing. Add potential missing error handlers
##0.8.1
## 0.8.1
+ Wallet: Add Wallet class that generates wallets
+ Make npm test runnable in Windows.
+ Fix several stability issues, see merged PR's for details
+ Fix bug in Amount.to_human_full()
+ Fix undefined fee states when connecting to a rippled that is syncing
##0.8.0
## 0.8.0
+ Orderbook: Added tracking of offer funds for determining when offers are not funded
+ Orderbook: Added tests
+ Orderbook: Update owner funds
+ Transactions: If transaction errs with `tefALREADY`, wait until all possible submissions err with the same before emitting `error`. Fixes a client "Transaction malformed" bug.
+ Transactions: Track submissions, don't bother submitting to unconnected servers
+ Request: `request.request()` now accepts an array of servers as first argument. Servers can be represented with URL, or the server object itself.
+ Request: `request.broadcast()` now returns the number of servers request was sent to
+ Server: Acquire host information from server without additional request
+ Amount: Add a constant for the maximum canonical value that can be expressed as a Ripple value
+ Amount: Make Constants static fields on the class, instead of a separate export
+ Amount: Make Constants static fields on the class, instead of a seperate export
##0.7.39
## 0.7.39
+ Improvements to multi-server support. Fixed an issue where a server's score was not reset and connections would keep dropping after being connected for a significant amount of time.
+ Improvements in order book support. Added support for currency pairs with interest bearing currencies. You can request an order book with hex, ISO code or full name for the currency.
+ Fix value parsing for amount/currency order pairs, e.g. `Amount.from_human("XAU 12345.6789")`
+ Improved Amount parsing from human readable string given a hex currency, e.g. `Amount.from_human("10 015841551A748AD2C1F76FF6ECB0CCCD00000000")`
+ Improvements to username normalization in the vault client
+ Add 2-factor authentication support for vault client
+ Removed vestiges of Grunt, switched to Gulp
##0.7.37
## 0.7.37
+ **Deprecations**
@@ -354,11 +689,8 @@ var request = remote.requestAccountOffers(options);
5. Removed `transaction.transactionManager` getter.
+ Improved multi-server support. Servers are now ranked dynamically, and transactions are broadcasted to all connected servers.
+ Automatically ping connected servers. Client configuration now should contain `ping: <seconds>` to specify the ping interval.
+ Added `transaction.lastLedger` to specify `LastLedgerSequence`. Setting it this way also ensures that the sequence is not bumped on subsequent requests.
+ Added optional `remote.accountTx` binary parsing.
```js
{
@@ -367,28 +699,19 @@ var request = remote.requestAccountOffers(options);
}
```
+ Added full currency name support, e.g. `Currency.from_json('XRP').to_human({full_name:'Ripples'})` will return `XRP - Ripples`
+ Improved interest bearing currency support, e.g. `Currency.from_human('USD - US Dollar (2.5%pa)')`
+ Improve test coverage
+ Added blob vault client. The vault client facilitates interaction with ripple's namespace and blob vault or 3rd party blob vaults using ripple's blob vault software (https://github.com/ripple/ripple-blobvault). A list of the available functions can be found at [docs/VAULTCLIENT.md](docs/VAULTCLIENT.md)
##0.7.35
## 0.7.35
+ `LastLedgerSequence` is set by default on outgoing transactions. This refers to the last valid ledger index (AKA sequence) for a transaction. By default, this index is set to the current index (at submission time) plus 8. In theory, this allows ripple-lib to deterministically fail a transaction whose submission request timed out, but whose associated server continues to emit ledger_closed events.
+ Transactions that err with `telINSUF_FEE_P` will be automatically resubmitted. This error indicates that the `Fee` supplied in the transaction submission request was inadquate. Ideally, the `Fee` is tracked by ripple-lib in real-time, and the resubmitted transaction will most likely succeed.
+ Transactions that err with `telINSUF_FEE_P` will be automatically resubmitted. This error indicates that the `Fee` supplied in the transaction submission request was inadequate. Ideally, the `Fee` is tracked by ripple-lib in real-time, and the resubmitted transaction will most likely succeed.
+ Added Transaction.iff(function(callback) { }). Callback expects first argument to be an Error or null, second argument is a boolean which indicates whether or not to proceed with the transaction submission. If an `iff` function is specified, it will be executed prior to every submission of the transaction (including resubmissions).
+ Transactions will now emit `presubmit` and `postsubmit` events. They will be emitted before and after a transaction is submitted, respectively.
+ Added Transaction.summary(). Returns a summary of a transaction in semi-human-readable form. JSON-stringifiable.
+ Remote.requestAccountTx() with `binary: true` will automatically parse transactions.
+ Added Remote.requestAccountTx filter, map, and reduce.
```js
@@ -416,6 +739,4 @@ var request = remote.requestAccountOffers(options);
```
+ Added persistence hooks.
+ General performance improvements, especially for long-running processes.

43
LICENSE
View File

@@ -1,4 +1,6 @@
Copyright (c) 2012,2013,2014 Ripple Labs Inc.
ISC License
Copyright (c) 2012-2015 Ripple Labs Inc.
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@@ -11,42 +13,3 @@ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
--------------------------------------
Some code from Tom Wu:
This software is covered under the following copyright:
Copyright (c) 2003-2005 Tom Wu
All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL TOM WU BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
In addition, the following condition applies:
All redistributions must retain an intact copy of this copyright notice
and disclaimer.
Address all questions regarding this license to:
Tom Wu
tjw@cs.Stanford.EDU

109
README.md
View File

@@ -1,100 +1,73 @@
#ripple-lib
# ripple-lib
A JavaScript API for interacting with Ripple in Node.js and the browser
A JavaScript API for interacting with the XRP Ledger
[![Circle CI](https://circleci.com/gh/ripple/ripple-lib/tree/develop.svg?style=svg)](https://circleci.com/gh/ripple/ripple-lib/tree/develop) [![Coverage Status](https://coveralls.io/repos/ripple/ripple-lib/badge.png?branch=develop)](https://coveralls.io/r/ripple/ripple-lib?branch=develop)
[![NPM](https://nodei.co/npm/ripple-lib.png)](https://www.npmjs.org/package/ripple-lib)
###Features
### Features
+ Connect to a rippled server in JavaScript (Node.js or browser)
+ Connect to a `rippled` server from Node.js or a web browser
+ Issue [rippled API](https://ripple.com/build/rippled-apis/) requests
+ Listen to events on the Ripple network (transaction, ledger, etc.)
+ Sign and submit transactions to the Ripple network
+ Listen to events on the XRP Ledger (transaction, ledger, etc.)
+ Sign and submit transactions to the XRP Ledger
###In this file
## Getting Started
1. [Installation](#installation)
2. [Quick start](#quick-start)
3. [Running tests](#running-tests)
See also: [RippleAPI Beginners Guide](https://ripple.com/build/rippleapi-beginners-guide/)
###Additional documentation
You can use `npm`, but we recommend using `yarn` for the added assurance provided by `yarn.lock`.
1. [Guides](docs/GUIDES.md)
2. [API Reference](docs/REFERENCE.md)
3. [Wiki](https://ripple.com/wiki/Ripple_JavaScript_library)
###Also see
+ [The Ripple wiki](https://ripple.com/wiki)
+ [ripple.com](https://ripple.com)
##Installation
**Via npm for Node.js**
+ [Yarn Installation Instructions](https://yarnpkg.com/en/docs/install)
Install `ripple-lib`:
```
$ npm install ripple-lib
$ yarn add ripple-lib
```
**Via bower (for browser use)**
Then see the [documentation](https://github.com/ripple/ripple-lib/blob/develop/docs/index.md) and [code samples](https://github.com/ripple/ripple-lib/tree/develop/docs/samples).
### Mailing Lists
We have a low-traffic mailing list for announcements of new ripple-lib releases. (About 1 email per week)
+ [Subscribe to ripple-lib-announce](https://groups.google.com/forum/#!forum/ripple-lib-announce)
If you're using the XRP Ledger in production, you should run a [rippled server](https://github.com/ripple/rippled) and subscribe to the ripple-server mailing list as well.
+ [Subscribe to ripple-server](https://groups.google.com/forum/#!forum/ripple-server)
## Development
To build the library for Node.js:
```
$ bower install ripple
$ yarn compile
```
See the [bower-ripple repo](https://github.com/ripple/bower-ripple) for additional bower instructions.
**Building ripple-lib for browser environments**
ripple-lib uses Gulp to generate browser builds. These steps will generate minified and non-minified builds of ripple-lib in the `build/` directory.
The TypeScript compiler will [output](./tsconfig.json#L7) the resulting JS files in `./dist/npm/`.
To build the library for the browser:
```
$ git clone https://github.com/ripple/ripple-lib
$ npm install
$ npm run build
$ yarn build
```
**Restricted browser builds**
Gulp will [output](./Gulpfile.js) the resulting JS files in `./build/`.
You may generate browser builds that contain a subset of features. To do this, run `./node_modules/.bin/gulp build-<name>`
For more details, see the `scripts` in `package.json`.
+ `build-core` Contains the functionality to make requests and listen for events such as `ledgerClose`. Only `ripple.Remote` is currently exposed. Advanced features like transaction submission and orderbook tracking are excluded from this build.
##Quick start
`Remote.js` ([remote.js](https://github.com/ripple/ripple-lib/blob/develop/src/js/ripple/remote.js)) is the point of entry for interacting with rippled
```js
/* Loading ripple-lib with Node.js */
var Remote = require('ripple-lib').Remote;
/* Loading ripple-lib in a webpage */
// var Remote = ripple.Remote;
var remote = new Remote({
// see the API Reference for available options
servers: [ 'wss://s1.ripple.com:443' ]
});
remote.connect(function() {
/* remote connected */
remote.requestServerInfo(function(err, info) {
// process err and info
});
});
```
##Running tests
## Running Tests
1. Clone the repository
2. `cd` into the repository and install dependencies with `yarn install`
3. `yarn test`
2. `cd` into the repository and install dependencies with `npm install`
## Generating Documentation
3. `npm test`
The continuous integration tests require that the documentation stays up-to-date. If you make changes to the JSON schemas, fixtures, or documentation sources, you must update the documentation by running `yarn run docgen`.
**Generating code coverage**
`npm` may be used instead of `yarn` in the commands above.
ripple-lib uses `istanbul` to generate code coverage. To create a code coverage report, run `npm test --coverage`. The report will be created in `coverage/lcov-report/`.
## More Information
+ [Ripple Developer Center](https://ripple.com/build/)

View File

@@ -1,65 +0,0 @@
#!/bin/bash -ex
NODE_INDEX="$1"
TOTAL_NODES="$2"
typecheck() {
npm install -g flow-bin
flow --version
npm run typecheck
}
lint() {
echo "eslint $(node_modules/.bin/eslint --version)"
npm list babel-eslint | grep babel-eslint
REPO_URL="https://raw.githubusercontent.com/ripple/javascript-style-guide"
curl "$REPO_URL/es6/eslintrc" > ./eslintrc
echo "parser: babel-eslint" >> ./eslintrc
node_modules/.bin/eslint -c ./eslintrc $(git --no-pager diff --name-only -M100% --diff-filter=AM --relative $(git merge-base FETCH_HEAD origin/HEAD) FETCH_HEAD | grep "\.js$")
}
unittest() {
# test "src"
npm test --coverage
npm run coveralls
# test compiled version in "dist/npm"
babel -D --optional runtime --ignore "**/node_modules/**" -d test-compiled/ test/
echo "--reporter spec --timeout 5000 --slow 500" > test-compiled/mocha.opts
mkdir -p test-compiled/node_modules
ln -nfs ../../dist/npm/core test-compiled/node_modules/ripple-lib
ln -nfs ../../dist/npm test-compiled/node_modules/ripple-api
mocha --opts test-compiled/mocha.opts test-compiled
rm -rf test-compiled
}
oneNode() {
lint
typecheck
unittest
}
twoNodes() {
case "$NODE_INDEX" in
0) lint && unittest;;
1) typecheck;;
*) echo "ERROR: invalid usage"; exit 2;;
esac
}
threeNodes() {
case "$NODE_INDEX" in
0) lint;;
1) typecheck;;
2) unittest;;
*) echo "ERROR: invalid usage"; exit 2;;
esac
}
case "$TOTAL_NODES" in
"") oneNode;;
1) oneNode;;
2) twoNodes;;
3) threeNodes;;
*) echo "ERROR: invalid usage"; exit 2;;
esac

View File

@@ -1,52 +0,0 @@
#!/usr/bin/env node
/* eslint-disable no-var */
'use strict';
var SerializedObject = require('..').SerializedObject;
function main() {
var argv = process.argv.slice(2);
var blob = argv.shift();
if (blob === '-') {
read_input(ready);
} else {
ready(blob);
}
}
function read_input(callback) {
var tx_json = '';
process.stdin.on('data', function(data) {
tx_json += data;
});
process.stdin.on('end', callback);
process.stdin.resume();
}
function ready(blob) {
var valid_arguments = blob;
if (!valid_arguments) {
console.error('Invalid arguments\n');
print_usage();
} else {
decode(blob);
}
}
function print_usage() {
/* eslint-disable max-len */
console.log(
'Usage: decode_binary.js <hex_blob>\n\n',
'Example: decode_binary.js 120000240000000161D6871AFD498D00000000000000000000000000005553440000000000550FC62003E785DC231A1058A05E56E3F09CF4E668400000000000000A732102AE75B908F0A95F740A7BFA96057637E5C2170BC8DAD13B2F7B52AE75FAEBEFCF811450F97A072F1C4357F1AD84566A609479D927C9428314550FC62003E785DC231A1058A05E56E3F09CF4E6'
);
/* eslint-enable max-len */
}
function decode(blob) {
var buffer = new SerializedObject(blob);
console.log(buffer.to_json());
}
main();
// vim:sw=2:sts=2:ts=8:et

View File

@@ -1,97 +0,0 @@
#!/usr/bin/env node
/* eslint-disable no-var */
'use strict';
var Transaction = require('..').Transaction;
function read_input(callback) {
var stdin = '';
process.stdin.on('data', function(data) {
stdin += data;
});
process.stdin.on('end', function() {
callback(stdin);
});
process.stdin.resume();
}
function print_usage() {
console.log(
'Usage: rsign.js <secret> <json>\n\n',
'Example: rsign.js ssq55ueDob4yV3kPVnNQLHB6icwpC', '\'' +
JSON.stringify({
TransactionType: 'Payment',
Account: 'r3P9vH81KBayazSTrQj6S25jW6kDb779Gi',
Destination: 'r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV',
Amount: '200000000',
Fee: '10',
Sequence: 1
}) + '\''
);
}
function sign_transaction(tx_json_object, secret, verbose) {
var tx = new Transaction();
tx.tx_json = tx_json_object;
tx._secret = secret;
tx.complete();
var unsigned_blob = tx.serialize().to_hex();
var unsigned_hash = tx.signingHash();
tx.sign();
if (verbose) {
var sim = { };
sim.tx_blob = tx.serialize().to_hex();
sim.tx_json = tx.tx_json;
sim.tx_signing_hash = unsigned_hash;
sim.tx_unsigned = unsigned_blob;
console.log(JSON.stringify(sim, null, 2));
} else {
console.log(tx.serialize().to_hex());
}
}
function ready(tx_json, secret, verbose) {
if (!(tx_json && secret)) {
console.error('Invalid arguments\n');
print_usage();
return;
}
var tx_json_object;
try {
tx_json_object = JSON.parse(tx_json);
} catch(exception) {
console.error('Invalid JSON\n');
print_usage();
return;
}
sign_transaction(tx_json_object, secret, verbose);
}
function main() {
var argv = process.argv.slice(2);
var verbose;
var secret;
var tx_json;
if (~argv.indexOf('-v')) {
argv.splice(argv.indexOf('-v'), 1);
verbose = true;
}
secret = argv.shift();
tx_json = argv.shift();
if (tx_json === '-') {
read_input(function(stdin) {
ready(stdin, secret, verbose);
});
} else {
ready(tx_json, secret, verbose);
}
}
main();
// vim:sw=2:sts=2:ts=8:et

View File

@@ -1,32 +0,0 @@
#!/usr/bin/env node
/* eslint-disable no-var */
'use strict';
var UInt160 = require('..').UInt160;
function main() {
var address = process.argv[2];
if (address === '-') {
readInput(validateAddress);
} else {
validateAddress(address);
}
}
function readInput(callback) {
var result = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(data) {
result += data;
});
process.stdin.on('end', function() {
callback(result);
});
}
function validateAddress(address) {
process.stdout.write((UInt160.is_valid(address.trim()) ? '0' : '1') + '\r\n');
}
main();

View File

@@ -1,7 +1,18 @@
machine:
node:
version: 0.12.0
version: 6.11.3
hosts:
testripple.circleci.com: 127.0.0.1
dependencies:
pre:
- wget https://s3-us-west-2.amazonaws.com/ripple-debs/rippled_0.30.1-b11-1.deb
- sudo dpkg -i rippled_0.30.1-b11-1.deb
test:
pre:
- rippled -a --start --conf "$HOME/$CIRCLE_PROJECT_REPONAME/test/integration/rippled.cfg":
background: true
override:
- bin/ci.sh "$CIRCLE_NODE_INDEX" "$CIRCLE_NODE_TOTAL":
- scripts/ci.sh "$CIRCLE_NODE_INDEX" "$CIRCLE_NODE_TOTAL":
parallel: true
post:
- killall /usr/bin/rippled

9
custom_typings/node.d.ts vendored Normal file
View File

@@ -0,0 +1,9 @@
/**
* This is an extension of Node's `process` object to include the browser
* property, which is added by webpack.
*/
interface AmbiguousProcess extends NodeJS.Process {
browser?: true
}
declare var process: AmbiguousProcess;

View File

@@ -1,20 +0,0 @@
Using Flow typechecking
=======================
Stage 1
-------
1. Add /* @flow */ to the top of a file you want to typecheck
2. Run `gulp typecheck` to generate a list of warnings
Stage 2
-------
When all source files have the /* @flow */ header and all warnings have been
addressed, remove the `weak: true` option from Gulpfile.js, run
`gulp typecheck` and remove all the additional warnings.
Stage 3
-------
Add type annotations to the source code and run `gulp strip` to strip
the type annotations and write the output to the `out` directory. After
type annotations are added, the program must be run from the `out` directory
because Node does not understand the annotations

View File

@@ -1,252 +0,0 @@
#Guides
This file provides step-by-step walkthroughs for some of the most common usages of `ripple-lib`.
###In this document
1. [Connecting to the Ripple network with `Remote`](GUIDES.md#connecting-to-the-ripple-network)
2. [Using `Remote` functions and `Request` objects](GUIDES.md#sending-rippled-API-requests)
3. [Listening to the network](GUIDES.md#listening-to-the-network)
4. [Submitting a payment to the network](GUIDES.md#submitting-a-payment-to-the-network)
* [A note on transaction fees](GUIDES.md#a-note-on-transaction-fees)
5. [Submitting a trade offer to the network](GUIDES.md#submitting-a-trade-offer-to-the-network)
###Also see
1. [The ripple-lib README](../README.md)
2. [The ripple-lib API Reference](REFERENCE.md)
##Connecting to the Ripple network
1. [Get ripple-lib](../README.md#installation)
2. Load the ripple-lib module into a Node.js file or webpage:
```js
/* Loading ripple-lib with Node.js */
var Remote = require('ripple-lib').Remote;
/* Loading ripple-lib in a webpage */
// var Remote = ripple.Remote;
```
3. Create a new `Remote` and connect to the network:
```js
var options = {
trace : false,
trusted: true,
local_signing: true,
servers: [
{ host: 's-west.ripple.com', port: 443, secure: true }
]
};
var remote = new Remote(options);
remote.connect(function(err, res) {
/* remote connected, use some remote functions here */
});
```
__NOTE:__ See the API Reference for available [`Remote` options](REFERENCE.md#1-remote-options)
4. You're connected! Read on to see what to do now.
##Generating a new Ripple Wallet
```js
var ripple = require('ripple-lib');
// subscribing to a server allows for more entropy
var remote = new ripple.Remote({
servers: [
{ host: 's1.ripple.com', port: 443, secure: true }
]
});
remote.connect(function(err, res) {
/* remote connected */
});
// Wait for randomness to have been added.
// The entropy of the random generator is increased
// by random data received from a rippled
remote.once('random', function(err, info) {
var wallet = ripple.Wallet.generate();
console.log(wallet);
// { address: 'rEf4sbVobiiDGExrNj2PkNHGMA8eS6jWh3',
// secret: 'shFh4a38EZpEdZxrLifEnVPAoBRce' }
});
```
##Sending rippled API requests
`Remote` contains functions for constructing a `Request` object.
A `Request` is an `EventEmitter` so you can listen for success or failure events -- or, instead, you can provide a callback.
Here is an example, using [requestServerInfo](https://ripple.com/wiki/JSON_Messages#server_info).
+ Constructing a `Request` with event listeners
```js
var request = remote.requestServerInfo();
request.on('success', function onSuccess(res) {
//handle success
});
request.on('error', function onError(err) {
//handle error
});
request.request();
```
+ Using a callback:
```js
remote.request('server_info', function(err, res) {
if (err) {
//handle error
} else {
//handle success
}
});
```
__NOTE:__ See the API Reference for available [`Remote` functions](REFERENCE.md#2-remote-functions)
##Listening to the network
See the [wiki](https://ripple.com/wiki/JSON_Messages#subscribe) for details on subscription requests.
```js
/* Loading ripple-lib with Node.js */
var Remote = require('ripple-lib').Remote;
/* Loading ripple-lib in a webpage */
// var Remote = ripple.Remote;
var remote = new Remote({options});
remote.connect(function() {
var remote = new Remote({
// see the API Reference for available options
servers: [ 'wss://s1.ripple.com:443' ]
});
remote.connect(function() {
console.log('Remote connected');
var streams = [
'ledger',
'transactions'
];
var request = remote.requestSubscribe(streams);
request.on('error', function(error) {
console.log('request error: ', error);
});
// the `ledger_closed` and `transaction` will come in on the remote
// since the request for subscribe is finalized after the success return
// the streaming events will still come in, but not on the initial request
remote.on('ledger_closed', function(ledger) {
console.log('ledger_closed: ', JSON.stringify(ledger, null, 2));
});
remote.on('transaction', function(transaction) {
console.log('transaction: ', JSON.stringify(transaction, null, 2));
});
remote.on('error', function(error) {
console.log('remote error: ', error);
});
// fire the request
request.request();
});
});
```
* https://ripple.com/wiki/RPC_API#transactions_stream_messages
* https://ripple.com/wiki/RPC_API#ledger_stream_messages
##Submitting a payment to the network
Submitting a payment transaction to the Ripple network involves connecting to a `Remote`, creating a transaction, signing it with the user's secret, and submitting it to the `rippled` server. Note that the `Amount` module is used to convert human-readable amounts like '1 XRP' or '10.50 USD' to the type of Amount object used by the Ripple network.
```js
/* Loading ripple-lib Remote and Amount modules in Node.js */
var Remote = require('ripple-lib').Remote;
var Amount = require('ripple-lib').Amount;
/* Loading ripple-lib Remote and Amount modules in a webpage */
// var Remote = ripple.Remote;
// var Amount = ripple.Amount;
var MY_ADDRESS = 'rrrMyAddress';
var MY_SECRET = 'secret';
var RECIPIENT = 'rrrRecipient';
var AMOUNT = Amount.from_human('1 USD').set_issuer('rrrIssuer');
var remote = new Remote({ /* Remote options */ });
remote.connect(function() {
remote.setSecret(MY_ADDRESS, MY_SECRET);
var transaction = remote.createTransaction('Payment', {
account: MY_ADDRESS,
destination: RECIPIENT,
amount: AMOUNT
});
transaction.submit(function(err, res) {
/* handle submission errors / success */
});
});
```
###A note on transaction fees
A full description of network transaction fees can be found on the [Ripple Wiki](https://ripple.com/wiki/Transaction_Fee).
In short, transaction fees are very small amounts (on the order of ~10) of [XRP drops](https://ripple.com/wiki/Ripple_credits#Notes_on_drops) spent and destroyed with every transaction. They are largely used to account for network load and prevent spam. With `ripple-lib`, transaction fees are calculated locally by default and the fee you are willing to pay is submitted along with your transaction.
Since the fee required for a transaction may change between the time when the original fee was calculated and the time when the transaction is submitted, it is wise to use the [`fee_cushion`](REFERENCE.md#1-remote-options) to ensure that the transaction will go through. For example, suppose the original fee calculated for a transaction was 10 XRP drops but at the instant the transaction is submitted the server is experiencing a higher load and it has raised its minimum fee to 12 XRP drops. Without a `fee_cusion`, this transaction would not be processed by the server, but with a `fee_cusion` of, say, 1.5 it would be processed and you would just pay the 2 extra XRP drops.
The [`max_fee`](REFERENCE.md#1-remote-options) option can be used to avoid submitting a transaction to a server that is charging unreasonably high fees.
##Submitting a trade offer to the network
Submitting a trade offer to the network is similar to submitting a payment transaction. Here is an example offering to sell 1 USD in exchange for 100 XRP:
```js
/* Loading ripple-lib Remote and Amount modules in Node.js */
var Remote = require('ripple-lib').Remote;
var Amount = require('ripple-lib').Amount;
/* Loading ripple-lib Remote and Amount modules in a webpage */
// var Remote = ripple.Remote;
// var Amount = ripple.Amount;
var MY_ADDRESS = 'rrrMyAddress';
var MY_SECRET = 'secret';
var GATEWAY = 'rrrGateWay';
var remote = new Remote({ /* Remote options */ });
remote.connect(function() {
remote.setSecret(MY_ADDRESS, MY_SECRET);
var transaction = remote.createTransaction('OfferCreate', {
account: MY_ADDRESS,
taker_pays: '100',
taker_gets: '1/USD/' + GATEWAY
});
transaction.submit(function(err, res) {
/* handle submission errors / success */
});
});
```

View File

@@ -1,354 +0,0 @@
#API Reference
__(More examples coming soon!)__
###In this document:
1. [`Remote` options](REFERENCE.md#remote-options)
2. [`Request` constructors](REFERENCE.md#request-constructor-functions)
+ [Server requests](REFERENCE.md#server-requests)
+ [Ledger requests](REFERENCE.md#ledger-requests)
+ [Transaction requests](REFERENCE.md#transaction-requests)
+ [Account requests](REFERENCE.md#account-requests)
+ [Orderbook requests](REFERENCE.md#orderbook-requests)
+ [Transaction requests](REFERENCE.md#transaction-requests)
3. [`Transaction` constructors](REFERENCE.md#transaction-constructors)
+ [Transaction events](REFERENCE.md#transaction-events)
###Also see:
1. [The ripple-lib README](../README.md)
2. [The ripple-lib GUIDES](GUIDES.md)a
#Remote options
```js
/* Loading ripple-lib with Node.js */
var Remote = require('ripple-lib').Remote;
/* Loading ripple-lib in a webpage */
// var Remote = ripple.Remote;
var options = { };
var remote = new Remote(options);
```
A new `Remote` can be created with the following options:
+ `trace` *boolean default: false* Log all of the events emitted
+ `max_listeners` *number default: 0* Set maxListeners for servers
+ `trusted` *boolean default: false*, if remote is trusted (boolean)
+ `local_signing` *boolean default: true*
+ `local_fee` *boolean default: true* Set whether the transaction fee range will be set locally, see [A note on transaction fees](GUIDES.md#a-note-on-transaction-fees))
+ `fee_cushion` *number default: 1.2* Extra fee multiplier to account for async fee changes, see [A note on transaction fees](GUIDES.md#a-note-on-transaction-fees))
+ `max_fee` *number default: Infinity* Maximum acceptable transaction fee, see [A note on transaction fees](GUIDES.md#a-note-on-transaction-fees)
+ `servers` *array* Array of server objects of the following form:
```js
{
host: <string>,
port: <number>,
secure: <boolean>
}
```
or
```js
'wss://host:port'
```
#Request constructor functions
Some requests have helper methods to construct the requests object and set properties on the message object. These will often be the more used requests and the helper methods is the preferred way of constructing these requests.
Other request can still be made, but the type will have to be passed in directly to request constructor. See examples below.
If the method is camelCased and starts with `request`, it's a helper method that wraps the request constructor.
##Server requests
**[requestServerInfo([callback])](https://ripple.com/wiki/JSON_Messages#server_info)**
Returns information about the state of the server. If you are connected to multiple servers and want to select by a particular host, use `request.setServer`. Example:
```js
var request = remote.requestServerInfo();
request.setServer('wss://s1.ripple.com');
request.request(function(err, res) {
});
```
**[requestPeers([callback])](https://ripple.com/wiki/JSON_Messages#peers)**
**[requestConnect(ip, port, [callback])](https://ripple.com/wiki/JSON_Messages#connect)**
**[unl_list([callback])](https://ripple.com/wiki/JSON_Messages#unl_list)**
```js
var request = remote.request('un_list');
request.setServer('wss://s1.ripple.com');
request.request(function(err, res) {
});
```
**[unl_add(addr, comment, [callback])](https://ripple.com/wiki/JSON_Messages#unl_add)**
**[unl_delete(node, [callback])](https://ripple.com/wiki/JSON_Messages#unl_delete)**
##Ledger requests
**[requestLedger([opts], [callback])](https://ripple.com/wiki/JSON_Messages#ledger)**
**[requestLedgerHeader([callback])](https://wiki.ripple.com/JSON_Messages#ledger_data)**
**[requestLedgerCurrent([callback])](https://ripple.com/wiki/JSON_Messages#ledger_current)**
**[requestLedgerEntry(type, [callback])](https://ripple.com/wiki/JSON_Messages#ledger_entry)**
**[requestSubscribe([streams], [callback])](https://ripple.com/wiki/JSON_Messages#subscribe)**
Start receiving selected streams from the server.
**[requestUnsubscribe([streams], [callback])](https://ripple.com/wiki/JSON_Messages#unsubscribe)**
Stop receiving selected streams from the server.
##Account requests
**[requestAccountInfo(options, [callback])](https://ripple.com/wiki/JSON_Messages#account_info)**
Return information about the specified account.
```
var options = {
account: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B',
ledger: 'validated'
};
var request = remote.requestAccountInfo(options, function(err, info) {
/* process info */
});
// response
{
ledger_current_index: <number>,
account_data: {
Account: <string>,
Balance: <number>,
Flags: <number>,
LedgerEntryType: <string>,
OwnerCount: <number>,
PreviousTxnID: <string>,
PreviousTxnLgrSeq: <number>,
Sequence: <number> ,
index: <string>
}
}
```
**[requestAccountLines(options, [callback])](https://ripple.com/wiki/JSON_Messages#account_lines)**
**[requestAccountOffers(options, [callback])](https://ripple.com/wiki/JSON_Messages#account_offers)**
Return the specified account's outstanding offers.
Requests for both `account_lines` and `account_offers` support paging. The amount of results per response can be configured with the `limit`.
The responses can be paged through by using the `marker`.
```
// A valid `ledger_index` or `ledger_hash` is required to provide a reliable result.
// Results can change between ledger closes, so the provided ledger will be used as base.
var options = {
account: < rippleAccount >,
limit: < Number between 10 and 400 >,
ledger: < valid ledger_index or ledger_hash >
}
// The `marker` comes back in an account request if there are more results than are returned
// in the current response. The amount of results per response are determined by the `limit`.
if (marker) {
options.marker = < marker >;
}
var request = remote.requestAccountOffers(options);
```
**[requestAccountTransactions(options, [callback])](https://ripple.com/wiki/JSON_Messages#account_tx)**
Fetch a list of transactions that applied to this account.
Options:
+ `account`
+ `ledger_index_min`
+ `ledger_index_max`
+ `binary` *false*
+ `count` *false*
+ `descending` *false*
+ `offset` *0*
+ `limit`
+ `forward` *false*
+ `fwd_marker`
+ `rev_marker`
**[requestWalletAccounts(seed, [callback])](https://ripple.com/wiki/JSON_Messages#wallet_accounts)**
Return a list of accounts for a wallet. *Requires trusted remote*
**requestAccountBalance(account, [ledger], [callback])**
Get the balance for an account. Returns an [Amount](https://github.com/ripple/ripple-lib/blob/develop/src/js/ripple/amount.js) object.
**requestAccountFlags(account, [ledger], [callback])**
Return the flags for an account.
**requestOwnerCount(account, [ledger], [callback])**
Return the owner count for an account.
**requestRippleBalance(account, issuer, currency, [ledger], [callback])**
Return a request to get a ripple balance
##Orderbook requests
**[requestBookOffers(options, [callback])](https://ripple.com/wiki/JSON_Messages#book_offers)**
Return the offers for an order book, also called a *snapshot*
```js
var options = {
gets: {
issuer: < issuer >,
currency: < currency >
},
pays: {
issuer: < issuer >,
currency: < currency >
},
limit: < limit >
};
var request = remote.requestBookOffers(options);
request.request(function(err, offers) {
//handle offers
});
```
##Transaction requests
**[requestTransactionEntry(hash, [ledger_hash], [callback])](https://ripple.com/wiki/JSON_Messages#transaction_entry)**
Searches a particular ledger for a transaction hash. Default ledger is the open ledger.
**[requestTransaction(hash, [callback])](https://ripple.com/wiki/JSON_Messages#tx)**
Searches ledger history for validated transaction hashes.
**[requestSign(secret, tx_json, [callback])](https://ripple.com/wiki/JSON_Messages#sign)**
Sign a transaction. *Requires trusted remote*
**[requestSubmit([callback])](https://ripple.com/wiki/JSON_Messages#submit)**
Submit a transaction to the network. This command is used internally to submit transactions with a greater degree of reliability. See [Submitting a payment to the network](GUIDES.md#3-submitting-a-payment-to-the-network) for details.
**[pathFind(src_account, dst_account, dst_amount, src_currencies)](https://ripple.com/wiki/JSON_Messages#path_find)**
#Transaction constructors
Use `remote.createTransaction('TransactionType', [options])` to construct a transaction. To submit, use `transaction.submit([callback])`.
**Payment**
```js
var transaction = remote.createTransaction('Payment', {
account: MY_ADDRESS,
destination: DEST_ADDRESS,
amount: AMOUNT
});
```
**AccountSet**
```js
var transaction = remote.createTransaction('AccountSet', {
account: MY_ADDRESS,
set: 'RequireDest',
clear: 'RequireAuth'
});
```
**TrustSet**
```js
var transaction = remote.createTransaction('TrustSet', {
account: MY_ADDRESS,
limit: '1/USD/rrrrrrrrrrrrrrrrrrrrBZbvji'
});
```
**OfferCreate**
```js
var transaction = remote.createTransaction('OfferCreate', {
account: MY_ADDRESS,
taker_pays: '1',
taker_gets: '1/USD/rrrrrrrrrrrrrrrrrrrrBZbvji'
});
```
##Transaction events
[Transaction](https://github.com/ripple/ripple-lib/blob/develop/src/js/ripple/transaction.js) objects are EventEmitters. They may emit the following events.
+ `final` Transaction has erred or succeeded. This event indicates that the transaction has finished processing.
+ `error` Transaction has erred. This event is a final state.
+ `success` Transaction succeeded. This event is a final state.
+ `presubmit` Immediately before transaction is submitted
+ `postsubmit` Immediately after transaction is submitted
+ `submitted` Transaction has been submitted to the network. The submission may result in a remote error or success.
+ `resubmitted` Transaction is beginning resubmission.
+ `proposed` Transaction has been submitted *successfully* to the network. The transaction at this point is awaiting validation in a ledger.
+ `timeout` Transaction submission timed out. The transaction will be resubmitted.
+ `fee_adjusted` Transaction fee has been adjusted during its pending state. The transaction fee will only be adjusted if the remote is configured for local fees, which it is by default.
+ `abort` Transaction has been aborted. Transactions are only aborted by manual calls to `#abort`.
+ `missing` Four ledgers have closed without detecting validated transaction
+ `lost` Eight ledgers have closed without detecting validated transaction. Consider the transaction lost and err/finalize.
##Complete payment example
```js
remote.setSecret(MY_ADDRESS, MY_SECRET);
var transaction = remote.createTransaction('Payment', {
account: MY_ADDRESS,
destination: DEST_ADDRESS,
amount: AMOUNT
});
transaction.on('resubmitted', function() {
// initial submission failed, resubmitting
});
transaction.submit(function(err, res) {
// submission has finalized with either an error or success.
// the transaction will not be retried after this point
});
```
#Amount objects
Coming Soon

View File

@@ -1,168 +0,0 @@
ripple-vault-client
===================
A javascript / http client to interact with Ripple Vault servers.
The purpose of this tool is to enable applications in any javascript
environment to login with the ripple vault and access the decrypted
data stored using credentials originally obtained at ripple.com
## Vault Client Usage
vaultClient = new ripple.VaultClient(domain);
vaultClient.getAuthInfo(username, callback);
vaultClient.getRippleName(address, url, callback);
vaultClient.exists(username, callback);
vaultClient.login(username, password, callback);
vaultClient.relogin(id, cryptKey, callback);
vaultClient.unlock(username, password, encryptSecret, callback);
vaultClient.loginAndUnlock(username, password, callback);
vaultClient.register(options, callback);
vaultClient.deleteBlob(options, callback);
vaultClient.recoverBlob(options, callback);
vaultClient.rename(options, callback);
vaultClient.changePassword(options, callback);
vaultClient.verify(username, token, callback);
vaultClient.resendEmail(options, callback);
vaultClient.updateProfile(options, fn);
# Blob Methods
blob.encrypt();
blob.decrypt(encryptedBlob);
blob.encryptSecret(encryptionKey);
blob.decryptSecret(encryptionKey, secret);
blob.set(pointer, value, callback);
blob.unset(pointer, callback);
blob.extend(pointer, value, callback);
blob.unshift(pointer, value, callback);
blob.filter(pointer, field, value, subcommands, callback);
## Identity Vault
The identity vault stores identity information inside the encrypted
blob vault. The identity fields can be additionally encrypted with the
unlock key, that encrypts the secret, for added security. Methods are
accessed from the 'identity' property of the blob object.
# Identity fields
+ name
+ entityType (individual, corporation, organization)
+ email
+ phone
+ address
+ contact
+ line1
+ line2
+ city
+ postalCode
+ region - state/province/region
+ country
+ nationalID
+ number
+ type (ssn, taxID, passport, driversLicense, other)
+ country - issuing country
+ birthday
+ birthplace
# Identity Methods
blob.identity.set(pointer, key, value, callback);
blob.identity.unset(pointer, key, callback);
blob.identity.get(pointer, key);
blob.identity.getAll(key);
blob.identity.getFullAddress(key); //get text string of full address
## Spec Tests
Run `npm test` to test the high-level behavior specs
Ripple Txt
✓ should get the content of a ripple.txt file from a given domain
✓ should get currencies from a ripple.txt file for a given domain
✓ should get the domain from a given url
AuthInfo
✓ should get auth info
VaultClient
#initialization
✓ should be initialized with a domain
✓ should default to ripple.com without a domain
#exists
✓ should determine if a username exists on the domain
#login
✓ with username and password should retrive the blob, crypt key, and id
#relogin
✓ should retrieve the decrypted blob with blob vault url, id, and crypt key
#unlock
✓ should access the wallet secret using encryption secret, username and password
#loginAndUnlock
✓ should get the decrypted blob and decrypted secret given name and password
#register
✓ should create a new blob
#deleteBlob
✓ should remove an existing blob
#updateProfile
✓ should update profile parameters associated with a blob
Blob
#set
#extend
#unset
#unshift
#filter
#consolidate
#rename
✓ should change the username of a blob
#changePassword
✓ should change the password and keys of a blob
#recoverBlob
✓ should recover the blob given a username and secret
#verifyEmail
✓ should verify an email given a username and token
#resendVerifcationEmail
✓ should resend a verification given options
identity
#identity_set
#identity_get
#identity_getAll
#identity_getFullAddress
#identity_unset

View File

@@ -1,358 +0,0 @@
<html>
<head>
<style>
a {
text-decoration: none;
}
.method {
margin-bottom: 10px;
}
.details {
font-family: "Courier New", monospace;
white-space: pre;
display: none;
}
</style>
<script type="text/javascript">
function toggle(element) {
var results = element.parentElement.getElementsByClassName('details');
if (results.length > 0) {
var style = results[0].style;
style.display = (style.display === 'block') ? 'none' : 'block';
}
}
</script>
</head>
<body>
<h2><a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/index.js">RippleAPI</a></h2>
<div class="method">
connect()
</div>
<div class="method">
disconnect()
</div>
<div class="method">
isConnected()
</div>
<div class="method">
getServerInfo()
</div>
<div class="method">
getFee()
</div>
<div class="method">
getLedgerVersion()
</div>
<div class="method">
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/get-transaction.json">getTransaction</a>(
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/hash256.json">identifier</a>[,
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/transaction-options.json">options</a>]
)
<a href="#" onclick="javascript:toggle(this)">+</a>
<div class="details">
identifier: txhash
options: {minLedgerVersion: int, maxLedgerVersion: int}
</div>
</div>
<div class="method">
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/get-transactions.json">getTransactions</a>(
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/address.json">account</a>[,
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/transactions-options.json">options</a>]
)
<a href="#" onclick="javascript:toggle(this)">+</a>
<div class="details">
options: {
start: txhash,
limit: int,
minLedgerVersion: int,
maxLedgerVersion: int,
earliestFirst: bool,
excludeFailures: bool,
initiated: bool,
counterparty: address,
types: [string],
binary: bool
}
</div>
</div>
<div class="method">
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/get-trustlines.json">getTrustlines</a>(
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/address.json">account</a>[,
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/trustlines-options.json">options</a>]
)
<a href="#" onclick="javascript:toggle(this)">+</a>
<div class="details">
options: {counterparty: address, currency: string, limit: int, ledgerVersion: int}
</div>
</div>
<div class="method">
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/get-balances.json">getBalances</a>(
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/address.json">account</a>[,
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/trustlines-options.json">options</a>]
)
<a href="#" onclick="javascript:toggle(this)">+</a>
<div class="details">
options: {counterparty: address, currency: string, limit: int, ledgerVersion: int}
</div>
</div>
<div class="method">
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/get-paths.json">getPaths</a>(
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/pathfind.json">pathfind</a>
)
<a href="#" onclick="javascript:toggle(this)">+</a>
<div class="details">
pathfind: {
source: {
address: address,
currencies: [{
currency: string,
counterparty: address
}]
},
destination: adjustment
}
adjustment = {address: address, amount: amount, tag?: int}
amount = {currency: string, counterparty: address, value: floatstr}
</div>
</div>
<div class="method">
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/get-orders.json">getOrders</a>(
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/address.json">account</a>[,
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/orders-options.json">options</a>]
)
<a href="#" onclick="javascript:toggle(this)">+</a>
<div class="details">
options: {limit: int, ledverVersion: int}
</div>
</div>
<div class="method">
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/get-orderbook.json">getOrderbook</a>(
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/address.json">account</a>,
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/orderbook.json">orderbook</a>[,
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/orders-options.json">options</a>]
)
<a href="#" onclick="javascript:toggle(this)">+</a>
<div class="details">
orderbook: {
base: {
currency,
counterparty
},
counter: {
currency,
counterparty
}
}
options: {limit: int, ledverVersion: int}
</div>
</div>
<div class="method">
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/get-settings.json">getSettings</a>(
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/address.json">account</a>[,
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/settings-options.json">options</a>]
)
<a href="#" onclick="javascript:toggle(this)">+</a>
<div class="details">
options: {ledgerVersion: int}
</div>
</div>
<div class="method">
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/get-account-info.json">getAccountInfo</a>(
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/address.json">account</a>[,
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/settings-options.json">options</a>]
)
<a href="#" onclick="javascript:toggle(this)">+</a>
<div class="details">
options: {ledgerVersion: int}
</div>
</div>
<div class="method">
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/tx.json">preparePayment</a>(
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/address.json">account</a>,
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/payment.json">payment</a>[,
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/instructions.json">instructions</a>]
)
<a href="#" onclick="javascript:toggle(this)">+</a>
<div class="details">
payment: {
source: adjustment,
destination: adjustment,
paths?: string,
slippage?: strfloat,
memos?: [{
type: string,
format: string,
data: string
}],
invoiceID?: hash256,
allowPartialPayment?: bool,
noDirectRipple?: bool,
limitQuality?: bool
}
adjustment = {address: address, amount: amount, tag?: int}
amount = {currency: string, counterparty: address, value: floatstr}
instructions: {
sequence: int,
fee: floatstr,
maxFee: floatstr,
maxLedgerVersion: int,
maxLedgerVersionOffset: int
}
</div>
</div>
<div class="method">
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/tx.json">prepareTrustline</a>(
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/address.json">account</a>,
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/trustline.json">trustline</a>[,
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/instructions.json">instructions</a>]
)
<a href="#" onclick="javascript:toggle(this)">+</a>
<div class="details">
trustline: {
currency: string,
counterparty: address,
limit: strfloat,
qualityIn?: float,
qualityOut?: float,
allowRippling?: bool,
authorized?: bool,
frozen?: bool
}
instructions: {
sequence: int,
fee: floatstr,
maxFee: floatstr,
maxLedgerVersion: int,
maxLedgerVersionOffset: int
}
</div>
</div>
<div class="method">
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/tx.json">prepareOrder</a>(
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/address.json">account</a>,
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/order.json">order</a>[,
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/instructions.json">instructions</a>]
)
<a href="#" onclick="javascript:toggle(this)">+</a>
<div class="details">
order: {
direction: ("buy"|"sell"),
quantity: amount,
totalPrice: amount,
immediateOrCancel?: bool,
fillOrKill?: bool,
passive?: bool
}
amount = {currency: string, counterparty: address, value: floatstr}
instructions: {
sequence: int,
fee: floatstr,
maxFee: floatstr,
maxLedgerVersion: int,
maxLedgerVersionOffset: int
}
</div>
</div>
<div class="method">
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/tx.json">prepareOrderCancellation</a>(
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/address.json">account</a>,
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/sequence.json">sequence</a>[,
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/instructions.json">instructions</a>]
)
<a href="#" onclick="javascript:toggle(this)">+</a>
<div class="details">
sequence: int
instructions: {
sequence: int,
fee: floatstr,
maxFee: floatstr,
maxLedgerVersion: int,
maxLedgerVersionOffset: int
}
</div>
</div>
<div class="method">
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/tx.json">prepareSettings</a>(
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/address.json">account</a>,
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/settings.json">settings</a>[,
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/instructions.json">instructions</a>]
)
<a href="#" onclick="javascript:toggle(this)">+</a>
<div class="details">
settings: {
passwordSpent: bool,
requireDestinationTag: bool,
requireAuthorization: bool,
disallowIncomingXRP: bool,
disableMasterKey: bool,
enableTransactionIDTracking: bool,
noFreeze: bool,
globalFreeze: bool,
defaultRipple: bool,
emailHash: hash128,
walletLocator: hash256,
walletSize: int,
messageKey: string,
domain: string,
transferRate: float,
signers: string,
regularKey: address
}
instructions: {
sequence: int,
fee: floatstr,
maxFee: floatstr,
maxLedgerVersion: int,
maxLedgerVersionOffset: int
}
</div>
</div>
<div class="method">
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/sign.json">sign</a>(
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/tx.json">txJSON</a>,
secret)
</div>
<div class="method">
submit(
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/schemas/blob.json">txBlob</a>
)
</div>
<div class="method">
generateWallet()
</div>
<a href="https://github.com/ripple/ripple-lib/blob/develop/src/api/common/errors.js">errors</a>
</body>
</html>

5431
docs/index.md Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
'use strict';
const RippleAPI = require('../../src').RippleAPI; // require('ripple-lib')
const api = new RippleAPI({servers: ['wss://s1.ripple.com:443']});
const api = new RippleAPI({server: 'wss://s1.ripple.com:443'});
const address = 'r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV';
api.connect().then(() => {

38
docs/samples/cancelall.js Normal file
View File

@@ -0,0 +1,38 @@
'use strict';
const RippleAPI = require('../../dist/npm').RippleAPI; // require('ripple-lib')
const address = 'rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K';
const secret = '';
const api = new RippleAPI({server: 'wss://s1.ripple.com:443'});
const instructions = {maxLedgerVersionOffset: 5};
function fail(message) {
console.error(message);
process.exit(1);
}
function cancelOrder(orderSequence) {
console.log('Cancelling order: ' + orderSequence.toString());
return api.prepareOrderCancellation(address, {orderSequence}, instructions)
.then(prepared => {
const signing = api.sign(prepared.txJSON, secret);
return api.submit(signing.signedTransaction);
});
}
function cancelAllOrders(orderSequences) {
if (orderSequences.length === 0) {
return Promise.resolve();
}
const orderSequence = orderSequences.pop();
return cancelOrder(orderSequence).then(() => cancelAllOrders(orderSequences));
}
api.connect().then(() => {
console.log('Connected...');
return api.getOrders(address).then(orders => {
const orderSequences = orders.map(order => order.properties.sequence);
return cancelAllOrders(orderSequences);
}).then(() => process.exit(0));
}).catch(fail);

View File

@@ -4,13 +4,13 @@ const RippleAPI = require('../../src').RippleAPI; // require('ripple-lib')
const address = 'INSERT ADDRESS HERE';
const secret = 'INSERT SECRET HERE';
const api = new RippleAPI({servers: ['wss://s1.ripple.com:443']});
const api = new RippleAPI({server: 'wss://s1.ripple.com:443'});
const instructions = {maxLedgerVersionOffset: 5};
const payment = {
source: {
address: address,
amount: {
maxAmount: {
value: '0.01',
currency: 'XRP'
}
@@ -24,18 +24,22 @@ const payment = {
}
};
function quit(message) {
console.log(message);
process.exit(0);
}
function fail(message) {
console.error(message);
process.exit(1);
}
api.connect().then(() => {
console.log('Connected...');
api.preparePayment(address, payment, instructions).then(txJSON => {
return api.preparePayment(address, payment, instructions).then(prepared => {
console.log('Payment transaction prepared...');
const signedTransaction = api.sign(txJSON, secret).signedTransaction;
const {signedTransaction} = api.sign(prepared.txJSON, secret);
console.log('Payment transaction signed...');
api.submit(signedTransaction).then(response => {
console.log(response);
process.exit(0);
}).catch(error => {
console.log(error);
process.exit(1);
});
api.submit(signedTransaction).then(quit, fail);
});
});
}).catch(fail);

View File

@@ -0,0 +1,55 @@
# Basic Types
## Address
```json
"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59"
```
Every XRP Ledger account has an *address*, which is a base58-encoding of a hash of the account's public key. XRP Ledger addresses always start with the lowercase letter `r`.
## Account Sequence Number
Every XRP Ledger account has a *sequence number* that is used to keep transactions in order. Every transaction must have a sequence number. A transaction can only be executed if it has the next sequence number in order, of the account sending it. This prevents one transaction from executing twice and transactions executing out of order. The sequence number starts at `1` and increments for each transaction that the account makes.
## Currency
Currencies are represented as either 3-character currency codes or 40-character uppercase hexadecimal strings. We recommend using uppercase [ISO 4217 Currency Codes](http://www.xe.com/iso4217.php) only. The string "XRP" is disallowed on trustlines because it is reserved for the XRP Ledger's native currency. The following characters are permitted: all uppercase and lowercase letters, digits, as well as the symbols `?`, `!`, `@`, `#`, `$`, `%`, `^`, `&`, `*`, `<`, `>`, `(`, `)`, `{`, `}`, `[`, `]`, and `|`.
## Value
A *value* is a quantity of a currency represented as a decimal string. Be careful: JavaScript's native number format does not have sufficient precision to represent all values. XRP has different precision from other currencies.
**XRP** has 6 significant digits past the decimal point. In other words, XRP cannot be divided into positive values smaller than `0.000001` (1e-6). This smallest unit is called a "drop". XRP has a maximum value of `100000000000` (1e11). Some RippleAPI methods accept XRP in order to maintain compatibility with older versions of the API. For consistency with the `rippled` APIs, we recommend formally specifying XRP values in *drops* in all API requests, and converting them to XRP for display. This is similar to Bitcoin's *satoshis* and Ethereum's *wei*. 1 XRP = 1,000,000 drops.
**Non-XRP values** have 16 decimal digits of precision, with a maximum value of `9999999999999999e80`. The smallest positive non-XRP value is `1e-81`.
## Amount
Example 100.00 USD amount:
```json
{
"currency": "USD",
"counterparty": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM",
"value": "100"
}
```
Example 3.0 XRP amount, in drops:
```json
{
"currency": "drops",
"value": "3000000"
}
```
(Requires `ripple-lib` version 1.0.0 or higher.)
An *amount* is an object specifying a currency, a quantity of that currency, and the counterparty (issuer) on the trustline that holds the value. For XRP, there is no counterparty.
A *lax amount* allows the counterparty to be omitted for all currencies. If the counterparty is not specified in an amount within a transaction specification, then any counterparty may be used for that amount.
A *lax lax amount* allows either or both the counterparty and value to be omitted.
A *balance* is an amount than can have a negative value.
<%- renderSchema('objects/amountbase.json') %>

View File

@@ -0,0 +1,62 @@
## Boilerplate
Use the following [boilerplate code](https://en.wikipedia.org/wiki/Boilerplate_code) to wrap your custom code using RippleAPI.
```javascript
const RippleAPI = require('ripple-lib').RippleAPI;
const api = new RippleAPI({
server: 'wss://s1.ripple.com' // Public rippled server hosted by Ripple, Inc.
});
api.on('error', (errorCode, errorMessage) => {
console.log(errorCode + ': ' + errorMessage);
});
api.on('connected', () => {
console.log('connected');
});
api.on('disconnected', (code) => {
// code - [close code](https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent) sent by the server
// will be 1000 if this was normal closure
console.log('disconnected, code:', code);
});
api.connect().then(() => {
/* insert code here */
}).then(() => {
return api.disconnect();
}).catch(console.error);
```
RippleAPI is designed to work in [Node.js](https://nodejs.org) version **6.11.3**. RippleAPI may work on older Node.js versions if you use [Babel](https://babeljs.io/) for [ECMAScript 6](https://babeljs.io/docs/learn-es2015/) support.
The code samples in this documentation are written with ECMAScript 6 (ES6) features, but `RippleAPI` also works with ECMAScript 5 (ES5). Regardless of whether you use ES5 or ES6, the methods that return Promises return [ES6-style promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise).
<aside class="notice">
All the code snippets in this documentation assume that you have surrounded them with this boilerplate.
</aside>
<aside class="notice">
If you omit the "catch" section, errors may not be visible.
</aside>
<aside class="notice">
The "error" event is emitted whenever an error occurs that cannot be associated with a specific request. If the listener is not registered, an exception will be thrown whenever the event is emitted.
</aside>
### Parameters
The RippleAPI constructor optionally takes one argument, an object with the following options:
<%- renderSchema('input/api-options.json') %>
If you omit the `server` parameter, RippleAPI operates [offline](#offline-functionality).
### Installation ###
1. Install [Node.js](https://nodejs.org) and [Yarn](https://yarnpkg.com/en/docs/install). Most Linux distros have a package for Node.js; check that it's the version you want.
2. Use yarn to install RippleAPI:
`yarn add ripple-lib`
After you have installed ripple-lib, you can create scripts using the [boilerplate](#boilerplate) and run them using the Node.js executable, typically named `node`:
`node script.js`

24
docs/src/combine.md.ejs Normal file
View File

@@ -0,0 +1,24 @@
## combine
`combine(signedTransactions: Array<string>): {signedTransaction: string, id: string}`
Combines signed transactions from multiple accounts for a multisignature transaction. The signed transaction must subsequently be [submitted](#submit).
### Parameters
<%- renderSchema("input/combine.json") %>
### Return Value
This method returns an object with the following structure:
<%- renderSchema("output/sign.json") %>
### Example
```javascript
const signedTransactions = <%- importFile('test/fixtures/requests/combine.json') %>;
return api.combine(signedTransactions);
```
<%- renderFixture("responses/combine.json") %>

View File

@@ -0,0 +1,28 @@
## computeLedgerHash
`computeLedgerHash(ledger: Object): string`
Compute the hash of a ledger.
### Parameters
<aside class="notice">
The parameter to this method has the same structure as the return value of getLedger.
</aside>
<%- renderSchema('input/compute-ledger-hash.json') %>
### Return Value
This method returns an uppercase hexadecimal string representing the hash of the ledger.
### Example
```javascript
const ledger = <%- importFile('test/fixtures/requests/compute-ledger-hash.json') %>;
return api.computeLedgerHash(ledger);
```
```json
"F4D865D83EB88C1A1911B9E90641919A1314F36E1B099F8E95FE3B7C77BE3349"
```

17
docs/src/connect.md.ejs Normal file
View File

@@ -0,0 +1,17 @@
## connect
`connect(): Promise<void>`
Tells the RippleAPI instance to connect to its rippled server.
### Parameters
This method has no parameters.
### Return Value
This method returns a promise that resolves with a void value when a connection is established.
### Example
See [Boilerplate](#boilerplate) for code sample.

View File

@@ -0,0 +1,19 @@
## deriveAddress
`deriveAddress(publicKey: string): string`
Derive an XRP Ledger address from a public key.
### Parameters
This method takes one parameter, the public key from which to derive the address.
### Return Value
This method returns a string corresponding to the address derived from the public key.
### Example
```javascript
var address = api.deriveAddress(public_key);
```

View File

@@ -0,0 +1,21 @@
## deriveKeypair
`deriveKeypair(seed: string): {privateKey: string, publicKey: string}`
Derive a public and private key from a seed.
### Parameters
This method takes one parameter, the seed from which to derive the public and private key.
### Return Value
This method returns an object containing the public and private components of the keypair corresponding to the seed.
### Example
```javascript
var keypair = api.deriveKeypair(seed)
var public_key = keypair.publicKey;
var private_key = keypair.privateKey;
```

View File

@@ -0,0 +1,17 @@
## disconnect
`disconnect(): Promise<void>`
Tells the RippleAPI instance to disconnect from its rippled server.
### Parameters
This method has no parameters.
### Return Value
This method returns a promise that resolves with a void value when a connection is destroyed.
### Example
See [Boilerplate](#boilerplate) for code sample

81
docs/src/events.md.ejs Normal file
View File

@@ -0,0 +1,81 @@
# API Events
## ledger
This event is emitted whenever a new ledger version is validated on the connected server.
### Return Value
<%- renderSchema('output/ledger-event.json') %>
### Example
```javascript
api.on('ledger', ledger => {
console.log(JSON.stringify(ledger, null, 2));
});
```
<%- renderFixture('responses/ledger-event.json') %>
## error
This event is emitted when there is an error on the connection to the server that cannot be associated to a specific request.
### Return Value
The first parameter is a string indicating the error type:
* `badMessage` - rippled returned a malformed message
* `websocket` - the websocket library emitted an error
* one of the error codes found in the [rippled Universal Errors](https://ripple.com/build/rippled-apis/#universal-errors).
The second parameter is a message explaining the error.
The third parameter is:
* the message that caused the error for `badMessage`
* the error object emitted for `websocket`
* the parsed response for rippled errors
### Example
```javascript
api.on('error', (errorCode, errorMessage, data) => {
console.log(errorCode + ': ' + errorMessage);
});
```
```
tooBusy: The server is too busy to help you now.
```
## connected
This event is emitted after connection successfully opened.
### Example
```javascript
api.on('connected', () => {
console.log('Connection is open now.');
});
```
## disconnected
This event is emitted when connection is closed.
### Return Value
The only parameter is a number containing the [close code](https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent) send by the server.
### Example
```javascript
api.on('disconnected', (code) => {
if (code !== 1000) {
console.log('Connection is closed due to error.');
} else {
console.log('Connection is closed normally.');
}
});
```

View File

@@ -0,0 +1,23 @@
## generateAddress
`generateAddress(): {address: string, secret: string}`
Generate a new XRP Ledger address and corresponding secret.
### Parameters
<%- renderSchema('input/generate-address.json') %>
### Return Value
This method returns an object with the following structure:
<%- renderSchema('output/generate-address.json') %>
### Example
```javascript
return api.generateAddress();
```
<%- renderFixture('responses/generate-address.json') %>

View File

@@ -0,0 +1,25 @@
## getAccountInfo
`getAccountInfo(address: string, options: Object): Promise<Object>`
Returns information for the specified account. Note: For account data that is modifiable by the user, see [getSettings](#getsettings).
### Parameters
<%- renderSchema('input/get-account-info.json') %>
### Return Value
This method returns a promise that resolves with an object with the following structure:
<%- renderSchema('output/get-account-info.json') %>
### Example
```javascript
const address = 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59';
return api.getAccountInfo(address).then(info =>
{/* ... */});
```
<%- renderFixture('responses/get-account-info.json') %>

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

@@ -0,0 +1,25 @@
## getBalanceSheet
`getBalanceSheet(address: string, options: Object): Promise<Object>`
Returns aggregate balances by currency plus a breakdown of assets and obligations for a specified account.
### Parameters
<%- renderSchema('input/get-balance-sheet.json') %>
### Return Value
This method returns a promise that resolves with an object with the following structure:
<%- renderSchema('output/get-balance-sheet.json') %>
### Example
```javascript
const address = 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59';
return api.getBalanceSheet(address).then(balanceSheet =>
{/* ... */});
```
<%- renderFixture('responses/get-balance-sheet.json') %>

View File

@@ -0,0 +1,25 @@
## getBalances
`getBalances(address: string, options: Object): Promise<Array<Object>>`
Returns balances for a specified account.
### Parameters
<%- renderSchema('input/get-balances.json') %>
### Return Value
This method returns a promise that resolves with an array of objects with the following structure:
<%- renderSchema('output/get-balances.json') %>
### Example
```javascript
const address = 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59';
return api.getBalances(address).then(balances =>
{/* ... */});
```
<%- renderFixture('responses/get-balances.json') %>

25
docs/src/getFee.md.ejs Normal file
View File

@@ -0,0 +1,25 @@
## getFee
`getFee(): Promise<string>`
Returns the estimated transaction fee for the rippled server the RippleAPI instance is connected to.
This will use the [feeCushion parameter](#parameters) provided to the RippleAPI constructor, or the default value of `1.2`.
### Parameters
<%- renderSchema('input/get-fee.json') %>
### Return Value
This method returns a promise that resolves with a string-encoded floating point value representing the estimated fee to submit a transaction, expressed in XRP.
### Example
```javascript
return api.getFee().then(fee => {/* ... */});
```
```json
"0.000012"
```

24
docs/src/getLedger.md.ejs Normal file
View File

@@ -0,0 +1,24 @@
## getLedger
`getLedger(options: Object): Promise<Object>`
Returns header information for the specified ledger (or the most recent validated ledger if no ledger is specified). Optionally, all the transactions that were validated in the ledger or the account state information can be returned with the ledger header.
### Parameters
<%- renderSchema('input/get-ledger.json') %>
### Return Value
This method returns a promise that resolves with an object with the following structure:
<%- renderSchema('output/get-ledger.json') %>
### Example
```javascript
return api.getLedger()
.then(ledger => {/* ... */});
```
<%- renderFixture('responses/get-ledger.json') %>

View File

@@ -0,0 +1,26 @@
## getLedgerVersion
`getLedgerVersion(): Promise<number>`
Returns the most recent validated ledger version number known to the connected server.
### Parameters
This method has no parameters.
### Return Value
This method returns a promise that resolves with a positive integer representing the most recent validated ledger version number known to the connected server.
### Example
```javascript
return api.getLedgerVersion().then(ledgerVersion => {
/* ... */
});
```
```json
16869039
```

View File

@@ -0,0 +1,32 @@
## getOrderbook
`getOrderbook(address: string, orderbook: Object, options: Object): Promise<Object>`
Returns open orders for the specified account. Open orders are orders that have not yet been fully executed and are still in the order book.
### Parameters
<%- renderSchema('input/get-orderbook.json') %>
### Return Value
This method returns a promise that resolves with an object with the following structure (Note: the structures of `bids` and `asks` are identical):
<%- renderSchema('output/get-orderbook.json') %>
### Raw order data
(Requires ripple-lib 0.22.0 or higher.) The response includes a `data` property containing the raw order data. This may include `owner_funds`, `Flags`, and other fields.
For details, see the rippled method [book_offers](https://ripple.com/build/rippled-apis/#book-offers).
### Example
```javascript
const address = 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59';
const orderbook = <%- importFile('test/fixtures/requests/get-orderbook.json') %>;
return api.getOrderbook(address, orderbook)
.then(orderbook => {/* ... */});
```
<%- renderFixture('responses/get-orderbook.json') %>

25
docs/src/getOrders.md.ejs Normal file
View File

@@ -0,0 +1,25 @@
## getOrders
`getOrders(address: string, options: Object): Promise<Array<Object>>`
Returns open orders for the specified account. Open orders are orders that have not yet been fully executed and are still in the order book.
### Parameters
<%- renderSchema('input/get-orders.json') %>
### Return Value
This method returns a promise that resolves with an array of objects with the following structure:
<%- renderSchema('output/get-orders.json') %>
### Example
```javascript
const address = 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59';
return api.getOrders(address).then(orders =>
{/* ... */});
```
<%- renderFixture('responses/get-orders.json') %>

25
docs/src/getPaths.md.ejs Normal file
View File

@@ -0,0 +1,25 @@
## getPaths
`getPaths(pathfind: Object): Promise<Array<Object>>`
Finds paths to send a payment. Paths are options for how to route a payment.
### Parameters
<%- renderSchema("input/get-paths.json") %>
### Return Value
This method returns a promise that resolves with an array of objects with the following structure:
<%- renderSchema("output/get-paths.json") %>
### Example
```javascript
const pathfind = <%- importFile('test/fixtures/requests/getpaths/normal.json') %>;
return api.getPaths(pathfind)
.then(paths => {/* ... */});
```
<%- renderFixture("responses/get-paths.json") %>

View File

@@ -0,0 +1,26 @@
## getPaymentChannel
`getPaymentChannel(id: string): Promise<Object>`
Returns specified payment channel.
### Parameters
<%- renderSchema('input/get-payment-channel.json') %>
### Return Value
This method returns a promise that resolves with an object with the following structure:
<%- renderSchema('output/get-payment-channel.json') %>
### Example
```javascript
const channelId =
'E30E709CF009A1F26E0E5C48F7AA1BFB79393764F15FB108BDC6E06D3CBD8415';
return api.getPaymentChannel(channelId).then(channel =>
{/* ... */});
```
<%- renderFixture('responses/get-payment-channel.json') %>

View File

@@ -0,0 +1,23 @@
## getServerInfo
`getServerInfo(): Promise<object>`
Get status information about the server that the RippleAPI instance is connected to.
### Parameters
This method has no parameters.
### Return Value
This method returns a promise that resolves with an object with the following structure:
<%- renderSchema('output/get-server-info.json') %>
### Example
```javascript
return api.getServerInfo().then(info => {/* ... */});
```
<%- renderFixture('responses/get-server-info.json') %>

View File

@@ -0,0 +1,25 @@
## getSettings
`getSettings(address: string, options: Object): Promise<Object>`
Returns settings for the specified account. Note: For account data that is not modifiable by the user, see [getAccountInfo](#getaccountinfo).
### Parameters
<%- renderSchema('input/get-settings.json') %>
### Return Value
This method returns a promise that resolves with an array of objects with the following structure (Note: all fields are optional as they will not be shown if they are set to their default value):
<%- renderSchema('output/get-settings.json') %>
### Example
```javascript
const address = 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59';
return api.getSettings(address).then(settings =>
{/* ... */});
```
<%- renderFixture('responses/get-settings.json') %>

View File

@@ -0,0 +1,26 @@
## getTransaction
`getTransaction(id: string, options: Object): Promise<Object>`
Retrieves a transaction by its [Transaction ID](#transaction-id).
### Parameters
<%- renderSchema('input/get-transaction.json') %>
### Return Value
This method returns a promise that resolves with a transaction object containing the following fields.
<%- renderSchema('output/get-transaction.json') %>
### Example
```javascript
const id = '01CDEAA89BF99D97DFD47F79A0477E1DCC0989D39F70E8AACBFE68CC83BD1E94';
return api.getTransaction(id).then(transaction => {
/* ... */
});
```
<%- renderFixture('responses/get-transaction-payment.json') %>

View File

@@ -0,0 +1,24 @@
## getTransactions
`getTransactions(address: string, options: Object): Promise<Array<Object>>`
Retrieves historical transactions of an account.
### Parameters
<%- renderSchema('input/get-transactions.json') %>
### Return Value
This method returns a promise that resolves with an array of transaction object in the same format as [getTransaction](#gettransaction).
### Example
```javascript
const address = 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59';
return api.getTransactions(address).then(transaction => {
/* ... */
});
```
<%- renderFixture('responses/get-transactions.json') %>

View File

@@ -0,0 +1,25 @@
## getTrustlines
`getTrustlines(address: string, options: Object): Promise<Array<Object>>`
Returns trustlines for a specified account.
### Parameters
<%- renderSchema("input/get-trustlines.json") %>
### Return Value
This method returns a promise that resolves with an array of objects with the following structure.
<%- renderSchema("output/get-trustlines.json") %>
### Example
```javascript
const address = 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59';
return api.getTrustlines(address).then(trustlines =>
{/* ... */});
```
<%- renderFixture("responses/get-trustlines.json") %>

View File

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

56
docs/src/index.md.ejs Normal file
View File

@@ -0,0 +1,56 @@
<% include introduction.md.ejs %>
<% include boilerplate.md.ejs %>
<% include offline.md.ejs %>
<% include basictypes.md.ejs %>
<% include transactions.md.ejs %>
<% include specifications.md.ejs %>
<% include rippledAPIs.md.ejs %>
<% include request.md.ejs %>
<% include hasNextPage.md.ejs %>
<% include requestNextPage.md.ejs %>
<% include methods.md.ejs %>
<% include connect.md.ejs %>
<% include disconnect.md.ejs %>
<% include isConnected.md.ejs %>
<% include getServerInfo.md.ejs %>
<% include getFee.md.ejs %>
<% include getLedgerVersion.md.ejs %>
<% include getTransaction.md.ejs %>
<% include getTransactions.md.ejs %>
<% include getTrustlines.md.ejs %>
<% include getBalances.md.ejs %>
<% include getBalanceSheet.md.ejs %>
<% include getPaths.md.ejs %>
<% include getOrders.md.ejs %>
<% 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 %>
<% include prepareTrustline.md.ejs %>
<% include prepareOrder.md.ejs %>
<% include prepareOrderCancellation.md.ejs %>
<% include prepareSettings.md.ejs %>
<% include prepareEscrowCreation.md.ejs %>
<% include prepareEscrowCancellation.md.ejs %>
<% include prepareEscrowExecution.md.ejs %>
<% 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 %>
<% include generateAddress.md.ejs %>
<% include isValidAddress.md.ejs %>
<% include isValidSecret.md.ejs %>
<% include deriveKeypair.md.ejs %>
<% include deriveAddress.md.ejs %>
<% include signPaymentChannelClaim.md.ejs %>
<% include verifyPaymentChannelClaim.md.ejs %>
<% include computeLedgerHash.md.ejs %>
<% include events.md.ejs %>

View File

@@ -0,0 +1,10 @@
# Introduction
RippleAPI (ripple-lib) is the official client library to the XRP Ledger. Currently, RippleAPI is only available in JavaScript.
Using RippleAPI, you can:
* [Query transactions from the XRP Ledger history](#gettransaction)
* [Sign](#sign) transactions securely without connecting to any server
* [Submit](#submit) transactions to the XRP Ledger, including [Payments](#payment), [Orders](#order), [Settings changes](#settings), and [other types](#transaction-types)
* [Generate a new XRP Ledger Address](#generateaddress)
* ... and [much more](#api-methods).

View File

@@ -0,0 +1,23 @@
## isConnected
`isConnected(): boolean`
Checks if the RippleAPI instance is connected to its rippled server.
### Parameters
This method has no parameters.
### Return Value
This method returns `true` if connected and `false` if not connected.
### Example
```javascript
return api.isConnected();
```
```json
true
```

View File

@@ -0,0 +1,19 @@
## isValidAddress
`isValidAddress(address: string): boolean`
Checks if the specified string contains a valid address.
### Parameters
This method takes one parameter, the address to validate.
### Return Value
This method returns `true` if the address is valid and `false` if it is not.
### Example
```javascript
return api.isValidAddress("address")
```

View File

@@ -0,0 +1,19 @@
## isValidSecret
`isValidSecret(secret: string): boolean`
Checks if the specified string contains a valid secret.
### Parameters
This method takes one parameter, the secret which to validate.
### Return Value
This method returns `true` if the secret is valid and `false` if it is not.
### Example
```javascript
return api.isValidSecret("secret")
```

1
docs/src/methods.md.ejs Normal file
View File

@@ -0,0 +1 @@
# API Methods

26
docs/src/offline.md.ejs Normal file
View File

@@ -0,0 +1,26 @@
## Offline functionality
RippleAPI can also function without internet connectivity. This can be useful in order to generate secrets and sign transactions from a secure, isolated machine.
To instantiate RippleAPI in offline mode, use the following boilerplate code:
```javascript
const RippleAPI = require('ripple-lib').RippleAPI;
const api = new RippleAPI();
/* insert code here */
```
Methods that depend on the state of the XRP Ledger are unavailable in offline mode. To prepare transactions offline, you **must** specify the `fee`, `sequence`, and `maxLedgerVersion` parameters in the [transaction instructions](#transaction-instructions). You can use the following methods while offline:
* [preparePayment](#preparepayment)
* [prepareTrustline](#preparetrustline)
* [prepareOrder](#prepareorder)
* [prepareOrderCancellation](#prepareordercancellation)
* [prepareSettings](#preparesettings)
* [prepareEscrowCreation](#prepareescrowcreation)
* [prepareEscrowCancellation](#prepareescrowcancellation)
* [prepareEscrowExecution](#prepareescrowexecution)
* [sign](#sign)
* [generateAddress](#generateaddress)
* [computeLedgerHash](#computeledgerhash)

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

@@ -0,0 +1,30 @@
## prepareEscrowCancellation
`prepareEscrowCancellation(address: string, escrowCancellation: Object, instructions: Object): Promise<Object>`
Prepare an escrow cancellation transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
### Parameters
<%- renderSchema('input/prepare-escrow-cancellation.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 escrowCancellation = <%- importFile('test/fixtures/requests/prepare-escrow-cancellation.json') %>;
return api.prepareEscrowCancellation(address, escrowCancellation).then(prepared =>
{/* ... */});
```
<%- renderFixture('responses/prepare-escrow-cancellation.json') %>

View File

@@ -0,0 +1,36 @@
## prepareEscrowCreation
`prepareEscrowCreation(address: string, escrowCreation: Object, instructions: Object): Promise<Object>`
Prepare an escrow creation transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
### Parameters
<%- renderSchema('input/prepare-escrow-creation.json') %>
This is a convenience method for generating the EscrowCreate JSON used by rippled, so the same restrictions apply.
Field mapping: `allowCancelAfter` is equivalent to rippled's `CancelAfter`; `allowExecuteAfter` is equivalent to `FinishAfter`. At the `allowCancelAfter` time, the escrow is considered expired. This means that the funds can only be returned to the sender. At the `allowExecuteAfter` time, the escrow is permitted to be released to the recipient (if the `condition` is fulfilled).
Note that `allowCancelAfter` must be chronologically later than `allowExecuteAfter`.
### Return Value
This method returns a promise that resolves with an object with the following structure:
<aside class="notice">
All "prepare*" methods have the same return type.
</aside>
<%- renderSchema('output/prepare.json') %>
### Example
```javascript
const address = 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59';
const escrowCreation = <%- importFile('test/fixtures/requests/prepare-escrow-creation.json') %>;
return api.prepareEscrowCreation(address, escrowCreation).then(prepared =>
{/* ... */});
```
<%- renderFixture('responses/prepare-escrow-creation.json') %>

View File

@@ -0,0 +1,30 @@
## prepareEscrowExecution
`prepareEscrowExecution(address: string, escrowExecution: Object, instructions: Object): Promise<Object>`
Prepare an escrow execution transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
### Parameters
<%- renderSchema('input/prepare-escrow-execution.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 escrowExecution = <%- importFile('test/fixtures/requests/prepare-escrow-execution.json') %>;
return api.prepareEscrowExecution(address, escrowExecution).then(prepared =>
{/* ... */});
```
<%- renderFixture('responses/prepare-escrow-execution.json') %>

View File

@@ -0,0 +1,32 @@
## prepareOrder
`prepareOrder(address: string, order: Object, instructions: Object): Promise<Object>`
Prepare an order transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
### Parameters
<%- renderSchema('input/prepare-order.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';
// Buy 10.10 USD (of the specified issuer) for 2.0 XRP (2000000 drops), fill or kill.
const order = <%- importFile('test/fixtures/requests/prepare-order.json') %>;
return api.prepareOrder(address, order)
.then(prepared => {/* ... */});
```
<%- renderFixture('responses/prepare-order.json') %>

View File

@@ -0,0 +1,30 @@
## prepareOrderCancellation
`prepareOrderCancellation(address: string, orderCancellation: Object, instructions: Object): Promise<Object>`
Prepare an order cancellation transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
### Parameters
<%- renderSchema("input/prepare-order-cancellation.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 orderCancellation = {orderSequence: 123};
return api.prepareOrderCancellation(address, orderCancellation)
.then(prepared => {/* ... */});
```
<%- renderFixture("responses/prepare-order-cancellation.json") %>

View File

@@ -0,0 +1,30 @@
## preparePayment
`preparePayment(address: string, payment: Object, instructions: Object): Promise<Object>`
Prepare a payment transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
### Parameters
<%- renderSchema("input/prepare-payment.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 payment = <%- importFile('test/fixtures/requests/prepare-payment.json') %>;
return api.preparePayment(address, payment).then(prepared =>
{/* ... */});
```
<%- renderFixture("responses/prepare-payment.json") %>

View File

@@ -0,0 +1,30 @@
## preparePaymentChannelClaim
`preparePaymentChannelClaim(address: string, paymentChannelClaim: Object, instructions: Object): Promise<Object>`
Prepare a payment channel claim transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
### Parameters
<%- renderSchema('input/prepare-payment-channel-claim.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 paymentChannelClaim = <%- importFile('test/fixtures/requests/prepare-payment-channel-claim.json') %>;
return api.preparePaymentChannelClaim(address, paymentChannelClaim).then(prepared =>
{/* ... */});
```
<%- renderFixture('responses/prepare-payment-channel-claim.json') %>

View File

@@ -0,0 +1,30 @@
## preparePaymentChannelCreate
`preparePaymentChannelCreate(address: string, paymentChannelCreate: Object, instructions: Object): Promise<Object>`
Prepare a payment channel creation transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
### Parameters
<%- renderSchema('input/prepare-payment-channel-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 paymentChannelCreate = <%- importFile('test/fixtures/requests/prepare-payment-channel-create.json') %>;
return api.preparePaymentChannelCreate(address, paymentChannelCreate).then(prepared =>
{/* ... */});
```
<%- renderFixture('responses/prepare-payment-channel-create.json') %>

View File

@@ -0,0 +1,30 @@
## preparePaymentChannelFund
`preparePaymentChannelFund(address: string, paymentChannelFund: Object, instructions: Object): Promise<Object>`
Prepare a payment channel fund transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
### Parameters
<%- renderSchema('input/prepare-payment-channel-fund.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 paymentChannelFund = <%- importFile('test/fixtures/requests/prepare-payment-channel-fund.json') %>;
return api.preparePaymentChannelFund(address, paymentChannelFund).then(prepared =>
{/* ... */});
```
<%- renderFixture('responses/prepare-payment-channel-fund.json') %>

View File

@@ -0,0 +1,30 @@
## prepareSettings
`prepareSettings(address: string, settings: Object, instructions: Object): Promise<Object>`
Prepare a settings transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
### Parameters
<%- renderSchema('input/prepare-settings.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 settings = <%- importFile('test/fixtures/requests/prepare-settings.json') %>;
return api.prepareSettings(address, settings)
.then(prepared => {/* ... */});
```
<%- renderFixture('requests/prepare-settings.json') %>

View File

@@ -0,0 +1,30 @@
## prepareTrustline
`prepareTrustline(address: string, trustline: Object, instructions: Object): Promise<Object>`
Prepare a trustline transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
### Parameters
<%- renderSchema("input/prepare-trustline.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 trustline = <%- importFile('test/fixtures/requests/prepare-trustline.json') %>;
return api.prepareTrustline(address, trustline).then(prepared =>
{/* ... */});
```
<%- renderFixture("responses/prepare-trustline.json") %>

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

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

View File

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

View File

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

29
docs/src/sign.md.ejs Normal file
View File

@@ -0,0 +1,29 @@
## sign
```
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).
### Parameters
<%- renderSchema("input/sign.json") %>
### Return Value
This method returns an object with the following structure:
<%- renderSchema("output/sign.json") %>
### Example
```javascript
const txJSON = '{"Flags":2147483648,"TransactionType":"AccountSet","Account":"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59","Domain":"726970706C652E636F6D","LastLedgerSequence":8820051,"Fee":"12","Sequence":23}';
const secret = 'shsWGZcmZz6YsWWmcnpfr6fLTdtFV';
const keypair = { privateKey: '00ACCD3309DB14D1A4FC9B1DAE608031F4408C85C73EE05E035B7DC8B25840107A', publicKey: '02F89EAEC7667B30F33D0687BBA86C3FE2A08CCA40A9186C5BDE2DAA6FA97A37D8' };
return api.sign(txJSON, secret); // or: api.sign(txJSON, keypair);
```
<%- renderFixture("responses/sign.json") %>

View File

@@ -0,0 +1,28 @@
## signPaymentChannelClaim
`signPaymentChannelClaim(channel: string, amount: string, privateKey: string): string`
Sign a payment channel claim. The signature can be submitted in a subsequent [PaymentChannelClaim](#preparepaymentchannelclaim) transaction.
### Parameters
<%- renderSchema("input/sign-payment-channel-claim.json") %>
### Return Value
This method returns a signature string:
<%- renderSchema("output/sign-payment-channel-claim.json") %>
### Example
```javascript
const channel =
'3E18C05AD40319B809520F1A136370C4075321B285217323396D6FD9EE1E9037';
const amount = '.00001';
const privateKey =
'ACCD3309DB14D1A4FC9B1DAE608031F4408C85C73EE05E035B7DC8B25840107A';
return api.signPaymentChannelClaim(channel, amount, privateKey);
```
<%- renderFixture("responses/sign-payment-channel-claim.json") %>

View File

@@ -0,0 +1,145 @@
# Transaction Specifications
A *transaction specification* specifies what a transaction should do. Each [Transaction Type](#transaction-types) has its own type of specification.
## Payment
See [Transaction Types](#transaction-types) for a description.
<%- renderSchema('specifications/payment.json') %>
### Example
<%- renderFixture('requests/prepare-payment.json') %>
## Trustline
See [Transaction Types](#transaction-types) for a description.
<%- renderSchema('specifications/trustline.json') %>
### Example
<%- renderFixture('requests/prepare-trustline.json') %>
## Order
See [Transaction Types](#transaction-types) for a description.
<%- renderSchema('specifications/order.json') %>
The following invalid flag combination causes a `ValidationError`: `immediateOrCancel` and `fillOrKill`. These fields are mutually exclusive, and cannot both be set at the same time.
### Example
<%- renderFixture('requests/prepare-order.json') %>
## Order Cancellation
See [Transaction Types](#transaction-types) for a description.
<%- renderSchema('specifications/order-cancellation.json') %>
### Example
<%- renderFixture('requests/prepare-order-cancellation.json') %>
## Settings
See [Transaction Types](#transaction-types) for a description.
<%- renderSchema('output/get-settings.json') %>
### Example
<%- renderFixture('requests/prepare-settings.json') %>
## Escrow Creation
See [Transaction Types](#transaction-types) for a description.
<%- renderSchema('specifications/escrow-creation.json') %>
### Example
<%- renderFixture('requests/prepare-escrow-creation.json') %>
## Escrow Cancellation
See [Transaction Types](#transaction-types) for a description.
<%- renderSchema('specifications/escrow-cancellation.json') %>
### Example
<%- renderFixture('requests/prepare-escrow-cancellation.json') %>
## Escrow Execution
See [Transaction Types](#transaction-types) for a description.
<%- renderSchema('specifications/escrow-execution.json') %>
### Example
<%- 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.
<%- renderSchema('specifications/payment-channel-create.json') %>
### Example
<%- renderFixture('requests/prepare-payment-channel-create.json') %>
## Payment Channel Fund
See [Transaction Types](#transaction-types) for a description.
<%- renderSchema('specifications/payment-channel-fund.json') %>
### Example
<%- renderFixture('requests/prepare-payment-channel-fund.json') %>
## Payment Channel Claim
See [Transaction Types](#transaction-types) for a description.
<%- renderSchema('specifications/payment-channel-claim.json') %>
### Example
<%- renderFixture('requests/prepare-payment-channel-claim.json') %>

25
docs/src/submit.md.ejs Normal file
View File

@@ -0,0 +1,25 @@
## submit
`submit(signedTransaction: string): Promise<Object>`
Submits a signed transaction. The transaction is not guaranteed to succeed; it must be verified with [getTransaction](#gettransaction).
### Parameters
<%- renderSchema('input/submit.json') %>
### Return Value
This method returns an object with the following structure:
<%- renderSchema('output/submit.json') %>
### Example
```javascript
const signedTransaction = '12000322800000002400000017201B0086955368400000000000000C732102F89EAEC7667B30F33D0687BBA86C3FE2A08CCA40A9186C5BDE2DAA6FA97A37D874473045022100BDE09A1F6670403F341C21A77CF35BA47E45CDE974096E1AA5FC39811D8269E702203D60291B9A27F1DCABA9CF5DED307B4F23223E0B6F156991DB601DFB9C41CE1C770A726970706C652E636F6D81145E7B112523F68D2F5E879DB4EAC51C6698A69304';
return api.submit(signedTransaction)
.then(result => {/* ... */});
```
<%- renderFixture('responses/submit.json') %>

View File

@@ -0,0 +1,72 @@
# Transaction Overview
## Transaction Types
A transaction type is specified by the strings in the first column in the table below.
Type | Description
---- | -----------
[payment](#payment) | A `payment` transaction represents a transfer of value from one account to another. Depending on the [path](https://ripple.com/build/paths/) taken, additional exchanges of value may occur atomically to facilitate the payment.
[order](#order) | An `order` transaction creates a limit order. It defines an intent to exchange currencies, and creates an order in the XRP Ledger's order book if not completely fulfilled when placed. Orders can be partially fulfilled.
[orderCancellation](#order-cancellation) | An `orderCancellation` transaction cancels an order in the XRP Ledger's order book.
[trustline](#trustline) | A `trustline` transactions creates or modifies a trust line between two accounts.
[settings](#settings) | A `settings` transaction modifies the settings of an account in the XRP Ledger.
[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
Executing a transaction with `RippleAPI` requires the following four steps:
1. Prepare - Create an unsigned transaction based on a [specification](#transaction-specifications) and [instructions](#transaction-instructions). There is a method to prepare each type of transaction:
* [preparePayment](#preparepayment)
* [prepareTrustline](#preparetrustline)
* [prepareOrder](#prepareorder)
* [prepareOrderCancellation](#prepareordercancellation)
* [prepareSettings](#preparesettings)
* [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.
## Transaction Fees
Every transaction must destroy a small amount of XRP as a cost to send the transaction. This is also called a *transaction fee*. The transaction cost is designed to increase along with the load on the XRP Ledger, making it very expensive to deliberately or inadvertently overload the peer-to-peer network that powers the XRP Ledger.
You can choose the size of the fee you want to pay or let a default be used. You can get an estimate of the fee required to be included in the next ledger closing with the [getFee](#getfee) method.
## Transaction Instructions
Transaction instructions indicate how to execute a transaction, complementary with the [transaction specification](#transaction-specifications).
<%- renderSchema("objects/instructions.json") %>
We recommend that you specify a `maxLedgerVersion` so that you can quickly determine that a failed transaction will never succeeed in the future. It is impossible for a transaction to succeed after the XRP Ledger's consensus-validated ledger version exceeds the transaction's `maxLedgerVersion`. If you omit `maxLedgerVersion`, the "prepare\*" method automatically supplies a `maxLedgerVersion` equal to the current ledger plus 3, which it includes in the return value from the "prepare\*" method.
## Transaction ID
```json
"F4AB442A6D4CBB935D66E1DA7309A5FC71C7143ED4049053EC14E3875B0CF9BF"
```
A transaction ID is a 64-bit hexadecimal string that uniquely identifies the transaction. The transaction ID is derived from the transaction instruction and specifications, using a strong hash function.
You can look up a transaction by ID using the [getTransaction](#gettransaction) method.
## Transaction Memos
Every transaction can optionally have an array of memos for user applications. The `memos` field in each [transaction specification](#transaction-specifications) is an array of objects with the following structure:
<%- renderSchema('objects/memos.json') %>

View File

@@ -0,0 +1,31 @@
## verifyPaymentChannelClaim
`verifyPaymentChannelClaim(channel: string, amount: string, signature: string, publicKey: string): boolean`
Verify a payment channel claim signature.
### Parameters
<%- renderSchema("input/verify-payment-channel-claim.json") %>
### Return Value
This method returns `true` if the claim signature is valid.
<%- renderSchema("output/verify-payment-channel-claim.json") %>
### Example
```javascript
const channel =
'3E18C05AD40319B809520F1A136370C4075321B285217323396D6FD9EE1E9037';
const amount = '.00001';
const signature = <%- importFile("test/fixtures/responses/sign-payment-channel-claim.json") %>;
const publicKey =
'02F89EAEC7667B30F33D0687BBA86C3FE2A08CCA40A9186C5BDE2DAA6FA97A37D8';
return api.verifyPaymentChannelClaim(channel, amount, signature, publicKey);
```
```json
true
```

212
npm-shrinkwrap.json generated
View File

@@ -1,212 +0,0 @@
{
"name": "ripple-lib",
"version": "0.13.0-rc10",
"npm-shrinkwrap-version": "5.4.0",
"node-version": "v0.12.7",
"dependencies": {
"async": {
"version": "0.9.2",
"resolved": "https://registry.npmjs.org/async/-/async-0.9.2.tgz"
},
"babel-runtime": {
"version": "5.8.24",
"resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-5.8.24.tgz",
"dependencies": {
"core-js": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-1.1.4.tgz"
}
}
},
"bignumber.js": {
"version": "2.0.7",
"resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-2.0.7.tgz"
},
"bn.js": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-3.1.2.tgz"
},
"es6-promisify": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-2.0.0.tgz",
"dependencies": {
"es6-promise": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-2.3.0.tgz"
}
}
},
"extend": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/extend/-/extend-1.2.1.tgz"
},
"hash.js": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.0.3.tgz",
"dependencies": {
"inherits": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz"
}
}
},
"https-proxy-agent": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-1.0.0.tgz",
"dependencies": {
"agent-base": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-2.0.1.tgz",
"dependencies": {
"semver": {
"version": "5.0.3",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.0.3.tgz"
}
}
},
"debug": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz",
"dependencies": {
"ms": {
"version": "0.7.1",
"resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz"
}
}
},
"extend": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/extend/-/extend-3.0.0.tgz"
}
}
},
"is-my-json-valid": {
"version": "2.12.2",
"resolved": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.12.2.tgz",
"dependencies": {
"generate-function": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.0.0.tgz"
},
"generate-object-property": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/generate-object-property/-/generate-object-property-1.2.0.tgz",
"dependencies": {
"is-property": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz"
}
}
},
"jsonpointer": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-2.0.0.tgz"
},
"xtend": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.0.tgz"
}
}
},
"lodash": {
"version": "3.10.1",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz"
},
"lru-cache": {
"version": "2.5.2",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.5.2.tgz"
},
"ripple-address-codec": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/ripple-address-codec/-/ripple-address-codec-1.6.0.tgz",
"dependencies": {
"x-address-codec": {
"version": "0.6.0",
"resolved": "https://registry.npmjs.org/x-address-codec/-/x-address-codec-0.6.0.tgz",
"dependencies": {
"base-x": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/base-x/-/base-x-1.0.1.tgz"
}
}
}
}
},
"ripple-keypairs": {
"version": "0.8.0",
"resolved": "https://registry.npmjs.org/ripple-keypairs/-/ripple-keypairs-0.8.0.tgz",
"dependencies": {
"brorand": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/brorand/-/brorand-1.0.5.tgz"
},
"elliptic": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/elliptic/-/elliptic-5.1.0.tgz",
"dependencies": {
"inherits": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz"
}
}
}
}
},
"ripple-lib-transactionparser": {
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/ripple-lib-transactionparser/-/ripple-lib-transactionparser-0.5.0.tgz",
"dependencies": {
"bignumber.js": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-1.4.1.tgz"
}
}
},
"sjcl-codec": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/sjcl-codec/-/sjcl-codec-0.1.0.tgz"
},
"ws": {
"version": "0.7.2",
"resolved": "https://registry.npmjs.org/ws/-/ws-0.7.2.tgz",
"dependencies": {
"bufferutil": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-1.1.0.tgz",
"dependencies": {
"bindings": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.2.1.tgz"
},
"nan": {
"version": "1.8.4",
"resolved": "https://registry.npmjs.org/nan/-/nan-1.8.4.tgz"
}
}
},
"options": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/options/-/options-0.0.6.tgz"
},
"ultron": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/ultron/-/ultron-1.0.2.tgz"
},
"utf-8-validate": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-1.1.0.tgz",
"dependencies": {
"bindings": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.2.1.tgz"
},
"nan": {
"version": "1.8.4",
"resolved": "https://registry.npmjs.org/nan/-/nan-1.8.4.tgz"
}
}
}
}
}
}
}

View File

@@ -1,70 +1,77 @@
{
"name": "ripple-lib",
"version": "0.13.0-rc10",
"version": "1.0.1",
"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"
},
"dependencies": {
"async": "~0.9.0",
"babel-runtime": "^5.5.4",
"bignumber.js": "^2.0.3",
"bn.js": "^3.1.1",
"es6-promisify": "^2.0.0",
"extend": "~1.2.1",
"hash.js": "^1.0.3",
"https-proxy-agent": "^1.0.0",
"is-my-json-valid": "^2.12.2",
"lodash": "^3.1.0",
"lru-cache": "~2.5.0",
"ripple-address-codec": "^1.6.0",
"ripple-keypairs": "^0.8.0",
"ripple-lib-transactionparser": "^0.5.0",
"sjcl-codec": "0.1.0",
"ws": "~0.7.1"
"@types/lodash": "^4.14.85",
"@types/ws": "^3.2.0",
"bignumber.js": "^4.1.0",
"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.13",
"ripple-hashes": "^0.3.1",
"ripple-keypairs": "^0.10.1",
"ripple-lib-transactionparser": "0.7.1",
"ws": "^3.3.1"
},
"devDependencies": {
"@types/node": "^8.0.53",
"assert-diff": "^1.0.1",
"babel": "^5.8.21",
"babel-core": "^5.8.22",
"babel-eslint": "^4.0.5",
"babel-loader": "^5.3.2",
"coveralls": "~2.10.0",
"eslint": "^1.3.0",
"eslint-plugin-flowtype": "^1.0.0",
"coveralls": "^2.13.1",
"doctoc": "^0.15.0",
"ejs": "^2.3.4",
"eventemitter2": "^0.4.14",
"flow-bin": "^0.14",
"gulp": "~3.8.10",
"gulp-bump": "~0.1.13",
"gulp-rename": "~1.2.0",
"gulp-uglify": "~1.1.0",
"istanbul": "~0.3.5",
"gulp": "^3.8.10",
"gulp-bump": "^0.1.13",
"gulp-rename": "^1.2.0",
"http-server": "^0.8.5",
"jayson": "^1.2.2",
"json-loader": "^0.5.2",
"mocha": "~2.1.0",
"webpack": "~1.5.3",
"yargs": "~1.3.1"
"json-schema-to-markdown-table": "^0.4.0",
"mocha": "^2.1.0",
"mocha-in-sauce": "^0.0.1",
"mocha-junit-reporter": "^1.9.1",
"null-loader": "^0.1.1",
"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",
"typescript": "2.9.2",
"uglifyjs-webpack-plugin": "^1.1.4",
"webpack": "^3.10.0",
"yargs": "^8.0.2"
},
"scripts": {
"build": "gulp",
"clean": "rm -rf dist/npm && rm -rf build/flow",
"typecheck": "babel --optional runtime --blacklist flow -d build/flow/ src/ && flow check",
"compile": "babel -D --optional runtime -d dist/npm/ src/",
"watch": "babel -w -D --optional runtime -d dist/npm/ src/",
"compile-with-source-maps": "babel -D --optional runtime -s -t -d dist/npm/ src/",
"prepublish": "npm run clean && npm run compile",
"test": "istanbul test _mocha",
"doctoc": "doctoc docs/index.md --title '# RippleAPI Reference' --github --maxlevel 2",
"docgen": "node --harmony scripts/build_docs.js",
"clean": "rm -rf dist/npm",
"compile": "mkdir -p dist/npm/common && cp -r src/common/schemas dist/npm/common/ && tsc",
"watch": "tsc -w",
"prepublish": "npm run clean && npm run compile && npm run build",
"test": "nyc mocha",
"coveralls": "cat ./coverage/lcov.info | coveralls",
"lint": "if ! [ -f eslintrc ]; then curl -o eslintrc 'https://raw.githubusercontent.com/ripple/javascript-style-guide/es6/eslintrc'; echo 'parser: babel-eslint' >> eslintrc; fi; eslint -c eslintrc src/",
"perf": "./scripts/perf_test.sh"
"lint": "tslint -p ./",
"perf": "./scripts/perf_test.sh",
"start": "node scripts/http.js",
"sauce": "node scripts/sauce-runner.js"
},
"repository": {
"type": "git",
@@ -72,6 +79,6 @@
},
"readmeFilename": "README.md",
"engines": {
"node": ">=0.12.0"
"node": ">=6.12.3"
}
}

51
scripts/build_docs.js Normal file
View File

@@ -0,0 +1,51 @@
'use strict';
const fs = require('fs');
const path = require('path');
const execSync = require('child_process').execSync;
const ejs = require('ejs');
const renderFromPaths =
require('json-schema-to-markdown-table').renderFromPaths;
const ROOT = path.dirname(path.normalize(__dirname));
function strip(string) {
return string.replace(/^\s+|\s+$/g, '');
}
function importFile(relativePath) {
const absolutePath = path.join(ROOT, relativePath);
return strip(fs.readFileSync(absolutePath).toString('utf-8'));
}
function renderFixture(fixtureRelativePath) {
const json = importFile(path.join('test', 'fixtures', fixtureRelativePath));
return '\n```json\n' + json + '\n```\n';
}
function renderSchema(schemaRelativePath) {
const schemasPath = path.join(ROOT, 'src', 'common', 'schemas');
const schemaPath = path.join(schemasPath, schemaRelativePath);
return renderFromPaths(schemaPath, schemasPath);
}
function main() {
const locals = {
importFile: importFile,
renderFixture: renderFixture,
renderSchema: renderSchema
};
const indexPath = path.join(ROOT, 'docs', 'src', 'index.md.ejs');
ejs.renderFile(indexPath, locals, function(error, output) {
if (error) {
console.error(error);
process.exit(1);
} else {
const outputPath = path.join(ROOT, 'docs', 'index.md');
fs.writeFileSync(outputPath, output);
execSync('npm run doctoc', {cwd: ROOT});
process.exit(0);
}
});
}
main();

18
scripts/checkeol.sh Executable file
View File

@@ -0,0 +1,18 @@
#!/bin/bash
function checkEOL {
local changedFiles=$(git --no-pager diff --name-only -M100% --diff-filter=AM --relative $(git merge-base FETCH_HEAD origin/HEAD) FETCH_HEAD)
local result=0
for name in $changedFiles; do
grep -c -U -q $'\r' $name
if [ $? -eq 0 ]; then
echo "windows eol found in $name" >&2
result=1
fi
done
if [ $result -eq 1 ]; then
false
fi
}
checkEOL

96
scripts/ci.sh Executable file
View File

@@ -0,0 +1,96 @@
#!/bin/bash -ex
NODE_INDEX="$1"
TOTAL_NODES="$2"
function checkEOL {
./scripts/checkeol.sh
}
lint() {
echo "tslint $(node_modules/.bin/tslint --version)"
yarn lint
}
unittest() {
# test "src"
mocha test --reporter mocha-junit-reporter --reporter-options mochaFile=$CIRCLE_TEST_REPORTS/test-results.xml
yarn test --coverage
yarn run coveralls
# test compiled version in "dist/npm"
$(npm bin)/babel -D --optional runtime --ignore "**/node_modules/**" -d test-compiled/ test/
echo "--reporter spec --timeout 5000 --slow 500" > test-compiled/mocha.opts
mkdir -p test-compiled/node_modules
ln -nfs ../../dist/npm test-compiled/node_modules/ripple-api
mocha --opts test-compiled/mocha.opts test-compiled
#compile tests for browser testing
#gulp build-min build-tests
#node --harmony test-compiled/mocked-server.js > /dev/null &
#echo "Running tests in PhantomJS"
#mocha-phantomjs test/localrunner.html
#echo "Running tests using minified version in PhantomJS"
#mocha-phantomjs test/localrunnermin.html
#echo "Running tests in SauceLabs"
#http-server &
#yarn run sauce
#pkill -f mocked-server.js
#pkill -f http-server
rm -rf test-compiled
}
integrationtest() {
mocha test/integration/integration-test.js
mocha test/integration/http-integration-test.js
# run integration tests in PhantomJS
#gulp build-tests build-min
#echo "Running integragtion tests in PhantomJS"
#mocha-phantomjs test/localintegrationrunner.html
}
doctest() {
mv docs/index.md docs/index.md.save
yarn run docgen
mv docs/index.md docs/index.md.test
mv docs/index.md.save docs/index.md
cmp docs/index.md docs/index.md.test
rm docs/index.md.test
}
oneNode() {
checkEOL
doctest
lint
unittest
integrationtest
}
twoNodes() {
case "$NODE_INDEX" in
0) doctest; lint; integrationtest;;
1) checkEOL; unittest;;
*) echo "ERROR: invalid usage"; exit 2;;
esac
}
threeNodes() {
case "$NODE_INDEX" in
0) doctest; lint; integrationtest;;
1) checkEOL;;
2) unittest;;
*) echo "ERROR: invalid usage"; exit 2;;
esac
}
case "$TOTAL_NODES" in
"") oneNode;;
1) oneNode;;
2) twoNodes;;
3) threeNodes;;
*) echo "ERROR: invalid usage"; exit 2;;
esac

16
scripts/http.js Normal file
View File

@@ -0,0 +1,16 @@
'use strict';
const createHTTPServer = require('../dist/npm/http').createHTTPServer;
const port = 5990;
const serverUrl = 'wss://s1.ripple.com';
function main() {
const server = createHTTPServer({server: serverUrl}, port);
server.start().then(() => {
console.log('Server started on port ' + String(port));
});
}
main();

View File

@@ -1,44 +0,0 @@
var Benchmark;
try {
Benchmark = require('benchmark');
} catch (e) {
console.error("Please install Benchmark.js: npm install benchmark");
process.exit(1);
}
var sjcl = require('../build/sjcl');
var jsbn = require('../src/js/jsbn/jsbn');
var base = "3f70f29d3f3ae354a6d2536ceafba83cfc787cd91e7acd2b6bde05e62beb8295ae18e3f786726f8d034bbc15bf8331df959f59d431736d5f306aaba63dacec279484e39d76db9b527738072af15730e8b9956a64e8e4dbe868f77d1414a8a8b8bf65380a1f008d39c5fabe1a9f8343929342ab7b4f635bdc52532d764701ff3d8072c475c012ff0c59373e8bc423928d99f58c3a6d9f6ab21ee20bc8e8818fc147db09f60c81906f2c6f73dc69725f075853a89f0cd02a30a8dd86b660ccdeffc292f398efb54088c822774445a6afde471f7dd327ef9996296898a5747726ccaeeceeb2e459df98b4128cb5ab8c7cd20c563f960a1aa770f3c81f13f967b6cc";
var exponent = "322e393f76a1c22b147e7d193c00c023afb7c1500b006ff1bc1cc8d391fc38bd";
var modulus = "c7f1bc1dfb1be82d244aef01228c1409c198894eca9e21430f1669b4aa3864c9f37f3d51b2b4ba1ab9e80f59d267fda1521e88b05117993175e004543c6e3611242f24432ce8efa3b81f0ff660b4f91c5d52f2511a6f38181a7bf9abeef72db056508bbb4eeb5f65f161dd2d5b439655d2ae7081fcc62fdcb281520911d96700c85cdaf12e7d1f15b55ade867240722425198d4ce39019550c4c8a921fc231d3e94297688c2d77cd68ee8fdeda38b7f9a274701fef23b4eaa6c1a9c15b2d77f37634930386fc20ec291be95aed9956801e1c76601b09c413ad915ff03bfdc0b6b233686ae59e8caf11750b509ab4e57ee09202239baee3d6e392d1640185e1cd";
var expected = "5b3823974b3eda87286d3f38499de290bd575d8b02f06720acacf3d50950f9ca0ff6b749f3be03913ddca0b291e0b263bdab6c9cb97e4ab47ee9c235ff20931a8ca358726fab93614e2c549594f5c50b1c979b34f840b6d4fc51d6feb2dd072995421d17862cb405e040fc1ed662a3245a1f97bbafa6d1f7f76c7db6a802e3037acdf01ab5053f5da518d6753477193b9c25e1720519dcb9e2f6e70d5786656d356151845a49861dfc40187eff0e85cd18b1f3f3b97c476472edfa090b868b2388edfffecc521c20df8cebb8aacfb3669b020330dd6ea64b2a3067a972b8f249bccc19347eff43893e916f0949bd5789a5cce0f8b7cd87cece909d679345c0d4";
var BigInteger = jsbn.BigInteger;
var jsbnBase = new BigInteger(base, 16);
var jsbnExponent = new BigInteger(exponent, 16);
var jsbnModulus = new BigInteger(modulus, 16);
var bn = sjcl.bn;
var sjclBase = new bn(base);
var sjclExponent = new bn(exponent);
var sjclModulus = new bn(modulus);
var suite = new Benchmark.Suite;
// add tests
suite.add('jsbn#modPow', function() {
jsbnBase.modPow(jsbnExponent, jsbnModulus);
});
suite.add('sjcl#powermodMontgomery', function() {
sjclBase.powermodMontgomery(sjclExponent, sjclModulus);
});
suite.on('cycle', function(event) {
console.log(String(event.target));
});
suite.on('complete', function() {
console.log('Fastest is ' + this.filter('fastest').pluck('name'));
});
// run async
console.log("Running benchmark...");
suite.run({ 'async': false });

View File

@@ -1,11 +0,0 @@
#!/bin/sh
URL="https://www.dropbox.com/s/a0gy7vbb86eeqlq/ledger-full-1000000.json?dl=1"
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
DEST="$DIR/cache/ledger-full-1000000.json"
if [ ! -e "$DEST" ]
then
echo "Downloading test data..."
mkdir -p "$DIR/cache"
curl -L "$URL" > "$DEST"
fi
npm run compile && time node "$DIR/verify_ledger_json.js" "$DEST"

View File

@@ -7,37 +7,12 @@ function exit_on_error {
rm -rf build
npm install
yarn install
gulp
npm test
yarn test
exit_on_error
echo ""
echo "publish to npm"
npm publish
yarn publish
exit_on_error
rm -rf dist/bower
echo ""
echo "publish to bower"
git clone git@github.com:ripple/bower-ripple.git dist/bower
gulp bower
exit_on_error
cd dist/bower
version=$(cat bower.json | grep -Eo '([0-9]\.?)+(-rc[0-9])?')
echo "version: $version"
git add ripple.js ripple-debug.js ripple-min.js bower.json
exit_on_error
git commit -m "[TASK] add v$version"
exit_on_error
git tag "v$version"
exit_on_error
git push origin master
git push --tags origin master
cd ..

View File

@@ -7,37 +7,12 @@ function exit_on_error {
rm -rf build
npm install
yarn install
gulp
npm test
yarn test
exit_on_error
echo ""
echo "publish rc to npm"
npm publish --tag beta
yarn publish --tag beta
exit_on_error
rm -rf dist/bower
echo ""
echo "publish to bower"
git clone git@github.com:ripple/bower-ripple.git dist/bower
gulp bower
exit_on_error
cd dist/bower
version=$(cat bower.json | grep -Eo '([0-9]\.?)+(-rc[0-9])?')
echo "version: $version"
git add ripple.js ripple-debug.js ripple-min.js bower.json
exit_on_error
git commit -m "[TASK] add v$version"
exit_on_error
git tag "v$version"
exit_on_error
git push origin master
git push --tags origin master
cd ..

View File

@@ -1,12 +0,0 @@
rm -rf dist/bower
git clone git@github.com:ripple/bower-ripple.git dist/bower
gulp bower
cd dist/bower
version=$(cat bower.json | grep -Eo '([0-9]\.?)+(-rc[0-9])?')
echo "version: $version"
git add ripple.js ripple-debug.js ripple-min.js bower.json
git commit -m "[TASK] add v$version"
git tag "v$version"
git push origin master
git push --tags origin master
cd ..

100
scripts/sauce-runner.js Normal file
View File

@@ -0,0 +1,100 @@
const _ = require('lodash');
const MochaSauce = require('mocha-in-sauce');
const testUrl = 'http://testripple.circleci.com:8080/test/saucerunner.html';
function main() {
// uncomment for more debug info
// process.env.DEBUG = '*';
// configure
const config = {
name: 'RippleAPI',
host: 'localhost',
port: 4445,
maxDuration: 180000,
// the current build name (optional)
build: Date.now(),
url: testUrl,
runSauceConnect: true
};
if (process.env.CIRCLE_BUILD_NUM) {
config.build = process.env.CIRCLE_BUILD_NUM;
config.tags = [process.env.CIRCLE_BRANCH, process.env.CIRCLE_SHA1];
config.tunnelIdentifier = process.env.CIRCLE_BUILD_NUM;
}
const sauce = new MochaSauce(config);
sauce.concurrency(5);
// setup what browsers to test with
sauce.browser({browserName: 'firefox', platform: 'Linux',
version: '43'});
sauce.browser({browserName: 'firefox', platform: 'Windows 8.1',
version: '43'});
sauce.browser({browserName: 'firefox', platform: 'OS X 10.11',
version: '43'});
sauce.browser({browserName: 'safari', platform: 'OS X 10.11',
version: '9'});
sauce.browser({browserName: 'safari', platform: 'OS X 10.10',
version: '8'});
sauce.browser({browserName: 'safari', platform: 'OS X 10.9',
version: '7'});
sauce.browser({browserName: 'chrome', platform: 'OS X 10.11',
version: '47'});
sauce.browser({browserName: 'chrome', platform: 'Linux',
version: '47'});
sauce.browser({browserName: 'chrome', platform: 'Windows 8.1',
version: '47'});
sauce.browser({browserName: 'internet explorer', platform: 'Windows 10',
version: '11'});
sauce.browser({browserName: 'MicrosoftEdge', platform: 'Windows 10',
version: '20'});
sauce.on('init', function(browser) {
console.log(' init : %s %s', browser.browserName, browser.platform);
});
sauce.on('start', function(browser) {
console.log(' start : %s %s', browser.browserName, browser.platform);
});
sauce.on('end', function(browser, res) {
console.log(' end : %s %s : %d failures', browser.browserName,
browser.platform, res && res.failures);
});
sauce.on('connected', sauceConnectProcess => {
sauceConnectProcess.on('exit', function(code, /* signal */) {
if (code > 0) {
console.log('something wrong - exiting');
process.exit();
} else {
console.log('normal tunnel exit');
}
});
});
sauce.start(function(err, res) {
let failure = false;
if (err) {
console.log('Error starting Sauce');
console.error(err);
process.exitCode = 2;
} else {
console.log('-------------- done --------------');
failure = _.some(res, 'failures');
console.log('Tests are failed:', failure);
if (failure) {
process.exitCode = 1;
}
}
});
}
main();

View File

@@ -1,67 +0,0 @@
/* eslint-disable no-var */
'use strict';
var fs = require('fs');
var ripple = require('../dist/npm')._DEPRECATED;
var Amount = ripple.Amount;
var Ledger = ripple.Ledger;
function parse_options(from, flags) {
var argv = from.slice();
var opts_ = {argv: argv};
flags.forEach(function(f) {
// Do we have the flag?
var flag_index = argv.indexOf('--' + f);
// normalize the name of the flag
var flag = f.replace('-', '_');
// opts_ has Boolean value for normalized flag key
opts_[flag] = flag_index !== -1;
if (opts_[flag]) {
// remove the flag from the argv
argv.splice(flag_index, 1);
}
});
return opts_;
}
var opts = parse_options(process.argv.slice(2), // remove `node` and `this.js`
['sanity-test']);
if (opts.argv.length < 1) {
console.error('Usage: scripts/verify_ledger_json path/to/ledger.json');
console.error(' optional: --sanity-test (json>binary>json>binary)');
process.exit(1);
}
var json = fs.readFileSync(opts.argv[0], 'utf-8');
var ledger = Ledger.from_json(JSON.parse(json));
// This will serialize each accountState object to binary and then back to json
// before finally serializing for hashing. This is mostly to expose any issues
// with ripple-libs binary <--> json codecs.
if (opts.sanity_test) {
console.log('All accountState nodes will be processed from ' +
'json->binary->json->binary. This may take some time ' +
'with large ledgers.');
}
// To recompute the hashes of some ledgers, we must allow values that slipped in
// before strong policies were in place.
Amount.strict_mode = false;
console.log('Transaction hash in header: ' +
ledger.ledger_json.transaction_hash);
console.log('Calculated transaction hash: ' +
ledger.calc_tx_hash().to_hex());
console.log('Account state hash in header: ' +
ledger.ledger_json.account_hash);
if (ledger.ledger_json.accountState) {
console.log('Calculated account state hash: ' +
ledger.calc_account_hash({sanity_test: opts.sanity_test})
.to_hex());
} else {
console.log('Ledger has no accountState');
}

343
src/api.ts Normal file
View File

@@ -0,0 +1,343 @@
import {EventEmitter} from 'events'
import {
Connection,
errors,
validate,
xrpToDrops,
dropsToXrp,
iso8601ToRippleTime,
txFlags
} from './common'
import {
connect,
disconnect,
isConnected,
getLedgerVersion,
formatLedgerClose
} from './server/server'
import getTransaction from './ledger/transaction'
import getTransactions from './ledger/transactions'
import getTrustlines from './ledger/trustlines'
import getBalances from './ledger/balances'
import getBalanceSheet from './ledger/balance-sheet'
import getPaths from './ledger/pathfind'
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'
import prepareOrder from './transaction/order'
import prepareOrderCancellation from './transaction/ordercancellation'
import prepareEscrowCreation from './transaction/escrow-creation'
import prepareEscrowExecution from './transaction/escrow-execution'
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'
import submit from './transaction/submit'
import {generateAddressAPI} from './offline/generate-address'
import {deriveKeypair, deriveAddress} from './offline/derive'
import computeLedgerHash from './offline/ledgerhash'
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,
ServerInfoRequest, ServerInfoResponse
} from './common/types/commands'
import RangeSet from './common/rangeset'
import * as ledgerUtils from './ledger/utils'
import * as transactionUtils from './transaction/utils'
import * as schemaValidator from './common/schema-validator'
import {getServerInfo, getFee} from './common/serverinfo'
import {clamp} from './ledger/utils'
import {Instructions, Prepare} from './transaction/types'
export type APIOptions = {
server?: string,
feeCushion?: number,
maxFeeXRP?: string,
trace?: boolean,
proxy?: string,
timeout?: number
}
/**
* 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
}
}
class RippleAPI extends EventEmitter {
_feeCushion: number
_maxFeeXRP: string
// New in > 0.21.0
// non-validated ledger versions are allowed, and passed to rippled as-is.
connection: Connection
// these are exposed only for use by unit tests; they are not part of the API.
static _PRIVATE = {
validate,
RangeSet,
ledgerUtils,
schemaValidator
}
constructor(options: APIOptions = {}) {
super()
validate.apiOptions(options)
this._feeCushion = options.feeCushion || 1.2
this._maxFeeXRP = options.maxFeeXRP || '2'
const serverURL = options.server
if (serverURL !== undefined) {
this.connection = new Connection(serverURL, options)
this.connection.on('ledgerClosed', message => {
this.emit('ledger', formatLedgerClose(message))
})
this.connection.on('error', (errorCode, errorMessage, data) => {
this.emit('error', errorCode, errorMessage, data)
})
this.connection.on('connected', () => {
this.emit('connected')
})
this.connection.on('disconnected', code => {
this.emit('disconnected', code)
})
} else {
// use null object pattern to provide better error message if user
// tries to call a method that requires a connection
this.connection = new Connection(null, options)
}
}
/**
* Makes a request to the API with the given command and
* additional request body parameters.
*/
async request(command: 'account_info', params: AccountInfoRequest):
Promise<AccountInfoResponse>
async request(command: 'account_lines', params: AccountLinesRequest):
Promise<AccountLinesResponse>
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>
async request(command: 'server_info', params?: ServerInfoRequest):
Promise<ServerInfoResponse>
async request(command: string, params: any):
Promise<any>
async request(command: string, params: any = {}): Promise<any> {
return this.connection.request({
...params,
command
})
}
/**
* Returns true if there are more pages of data.
*
* When there are more results than contained in the response, the response
* includes a `marker` field.
*
* See https://ripple.com/build/rippled-apis/#markers-and-pagination
*/
hasNextPage<T extends {marker?: string}>(currentResponse: T): boolean {
return !!currentResponse.marker
}
async requestNextPage<T extends {marker?: string}>(
command: string,
params: object = {},
currentResponse: T
): Promise<object> {
if (!currentResponse.marker) {
return Promise.reject(
new errors.NotFoundError('response does not have a next page')
)
}
const nextPageParams = Object.assign({}, params, {
marker: currentResponse.marker
})
return this.request(command, nextPageParams)
}
/**
* Prepare a transaction.
*
* You can later submit the transaction with `submit()`.
*/
async prepareTransaction(txJSON: object, instructions: Instructions = {}):
Promise<Prepare> {
return transactionUtils.prepareTransaction(txJSON, this, instructions)
}
/**
* Convert a string to hex.
*
* This can be used to generate `MemoData`, `MemoType`, and `MemoFormat`.
*
* @param string string to convert to hex
*/
convertStringToHex(string: string): string {
return transactionUtils.convertStringToHex(string)
}
/**
* Makes multiple paged requests to the API to return a given number of
* resources. _requestAll() will make multiple requests until the `limit`
* 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 used by existing methods and is not recommended for
* general use. Instead, use rippled's built-in pagination and make multiple
* requests as needed.
*/
async _requestAll(command: 'account_offers', params: AccountOffersRequest):
Promise<AccountOffersResponse[]>
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
}
const singleResult = await 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
getServerInfo = getServerInfo
getFee = getFee
getLedgerVersion = getLedgerVersion
getTransaction = getTransaction
getTransactions = getTransactions
getTrustlines = getTrustlines
getBalances = getBalances
getBalanceSheet = getBalanceSheet
getPaths = getPaths
getOrders = getOrders
getOrderbook = getOrderbook
getSettings = getSettings
getAccountInfo = getAccountInfo
getAccountObjects = getAccountObjects
getPaymentChannel = getPaymentChannel
getLedger = getLedger
preparePayment = preparePayment
prepareTrustline = prepareTrustline
prepareOrder = prepareOrder
prepareOrderCancellation = prepareOrderCancellation
prepareEscrowCreation = prepareEscrowCreation
prepareEscrowExecution = prepareEscrowExecution
prepareEscrowCancellation = prepareEscrowCancellation
preparePaymentChannelCreate = preparePaymentChannelCreate
preparePaymentChannelFund = preparePaymentChannelFund
preparePaymentChannelClaim = preparePaymentChannelClaim
prepareCheckCreate = prepareCheckCreate
prepareCheckCash = prepareCheckCash
prepareCheckCancel = prepareCheckCancel
prepareSettings = prepareSettings
sign = sign
combine = combine
submit = submit
generateAddress = generateAddressAPI
deriveKeypair = deriveKeypair
deriveAddress = deriveAddress
computeLedgerHash = computeLedgerHash
signPaymentChannelClaim = signPaymentChannelClaim
verifyPaymentChannelClaim = verifyPaymentChannelClaim
errors = errors
xrpToDrops = xrpToDrops
dropsToXrp = dropsToXrp
iso8601ToRippleTime = iso8601ToRippleTime
txFlags = txFlags
isValidAddress = schemaValidator.isValidAddress
isValidSecret = schemaValidator.isValidSecret
}
export {
RippleAPI
}

View File

@@ -1,44 +0,0 @@
'use strict';
const core = require('./utils').core;
const flagIndices = core.Transaction.set_clear_flags.AccountSet;
const flags = core.Remote.flags.account_root;
const AccountFlags = {
passwordSpent: flags.PasswordSpent,
requireDestinationTag: flags.RequireDestTag,
requireAuthorization: flags.RequireAuth,
disallowIncomingXRP: flags.DisallowXRP,
disableMasterKey: flags.DisableMaster,
noFreeze: flags.NoFreeze,
globalFreeze: flags.GlobalFreeze,
defaultRipple: flags.DefaultRipple
};
const AccountFlagIndices = {
requireDestinationTag: flagIndices.asfRequireDest,
requireAuthorization: flagIndices.asfRequireAuth,
disallowIncomingXRP: flagIndices.asfDisallowXRP,
disableMasterKey: flagIndices.asfDisableMaster,
enableTransactionIDTracking: flagIndices.asfAccountTxnID,
noFreeze: flagIndices.asfNoFreeze,
globalFreeze: flagIndices.asfGlobalFreeze,
defaultRipple: flagIndices.asfDefaultRipple
};
const AccountFields = {
EmailHash: {name: 'emailHash', encoding: 'hex',
length: 32, defaults: '0'},
WalletLocator: {name: 'walletLocator', encoding: 'hex',
length: 64, defaults: '0'},
WalletSize: {name: 'walletSize', defaults: 0},
MessageKey: {name: 'messageKey'},
Domain: {name: 'domain', encoding: 'hex'},
TransferRate: {name: 'transferRate', defaults: 0, shift: 9},
Signers: {name: 'signers'}
};
module.exports = {
AccountFields,
AccountFlagIndices,
AccountFlags
};

View File

@@ -1,97 +0,0 @@
/* eslint-disable valid-jsdoc */
'use strict';
/**
* Base class for all errors
*/
function RippleError(message) {
this.message = message;
}
RippleError.prototype = new Error();
RippleError.prototype.name = 'RippleError';
function ValidationError(message) {
this.message = message;
}
ValidationError.prototype = new RippleError();
ValidationError.prototype.name = 'ValidationError';
/**
* Timeout, disconnects and too busy
*/
function NetworkError(message) {
this.message = message;
}
NetworkError.prototype = new RippleError();
NetworkError.prototype.name = 'NetworkError';
/**
* Failed transactions, no paths found, not enough balance, etc.
*/
function RippledNetworkError(message) {
this.message = message !== undefined ? message : 'Cannot connect to rippled';
}
RippledNetworkError.prototype = new NetworkError();
/**
* Failed transactions, no paths found, not enough balance, etc.
*/
function TransactionError(message) {
this.message = message;
}
TransactionError.prototype = new RippleError();
TransactionError.prototype.name = 'TransactionError';
/**
* Asset could not be found
*/
function NotFoundError(message) {
this.message = message;
}
NotFoundError.prototype = new RippleError();
NotFoundError.prototype.name = 'NotFoundError';
function MissingLedgerHistoryError(message) {
this.message = message ||
'Server is missing ledger history in the specified range';
}
MissingLedgerHistoryError.prototype = new RippleError();
MissingLedgerHistoryError.prototype.name = 'MissingLedgerHistoryError';
function PendingLedgerVersionError(message) {
this.message = message ||
'maxLedgerVersion is greater than server\'s most recent validated ledger';
}
PendingLedgerVersionError.prototype = new RippleError();
PendingLedgerVersionError.prototype.name = 'PendingLedgerVersionError';
/**
* Request timed out
*/
function TimeOutError(message) {
this.message = message;
}
TimeOutError.prototype = new RippleError();
TimeOutError.prototype.name = 'TimeOutError';
/**
* API logic failed to do what it intended
*/
function ApiError(message) {
this.message = message;
}
ApiError.prototype = new RippleError();
ApiError.prototype.name = 'ApiError';
module.exports = {
ValidationError,
NetworkError,
TransactionError,
RippledNetworkError,
NotFoundError,
PendingLedgerVersionError,
MissingLedgerHistoryError,
TimeOutError,
ApiError,
RippleError
};

View File

@@ -1,20 +0,0 @@
'use strict';
const utils = require('./utils');
module.exports = {
core: utils.core,
constants: require('./constants'),
errors: require('./errors'),
validate: require('./validate'),
dropsToXrp: utils.dropsToXrp,
xrpToDrops: utils.xrpToDrops,
toRippledAmount: utils.toRippledAmount,
generateAddress: utils.generateAddress,
composeAsync: utils.composeAsync,
wrapCatch: utils.wrapCatch,
convertErrors: utils.convertErrors,
convertExceptions: utils.convertExceptions,
convertKeysFromSnakeCaseToCamelCase:
utils.convertKeysFromSnakeCaseToCamelCase,
promisify: utils.promisify
};

View File

@@ -1,122 +0,0 @@
// flow is disabled for this file until support for requiring json is added:
// https://github.com/facebook/flow/issues/167
'use strict';
const _ = require('lodash');
const assert = require('assert');
const validator = require('is-my-json-valid');
const core = require('./utils').core;
const ValidationError = require('./errors').ValidationError;
let SCHEMAS = {};
function isValidAddress(address: string): boolean {
return typeof address === 'string' && address.length > 0 &&
address[0] === 'r' &&
core.UInt160.is_valid(address);
}
function isValidLedgerHash(ledgerHash) {
return core.UInt256.is_valid(ledgerHash);
}
function loadSchemas() {
// listed explicitly for webpack (instead of scanning schemas directory)
const schemas = [
require('./schemas/address.json'),
require('./schemas/adjustment.json'),
require('./schemas/amount.json'),
require('./schemas/amountbase.json'),
require('./schemas/balance.json'),
require('./schemas/blob.json'),
require('./schemas/currency.json'),
require('./schemas/get-account-info.json'),
require('./schemas/get-balances.json'),
require('./schemas/get-ledger.json'),
require('./schemas/get-orderbook.json'),
require('./schemas/get-orders.json'),
require('./schemas/get-paths.json'),
require('./schemas/get-server-info.json'),
require('./schemas/get-settings.json'),
require('./schemas/get-transaction.json'),
require('./schemas/get-transactions.json'),
require('./schemas/get-trustlines.json'),
require('./schemas/hash128.json'),
require('./schemas/hash256.json'),
require('./schemas/instructions.json'),
require('./schemas/issue.json'),
require('./schemas/ledger-options.json'),
require('./schemas/ledgerversion.json'),
require('./schemas/max-adjustment.json'),
require('./schemas/memo.json'),
require('./schemas/order-cancellation-transaction.json'),
require('./schemas/order-cancellation.json'),
require('./schemas/order-change.json'),
require('./schemas/order-transaction.json'),
require('./schemas/order.json'),
require('./schemas/orderbook-orders.json'),
require('./schemas/orderbook.json'),
require('./schemas/orders-options.json'),
require('./schemas/outcome.json'),
require('./schemas/pathfind.json'),
require('./schemas/payment-transaction.json'),
require('./schemas/payment.json'),
require('./schemas/quality.json'),
require('./schemas/remote-options.json'),
require('./schemas/sequence.json'),
require('./schemas/settings-options.json'),
require('./schemas/settings-transaction.json'),
require('./schemas/settings.json'),
require('./schemas/sign.json'),
require('./schemas/signed-value.json'),
require('./schemas/submit.json'),
require('./schemas/suspended-payment-cancellation.json'),
require('./schemas/suspended-payment-execution.json'),
require('./schemas/suspended-payment-creation.json'),
require('./schemas/timestamp.json'),
require('./schemas/transaction-options.json'),
require('./schemas/transactions-options.json'),
require('./schemas/trustline-transaction.json'),
require('./schemas/trustline.json'),
require('./schemas/trustlines-options.json'),
require('./schemas/tx.json'),
require('./schemas/uint32.json'),
require('./schemas/value.json'),
require('./schemas/prepare.json'),
require('./schemas/ledger-closed.json')
];
const titles = _.map(schemas, schema => schema.title);
const duplicates = _.keys(_.pick(_.countBy(titles), count => count > 1));
assert(duplicates.length === 0, 'Duplicate schemas for: ' + duplicates);
return _.indexBy(schemas, 'title');
}
function formatSchemaError(error) {
return error.field + ' ' + error.message
+ (error.value ? ' (' + JSON.stringify(error.value) + ')' : '');
}
function formatSchemaErrors(errors) {
return errors.map(formatSchemaError).join(', ');
}
function schemaValidate(schemaName: string, object: any): void {
const formats = {address: isValidAddress,
ledgerHash: isValidLedgerHash};
const options = {schemas: SCHEMAS, formats: formats,
verbose: true, greedy: true};
const schema = SCHEMAS[schemaName];
if (schema === undefined) {
throw new Error('schema not found for: ' + schemaName);
}
const validate = validator(schema, options);
const isValid = validate(object);
if (!isValid) {
throw new ValidationError(formatSchemaErrors(validate.errors));
}
}
SCHEMAS = loadSchemas();
module.exports = {
schemaValidate: schemaValidate,
SCHEMAS: SCHEMAS
};

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