Compare commits

...

100 Commits

Author SHA1 Message Date
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
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
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
203 changed files with 10729 additions and 1808 deletions

View File

@@ -1,12 +1,84 @@
##0.13.0 (release candidate)
##0.16.4
**Changes**
+ [Update ws to 1.0.1](https://github.com/ripple/ripple-lib/pull/682)
##0.16.2
**Changes**
+ [Bump ripple-binary-codec dependency version to 0.1.1 to fix issue with computeLedgerHash for transactions with DeliverMin]
##0.16.1
**Changes**
+ [FIX: Use assert not assert-diff](https://github.com/ripple/ripple-lib/commit/f6ebe325193e7208c5ee8d8e84a7504714f0009e)
##0.16.0
**Breaking Changes**
+ [Fix types of XRP values in getServerInfo response](https://github.com/ripple/ripple-lib/commit/99d08065e4bda3dda6ae1f183adbd11abc70a9b7)
+ [Change error event format and fix crash due to error event on webscocket](https://github.com/ripple/ripple-lib/commit/9cd72595f0efc062d77b9d625695d6030c524cc6)
**Changes**
+ [Fix generateAddress docs and add error event listener to boilerplate](https://github.com/ripple/ripple-lib/commit/809d981987a2890fac3a73a40a05c598b9040334)
+ [Allow setting maxLedgerVersion to null to specify no maximum](https://github.com/ripple/ripple-lib/commit/82613e7e8b360d1ae1552eab4559ab4763c06d7e)
+ [Add support for client certificates](https://github.com/ripple/ripple-lib/commit/5f5e48e4140345d166b8c1a3ee0847b0d9e2d893)
+ [getFee returns a string not float](https://github.com/ripple/ripple-lib/commit/7bf2da6014c87e164542e69356efeaabb575a157)
+ [Fix parsing of quality for getTrustlines](https://github.com/ripple/ripple-lib/commit/86ff315ef2a39dfdc2ce97e0e1c4aa73f04e363b)
+ [Fix DeliverMin value when specifying minAmount](Fix DeliverMin value when specifying minAmount)
+ [http server example](https://github.com/ripple/ripple-lib/commit/76866ab901ea46a2dd73181605e0f7f4220043d4)
##0.15.2
**Changes**
+ [Fix support for proxy credentials in proxy URL and fix error when there are more than 10 outstanding requests](https://github.com/ripple/ripple-lib/commit/0990ad4a6f1d59ca9d2cb859b4e2d71693f3fc4b)
##0.15.1
**Changes**
+ [Fix babel-polyfill require](https://github.com/ripple/ripple-lib/commit/062148674c3b1293ab82c28e25615ddd530339fa)
+ [Fix samples](https://github.com/ripple/ripple-lib/commit/5d5cf868a2ddb1b1cd40e4a4f0a782d0066c2055)
+ [add unit tests for RippleAPIBroadcast](https://github.com/ripple/ripple-lib/commit/ddf8fe5b1a9c750490dca98fb9ffaaf8017f87e0)
##0.15.0
**Breaking Changes**
+ ["servers" parameter changed to single "server"](https://github.com/ripple/ripple-lib/commit/7061e9afe46f0682254d098adeff3dd7157521a1)
**Changes**
+ [fix handling memos in prepareSettings](https://github.com/ripple/ripple-lib/commit/c9704137b7b538e8dbf31c483bcdcf2dcfd7cd75)
+ [Docs: SusPay warnings, offline mode, and other tweaks](https://github.com/ripple/ripple-lib/commit/4b4fc36ebd93f1360781a65f2869bd2c4f0a5093)
+ [Fix prepareOrderCancellation documentation](https://github.com/ripple/ripple-lib/commit/5e720891f579fd73d43c64e5ec519d9121023c10)
##0.14.0
**Breaking Changes**
+ [prepareOrderCancellation now takes orderCancellation specification](https://github.com/ripple/ripple-lib/commit/7f33d8a71e56289e5a5e0ead1c74f75ebcde72bc)
+ [Rename "ledgerClosed" event to "ledger" and change format](https://github.com/ripple/ripple-lib/commit/8a3d4a64db5fbf560ebf87dc62e0212513c5e18a)
**Changes**
+ [Fix proxy support and add support for proxy authorization](https://github.com/ripple/ripple-lib/commit/14b840f3feca758e0384b746c94e36d8bf59b8c2)
+ [Fix trace option](https://github.com/ripple/ripple-lib/commit/af620755c53556c55eed12de4b0013ef5a349ce2)
+ [Allow memos on all transaction types](https://github.com/ripple/ripple-lib/commit/b5081344da8e66fbd3a5113cc3313325ef72a494)
+ [Add documentation for RippleAPI options](https://github.com/ripple/ripple-lib/commit/a76b554cadb9f9f918b06f8386bc29355682a1a4)
+ [Docs: more on basic types, tx types](https://github.com/ripple/ripple-lib/commit/fdbac63f466b4fd3be701d4878800d856692e26e)
+ [Docs: revised introductory material](https://github.com/ripple/ripple-lib/commit/ef2515507dbd3c6a426ab5b31332a1bdf72d5b2d)
+ [boost coverage to almost 100%](https://github.com/ripple/ripple-lib/commit/995606b1e6f3643af34d9fd442ccd31f320b03eb)
##0.13.2
**Changes**
+ [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))
**Changes**
+ [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**
+ [Removed timeout method of Request and added default timeout](https://github.com/ripple/ripple-lib/commit/634fe5683a9082e57682ff7d5c4fb9483b4af818)
+ Add new RippleAPI interface
+ Add new RippleAPI interface and delete old API
- [RippleAPI README and samples](https://github.com/ripple/ripple-lib/tree/develop/docs/samples)
- [Method documentation](https://rawgit.com/ripple/ripple-lib/develop/docs/api.html)
**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)
@@ -18,6 +90,10 @@
+ [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.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)

View File

@@ -1,6 +1,6 @@
#ripple-lib
A JavaScript API for interacting with Ripple in Node.js and the browser
A JavaScript API for interacting with Ripple in Node.js
[![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)
@@ -8,7 +8,7 @@ A JavaScript API for interacting with Ripple in Node.js and the browser
###Features
+ Connect to a rippled server in JavaScript (Node.js or browser)
+ Connect to a rippled server in Node.js
+ 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
@@ -20,7 +20,7 @@ Install `ripple-lib` using npm:
$ npm install ripple-lib
```
Then see the sample code in `docs/samples`.
Then see the [documentation](https://github.com/ripple/ripple-lib/blob/develop/docs/index.md) and [code samples](https://github.com/ripple/ripple-lib/tree/develop/docs/samples)
##Running tests
@@ -28,6 +28,10 @@ Then see the sample code in `docs/samples`.
2. `cd` into the repository and install dependencies with `npm install`
3. `npm test` or `npm test --coverage` (`istanbul` will create coverage reports in coverage/lcov-report/`)
##Generating Documentation
The continuous integration tests require that the documentation stays up-to-date. If you make changes the the JSON schemas, fixtures, or documentation sources, you must update the documentation by running `npm run docgen`.
##More Information
+ [Ripple Dev Portal](https://ripple.com/build/)

View File

@@ -1,7 +1,16 @@
machine:
node:
version: 0.12.0
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:
- scripts/ci.sh "$CIRCLE_NODE_INDEX" "$CIRCLE_NODE_TOTAL":
parallel: true
post:
- killall /usr/bin/rippled

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>

3579
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'
}

View File

@@ -0,0 +1,55 @@
# Basic Types
## Ripple Address
```json
"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59"
```
Every Ripple account has an *address*, which is a base58-encoding of a hash of the account's public key. Ripple addresses always start with the lowercase letter `r`.
## Account Sequence Number
Every Ripple account has a *sequence number* that is used to keep transactions in order. Every transaction must have a sequence number. A transaction can only be executed if it has the next sequence number in order, of the account sending it. This prevents one transaction from executing twice and transactions executing out of order. The sequence number starts at `1` and increments for each transaction that the account makes.
## Currency
Currencies are represented as either 3-character currency codes or 40-character uppercase hexadecimal strings. We recommend using uppercase [ISO 4217 Currency Codes](http://www.xe.com/iso4217.php) only. The string "XRP" is disallowed on trustlines because it is reserved for the Ripple native currency. The following characters are permitted: all uppercase and lowercase letters, digits, as well as the symbols `?`, `!`, `@`, `#`, `$`, `%`, `^`, `&`, `*`, `<`, `>`, `(`, `)`, `{`, `}`, `[`, `]`, and `|`.
## Value
A *value* is a quantity of a currency represented as a decimal string. Be careful: JavaScript's native number format does not have sufficient precision to represent all values. XRP has different precision from other currencies.
**XRP** has 6 significant digits past the decimal point. In other words, XRP cannot be divided into positive values smaller than `0.000001` (1e-6). XRP has a maximum value of `100000000000` (1e11).
**Non-XRP values** have 15 decimal digits of precision, with a maximum value of `9999999999999999e80`. The smallest positive non-XRP value is `1e-81`.
## Amount
Example amount:
```json
{
"currency": "USD",
"counterparty": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM",
"value": "100"
}
```
Example XRP amount:
```json
{
"currency": "XRP",
"value": "2000"
}
```
An *amount* is data structure representing a currency, a quantity of that currency, and the counterparty on the trustline that holds the value. For XRP, there is no counterparty.
A *lax amount* allows the counterparty to be omitted for all currencies. If the counterparty is not specified in an amount within a transaction specification, then any counterparty may be used for that amount.
A *lax 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/amount-base.json') %>

View File

@@ -0,0 +1,60 @@
## 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');
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.connect().then(() => {
/* insert code here */
}).then(() => {
return api.disconnect();
}).catch(console.error);
```
RippleAPI is designed to work in [NodeJS](https://nodejs.org) (version `0.12.0` or greater) using [Babel](https://babeljs.io/) for [ECMAScript 6](https://babeljs.io/docs/learn-es2015/) support.
The code samples in this documentation are written in ES6, but `RippleAPI` will work with ES5 also. Regardless of whether you use ES5 or ES6, the methods that return promises will return [ES6-style promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise).
<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 [NodeJS](https://nodejs.org) and the Node Package Manager (npm). Most Linux distros have a package for NodeJS, but make sure you have version `0.12.0` or higher.
2. Use npm to install [Babel](https://babeljs.io/) globally:
`npm install -g babel`
3. Use npm to install RippleAPI:
`npm install ripple-lib`
After you have installed ripple-lib, you can create scripts using the [boilerplate](#boilerplate) and run them using babel-node:
`babel-node script.js`
<aside class="notice">
Instead of using babel-node in production, we recommend using Babel to transpile to ECMAScript 5 first.
</aside>

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,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

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

@@ -0,0 +1,49 @@
# 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.
```

View File

@@ -0,0 +1,23 @@
## generateAddress
`generateAddress(): {address: string, secret: string}`
Generate a new Ripple 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,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 array of objects 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') %>

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

@@ -0,0 +1,23 @@
## getFee
`getFee(): Promise<number>`
Returns the estimated transaction fee for the rippled server the RippleAPI instance is connected to.
### Parameters
This method has no parameters.
### 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.012"
```

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,26 @@
## 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') %>
### 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,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") %>

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

@@ -0,0 +1,38 @@
<% 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 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 getLedger.md.ejs %>
<% include preparePayment.md.ejs %>
<% include prepareTrustline.md.ejs %>
<% include prepareOrder.md.ejs %>
<% include prepareOrderCancellation.md.ejs %>
<% include prepareSettings.md.ejs %>
<% include prepareSuspendedPaymentCreation.md.ejs %>
<% include prepareSuspendedPaymentCancellation.md.ejs %>
<% include prepareSuspendedPaymentExecution.md.ejs %>
<% include sign.md.ejs %>
<% include combine.md.ejs %>
<% include submit.md.ejs %>
<% include generateAddress.md.ejs %>
<% include computeLedgerHash.md.ejs %>
<% include events.md.ejs %>

View File

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

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
```

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

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

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

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

View File

@@ -0,0 +1,30 @@
## 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';
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, sequence)
.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 @@
## 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,32 @@
## prepareSuspendedPaymentCancellation
`prepareSuspendedPaymentCancellation(address: string, suspendedPaymentCancellation: Object, instructions: Object): Promise<Object>`
Prepare a suspended payment cancellation transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
**Caution:** Suspended Payments are currently available on the [Ripple Test Net](https://ripple.com/build/ripple-test-net/) only.
### Parameters
<%- renderSchema('input/prepare-suspended-payment-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 suspendedPaymentCancellation = <%- importFile('test/fixtures/requests/prepare-suspended-payment-cancellation.json') %>;
return api.prepareSuspendedPaymentCancellation(address, suspendedPaymentCancellation).then(prepared =>
{/* ... */});
```
<%- renderFixture('responses/prepare-suspended-payment-cancellation.json') %>

View File

@@ -0,0 +1,32 @@
## prepareSuspendedPaymentCreation
`prepareSuspendedPaymentCreation(address: string, suspendedPaymentCreation: Object, instructions: Object): Promise<Object>`
Prepare a suspended payment creation transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
**Caution:** Suspended Payments are currently available on the [Ripple Test Net](https://ripple.com/build/ripple-test-net/) only.
### Parameters
<%- renderSchema('input/prepare-suspended-payment-creation.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 suspendedPaymentCreation = <%- importFile('test/fixtures/requests/prepare-suspended-payment-creation.json') %>;
return api.prepareSuspendedPaymentCreation(address, suspendedPaymentCreation).then(prepared =>
{/* ... */});
```
<%- renderFixture('responses/prepare-suspended-payment-creation.json') %>

View File

@@ -0,0 +1,32 @@
## prepareSuspendedPaymentExecution
`prepareSuspendedPaymentExecution(address: string, suspendedPaymentExecution: Object, instructions: Object): Promise<Object>`
Prepare a suspended payment execution transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).
**Caution:** Suspended Payments are currently available on the [Ripple Test Net](https://ripple.com/build/ripple-test-net/) only.
### Parameters
<%- renderSchema('input/prepare-suspended-payment-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 suspendedPaymentExecution = <%- importFile('test/fixtures/requests/prepare-suspended-payment-execution.json') %>;
return api.prepareSuspendedPaymentExecution(address, suspendedPaymentExecution).then(prepared =>
{/* ... */});
```
<%- renderFixture('responses/prepare-suspended-payment-execution.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.preparePayment(address, trustline).then(prepared =>
{/* ... */});
```
<%- renderFixture("responses/prepare-trustline.json") %>

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

@@ -0,0 +1,25 @@
## sign
`sign(txJSON: string, secret: string, 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';
return api.sign(txJSON, secret);
```
<%- renderFixture("responses/sign.json") %>

View File

@@ -0,0 +1,83 @@
# 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') %>
### 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') %>
## Suspended Payment Creation
See [Transaction Types](#transaction-types) for a description.
<%- renderSchema('specifications/suspended-payment-creation.json') %>
### Example
<%- renderFixture('requests/prepare-suspended-payment-creation.json') %>
## Suspended Payment Cancellation
See [Transaction Types](#transaction-types) for a description.
<%- renderSchema('specifications/suspended-payment-cancellation.json') %>
### Example
<%- renderFixture('requests/prepare-suspended-payment-cancellation.json') %>
## Suspended Payment Execution
See [Transaction Types](#transaction-types) for a description.
<%- renderSchema('specifications/suspended-payment-execution.json') %>
### Example
<%- renderFixture('requests/prepare-suspended-payment-execution.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,65 @@
# 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 Ripple Consensus Ledger's order book if not completely fulfilled when placed. Orders can be partially fulfilled.
[orderCancellation](#order-cancellation) | An `orderCancellation` transaction cancels an order in the Ripple Consensus Ledger's order book.
[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 Ripple Consensus Ledger.
[suspendedPaymentCreation](#suspended-payment-creation) | A `suspendedPaymentCreation` transaction creates a suspended payment on the ledger, which locks XRP until a cryptographic condition is met or it expires. It is like an escrow service where the Ripple network acts as the escrow agent.
[suspendedPaymentCancellation](#suspended-payment-cancellation) | A `suspendedPaymentCancellation` transaction unlocks the funds in a suspended payment and sends them back to the creator of the suspended payment, but it will only work after the suspended payment expires.
[suspendedPaymentExecution](#suspended-payment-execution) | A `suspendedPaymentExecution` transaction unlocks the funds in a suspended payment and sends them to the destination of the suspended payment, but it will only work if the cryptographic condition is provided.
The three "suspended payment" transaction types are not supported by the production Ripple peer-to-peer network at this time. They are available for testing purposes if you [configure RippleAPI](#boilerplate) to connect to the [Ripple Test Net](https://ripple.com/build/ripple-test-net/) instead.
## Transaction Flow
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)
* [prepareSuspendedPaymentCreation](#preparesuspendedpaymentcreation)
* [prepareSuspendedPaymentCancellation](#preparesuspendedpaymentcancellation)
* [prepareSuspendedPaymentExecution](#preparesuspendedpaymentexecution)
2. [Sign](#sign) - Cryptographically sign the transaction locally and save the [transaction ID](#transaction-id). Signing is how the owner of an account authorizes a transaction to take place. 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 Ripple network, making it very expensive to deliberately or inadvertently overload the network.
You can choose the size of the fee you want to pay or let a default be used. 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 recommended that you specify a `maxLedgerVersion` so that you can quickly determine that a failed transaction will never succeeed in the future. It is impossible for a transaction to succeed after the network ledger version exceeds the transaction's `maxLedgerVersion`. If you omit `maxLedgerVersion`, the "prepare*" method automatically supplies a `maxLedgerVersion` equal to the current ledger plus 3, which it includes in the return value from the "prepare*" method.
## Transaction ID
```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') %>

179
npm-shrinkwrap.json generated
View File

@@ -1,93 +1,177 @@
{
"name": "ripple-lib",
"version": "0.13.0-rc16",
"npm-shrinkwrap-version": "5.4.0",
"node-version": "v0.12.7",
"version": "0.16.4",
"dependencies": {
"ajv": {
"version": "1.4.8",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-1.4.8.tgz",
"version": "1.4.10",
"from": "https://registry.npmjs.org/ajv/-/ajv-1.4.10.tgz",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-1.4.10.tgz",
"dependencies": {
"json-stable-stringify": {
"version": "1.0.0",
"from": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.0.tgz",
"resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.0.tgz",
"dependencies": {
"jsonify": {
"version": "0.0.0",
"from": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz",
"resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz"
}
}
}
}
},
"babel-runtime": {
"version": "5.8.29",
"resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-5.8.29.tgz",
"ajv-i18n": {
"version": "0.1.1",
"from": "https://registry.npmjs.org/ajv-i18n/-/ajv-i18n-0.1.1.tgz",
"resolved": "https://registry.npmjs.org/ajv-i18n/-/ajv-i18n-0.1.1.tgz"
},
"babel-polyfill": {
"version": "6.3.14",
"from": "https://registry.npmjs.org/babel-polyfill/-/babel-polyfill-6.3.14.tgz",
"resolved": "https://registry.npmjs.org/babel-polyfill/-/babel-polyfill-6.3.14.tgz",
"dependencies": {
"core-js": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-1.2.3.tgz"
"version": "1.2.6",
"from": "https://registry.npmjs.org/core-js/-/core-js-1.2.6.tgz",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-1.2.6.tgz"
},
"babel-regenerator-runtime": {
"version": "6.3.13",
"from": "https://registry.npmjs.org/babel-regenerator-runtime/-/babel-regenerator-runtime-6.3.13.tgz",
"resolved": "https://registry.npmjs.org/babel-regenerator-runtime/-/babel-regenerator-runtime-6.3.13.tgz"
}
}
},
"babel-runtime": {
"version": "5.8.34",
"from": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-5.8.34.tgz",
"resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-5.8.34.tgz",
"dependencies": {
"core-js": {
"version": "1.2.6",
"from": "https://registry.npmjs.org/core-js/-/core-js-1.2.6.tgz",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-1.2.6.tgz"
}
}
},
"bignumber.js": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-2.1.0.tgz"
"version": "2.1.2",
"from": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-2.1.2.tgz",
"resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-2.1.2.tgz"
},
"https-proxy-agent": {
"version": "1.0.0",
"from": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-1.0.0.tgz",
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-1.0.0.tgz",
"dependencies": {
"agent-base": {
"version": "2.0.1",
"from": "https://registry.npmjs.org/agent-base/-/agent-base-2.0.1.tgz",
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-2.0.1.tgz",
"dependencies": {
"semver": {
"version": "5.0.3",
"from": "https://registry.npmjs.org/semver/-/semver-5.0.3.tgz",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.0.3.tgz"
}
}
},
"debug": {
"version": "2.2.0",
"from": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz",
"dependencies": {
"ms": {
"version": "0.7.1",
"from": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz",
"resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz"
}
}
},
"extend": {
"version": "3.0.0",
"from": "https://registry.npmjs.org/extend/-/extend-3.0.0.tgz",
"resolved": "https://registry.npmjs.org/extend/-/extend-3.0.0.tgz"
}
}
},
"jayson": {
"version": "1.2.2",
"from": "https://registry.npmjs.org/jayson/-/jayson-1.2.2.tgz",
"resolved": "https://registry.npmjs.org/jayson/-/jayson-1.2.2.tgz",
"dependencies": {
"JSONStream": {
"version": "1.0.3",
"from": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.0.3.tgz",
"resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.0.3.tgz",
"dependencies": {
"jsonparse": {
"version": "1.0.0",
"from": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.0.0.tgz",
"resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.0.0.tgz"
},
"through": {
"version": "2.3.8",
"from": "https://registry.npmjs.org/through/-/through-2.3.8.tgz",
"resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz"
}
}
},
"commander": {
"version": "1.3.2",
"from": "https://registry.npmjs.org/commander/-/commander-1.3.2.tgz",
"resolved": "https://registry.npmjs.org/commander/-/commander-1.3.2.tgz",
"dependencies": {
"keypress": {
"version": "0.1.0",
"from": "https://registry.npmjs.org/keypress/-/keypress-0.1.0.tgz",
"resolved": "https://registry.npmjs.org/keypress/-/keypress-0.1.0.tgz"
}
}
},
"eyes": {
"version": "0.1.8",
"from": "https://registry.npmjs.org/eyes/-/eyes-0.1.8.tgz",
"resolved": "https://registry.npmjs.org/eyes/-/eyes-0.1.8.tgz"
},
"lodash": {
"version": "3.6.0",
"from": "https://registry.npmjs.org/lodash/-/lodash-3.6.0.tgz",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-3.6.0.tgz"
}
}
},
"lodash": {
"version": "3.10.1",
"from": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz"
},
"ripple-address-codec": {
"version": "2.0.1",
"from": "https://registry.npmjs.org/ripple-address-codec/-/ripple-address-codec-2.0.1.tgz",
"resolved": "https://registry.npmjs.org/ripple-address-codec/-/ripple-address-codec-2.0.1.tgz",
"dependencies": {
"hash.js": {
"version": "1.0.3",
"from": "https://registry.npmjs.org/hash.js/-/hash.js-1.0.3.tgz",
"resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.0.3.tgz",
"dependencies": {
"inherits": {
"version": "2.0.1",
"from": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz"
}
}
},
"x-address-codec": {
"version": "0.7.2",
"from": "https://registry.npmjs.org/x-address-codec/-/x-address-codec-0.7.2.tgz",
"resolved": "https://registry.npmjs.org/x-address-codec/-/x-address-codec-0.7.2.tgz",
"dependencies": {
"base-x": {
"version": "1.0.1",
"from": "https://registry.npmjs.org/base-x/-/base-x-1.0.1.tgz",
"resolved": "https://registry.npmjs.org/base-x/-/base-x-1.0.1.tgz"
}
}
@@ -95,97 +179,77 @@
}
},
"ripple-binary-codec": {
"version": "0.0.7",
"resolved": "https://registry.npmjs.org/ripple-binary-codec/-/ripple-binary-codec-0.0.7.tgz",
"version": "0.1.1",
"from": "https://registry.npmjs.org/ripple-binary-codec/-/ripple-binary-codec-0.1.1.tgz",
"resolved": "https://registry.npmjs.org/ripple-binary-codec/-/ripple-binary-codec-0.1.1.tgz",
"dependencies": {
"babel-runtime": {
"version": "5.8.34",
"resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-5.8.34.tgz",
"dependencies": {
"core-js": {
"version": "1.2.6",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-1.2.6.tgz"
}
}
},
"bn.js": {
"version": "3.3.0",
"from": "https://registry.npmjs.org/bn.js/-/bn.js-3.3.0.tgz",
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-3.3.0.tgz"
},
"create-hash": {
"version": "1.1.2",
"from": "https://registry.npmjs.org/create-hash/-/create-hash-1.1.2.tgz",
"resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.1.2.tgz",
"dependencies": {
"cipher-base": {
"version": "1.0.2",
"from": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.2.tgz",
"resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.2.tgz"
},
"ripemd160": {
"version": "1.0.1",
"from": "https://registry.npmjs.org/ripemd160/-/ripemd160-1.0.1.tgz",
"resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-1.0.1.tgz"
},
"sha.js": {
"version": "2.4.4",
"from": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.4.tgz",
"resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.4.tgz"
}
}
},
"decimal.js": {
"version": "4.0.3",
"from": "https://registry.npmjs.org/decimal.js/-/decimal.js-4.0.3.tgz",
"resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-4.0.3.tgz"
},
"inherits": {
"version": "2.0.1",
"from": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz"
},
"lodash": {
"version": "3.10.1",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz"
},
"ripple-address-codec": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/ripple-address-codec/-/ripple-address-codec-2.0.1.tgz",
"dependencies": {
"hash.js": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.0.3.tgz"
},
"x-address-codec": {
"version": "0.7.2",
"resolved": "https://registry.npmjs.org/x-address-codec/-/x-address-codec-0.7.2.tgz",
"dependencies": {
"base-x": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/base-x/-/base-x-1.0.1.tgz"
}
}
}
}
}
}
},
"ripple-hashes": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/ripple-hashes/-/ripple-hashes-0.0.1.tgz",
"version": "0.1.0",
"from": "https://registry.npmjs.org/ripple-hashes/-/ripple-hashes-0.1.0.tgz",
"resolved": "https://registry.npmjs.org/ripple-hashes/-/ripple-hashes-0.1.0.tgz",
"dependencies": {
"create-hash": {
"version": "1.1.2",
"from": "https://registry.npmjs.org/create-hash/-/create-hash-1.1.2.tgz",
"resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.1.2.tgz",
"dependencies": {
"cipher-base": {
"version": "1.0.2",
"from": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.2.tgz",
"resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.2.tgz"
},
"inherits": {
"version": "2.0.1",
"from": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz"
},
"ripemd160": {
"version": "1.0.1",
"from": "https://registry.npmjs.org/ripemd160/-/ripemd160-1.0.1.tgz",
"resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-1.0.1.tgz"
},
"sha.js": {
"version": "2.4.4",
"from": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.4.tgz",
"resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.4.tgz"
}
}
@@ -194,32 +258,39 @@
},
"ripple-keypairs": {
"version": "0.10.0",
"from": "https://registry.npmjs.org/ripple-keypairs/-/ripple-keypairs-0.10.0.tgz",
"resolved": "https://registry.npmjs.org/ripple-keypairs/-/ripple-keypairs-0.10.0.tgz",
"dependencies": {
"bn.js": {
"version": "3.3.0",
"from": "https://registry.npmjs.org/bn.js/-/bn.js-3.3.0.tgz",
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-3.3.0.tgz"
},
"brorand": {
"version": "1.0.5",
"from": "https://registry.npmjs.org/brorand/-/brorand-1.0.5.tgz",
"resolved": "https://registry.npmjs.org/brorand/-/brorand-1.0.5.tgz"
},
"elliptic": {
"version": "5.2.1",
"from": "https://registry.npmjs.org/elliptic/-/elliptic-5.2.1.tgz",
"resolved": "https://registry.npmjs.org/elliptic/-/elliptic-5.2.1.tgz",
"dependencies": {
"inherits": {
"version": "2.0.1",
"from": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz"
}
}
},
"hash.js": {
"version": "1.0.3",
"from": "https://registry.npmjs.org/hash.js/-/hash.js-1.0.3.tgz",
"resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.0.3.tgz",
"dependencies": {
"inherits": {
"version": "2.0.1",
"from": "inherits@>=2.0.1 <2.1.0",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz"
}
}
@@ -228,18 +299,22 @@
},
"ripple-lib-transactionparser": {
"version": "0.6.0",
"from": "https://registry.npmjs.org/ripple-lib-transactionparser/-/ripple-lib-transactionparser-0.6.0.tgz",
"resolved": "https://registry.npmjs.org/ripple-lib-transactionparser/-/ripple-lib-transactionparser-0.6.0.tgz"
},
"ws": {
"version": "0.7.2",
"resolved": "https://registry.npmjs.org/ws/-/ws-0.7.2.tgz",
"version": "1.0.1",
"from": "https://registry.npmjs.org/ws/-/ws-1.0.1.tgz",
"resolved": "https://registry.npmjs.org/ws/-/ws-1.0.1.tgz",
"dependencies": {
"options": {
"version": "0.0.6",
"from": "https://registry.npmjs.org/options/-/options-0.0.6.tgz",
"resolved": "https://registry.npmjs.org/options/-/options-0.0.6.tgz"
},
"ultron": {
"version": "1.0.2",
"from": "https://registry.npmjs.org/ultron/-/ultron-1.0.2.tgz",
"resolved": "https://registry.npmjs.org/ultron/-/ultron-1.0.2.tgz"
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "ripple-lib",
"version": "0.13.0-rc16",
"version": "0.16.4",
"license": "ISC",
"description": "A JavaScript API for interacting with Ripple in Node.js and the browser",
"files": [
@@ -16,16 +16,18 @@
},
"dependencies": {
"ajv": "^1.4.8",
"babel-polyfill": "^6.2.0",
"babel-runtime": "^5.5.4",
"bignumber.js": "^2.0.3",
"https-proxy-agent": "^1.0.0",
"jayson": "^1.2.2",
"lodash": "^3.1.0",
"ripple-address-codec": "^2.0.1",
"ripple-binary-codec": "^0.0.7",
"ripple-hashes": "^0.0.1",
"ripple-binary-codec": "^0.1.1",
"ripple-hashes": "^0.1.0",
"ripple-keypairs": "^0.10.0",
"ripple-lib-transactionparser": "^0.6.0",
"ws": "~0.7.1"
"ws": "^1.0.1"
},
"devDependencies": {
"assert-diff": "^1.0.1",
@@ -33,23 +35,28 @@
"babel-core": "^5.8.22",
"babel-eslint": "^4.1.3",
"babel-loader": "^5.3.2",
"coveralls": "~2.10.0",
"coveralls": "^2.10.0",
"doctoc": "^0.15.0",
"ejs": "^2.3.4",
"eslint": "^1.3.0",
"eslint-plugin-flowtype": "^1.0.0",
"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",
"gulp-uglify": "^1.1.0",
"istanbul": "^0.3.5",
"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",
"webpack": "^1.5.3",
"yargs": "^1.3.1"
},
"scripts": {
"build": "gulp",
"doctoc": "doctoc docs/index.md --title '# RippleAPI Reference' --github --maxlevel 2",
"docgen": "node --harmony scripts/build_docs.js",
"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/",
@@ -59,7 +66,8 @@
"test": "istanbul test _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"
"perf": "./scripts/perf_test.sh",
"start": "babel-node scripts/http.js"
},
"repository": {
"type": "git",

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

View File

@@ -3,6 +3,10 @@
NODE_INDEX="$1"
TOTAL_NODES="$2"
function checkEOL {
./scripts/checkeol.sh
}
typecheck() {
npm install -g flow-bin
flow --version
@@ -34,9 +38,21 @@ unittest() {
integrationtest() {
mocha test/integration/integration-test.js
mocha test/integration/http-integration-test.js
}
doctest() {
mv docs/index.md docs/index.md.save
npm 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
typecheck
unittest
@@ -45,16 +61,16 @@ oneNode() {
twoNodes() {
case "$NODE_INDEX" in
0) lint && integrationtest;;
1) typecheck && unittest;;
0) doctest; lint; integrationtest;;
1) checkEOL; typecheck; unittest;;
*) echo "ERROR: invalid usage"; exit 2;;
esac
}
threeNodes() {
case "$NODE_INDEX" in
0) lint && integrationtest;;
1) typecheck;;
0) doctest; lint; integrationtest;;
1) checkEOL; typecheck;;
2) unittest;;
*) echo "ERROR: invalid usage"; exit 2;;
esac

16
scripts/http.js Normal file
View File

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

View File

@@ -16,28 +16,3 @@ echo ""
echo "publish to npm"
npm 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

@@ -16,28 +16,3 @@ echo ""
echo "publish rc to npm"
npm 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 ..

147
src/api.js Normal file
View File

@@ -0,0 +1,147 @@
/* @flow */
'use strict';
/* eslint-disable max-len */
// Enable core-js polyfills. This allows use of ES6/7 extensions listed here:
// https://github.com/zloirock/core-js/blob/fb0890f32dabe8d4d88a4350d1b268446127132e/shim.js#L1-L103
/* eslint-enable max-len */
// In node.js env, polyfill might be already loaded (from any npm package),
// that's why we do this check.
if (!global._babelPolyfill) {
require('babel-polyfill');
}
const _ = require('lodash');
const EventEmitter = require('events').EventEmitter;
const common = require('./common');
const server = require('./server/server');
const connect = server.connect;
const disconnect = server.disconnect;
const getServerInfo = server.getServerInfo;
const getFee = server.getFee;
const isConnected = server.isConnected;
const getLedgerVersion = server.getLedgerVersion;
const getTransaction = require('./ledger/transaction');
const getTransactions = require('./ledger/transactions');
const getTrustlines = require('./ledger/trustlines');
const getBalances = require('./ledger/balances');
const getBalanceSheet = require('./ledger/balance-sheet');
const getPaths = require('./ledger/pathfind');
const getOrders = require('./ledger/orders');
const getOrderbook = require('./ledger/orderbook');
const getSettings = require('./ledger/settings');
const getAccountInfo = require('./ledger/accountinfo');
const preparePayment = require('./transaction/payment');
const prepareTrustline = require('./transaction/trustline');
const prepareOrder = require('./transaction/order');
const prepareOrderCancellation = require('./transaction/ordercancellation');
const prepareSuspendedPaymentCreation =
require('./transaction/suspended-payment-creation');
const prepareSuspendedPaymentExecution =
require('./transaction/suspended-payment-execution');
const prepareSuspendedPaymentCancellation =
require('./transaction/suspended-payment-cancellation');
const prepareSettings = require('./transaction/settings');
const sign = require('./transaction/sign');
const combine = require('./transaction/combine');
const submit = require('./transaction/submit');
const errors = require('./common').errors;
const generateAddress =
require('./offline/generate-address').generateAddressAPI;
const computeLedgerHash = require('./offline/ledgerhash');
const getLedger = require('./ledger/ledger');
type APIOptions = {
server?: string,
feeCushion?: number,
trace?: boolean,
proxy?: string,
timeout?: number
}
// prevent access to non-validated ledger versions
class RestrictedConnection extends common.Connection {
request(request, timeout) {
const ledger_index = request.ledger_index;
if (ledger_index !== undefined && ledger_index !== 'validated') {
if (!_.isNumber(ledger_index) || ledger_index > this._ledgerVersion) {
return Promise.reject(new errors.LedgerVersionError(
`ledgerVersion ${ledger_index} is greater than server\'s ` +
`most recent validated ledger: ${this._ledgerVersion}`));
}
}
return super.request(request, timeout);
}
}
class RippleAPI extends EventEmitter {
constructor(options: APIOptions = {}) {
common.validate.apiOptions(options);
super();
this._feeCushion = options.feeCushion || 1.2;
const serverURL = options.server;
if (serverURL !== undefined) {
this.connection = new RestrictedConnection(serverURL, options);
this.connection.on('ledgerClosed', message => {
this.emit('ledger', server.formatLedgerClose(message));
});
this.connection.on('error', (errorCode, errorMessage, data) => {
this.emit('error', errorCode, errorMessage, data);
});
} else {
// use null object pattern to provide better error message if user
// tries to call a method that requires a connection
this.connection = new RestrictedConnection(null, options);
}
}
}
_.assign(RippleAPI.prototype, {
connect,
disconnect,
isConnected,
getServerInfo,
getFee,
getLedgerVersion,
getTransaction,
getTransactions,
getTrustlines,
getBalances,
getBalanceSheet,
getPaths,
getOrders,
getOrderbook,
getSettings,
getAccountInfo,
getLedger,
preparePayment,
prepareTrustline,
prepareOrder,
prepareOrderCancellation,
prepareSuspendedPaymentCreation,
prepareSuspendedPaymentExecution,
prepareSuspendedPaymentCancellation,
prepareSettings,
sign,
combine,
submit,
generateAddress,
computeLedgerHash,
errors
});
// these are exposed only for use by unit tests; they are not part of the API
RippleAPI._PRIVATE = {
validate: common.validate,
RangeSet: require('./common/rangeset').RangeSet,
ledgerUtils: require('./ledger/utils'),
schemaValidator: require('./common/schema-validator')
};
module.exports = {
RippleAPI
};

67
src/broadcast.js Normal file
View File

@@ -0,0 +1,67 @@
'use strict';
const _ = require('lodash');
const RippleAPI = require('./api').RippleAPI;
class RippleAPIBroadcast extends RippleAPI {
constructor(servers, options) {
super(options);
this.ledgerVersion = 0;
const apis = servers.map(server => new RippleAPI(
_.assign({}, options, {server})
));
this.getMethodNames().forEach(name => {
this[name] = function() { // eslint-disable-line no-loop-func
return Promise.race(apis.map(api => api[name].apply(api, arguments)));
};
});
// connection methods must be overridden to apply to all api instances
this.connect = function() {
return Promise.all(apis.map(api => api.connect()));
};
this.disconnect = function() {
return Promise.all(apis.map(api => api.disconnect()));
};
this.isConnected = function() {
return _.every(apis.map(api => api.isConnected()));
};
// synchronous methods are all passed directly to the first api instance
const defaultAPI = apis[0];
const syncMethods = ['sign', 'generateAddress', 'computeLedgerHash'];
syncMethods.forEach(name => {
this[name] = defaultAPI[name].bind(defaultAPI);
});
apis.forEach(api => {
api.on('ledger', this.onLedgerEvent.bind(this));
api.on('error', (errorCode, errorMessage, data) =>
this.emit('error', errorCode, errorMessage, data));
});
}
onLedgerEvent(ledger) {
if (ledger.ledgerVersion > this.ledgerVersion) {
this.ledgerVersion = ledger.ledgerVersion;
this.emit('ledger', ledger);
}
}
getMethodNames() {
const methodNames = [];
for (const name in RippleAPI.prototype) {
if (RippleAPI.prototype.hasOwnProperty(name)) {
if (typeof RippleAPI.prototype[name] === 'function') {
methodNames.push(name);
}
}
}
return methodNames;
}
}
module.exports = {
RippleAPIBroadcast
};

View File

@@ -1,4 +1,5 @@
'use strict';
const _ = require('lodash');
const {EventEmitter} = require('events');
const WebSocket = require('ws');
const parseURL = require('url').parse;
@@ -15,9 +16,20 @@ function isStreamMessageType(type) {
class Connection extends EventEmitter {
constructor(url, options = {}) {
super();
this.setMaxListeners(Infinity);
this._url = url;
this._proxyURL = options.proxyURL;
this._trace = options.trace;
if (this._trace) {
// for easier unit testing
this._console = console;
}
this._proxyURL = options.proxy;
this._proxyAuthorization = options.proxyAuthorization;
this._authorization = options.authorization;
this._trustedCertificates = options.trustedCertificates;
this._key = options.key;
this._passphrase = options.passphrase;
this._certificate = options.certificate;
this._timeout = options.timeout || (20 * 1000);
this._isReady = false;
this._ws = null;
@@ -26,6 +38,17 @@ class Connection extends EventEmitter {
this._nextRequestID = 1;
}
_updateLedgerVersions(data) {
this._ledgerVersion = Number(data.ledger_index);
if (data.validated_ledgers) {
this._availableLedgerVersions.reset();
this._availableLedgerVersions.parseAndAddRanges(
data.validated_ledgers);
} else {
this._availableLedgerVersions.addValue(this._ledgerVersion);
}
}
// return value is array of arguments to Connection.emit
_parseMessage(message) {
const data = JSON.parse(message);
@@ -36,24 +59,24 @@ class Connection extends EventEmitter {
return [data.id.toString(), data];
} else if (isStreamMessageType(data.type)) {
if (data.type === 'ledgerClosed') {
this._ledgerVersion = Number(data.ledger_index);
this._availableLedgerVersions.reset();
this._availableLedgerVersions.parseAndAddRanges(
data.validated_ledgers);
this._updateLedgerVersions(data);
}
return [data.type, data];
} else if (data.type === undefined && data.error) {
return ['error', data.error, data.error_message]; // e.g. slowDown
return ['error', data.error, data.error_message, data]; // e.g. slowDown
}
throw new ResponseFormatError('unrecognized message type: ' + data.type);
}
_onMessage(message) {
let parameters;
if (this._trace) {
this._console.log(message);
}
try {
parameters = this._parseMessage(message);
} catch (error) {
this.emit('error', 'badMessage', message);
this.emit('error', 'badMessage', error.message, message);
return;
}
// we don't want this inside the try/catch or exceptions in listener
@@ -74,6 +97,7 @@ class Connection extends EventEmitter {
}
_onUnexpectedClose() {
this._ws = null;
this._isReady = false;
this.connect().then();
}
@@ -83,21 +107,28 @@ class Connection extends EventEmitter {
command: 'subscribe',
streams: ['ledger']
};
return this.request(request).then(response => {
this._ledgerVersion = Number(response.ledger_index);
this._availableLedgerVersions.parseAndAddRanges(
response.validated_ledgers);
return this.request(request).then(data => {
this._updateLedgerVersions(data);
this._isReady = true;
this.emit('connected');
});
}
_createWebSocket(url, proxyURL, authorization) {
_createWebSocket() {
const options = {};
if (proxyURL !== undefined) {
const parsedURL = parseURL(url);
const proxyOptions = parseURL(proxyURL);
proxyOptions.secureEndpoint = (parsedURL.protocol === 'wss:');
if (this._proxyURL !== undefined) {
const parsedURL = parseURL(this._url);
const parsedProxyURL = parseURL(this._proxyURL);
const proxyOverrides = _.omit({
secureEndpoint: (parsedURL.protocol === 'wss:'),
secureProxy: (parsedProxyURL.protocol === 'https:'),
auth: this._proxyAuthorization,
ca: this._trustedCertificates,
key: this._key,
passphrase: this._passphrase,
cert: this._certificate
}, _.isUndefined);
const proxyOptions = _.assign({}, parsedProxyURL, proxyOverrides);
let HttpsProxyAgent;
try {
HttpsProxyAgent = require('https-proxy-agent');
@@ -106,11 +137,22 @@ class Connection extends EventEmitter {
}
options.agent = new HttpsProxyAgent(proxyOptions);
}
if (authorization !== undefined) {
const base64 = new Buffer(authorization).toString('base64');
if (this._authorization !== undefined) {
const base64 = new Buffer(this._authorization).toString('base64');
options.headers = {Authorization: `Basic ${base64}`};
}
return new WebSocket(url, options);
const optionsOverrides = _.omit({
ca: this._trustedCertificates,
key: this._key,
passphrase: this._passphrase,
cert: this._certificate
}, _.isUndefined);
const websocketOptions = _.assign({}, options, optionsOverrides);
const websocket = new WebSocket(this._url, websocketOptions);
// we will have a listener for each outstanding request,
// so we have to raise the limit (the default is 10)
websocket.setMaxListeners(Infinity);
return websocket;
}
connect() {
@@ -124,10 +166,16 @@ class Connection extends EventEmitter {
} else if (this._state === WebSocket.CONNECTING) {
this._ws.once('open', resolve);
} else {
this._ws = this._createWebSocket(this._url, this._proxyURL,
this._authorization);
this._ws = this._createWebSocket();
// when an error causes the connection to close, the close event
// should still be emitted; the "ws" documentation says: "The close
// event is also emitted when then underlying net.Socket closes the
// connection (end or close)."
this._ws.on('error', error =>
this.emit('error', 'websocket', error.messsage, error));
this._ws.on('message', this._onMessage.bind(this));
this._ws.once('close', () => this._onUnexpectedClose);
this._onUnexpectedCloseBound = this._onUnexpectedClose.bind(this);
this._ws.once('close', this._onUnexpectedCloseBound);
this._ws.once('open', () => this._onOpen().then(resolve, reject));
}
});
@@ -140,7 +188,7 @@ class Connection extends EventEmitter {
} else if (this._state === WebSocket.CLOSING) {
this._ws.once('close', resolve);
} else {
this._ws.removeListener('close', this._onUnexpectedClose);
this._ws.removeListener('close', this._onUnexpectedCloseBound);
this._ws.once('close', () => {
this._ws = null;
this._isReady = false;
@@ -182,6 +230,9 @@ class Connection extends EventEmitter {
}
_send(message) {
if (this._trace) {
this._console.log(message);
}
return new Promise((resolve, reject) => {
this._ws.send(message, undefined, (error, result) => {
if (error) {

View File

@@ -43,6 +43,7 @@ function loadSchemas() {
require('./schemas/objects/signed-value.json'),
require('./schemas/objects/orderbook.json'),
require('./schemas/objects/instructions.json'),
require('./schemas/objects/settings.json'),
require('./schemas/specifications/settings.json'),
require('./schemas/specifications/payment.json'),
require('./schemas/specifications/suspended-payment-cancellation.json'),
@@ -61,7 +62,7 @@ function loadSchemas() {
require('./schemas/output/get-orders.json'),
require('./schemas/output/order-change.json'),
require('./schemas/output/prepare.json'),
require('./schemas/output/ledger-closed.json'),
require('./schemas/output/ledger-event.json'),
require('./schemas/output/get-paths.json'),
require('./schemas/output/get-server-info.json'),
require('./schemas/output/get-settings.json'),
@@ -91,8 +92,10 @@ function loadSchemas() {
require('./schemas/input/prepare-suspended-payment-cancellation.json'),
require('./schemas/input/prepare-suspended-payment-execution.json'),
require('./schemas/input/compute-ledger-hash'),
require('./schemas/input/sign'),
require('./schemas/input/submit')
require('./schemas/input/sign.json'),
require('./schemas/input/submit.json'),
require('./schemas/input/generate-address.json'),
require('./schemas/input/combine.json')
];
const titles = _.map(schemas, schema => schema.title);
const duplicates = _.keys(_.pick(_.countBy(titles), count => count > 1));

View File

@@ -3,21 +3,57 @@
"title": "api-options",
"type": "object",
"properties": {
"trace": {"type": "boolean"},
"feeCushion": {"$ref": "value"},
"servers": {
"type": "array",
"items": {
"type": "string",
"format": "uri",
"pattern": "^wss?://"
}
"trace": {
"type": "boolean",
"description": "If true, log rippled requests and responses to stdout."
},
"feeCushion": {
"type": "number",
"minimum": 1,
"description": "Factor to multiply estimated fee by to provide a cushion in case the required fee rises during submission of a transaction. Defaults to `1.2`."
},
"server": {
"type": "string",
"description": "URI for rippled websocket port to connect to. Must start with `wss://` or `ws://`.",
"format": "uri",
"pattern": "^wss?://"
},
"proxy": {
"format": "uri"
"format": "uri",
"description": "URI for HTTP/HTTPS proxy to use to connect to the rippled server."
},
"timeout": {
"type": "integer",
"description": "Timeout in milliseconds before considering a request to have failed.",
"minimum": 1
},
"proxyAuthorization": {
"type": "string",
"description": "Username and password for HTTP basic authentication to the proxy in the format **username:password**."
},
"authorization": {
"type": "string"
"type": "string",
"description": "Username and password for HTTP basic authentication to the rippled server in the format **username:password**."
},
"trustedCertificates": {
"type": "array",
"description": "Array of PEM-formatted SSL certificates to trust when connecting to a proxy. This is useful if you want to use a self-signed certificate on the proxy server. Note: Each element must contain a single certificate; concatenated certificates are not valid.",
"items": {
"type": "string",
"description": "A PEM-formatted SSL certificate to trust when connecting to a proxy."
}
},
"key": {
"type": "string",
"description": "A string containing the private key of the client in PEM format. (Can be an array of keys)."
},
"passphrase": {
"type": "string",
"description": "The passphrase for the private key of the client."
},
"certificate": {
"type": "string",
"description": "A string containing the certificate key of the client in PEM format. (Can be an array of certificates)."
}
},
"additionalProperties": false

View File

@@ -0,0 +1,19 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "combineParameters",
"type": "object",
"properties": {
"signedTransactions": {
"type": "array",
"description": "An array of signed transactions (from the output of [sign](#sign)) to combine.",
"items": {
"type": "string",
"pattern": "^[A-F0-9]+$",
"description": "A single-signed transaction represented as an uppercase hexadecimal string (from the output of [sign](#sign))"
},
"minLength": 1
}
},
"additionalProperties": false,
"required": ["signedTransactions"]
}

View File

@@ -0,0 +1,29 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "generateAddressParameters",
"type": "object",
"properties": {
"options": {
"type": "object",
"description": "Options to control how the address and secret are generated.",
"properties": {
"entropy": {
"type": "array",
"items": {
"type": "integer",
"minimum": 0,
"maximum": 255
},
"description": "The entropy to use to generate the seed."
},
"algorithm": {
"type": "string",
"enum": ["ecdsa-secp256k1", "ed25519"],
"description": "The digital signature algorithm to generate an address for. Can be `ecdsa-secp256k1` (default) or `ed25519`."
}
},
"additionalProperties": false
}
},
"additionalProperties": false
}

View File

@@ -7,12 +7,12 @@
"$ref": "address",
"description": "The address of the account that is creating the transaction."
},
"sequence": {
"$ref": "sequence",
"description": "The account sequence number of the transaction that created the order to cancel."
"orderCancellation": {
"$ref": "orderCancellation",
"description": "The specification of the order cancellation to prepare."
},
"instructions": {"$ref": "instructions"}
},
"additionalProperties": false,
"required": ["address", "sequence"]
"required": ["address", "orderCancellation"]
}

View File

@@ -11,6 +11,17 @@
"type": "string",
"format": "secret",
"description": "The secret of the account that is initiating the transaction."
},
"options": {
"type": "object",
"description": "Options that control the type of signature that will be generated.",
"properties": {
"signAs": {
"$ref": "address",
"description": "The account that the signature should count for in multisigning."
}
},
"additionalProperties": false
}
},
"additionalProperties": false,

View File

@@ -18,13 +18,21 @@
"$ref": "value"
},
"maxLedgerVersion": {
"description": "The highest ledger version that the transaction can be included in.",
"$ref": "ledgerVersion"
"description": "The highest ledger version that the transaction can be included in. If this option and `maxLedgerVersionOffset` are both omitted, the `maxLedgerVersion` option will default to 3 greater than the current validated ledger version (equivalent to `maxLedgerVersionOffset=3`). Use `null` to not set a maximum ledger version.",
"oneOf": [
{"$ref": "ledgerVersion"},
{"type": "null"}
]
},
"maxLedgerVersionOffset": {
"description": "Offset from current legder version to highest ledger version that the transaction can be included in.",
"description": "Offset from current validated legder version to highest ledger version that the transaction can be included in.",
"type": "integer",
"minimum": 0
},
"signersCount": {
"description": "Number of signers that will be signing this transaction.",
"type": "integer",
"minimum": 1
}
},
"additionalProperties": false,

View File

@@ -1,6 +1,7 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "memos",
"link": "transaction-memos",
"description": "Array of memos to attach to the transaction.",
"type": "array",
"items": {

View File

@@ -0,0 +1,103 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "settingsPlusMemos",
"type": "object",
"properties": {
"passwordSpent": {
"type": "boolean",
"description": "Indicates that the account has used its free SetRegularKey transaction."
},
"requireDestinationTag": {
"type": "boolean",
"description": "Requires incoming payments to specify a destination tag."
},
"requireAuthorization": {
"type": "boolean",
"description": "If set, this account must individually approve other users in order for those users to hold this accounts issuances."
},
"disallowIncomingXRP": {
"type": "boolean",
"description": "Indicates that client applications should not send XRP to this account. Not enforced by rippled."
},
"disableMasterKey": {
"type": "boolean",
"description": "Disallows use of the master key to sign transactions for this account."
},
"enableTransactionIDTracking": {
"type": "boolean",
"description": "Track the ID of this accounts most recent transaction."
},
"noFreeze": {
"type": "boolean",
"description": "Permanently give up the ability to freeze individual trust lines. This flag can never be disabled after being enabled."
},
"globalFreeze": {
"type": "boolean",
"description": "Freeze all assets issued by this account."
},
"defaultRipple": {
"type": "boolean",
"description": "Enable [rippling](https://ripple.com/knowledge_center/understanding-the-noripple-flag/) on this accounts trust lines by default. (New in [rippled 0.27.3](https://github.com/ripple/rippled/releases/tag/0.27.3))"
},
"emailHash": {
"description": "Hash of an email address to be used for generating an avatar image. Conventionally, clients use Gravatar to display this image. Use `null` to clear.",
"oneOf": [
{"type": "null"},
{"$ref": "hash128"}
]
},
"messageKey": {
"type": "string",
"description": "Public key for sending encrypted messages to this account. Conventionally, it should be a secp256k1 key, the same encryption that is used by the rest of Ripple."
},
"domain": {
"type": "string",
"description": " The domain that owns this account, as a hexadecimal string representing the ASCII for the domain in lowercase."
},
"transferRate": {
"description": " The fee to charge when users transfer this accounts issuances, represented as billionths of a unit. Use `null` to set no fee.",
"oneOf": [
{"type": "null"},
{"type": "number", "minimum": 1, "maximum": 4.294967295}
]
},
"regularKey": {
"oneOf": [
{"$ref": "address"},
{"type": "null"}
],
"description": "The public key of a new keypair, to use as the regular key to this account, as a base-58-encoded string in the same format as an account address. Use `null` to remove the regular key."
},
"signers": {
"type": "object",
"description": "Settings that determine what sets of accounts can be used to sign a transaction on behalf of this account using multisigning.",
"properties": {
"threshold": {
"$ref": "uint32",
"description": "A target number for the signer weights. A multi-signature from this list is valid only if the sum weights of the signatures provided is equal or greater than this value. To delete the signers setting, use the value `0`."
},
"weights": {
"type": "array",
"description": "Weights of signatures for each signer.",
"items": {
"type": "object",
"description": "An association of an address and a weight.",
"properties": {
"address": {"$ref": "address"},
"weight": {
"$ref": "uint32",
"description": "The weight that the signature of this account counts as towards the threshold."
}
},
"required": ["address", "weight"],
"additionalProperties": false
},
"minItems": 1,
"maxItems": 8
}
}
},
"memos": {"$ref": "memos"}
},
"additionalProperties": false
}

View File

@@ -1,7 +1,7 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "tag",
"description": "An arbitrary unsigned 32-bit integer most commonly used to identify a non-Ripple account.",
"description": "An arbitrary unsigned 32-bit integer that identifies a reason for payment or a non-Ripple account.",
"type": "integer",
"$ref": "uint32"
}

View File

@@ -83,7 +83,7 @@
"description": "The time since the ledger was closed, in seconds."
},
"baseFeeXRP": {
"type": "number",
"$ref": "value",
"description": "Base fee, in XRP. This may be represented in scientific notation such as 1e-05 for 0.00005."
},
"hash": {
@@ -91,14 +91,12 @@
"description": "Unique hash for the ledger, as an uppercase hexadecimal string."
},
"reserveBaseXRP": {
"type": "integer",
"minimum": 0,
"description": "Minimum amount of XRP (not drops) necessary for every account to keep in reserve."
"$ref": "value",
"description": "Minimum amount of XRP necessary for every account to keep in reserve."
},
"reserveIncrementXRP": {
"type": "integer",
"minimum": 0,
"description": "Amount of XRP (not drops) added to the account reserve for each object an account is responsible for in the ledger."
"$ref": "value",
"description": "Amount of XRP added to the account reserve for each object an account is responsible for in the ledger."
},
"ledgerVersion": {
"type": "integer",

View File

@@ -1,73 +1,8 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "getSettings",
"type": "object",
"properties": {
"passwordSpent": {
"type": "boolean",
"description": "Indicates that the account has used its free SetRegularKey transaction."
},
"requireDestinationTag": {
"type": "boolean",
"description": "Requires incoming payments to specify a destination tag."
},
"requireAuthorization": {
"type": "boolean",
"description": "If set, this account must individually approve other users in order for those users to hold this accounts issuances."
},
"disallowIncomingXRP": {
"type": "boolean",
"description": "Indicates that client applications should not send XRP to this account. Not enforced by rippled."
},
"disableMasterKey": {
"type": "boolean",
"description": "Disallows use of the master key to sign transactions for this account."
},
"enableTransactionIDTracking": {
"type": "boolean",
"description": "Track the ID of this accounts most recent transaction."
},
"noFreeze": {
"type": "boolean",
"description": "Permanently give up the ability to freeze individual trust lines. This flag can never be disabled after being enabled."
},
"globalFreeze": {
"type": "boolean",
"description": "Freeze all assets issued by this account."
},
"defaultRipple": {
"type": "boolean",
"description": "Enable [rippling](https://ripple.com/knowledge_center/understanding-the-noripple-flag/) on this accounts trust lines by default. (New in [rippled 0.27.3](https://github.com/ripple/rippled/releases/tag/0.27.3))"
},
"emailHash": {
"description": "Hash of an email address to be used for generating an avatar image. Conventionally, clients use Gravatar to display this image. Use `null` to clear.",
"oneOf": [
{"type": "null"},
{"$ref": "hash128"}
]
},
"messageKey": {
"type": "string",
"description": "Public key for sending encrypted messages to this account. Conventionally, it should be a secp256k1 key, the same encryption that is used by the rest of Ripple."
},
"domain": {
"type": "string",
"description": " The domain that owns this account, as a hexadecimal string representing the ASCII for the domain in lowercase."
},
"transferRate": {
"description": " The fee to charge when users transfer this accounts issuances, represented as billionths of a unit. Use `null` to set no fee.",
"oneOf": [
{"type": "null"},
{"type": "number", "minimum": 1, "maximum": 4.294967295}
]
},
"regularKey": {
"oneOf": [
{"$ref": "address"},
{"type": "null"}
],
"description": "The public key of a new keypair, to use as the regular key to this account, as a base-58-encoded string in the same format as an account address. Use `null` to remove the regular key."
}
},
"additionalProperties": false
"$ref": "settingsPlusMemos",
"not": {
"required": ["memos"]
}
}

View File

@@ -34,7 +34,7 @@
"state": {
"properties": {
"balance": {
"$ref": "value",
"$ref": "signedValue",
"description": "The balance on the trustline, representing which party owes the other and by how much."
}
},

View File

@@ -1,21 +0,0 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "ledgerClosed",
"description": "A ledgerClosed event message",
"type": "object",
"properties": {
"feeBase": {"type": "integer", "minimum": 0},
"feeReference": {"type": "integer", "minimum": 0},
"ledgerHash": {"$ref": "hash256"},
"ledgerVersion": {"$ref": "ledgerVersion"},
"ledgerTimestamp": {"type": "string", "format": "date-time"},
"reserveBase": {"type": "integer", "minimum": 0},
"reserveIncrement": {"type": "integer", "minimum": 0},
"transactionCount": {"type": "integer", "minimum": 0},
"validatedLedgerVersions": {"type": "string"}
},
"addtionalProperties": false,
"required": ["feeBase", "feeReference", "ledgerHash", "ledgerTimestamp",
"reserveBase", "reserveIncrement", "transactionCount",
"ledgerVersion", "validatedLedgerVersions"]
}

View File

@@ -0,0 +1,46 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "ledgerEvent",
"description": "A ledger event message",
"type": "object",
"properties": {
"baseFeeXRP": {
"$ref": "value",
"description": "Base fee, in XRP."
},
"ledgerHash": {
"$ref": "hash256",
"description": "Unique hash of the ledger that was closed, as hex."
},
"ledgerVersion": {
"$ref": "ledgerVersion",
"description": "Ledger version of the ledger that closed."
},
"ledgerTimestamp": {
"type": "string",
"format": "date-time",
"description": "The time at which this ledger closed."
},
"reserveBaseXRP": {
"$ref": "value",
"description": "The minimum reserve, in XRP, that is required for an account."
},
"reserveIncrementXRP": {
"$ref": "value",
"description": "The increase in account reserve that is added for each item the account owns, such as offers or trust lines."
},
"transactionCount": {
"type": "integer",
"minimum": 0,
"description": "Number of new transactions included in this ledger."
},
"validatedLedgerVersions": {
"type": "string",
"description": "Range of ledgers that the server has available. This may be discontiguous."
}
},
"addtionalProperties": false,
"required": ["baseFeeXRP", "ledgerHash", "ledgerTimestamp",
"reserveBaseXRP", "reserveIncrementXRP", "transactionCount",
"ledgerVersion", "validatedLedgerVersions"]
}

View File

@@ -21,12 +21,15 @@
"description": "The initiating account's sequence number for this transaction."
},
"maxLedgerVersion": {
"$ref": "ledgerVersion",
"description": "The highest ledger version that the transaction can be included in."
"oneOf": [
{"$ref": "ledgerVersion"},
{"type": "null"}
],
"description": "The highest ledger version that the transaction can be included in. Set to `null` if there is no maximum."
}
},
"additionalProperties": false,
"required": ["fee", "sequence"]
"required": ["fee", "sequence", "maxLedgerVersion"]
}
},
"additionalProperties": false,

View File

@@ -7,7 +7,8 @@
"orderSequence": {
"$ref": "sequence",
"description": "The [account sequence number](#account-sequence-number) of the order to cancel."
}
},
"memos": {"$ref": "memos"}
},
"required": ["orderSequence"],
"additionalProperties": false

View File

@@ -33,7 +33,8 @@
"type": "string",
"format": "date-time",
"description": "Time after which the offer is no longer active, as an [ISO 8601 date-time](https://en.wikipedia.org/wiki/ISO_8601)."
}
},
"memos": {"$ref": "memos"}
},
"required": ["direction", "quantity", "totalPrice"],
"additionalProperties": false,

View File

@@ -2,11 +2,17 @@
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "settings",
"link": "settings",
"allOf": [
"$ref": "settingsPlusMemos",
"oneOf": [
{
"$ref": "getSettings"
"required": ["memos"],
"minProperties": 2,
"maxProperties": 2
},
{
"not": {
"required": ["memos"]
},
"minProperties": 1,
"maxProperties": 1
}

View File

@@ -21,7 +21,7 @@
},
"digest": {
"$ref": "hash256",
"description": "The original `digest` from the suspended payment creation transaction. This is sha256 hash of `proof` string."
"description": "The original `digest` from the suspended payment creation transaction. This is sha256 hash of `proof` string. It is replicated here so that the relatively expensive hashing operation can be delegated to a server without ledger history and the server with ledger history only has to do a quick comparison of the old digest with the new digest."
},
"proof": {
"type": "string",

View File

@@ -35,7 +35,8 @@
"frozen": {
"type": "boolean",
"description": "If true, the trustline is frozen, which means that funds can only be sent to the owner."
}
},
"memos": {"$ref": "memos"}
},
"required": ["currency", "counterparty", "limit"],
"additionalProperties": false

View File

@@ -6,7 +6,7 @@ import type {Connection} from './connection';
export type GetServerInfoResponse = {
buildVersion: string,
completeLedgers: string,
hostid: string,
hostID: string,
ioLatencyMs: number,
load?: {
jobTypes: Array<Object>,
@@ -23,11 +23,11 @@ export type GetServerInfoResponse = {
serverState: string,
validatedLedger: {
age: number,
baseFeeXrp: number,
baseFeeXRP: string,
hash: string,
reserveBaseXrp: number,
reserveIncXrp: number,
seq: number
reserveBaseXRP: string,
reserveIncrementXRP: string,
ledgerVersion: number
},
validationQuorum: number
}
@@ -49,6 +49,12 @@ function getServerInfo(connection: Connection): Promise<GetServerInfoResponse> {
reserveIncXrp: 'reserveIncrementXRP',
seq: 'ledgerVersion'
});
info.validatedLedger.baseFeeXRP =
info.validatedLedger.baseFeeXRP.toString();
info.validatedLedger.reserveBaseXRP =
info.validatedLedger.reserveBaseXRP.toString();
info.validatedLedger.reserveIncrementXRP =
info.validatedLedger.reserveIncrementXRP.toString();
return info;
});
}

View File

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

View File

@@ -2,8 +2,6 @@
'use strict';
const _ = require('lodash');
const BigNumber = require('bignumber.js');
const errors = require('./errors');
const keypairs = require('ripple-keypairs');
const {deriveKeypair} = require('ripple-keypairs');
import type {Amount, RippledAmount} from './types.js';
@@ -37,21 +35,6 @@ function toRippledAmount(amount: Amount): RippledAmount {
};
}
function generateAddress(options?: Object): Object {
const secret = keypairs.generateSeed(options);
const keypair = keypairs.deriveKeypair(secret);
const address = keypairs.deriveAddress(keypair.publicKey);
return {secret, address};
}
function generateAddressAPI(options?: Object): Object {
try {
return generateAddress(options);
} catch (error) {
throw new errors.UnexpectedError(error.message);
}
}
const FINDSNAKE = /([a-zA-Z]_[a-zA-Z])/g;
function convertKeysFromSnakeCaseToCamelCase(obj: any): any {
if (typeof obj === 'object') {
@@ -101,8 +84,6 @@ module.exports = {
dropsToXrp,
xrpToDrops,
toRippledAmount,
generateAddress,
generateAddressAPI,
convertKeysFromSnakeCaseToCamelCase,
removeUndefined,
rippleTimeToISO8601,

View File

@@ -47,8 +47,10 @@ module.exports = {
prepareSuspendedPaymentExecution: _.partial(schemaValidate,
'prepareSuspendedPaymentExecutionParameters'),
sign: _.partial(schemaValidate, 'signParameters'),
combine: _.partial(schemaValidate, 'combineParameters'),
submit: _.partial(schemaValidate, 'submitParameters'),
computeLedgerHash: _.partial(schemaValidate, 'computeLedgerHashParameters'),
generateAddress: _.partial(schemaValidate, 'generateAddressParameters'),
apiOptions: _.partial(schemaValidate, 'api-options'),
instructions: _.partial(schemaValidate, 'instructions')
};

85
src/http.js Normal file
View File

@@ -0,0 +1,85 @@
/* eslint-disable new-cap */
'use strict';
const assert = require('assert');
const _ = require('lodash');
const jayson = require('jayson');
const RippleAPI = require('./api').RippleAPI;
function createHTTPServer(options, httpPort) {
const rippleAPI = new RippleAPI(options);
const methodNames = _.filter(_.keys(RippleAPI.prototype), k => {
return typeof RippleAPI.prototype[k] === 'function'
&& k !== 'connect'
&& k !== 'disconnect'
&& k !== 'constructor'
&& k !== 'RippleAPI';
});
function applyPromiseWithCallback(fnName, callback, args_) {
try {
let args = args_;
if (!_.isArray(args_)) {
const fnParameters = jayson.Utils.getParameterNames(rippleAPI[fnName]);
args = fnParameters.map(name => args_[name]);
const defaultArgs = _.omit(args_, fnParameters);
assert(_.size(defaultArgs) <= 1,
'Function must have no more than one default argument');
if (_.size(defaultArgs) > 0) {
args.push(defaultArgs[_.keys(defaultArgs)[0]]);
}
}
Promise.resolve(rippleAPI[fnName].apply(rippleAPI, args))
.then(res => callback(null, res))
.catch(err => {
callback({code: 99, message: err.message, data: {name: err.name}});
});
} catch (err) {
callback({code: 99, message: err.message, data: {name: err.name}});
}
}
const methods = {};
_.forEach(methodNames, fn => {
methods[fn] = jayson.Method((args, cb) => {
applyPromiseWithCallback(fn, cb, args);
}, {collect: true});
});
const server = jayson.server(methods);
let httpServer = null;
return {
server: server,
start: function() {
if (httpServer !== null) {
return Promise.reject('Already started');
}
return new Promise((resolve) => {
rippleAPI.connect().then(() => {
httpServer = server.http();
httpServer.listen(httpPort, resolve);
});
});
},
stop: function() {
if (httpServer === null) {
return Promise.reject('Not started');
}
return new Promise((resolve) => {
rippleAPI.disconnect();
httpServer.close(() => {
httpServer = null;
resolve();
});
});
}
};
}
module.exports = {
createHTTPServer
};

View File

@@ -1,145 +1,9 @@
/* @flow */
'use strict';
/* eslint-disable max-len */
// Enable core-js polyfills. This allows use of ES6/7 extensions listed here:
// https://github.com/zloirock/core-js/blob/fb0890f32dabe8d4d88a4350d1b268446127132e/shim.js#L1-L103
/* eslint-enable max-len */
// In node.js env, polyfill might be already loaded (from any npm package),
// that's why we do this check.
if (!global._babelPolyfill) {
require('babel-core/polyfill');
}
const _ = require('lodash');
const EventEmitter = require('events').EventEmitter;
const common = require('./common');
const server = require('./server/server');
const connect = server.connect;
const disconnect = server.disconnect;
const getServerInfo = server.getServerInfo;
const getFee = server.getFee;
const isConnected = server.isConnected;
const getLedgerVersion = server.getLedgerVersion;
const getTransaction = require('./ledger/transaction');
const getTransactions = require('./ledger/transactions');
const getTrustlines = require('./ledger/trustlines');
const getBalances = require('./ledger/balances');
const getBalanceSheet = require('./ledger/balance-sheet');
const getPaths = require('./ledger/pathfind');
const getOrders = require('./ledger/orders');
const getOrderbook = require('./ledger/orderbook');
const getSettings = require('./ledger/settings');
const getAccountInfo = require('./ledger/accountinfo');
const preparePayment = require('./transaction/payment');
const prepareTrustline = require('./transaction/trustline');
const prepareOrder = require('./transaction/order');
const prepareOrderCancellation = require('./transaction/ordercancellation');
const prepareSuspendedPaymentCreation =
require('./transaction/suspended-payment-creation');
const prepareSuspendedPaymentExecution =
require('./transaction/suspended-payment-execution');
const prepareSuspendedPaymentCancellation =
require('./transaction/suspended-payment-cancellation');
const prepareSettings = require('./transaction/settings');
const sign = require('./transaction/sign');
const submit = require('./transaction/submit');
const errors = require('./common').errors;
const generateAddress = common.generateAddressAPI;
const computeLedgerHash = require('./offline/ledgerhash');
const getLedger = require('./ledger/ledger');
type APIOptions = {
servers?: Array<string>,
feeCushion?: number,
trace?: boolean,
proxy?: string
}
// prevent access to non-validated ledger versions
class RestrictedConnection extends common.Connection {
request(request, timeout) {
const ledger_index = request.ledger_index;
if (ledger_index !== undefined && ledger_index !== 'validated') {
if (!_.isNumber(ledger_index) || ledger_index > this._ledgerVersion) {
return Promise.reject(new errors.LedgerVersionError(
`ledgerVersion ${ledger_index} is greater than server\'s ` +
`most recent validated ledger: ${this._ledgerVersion}`));
}
}
return super.request(request, timeout);
}
}
class RippleAPI extends EventEmitter {
constructor(options: APIOptions = {}) {
common.validate.apiOptions(options);
super();
this._feeCushion = options.feeCushion || 1.2;
if (options.servers !== undefined) {
const servers: Array<string> = options.servers;
if (servers.length === 1) {
this.connection = new RestrictedConnection(servers[0], options);
this.connection.on('ledgerClosed', message => {
this.emit('ledgerClosed', server.formatLedgerClose(message));
});
this.connection.on('error', (type, info) => {
this.emit('error', type, info);
});
} else {
throw new errors.RippleError('Multi-server not implemented');
}
} else {
// use null object pattern to provide better error message if user
// tries to call a method that requires a connection
this.connection = new RestrictedConnection(null, options);
}
}
}
_.assign(RippleAPI.prototype, {
connect,
disconnect,
isConnected,
getServerInfo,
getFee,
getLedgerVersion,
getTransaction,
getTransactions,
getTrustlines,
getBalances,
getBalanceSheet,
getPaths,
getOrders,
getOrderbook,
getSettings,
getAccountInfo,
getLedger,
preparePayment,
prepareTrustline,
prepareOrder,
prepareOrderCancellation,
prepareSuspendedPaymentCreation,
prepareSuspendedPaymentExecution,
prepareSuspendedPaymentCancellation,
prepareSettings,
sign,
submit,
generateAddress,
computeLedgerHash,
errors
});
// these are exposed only for use by unit tests; they are not part of the API
RippleAPI._PRIVATE = {
validate: common.validate,
RangeSet: require('./common/rangeset').RangeSet,
ledgerUtils: require('./ledger/utils'),
schemaValidator: require('./common/schema-validator')
module.exports = {
RippleAPI: require('./api').RippleAPI,
// Broadcast api is experimental
RippleAPIBroadcast: require('./broadcast').RippleAPIBroadcast,
// HTTP server is experimental
createHTTPServer: require('./http').createHTTPServer
};
module.exports.RippleAPI = RippleAPI;

View File

@@ -24,8 +24,8 @@ function parseAccountTrustline(trustline: Trustline): AccountTrustline {
limit: trustline.limit,
currency: trustline.currency,
counterparty: trustline.account,
qualityIn: trustline.quality_in || undefined,
qualityOut: trustline.quality_out || undefined,
qualityIn: utils.parseQuality(trustline.quality_in) || undefined,
qualityOut: utils.parseQuality(trustline.quality_out) || undefined,
ripplingDisabled: trustline.no_ripple || undefined,
frozen: trustline.freeze || undefined,
authorized: trustline.authorized || undefined

View File

@@ -1,5 +1,6 @@
/* @flow */
'use strict';
const _ = require('lodash');
const BigNumber = require('bignumber.js');
const AccountFields = require('./utils').constants.AccountFields;
@@ -22,6 +23,26 @@ function parseFields(data: Object): Object {
settings[info.name] = parseField(info, fieldValue);
}
}
if (data.RegularKey) {
settings.regularKey = data.RegularKey;
}
// TODO: this isn't implemented in rippled yet, may have to change this later
if (data.SignerQuorum || data.SignerEntries) {
settings.signers = {};
if (data.SignerQuorum) {
settings.signers.threshold = data.SignerQuorum;
}
if (data.SignerEntries) {
settings.signers.weights = _.map(data.SignerEntries, entry => {
return {
address: entry.SignerEntry.Account,
weight: entry.SignerEntry.SignerWeight
};
});
}
}
return settings;
}

View File

@@ -52,10 +52,10 @@ function parseFlags(tx: Object) {
function parseSettings(tx: Object) {
const txType = tx.TransactionType;
assert(txType === 'AccountSet' || txType === 'SetRegularKey');
assert(txType === 'AccountSet' || txType === 'SetRegularKey' ||
txType === 'SignerListSet');
const regularKey = tx.RegularKey ? {regularKey: tx.RegularKey} : {};
return _.assign(regularKey, parseFlags(tx), parseFields(tx));
return _.assign({}, parseFlags(tx), parseFields(tx));
}
module.exports = parseSettings;

View File

@@ -22,7 +22,8 @@ function parseTransactionType(type) {
SetRegularKey: 'settings',
SuspendedPaymentCreate: 'suspendedPaymentCreation',
SuspendedPaymentFinish: 'suspendedPaymentExecution',
SuspendedPaymentCancel: 'suspendedPaymentCancellation'
SuspendedPaymentCancel: 'suspendedPaymentCancellation',
SignerListSet: 'settings'
};
return mapping[type] || null;
}

View File

@@ -3,7 +3,6 @@
const assert = require('assert');
const utils = require('./utils');
const flags = utils.txFlags.TrustSet;
const BigNumber = require('bignumber.js');
function parseFlag(flagsValue, trueValue, falseValue) {
if (flagsValue & trueValue) {
@@ -15,13 +14,6 @@ function parseFlag(flagsValue, trueValue, falseValue) {
return undefined;
}
function parseQuality(quality?: number) {
if (typeof quality === 'number') {
return (new BigNumber(quality)).shift(-9).toNumber();
}
return undefined;
}
function parseTrustline(tx: Object): Object {
assert(tx.TransactionType === 'TrustSet');
@@ -29,8 +21,8 @@ function parseTrustline(tx: Object): Object {
limit: tx.LimitAmount.value,
currency: tx.LimitAmount.currency,
counterparty: tx.LimitAmount.issuer,
qualityIn: parseQuality(tx.QualityIn),
qualityOut: parseQuality(tx.QualityOut),
qualityIn: utils.parseQuality(tx.QualityIn),
qualityOut: utils.parseQuality(tx.QualityOut),
ripplingDisabled: parseFlag(
tx.Flags, flags.SetNoRipple, flags.ClearNoRipple),
frozen: parseFlag(tx.Flags, flags.SetFreeze, flags.ClearFreeze),

View File

@@ -17,6 +17,13 @@ function adjustQualityForXRP(
(new BigNumber(quality)).shift(shift).toString();
}
function parseQuality(quality: ?number) {
if (typeof quality === 'number') {
return (new BigNumber(quality)).shift(-9).toNumber();
}
return undefined;
}
function parseTimestamp(rippleTime: number): string | void {
return rippleTime ? utils.common.rippleTimeToISO8601(rippleTime) : undefined;
}
@@ -80,6 +87,7 @@ function parseMemos(tx: Object): ?Array<Object> {
}
module.exports = {
parseQuality,
parseOutcome,
parseMemos,
hexToString,

View File

@@ -1,55 +1,55 @@
/* @flow */
'use strict';
import type {Amount, LaxLaxAmount, RippledAmount, Adjustment, MaxAdjustment,
MinAdjustment} from '../common/types.js';
type Path = {
source: Adjustment | MaxAdjustment,
destination: Adjustment | MinAdjustment,
paths: string
}
export type GetPaths = Array<Path>
export type PathFind = {
source: {
address: string,
amount?: Amount,
currencies?: Array<{currency: string, counterparty?:string}>
},
destination: {
address: string,
amount: LaxLaxAmount
}
}
export type PathFindRequest = {
command: string,
source_account: string,
destination_amount: RippledAmount,
destination_account: string,
source_amount?: RippledAmount,
source_currencies?: Array<string>
}
export type RippledPathsResponse = {
alternatives: Array<{
paths_computed: Array<Array<{
type: number,
type_hex: string,
account?: string,
issuer?: string,
currency?: string
}>>,
source_amount: RippledAmount
}>,
type: string,
destination_account: string,
destination_amount: RippledAmount,
destination_currencies?: Array<string>,
source_account?: string,
source_currencies?: Array<{currency: string}>,
full_reply?: boolean
}
/* @flow */
'use strict';
import type {Amount, LaxLaxAmount, RippledAmount, Adjustment, MaxAdjustment,
MinAdjustment} from '../common/types.js';
type Path = {
source: Adjustment | MaxAdjustment,
destination: Adjustment | MinAdjustment,
paths: string
}
export type GetPaths = Array<Path>
export type PathFind = {
source: {
address: string,
amount?: Amount,
currencies?: Array<{currency: string, counterparty?:string}>
},
destination: {
address: string,
amount: LaxLaxAmount
}
}
export type PathFindRequest = {
command: string,
source_account: string,
destination_amount: RippledAmount,
destination_account: string,
source_currencies?: Array<string>,
send_max?: RippledAmount
}
export type RippledPathsResponse = {
alternatives: Array<{
paths_computed: Array<Array<{
type: number,
type_hex: string,
account?: string,
issuer?: string,
currency?: string
}>>,
source_amount: RippledAmount
}>,
type: string,
destination_account: string,
destination_amount: RippledAmount,
destination_currencies?: Array<string>,
source_account?: string,
source_currencies?: Array<{currency: string}>,
full_reply?: boolean
}

View File

@@ -46,9 +46,9 @@ function requestPathFind(connection: Connection, pathfind: PathFind): Promise {
throw new ValidationError('Cannot specify both source.amount'
+ ' and destination.amount.value in getPaths');
}
request.source_amount = toRippledAmount(pathfind.source.amount);
if (request.source_amount.currency && !request.source_amount.issuer) {
request.source_amount.issuer = pathfind.source.address;
request.send_max = toRippledAmount(pathfind.source.amount);
if (request.send_max.currency && !request.send_max.issuer) {
request.send_max.issuer = pathfind.source.address;
}
}

View File

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

View File

@@ -47,9 +47,6 @@ function parseAccountTxTransaction(tx) {
}
function counterpartyFilter(filters, tx: TransactionType) {
if (!filters.counterparty) {
return true;
}
if (tx.address === filters.counterparty || (
tx.specification && (
(tx.specification.destination &&
@@ -173,11 +170,11 @@ function getTransactions(address: string, options: TransactionsOptions = {}
const ledgerVersion = tx.outcome.ledgerVersion;
const bound = options.earliestFirst ?
{minLedgerVersion: ledgerVersion} : {maxLedgerVersion: ledgerVersion};
const newOptions = _.assign(defaults, options, {startTx: tx}, bound);
const newOptions = _.assign({}, defaults, options, {startTx: tx}, bound);
return getTransactionsInternal(this.connection, address, newOptions);
});
}
const newOptions = _.assign(defaults, options);
const newOptions = _.assign({}, defaults, options);
return getTransactionsInternal(this.connection, address, newOptions);
}

View File

@@ -1,33 +1,33 @@
/* @flow */
'use strict';
export type TrustLineSpecification = {
currency: string,
counterparty: string,
limit: string,
qualityIn?: number,
qualityOut?: number,
ripplingDisabled?: boolean,
authorized?: boolean,
frozen?: boolean
}
export type Trustline = {
specification: TrustLineSpecification,
counterparty: {
limit: string,
ripplingDisabled?: boolean,
frozen?: boolean,
authorized?: boolean
},
state: {
balance: string
}
}
export type TrustlinesOptions = {
counterparty?: string,
currency?: string,
limit?: number,
ledgerVersion?: number
}
/* @flow */
'use strict';
export type TrustLineSpecification = {
currency: string,
counterparty: string,
limit: string,
qualityIn?: number,
qualityOut?: number,
ripplingDisabled?: boolean,
authorized?: boolean,
frozen?: boolean
}
export type Trustline = {
specification: TrustLineSpecification,
counterparty: {
limit: string,
ripplingDisabled?: boolean,
frozen?: boolean,
authorized?: boolean
},
state: {
balance: string
}
}
export type TrustlinesOptions = {
counterparty?: string,
currency?: string,
limit?: number,
ledgerVersion?: number
}

View File

@@ -1,50 +1,50 @@
/* @flow */
'use strict';
import type {Amount} from '../common/types.js';
export type OrdersOptions = {
limit?: number,
ledgerVersion?: number
}
export type OrderSpecification = {
direction: string,
quantity: Amount,
totalPrice: Amount,
immediateOrCancel?: boolean,
fillOrKill?: boolean,
// If enabled, the offer will not consume offers that exactly match it, and
// instead becomes an Offer node in the ledger. It will still consume offers
// that cross it.
passive?: boolean
}
export type Order = {
specification: OrderSpecification,
properties: {
maker: string,
sequence: number,
makerExchangeRate: string
}
}
export type GetLedger = {
accepted: boolean,
closed: boolean,
stateHash: string,
closeTime: number,
closeTimeResolution: number,
closeFlags: number,
ledgerHash: string,
ledgerVersion: number,
parentLedgerHash: string,
parentCloseTime: number,
totalDrops: string,
transactionHash: string,
transactions?: Array<Object>,
rawTransactions?: string,
transactionHashes?: Array<string>,
rawState?: string,
stateHashes?: Array<string>
}
/* @flow */
'use strict';
import type {Amount} from '../common/types.js';
export type OrdersOptions = {
limit?: number,
ledgerVersion?: number
}
export type OrderSpecification = {
direction: string,
quantity: Amount,
totalPrice: Amount,
immediateOrCancel?: boolean,
fillOrKill?: boolean,
// If enabled, the offer will not consume offers that exactly match it, and
// instead becomes an Offer node in the ledger. It will still consume offers
// that cross it.
passive?: boolean
}
export type Order = {
specification: OrderSpecification,
properties: {
maker: string,
sequence: number,
makerExchangeRate: string
}
}
export type GetLedger = {
accepted: boolean,
closed: boolean,
stateHash: string,
closeTime: number,
closeTimeResolution: number,
closeFlags: number,
ledgerHash: string,
ledgerVersion: number,
parentLedgerHash: string,
parentCloseTime: number,
totalDrops: string,
transactionHash: string,
transactions?: Array<Object>,
rawTransactions?: string,
transactionHashes?: Array<string>,
rawState?: string,
stateHashes?: Array<string>
}

View File

@@ -0,0 +1,24 @@
'use strict';
const keypairs = require('ripple-keypairs');
const common = require('../common');
const {errors, validate} = common;
function generateAddress(options?: Object): Object {
const secret = keypairs.generateSeed(options);
const keypair = keypairs.deriveKeypair(secret);
const address = keypairs.deriveAddress(keypair.publicKey);
return {secret, address};
}
function generateAddressAPI(options?: Object): Object {
validate.generateAddress({options});
try {
return generateAddress(options);
} catch (error) {
throw new errors.UnexpectedError(error.message);
}
}
module.exports = {
generateAddressAPI
};

View File

@@ -30,13 +30,12 @@ function getFee(): Promise<number> {
function formatLedgerClose(ledgerClose: Object): Object {
return {
feeBase: ledgerClose.fee_base,
feeReference: ledgerClose.fee_ref,
baseFeeXRP: common.dropsToXrp(ledgerClose.fee_base),
ledgerHash: ledgerClose.ledger_hash,
ledgerVersion: ledgerClose.ledger_index,
ledgerTimestamp: common.rippleTimeToISO8601(ledgerClose.ledger_time),
reserveBase: ledgerClose.reserve_base,
reserveIncrement: ledgerClose.reserve_inc,
reserveBaseXRP: common.dropsToXrp(ledgerClose.reserve_base),
reserveIncrementXRP: common.dropsToXrp(ledgerClose.reserve_inc),
transactionCount: ledgerClose.txn_count,
validatedLedgerVersions: ledgerClose.validated_ledgers
};

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