Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into add-ledger-command-3
Browse files Browse the repository at this point in the history
  • Loading branch information
intelliot committed Mar 2, 2018
2 parents 85834b6 + 0ad8c57 commit 7e3c62d
Show file tree
Hide file tree
Showing 75 changed files with 1,467 additions and 63 deletions.
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
language: node_js
node_js:
- 6
- 8
- 9
script:
- yarn compile
- yarn test
- yarn build
256 changes: 253 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
- [Escrow Creation](#escrow-creation)
- [Escrow Cancellation](#escrow-cancellation)
- [Escrow Execution](#escrow-execution)
- [Check Create](#check-create)
- [Check Cancel](#check-cancel)
- [Check Cash](#check-cash)
- [Payment Channel Create](#payment-channel-create)
- [Payment Channel Fund](#payment-channel-fund)
- [Payment Channel Claim](#payment-channel-claim)
Expand Down Expand Up @@ -60,6 +63,9 @@
- [preparePaymentChannelCreate](#preparepaymentchannelcreate)
- [preparePaymentChannelClaim](#preparepaymentchannelclaim)
- [preparePaymentChannelFund](#preparepaymentchannelfund)
- [prepareCheckCreate](#preparecheckcreate)
- [prepareCheckCancel](#preparecheckcancel)
- [prepareCheckCash](#preparecheckcash)
- [sign](#sign)
- [combine](#combine)
- [submit](#submit)
Expand Down Expand Up @@ -266,6 +272,9 @@ Type | Description
[escrowCreation](#escrow-creation) | An `escrowCreation` transaction creates an escrow on the ledger, which locks XRP until a cryptographic condition is met or it expires. It is like an escrow service where the XRP Ledger acts as the escrow agent.
[escrowCancellation](#escrow-cancellation) | An `escrowCancellation` transaction unlocks the funds in an escrow and sends them back to the creator of the escrow, but it will only work after the escrow expires.
[escrowExecution](#escrow-execution) | An `escrowExecution` transaction unlocks the funds in an escrow and sends them to the destination of the escrow, but it will only work if the cryptographic condition is provided.
[checkCreate](#check-create) | A `checkCreate` transaction creates a check on the ledger, which is a deferred payment that can be cashed by its intended destination.
[checkCancel](#check-cancel) | A `checkCancel` transaction cancels an unreedemed Check, removing it from the ledger without sending any money.
[checkCash](#checkCash) | A `checkCash` transaction redeems a Check to receive up to the amount authorized by the corresponding `checkCreate` transaction. Only the `destination` address of a Check can cash it.

## Transaction Flow

Expand All @@ -280,6 +289,9 @@ Executing a transaction with `RippleAPI` requires the following four steps:
* [prepareEscrowCreation](#prepareescrowcreation)
* [prepareEscrowCancellation](#prepareescrowcancellation)
* [prepareEscrowExecution](#prepareescrowexecution)
* [prepareCheckCreate](#preparecheckcreate)
* [prepareCheckCancel](#preparecheckcancel)
* [prepareCheckCash](#preparecheckcash)
2. [Sign](#sign) - Cryptographically sign the transaction locally and save the [transaction ID](#transaction-id). Signing is how the owner of an account authorizes a transaction to take place. For multisignature transactions, the `signedTransaction` fields returned by `sign` must be collected and passed to the [combine](#combine) method.
3. [Submit](#submit) - Submit the transaction to the connected server.
4. Verify - Verify that the transaction got validated by querying with [getTransaction](#gettransaction). This is necessary because transactions may fail even if they were successfully submitted.
Expand Down Expand Up @@ -346,11 +358,11 @@ destination | object | The destination of the funds to be sent.
*destination.* tag | integer | *Optional* An arbitrary unsigned 32-bit integer that identifies a reason for payment or a non-Ripple account.
*destination.* address | [address](#address) | The address to send to.
*destination.* minAmount | [laxAmount](#amount) | The minimum amount to be delivered. (This field is exclusive with destination.amount)
allowPartialPayment | boolean | *Optional* A boolean that, if set to true, indicates that this payment should go through even if the whole amount cannot be delivered because of a lack of liquidity or funds in the source account account
allowPartialPayment | boolean | *Optional* If true, this payment should proceed even if the whole amount cannot be delivered due to a lack of liquidity or a lack of funds in the source account.
invoiceID | string | *Optional* A 256-bit hash that can be used to identify a particular payment.
limitQuality | boolean | *Optional* Only take paths where all the conversions have an input:output ratio that is equal or better than the ratio of destination.amount:source.maxAmount.
memos | [memos](#transaction-memos) | *Optional* Array of memos to attach to the transaction.
noDirectRipple | boolean | *Optional* A boolean that can be set to true if paths are specified and the sender would like the Ripple Network to disregard any direct paths from the source account to the destination account. This may be used to take advantage of an arbitrage opportunity or by gateways wishing to issue balances from a hot wallet to a user who has mistakenly set a trustline directly to the hot wallet
noDirectRipple | boolean | *Optional* If true and paths are specified, the sender would like the XRP Ledger to disregard any direct paths from the source account to the destination account. This may be used to take advantage of an arbitrage opportunity or by gateways wishing to issue balances from a hot wallet to a user who has mistakenly set a trustline directly to the hot wallet.
paths | string | *Optional* The paths of trustlines and orders to use in executing the payment.

### Example
Expand Down Expand Up @@ -593,6 +605,74 @@ memos | [memos](#transaction-memos) | *Optional* Array of memos to attach to the
```


## Check Create

See [Transaction Types](#transaction-types) for a description.

Name | Type | Description
---- | ---- | -----------
destination | [address](#address) | Address of the account that can cash the check.
sendMax | [laxAmount](#amount) | Amount of source currency the check is allowed to debit the sender, including transfer fees on non-XRP currencies.
destinationTag | integer | *Optional* Destination tag that identifies the reason for the check, or a hosted recipient to pay.
expiration | date-time string | *Optional* Time after which the check is no longer valid.
invoiceID | string | *Optional* 256-bit hash, as a 64-character hexadecimal string, representing a specific reason or identifier for this check.

### Example


```json
{
"destination": "rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW",
"sendMax": {
"currency": "XRP",
"value": "1"
}
}
```


## Check Cancel

See [Transaction Types](#transaction-types) for a description.

Name | Type | Description
---- | ---- | -----------
checkID | string | The ID of the Check ledger object to cancel, as a 64-character hexadecimal string.

### Example


```json
{
"checkID": "49647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB0"
}
```


## Check Cash

See [Transaction Types](#transaction-types) for a description.

Name | Type | Description
---- | ---- | -----------
checkID | string | The ID of the Check ledger object to cash, as a 64-character hexadecimal string.
amount | [laxAmount](#amount) | *Optional* Redeem the Check for exactly this amount, if possible. The currency must match that of the sendMax of the corresponding CheckCreate transaction. You must provide either this field or deliverMin.
deliverMin | [laxAmount](#amount) | *Optional* Redeem the Check for at least this amount and for as much as possible. The currency must match that of the sendMax of the corresponding CheckCreate transaction. You must provide either this field or amount.

### Example


```json
{
"amount": {
"currency": "XRP",
"value": "1"
},
"checkID": "838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334"
}
```


## Payment Channel Create

See [Transaction Types](#transaction-types) for a description.
Expand Down Expand Up @@ -1022,7 +1102,7 @@ options | object | *Optional* Options to filter the resulting transactions.
*options.* limit | integer | *Optional* If specified, return at most this many transactions.
*options.* maxLedgerVersion | integer | *Optional* Return only transactions in this ledger version or lower.
*options.* minLedgerVersion | integer | *Optional* Return only transactions in this ledger verion or higher.
*options.* start | string | *Optional* If specified, this transaction will be the first transaction in the result.
*options.* start | string | *Optional* If specified, this transaction will be the first transaction in the result. You cannot use `start` with `minLedgerVersion` or `maxLedgerVersion`. When `start` is specified, these ledger versions will be determined internally.
*options.* types | array\<[transactionType](#transaction-types)\> | *Optional* Only return transactions of the specified [Transaction Types](#transaction-types).

### Return Value
Expand Down Expand Up @@ -3592,6 +3672,176 @@ return api.preparePaymentChannelFund(address, paymentChannelFund).then(prepared
```


## prepareCheckCreate

`prepareCheckCreate(address: string, checkCreate: Object, instructions: Object): Promise<Object>`

Prepare a Check creation transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).

### Parameters

Name | Type | Description
---- | ---- | -----------
address | [address](#address) | The address of the account that is creating the transaction.
checkCreate | [checkCreate](#check-create) | The specification of the Check create creation to prepare.
instructions | [instructions](#transaction-instructions) | *Optional* Instructions for executing the transaction

### Return Value

This method returns a promise that resolves with an object with the following structure:

<aside class="notice">
All "prepare*" methods have the same return type.
</aside>

Name | Type | Description
---- | ---- | -----------
txJSON | string | The prepared transaction in rippled JSON format.
instructions | object | The instructions for how to execute the transaction after adding automatic defaults.
*instructions.* fee | [value](#value) | An exact fee to pay for the transaction. See [Transaction Fees](#transaction-fees) for more information.
*instructions.* sequence | [sequence](#account-sequence-number) | The initiating account's sequence number for this transaction.
*instructions.* maxLedgerVersion | integer,null | The highest ledger version that the transaction can be included in. Set to `null` if there is no maximum.

### Example

```javascript
const address = 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59';
const checkCreate = {
"destination": "rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW",
"sendMax": {
"currency": "XRP",
"value": "1"
}
};
return api.prepareCheckCreate(address, checkCreate).then(prepared =>
{/* ... */});
```


```json
{
"txJSON": "{\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"TransactionType\":\"CheckCreate\",\"Destination\":\"rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW\",\"SendMax\":\"1000000\",\"Flags\":2147483648,\"LastLedgerSequence\":8820051,\"Sequence\":23,\"Fee\":\"12\"}",
"instructions": {
"fee": "0.000012",
"sequence": 23,
"maxLedgerVersion": 8820051
}
}
```


## prepareCheckCancel

`prepareCheckCancel(address: string, checkCancel: Object, instructions: Object): Promise<Object>`

Prepare a Check cancellation transaction. This cancels an unredeemed Check, removing it from the ledger without sending any money. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).

### Parameters

Name | Type | Description
---- | ---- | -----------
address | [address](#address) | The address of the account that is creating the transaction.
checkCancel | [checkCancel](#check-cancel) | The specification of the Check cancellation to prepare.
instructions | [instructions](#transaction-instructions) | *Optional* Instructions for executing the transaction

### Return Value

This method returns a promise that resolves with an object with the following structure:

<aside class="notice">
All "prepare*" methods have the same return type.
</aside>

Name | Type | Description
---- | ---- | -----------
txJSON | string | The prepared transaction in rippled JSON format.
instructions | object | The instructions for how to execute the transaction after adding automatic defaults.
*instructions.* fee | [value](#value) | An exact fee to pay for the transaction. See [Transaction Fees](#transaction-fees) for more information.
*instructions.* sequence | [sequence](#account-sequence-number) | The initiating account's sequence number for this transaction.
*instructions.* maxLedgerVersion | integer,null | The highest ledger version that the transaction can be included in. Set to `null` if there is no maximum.

### Example

```javascript
const address = 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59';
const checkCancel = {
"checkID": "49647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB0"
};
return api.prepareCheckCancel(address, checkCancel).then(prepared =>
{/* ... */});
```


```json
{
"txJSON": "{\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"TransactionType\":\"CheckCancel\",\"CheckID\":\"49647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB0\",\"Flags\":2147483648,\"LastLedgerSequence\":8819954,\"Fee\":\"12\",\"Sequence\":23}",
"instructions": {
"fee": "0.000012",
"sequence": 23,
"maxLedgerVersion": 8819954
}
}
```


## prepareCheckCash

`prepareCheckCash(address: string, checkCash: Object, instructions: Object): Promise<Object>`

Prepare a Check cashing transaction. This redeems a Check to receive up to the amount authorized by the corresponding CheckCreate transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).

### Parameters

Name | Type | Description
---- | ---- | -----------
address | [address](#address) | The address of the account that is creating the transaction.
checkCash | [checkCash](#check-cash) | The specification of the Check cash to prepare.
instructions | [instructions](#transaction-instructions) | *Optional* Instructions for executing the transaction

### Return Value

This method returns a promise that resolves with an object with the following structure:

<aside class="notice">
All "prepare*" methods have the same return type.
</aside>

Name | Type | Description
---- | ---- | -----------
txJSON | string | The prepared transaction in rippled JSON format.
instructions | object | The instructions for how to execute the transaction after adding automatic defaults.
*instructions.* fee | [value](#value) | An exact fee to pay for the transaction. See [Transaction Fees](#transaction-fees) for more information.
*instructions.* sequence | [sequence](#account-sequence-number) | The initiating account's sequence number for this transaction.
*instructions.* maxLedgerVersion | integer,null | The highest ledger version that the transaction can be included in. Set to `null` if there is no maximum.

### Example

```javascript
const address = 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59';
const checkCash = {
"amount": {
"currency": "XRP",
"value": "1"
},
"checkID": "838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334"
};
return api.prepareCheckCash(address, checkCash).then(prepared =>
{/* ... */});
```


```json
{
"txJSON": "{\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"TransactionType\":\"CheckCash\",\"CheckID\":\"838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334\",\"Amount\":\"1000000\",\"Flags\":2147483648,\"LastLedgerSequence\":8819954,\"Sequence\":23,\"Fee\":\"12\"}",
"instructions": {
"fee": "0.000012",
"sequence": 23,
"maxLedgerVersion": 8819954
}
}
```


## sign

`sign(txJSON: string, secret: string, options: Object): {signedTransaction: string, id: string}`
Expand Down
3 changes: 3 additions & 0 deletions docs/src/index.md.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
<% include preparePaymentChannelCreate.md.ejs %>
<% include preparePaymentChannelClaim.md.ejs %>
<% include preparePaymentChannelFund.md.ejs %>
<% include prepareCheckCreate.md.ejs %>
<% include prepareCheckCancel.md.ejs %>
<% include prepareCheckCash.md.ejs %>
<% include sign.md.ejs %>
<% include combine.md.ejs %>
<% include submit.md.ejs %>
Expand Down
30 changes: 30 additions & 0 deletions docs/src/prepareCheckCancel.md.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
## prepareCheckCancel

`prepareCheckCancel(address: string, checkCancel: Object, instructions: Object): Promise<Object>`

Prepare a Check cancellation transaction. This cancels an unredeemed Check, removing it from the ledger without sending any money. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).

### Parameters

<%- renderSchema('input/prepare-check-cancel.json') %>

### Return Value

This method returns a promise that resolves with an object with the following structure:

<aside class="notice">
All "prepare*" methods have the same return type.
</aside>

<%- renderSchema('output/prepare.json') %>

### Example

```javascript
const address = 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59';
const checkCancel = <%- importFile('test/fixtures/requests/prepare-check-cancel.json') %>;
return api.prepareCheckCancel(address, checkCancel).then(prepared =>
{/* ... */});
```

<%- renderFixture('responses/prepare-check-cancel.json') %>
30 changes: 30 additions & 0 deletions docs/src/prepareCheckCash.md.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
## prepareCheckCash

`prepareCheckCash(address: string, checkCash: Object, instructions: Object): Promise<Object>`

Prepare a Check cashing transaction. This redeems a Check to receive up to the amount authorized by the corresponding CheckCreate transaction. The prepared transaction must subsequently be [signed](#sign) and [submitted](#submit).

### Parameters

<%- renderSchema('input/prepare-check-cash.json') %>

### Return Value

This method returns a promise that resolves with an object with the following structure:

<aside class="notice">
All "prepare*" methods have the same return type.
</aside>

<%- renderSchema('output/prepare.json') %>

### Example

```javascript
const address = 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59';
const checkCash = <%- importFile('test/fixtures/requests/prepare-check-cash-amount.json') %>;
return api.prepareCheckCash(address, checkCash).then(prepared =>
{/* ... */});
```

<%- renderFixture('responses/prepare-check-cash-amount.json') %>
Loading

0 comments on commit 7e3c62d

Please sign in to comment.