Skip to content

Commit 82613e7

Browse files
author
Chris Clark
committedNov 30, 2015
Allow setting maxLedgerVersion to null to specify no maximum
1 parent cfc21fd commit 82613e7

File tree

7 files changed

+44
-19
lines changed

7 files changed

+44
-19
lines changed
 

‎docs/index.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,8 @@ Name | Type | Description
277277
---- | ---- | -----------
278278
fee | [value](#value) | *Optional* An exact fee to pay for the transaction. See [Transaction Fees](#transaction-fees) for more information.
279279
maxFee | [value](#value) | *Optional* The maximum fee to pay for the transaction. See [Transaction Fees](#transaction-fees) for more information.
280-
maxLedgerVersion | integer | *Optional* The highest ledger version that the transaction can be included in.
281-
maxLedgerVersionOffset | integer | *Optional* Offset from current legder version to highest ledger version that the transaction can be included in.
280+
maxLedgerVersion | integer,null | *Optional* The highest ledger version that the transaction can be included in. If this option and `maxLedgerVersionOffset` are both omitted, the `maxLedgerVersion` option will default to 3 greater than the current validated ledger version (equivalent to `maxLedgerVersionOffset=3`). Use `null` to not set a maximum ledger version.
281+
maxLedgerVersionOffset | integer | *Optional* Offset from current validated legder version to highest ledger version that the transaction can be included in.
282282
sequence | [sequence](#account-sequence-number) | *Optional* The initiating account's sequence number for this transaction.
283283

284284
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.
@@ -2793,7 +2793,7 @@ txJSON | string | The prepared transaction in rippled JSON format.
27932793
instructions | object | The instructions for how to execute the transaction after adding automatic defaults.
27942794
*instructions.* fee | [value](#value) | An exact fee to pay for the transaction. See [Transaction Fees](#transaction-fees) for more information.
27952795
*instructions.* sequence | [sequence](#account-sequence-number) | The initiating account's sequence number for this transaction.
2796-
*instructions.* maxLedgerVersion | integer | *Optional* The highest ledger version that the transaction can be included in.
2796+
*instructions.* maxLedgerVersion | integer,null | The highest ledger version that the transaction can be included in. Set to `null` if there is no maximum.
27972797

27982798
### Example
27992799

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

28672867
### Example
28682868

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

29342934
### Example
29352935

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

29992999
### Example
30003000

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

30513051
### Example
30523052

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

31163116
### Example
31173117

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

31883188
### Example
31893189

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

32453245
### Example
32463246

‎src/common/schemas/objects/instructions.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,14 @@
1818
"$ref": "value"
1919
},
2020
"maxLedgerVersion": {
21-
"description": "The highest ledger version that the transaction can be included in.",
22-
"$ref": "ledgerVersion"
21+
"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.",
22+
"oneOf": [
23+
{"$ref": "ledgerVersion"},
24+
{"type": "null"}
25+
]
2326
},
2427
"maxLedgerVersionOffset": {
25-
"description": "Offset from current legder version to highest ledger version that the transaction can be included in.",
28+
"description": "Offset from current validated legder version to highest ledger version that the transaction can be included in.",
2629
"type": "integer",
2730
"minimum": 0
2831
}

‎src/common/schemas/output/prepare.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,15 @@
2121
"description": "The initiating account's sequence number for this transaction."
2222
},
2323
"maxLedgerVersion": {
24-
"$ref": "ledgerVersion",
25-
"description": "The highest ledger version that the transaction can be included in."
24+
"oneOf": [
25+
{"$ref": "ledgerVersion"},
26+
{"type": "null"}
27+
],
28+
"description": "The highest ledger version that the transaction can be included in. Set to `null` if there is no maximum."
2629
}
2730
},
2831
"additionalProperties": false,
29-
"required": ["fee", "sequence"]
32+
"required": ["fee", "sequence", "maxLedgerVersion"]
3033
}
3134
},
3235
"additionalProperties": false,

‎src/transaction/utils.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ function formatPrepareResponse(txJSON: Object): Object {
1010
const instructions = {
1111
fee: common.dropsToXrp(txJSON.Fee),
1212
sequence: txJSON.Sequence,
13-
maxLedgerVersion: txJSON.LastLedgerSequence
13+
maxLedgerVersion: txJSON.LastLedgerSequence === undefined ?
14+
null : txJSON.LastLedgerSequence
1415
};
1516
return {
1617
txJSON: JSON.stringify(txJSON),
@@ -36,7 +37,9 @@ function prepareTransaction(txJSON: Object, api: Object,
3637

3738
function prepareMaxLedgerVersion(): Promise<Object> {
3839
if (instructions.maxLedgerVersion !== undefined) {
39-
txJSON.LastLedgerSequence = instructions.maxLedgerVersion;
40+
if (instructions.maxLedgerVersion !== null) {
41+
txJSON.LastLedgerSequence = instructions.maxLedgerVersion;
42+
}
4043
return Promise.resolve(txJSON);
4144
}
4245
const offset = instructions.maxLedgerVersionOffset !== undefined ?

‎test/api-test.js

+7
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,13 @@ describe('RippleAPI', function() {
186186
_.partial(checkResult, responses.prepareSettings.flags, 'prepare'));
187187
});
188188

189+
it('prepareSettings - no maxLedgerVersion', function() {
190+
return this.api.prepareSettings(
191+
address, requests.prepareSettings, {maxLedgerVersion: null}).then(
192+
_.partial(checkResult, responses.prepareSettings.noMaxLedgerVersion,
193+
'prepare'));
194+
});
195+
189196
it('prepareSettings - no instructions', function() {
190197
return this.api.prepareSettings(
191198
address, requests.prepareSettings).then(

‎test/fixtures/responses/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ module.exports = {
8686
setTransferRate: require('./prepare-settings-set-transfer-rate.json'),
8787
fieldClear: require('./prepare-settings-field-clear.json'),
8888
noInstructions: require('./prepare-settings-no-instructions.json'),
89-
signed: require('./prepare-settings-signed.json')
89+
signed: require('./prepare-settings-signed.json'),
90+
noMaxLedgerVersion: require('./prepare-settings-no-maxledgerversion.json')
9091
},
9192
prepareSuspendedPaymentCreation: {
9293
normal: require('./prepare-suspended-payment-creation'),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"txJSON": "{\"TransactionType\":\"AccountSet\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Memos\":[{\"Memo\":{\"MemoData\":\"7465787465642064617461\",\"MemoType\":\"74657374\",\"MemoFormat\":\"706C61696E2F74657874\"}}],\"Domain\":\"726970706C652E636F6D\",\"Flags\":2147483648,\"Fee\":\"12\",\"Sequence\":23}",
3+
"instructions": {
4+
"fee": "0.000012",
5+
"sequence": 23,
6+
"maxLedgerVersion": null
7+
}
8+
}

0 commit comments

Comments
 (0)
Please sign in to comment.