Add support for order expiration

This commit is contained in:
Chris Clark
2015-10-29 16:22:07 -07:00
parent 36806e4724
commit 665f5f9664
22 changed files with 253 additions and 42 deletions

View File

@@ -1,8 +1,11 @@
'use strict';
module.exports = {
prepareOrder: require('./prepare-order'),
prepareOrderSell: require('./prepare-order-sell'),
prepareOrder: {
buy: require('./prepare-order'),
sell: require('./prepare-order-sell'),
expiration: require('./prepare-order-expiration')
},
preparePayment: require('./prepare-payment'),
preparePaymentAllOptions: require('./prepare-payment-all-options'),
preparePaymentNoCounterparty: require('./prepare-payment-no-counterparty'),

View File

@@ -0,0 +1,14 @@
{
"direction": "buy",
"quantity": {
"currency": "USD",
"counterparty": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM",
"value": "10.1"
},
"totalPrice": {
"currency": "XRP",
"value": "2"
},
"immediateOrCancel": true,
"expirationTime": "2015-01-14T18:36:52.000Z"
}

View File

@@ -52,7 +52,8 @@
"currency": "BTC",
"value": "0.3",
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
}
},
"expirationTime": "2014-12-25T01:14:43.000Z"
},
"properties": {
"maker": "raudnGKfTK23YKfnS7ixejHrqGERTYNFXk",
@@ -104,7 +105,8 @@
"currency": "BTC",
"value": "0.4499999999999999",
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
}
},
"expirationTime": "2014-12-25T01:14:44.000Z"
},
"properties": {
"maker": "raudnGKfTK23YKfnS7ixejHrqGERTYNFXk",
@@ -144,7 +146,8 @@
"currency": "BTC",
"value": "0.5",
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
}
},
"expirationTime": "2014-12-25T00:41:38.000Z"
},
"properties": {
"maker": "rDVBvAQScXrGRGnzrxRrcJPeNLeLeUTAqE",
@@ -196,7 +199,8 @@
"currency": "BTC",
"value": "0.8",
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
}
},
"expirationTime": "2014-12-25T00:41:39.000Z"
},
"properties": {
"maker": "rDVBvAQScXrGRGnzrxRrcJPeNLeLeUTAqE",
@@ -290,7 +294,8 @@
"currency": "BTC",
"value": "0.4499999999999999",
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
}
},
"expirationTime": "2014-12-25T01:14:44.000Z"
},
"properties": {
"maker": "raudnGKfTK23YKfnS7ixejHrqGERTYNFXk",
@@ -322,7 +327,8 @@
"currency": "BTC",
"value": "0.8",
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
}
},
"expirationTime": "2014-12-24T21:44:11.000Z"
},
"properties": {
"maker": "rDVBvAQScXrGRGnzrxRrcJPeNLeLeUTAqE",
@@ -434,7 +440,8 @@
"currency": "BTC",
"value": "1.6",
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
}
},
"expirationTime": "2014-12-24T21:44:12.000Z"
},
"properties": {
"maker": "rDVBvAQScXrGRGnzrxRrcJPeNLeLeUTAqE",

View File

@@ -25,15 +25,15 @@
"quantity": {
"currency": "USD",
"counterparty": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
"value": "0"
"value": "237"
},
"totalPrice": {
"currency": "XRP",
"value": "0"
"value": "0.0002"
},
"makerExchangeRate": "1185000",
"sequence": 465,
"status": "canceled"
"status": "cancelled"
}
]
},

View File

@@ -0,0 +1,44 @@
{
"type": "orderCancellation",
"address": "rBSZe33F5oxHTbxSF1nZJooVDpcrrqNFp3",
"sequence": 1122979,
"id": "097B9491CC76B64831F1FEA82EAA93BCD728106D90B65A072C933888E946C40B",
"specification": {
"orderSequence": 1122978
},
"outcome": {
"result": "tesSUCCESS",
"timestamp": "2015-01-14T18:27:00.000Z",
"fee": "0.011",
"balanceChanges": {
"rBSZe33F5oxHTbxSF1nZJooVDpcrrqNFp3": [
{
"currency": "XRP",
"value": "-0.011"
}
]
},
"orderbookChanges": {
"rBSZe33F5oxHTbxSF1nZJooVDpcrrqNFp3": [
{
"direction": "buy",
"quantity": {
"currency": "CNY",
"counterparty": "rnuF96W4SZoCJmbHYBFoJZpR8eCaxNvekK",
"value": "3200"
},
"totalPrice": {
"currency": "XRP",
"value": "34700.537395"
},
"sequence": 1122978,
"status": "cancelled",
"makerExchangeRate": "0.09221759200942773",
"expirationTime": "2015-01-14T18:36:52.000Z"
}
]
},
"ledgerVersion": 11119599,
"indexInLedger": 15
}
}

View File

@@ -68,16 +68,16 @@
"direction": "buy",
"quantity": {
"currency": "XRP",
"value": "-1.101198"
"value": "1.101198"
},
"totalPrice": {
"currency": "USD",
"counterparty": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
"value": "-0.001002"
"value": "0.001002"
},
"makerExchangeRate": "1099",
"sequence": 58,
"status": "open"
"status": "partially-filled"
}
]
},

View File

@@ -74,16 +74,16 @@
"direction": "buy",
"quantity": {
"currency": "XRP",
"value": "-1.101198"
"value": "1.101198"
},
"totalPrice": {
"currency": "USD",
"counterparty": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
"value": "-0.001002"
"value": "0.001002"
},
"makerExchangeRate": "1099",
"sequence": 58,
"status": "open"
"status": "partially-filled"
}
]
},
@@ -166,16 +166,16 @@
"direction": "buy",
"quantity": {
"currency": "XRP",
"value": "-1.101198"
"value": "1.101198"
},
"totalPrice": {
"currency": "USD",
"counterparty": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
"value": "-0.001002"
"value": "0.001002"
},
"makerExchangeRate": "1099",
"sequence": 58,
"status": "open"
"status": "partially-filled"
}
]
},

View File

@@ -17,6 +17,8 @@ module.exports = {
getSettings: require('./get-settings.json'),
getTransaction: {
orderCancellation: require('./get-transaction-order-cancellation.json'),
orderWithExpirationCancellation:
require('./get-transaction-order-with-expiration-cancellation.json'),
order: require('./get-transaction-order.json'),
payment: require('./get-transaction-payment.json'),
settings: require('./get-transaction-settings.json'),
@@ -36,8 +38,11 @@ module.exports = {
withSettingsTx: require('./get-ledger-with-settings-tx')
},
prepareOrderCancellation: require('./prepare-order-cancellation.json'),
prepareOrder: require('./prepare-order.json'),
prepareOrderSell: require('./prepare-order-sell.json'),
prepareOrder: {
buy: require('./prepare-order.json'),
sell: require('./prepare-order-sell.json'),
expiration: require('./prepare-order-expiration')
},
preparePayment: {
normal: require('./prepare-payment.json'),
allOptions: require('./prepare-payment-all-options.json'),

View File

@@ -0,0 +1,8 @@
{
"txJSON": "{\"Flags\":2147614720,\"TransactionType\":\"OfferCreate\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"TakerGets\":\"2000000\",\"TakerPays\":{\"value\":\"10.1\",\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\"},\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23,\"Expiration\":474575812}",
"instructions": {
"fee": "0.000012",
"sequence": 23,
"maxLedgerVersion": 8820051
}
}

View File

@@ -43,6 +43,7 @@ module.exports = {
NoLedgerIndex: require('./tx/no-ledger-index.json'),
NoLedgerFound: require('./tx/no-ledger-found.json'),
LedgerWithoutTime: require('./tx/ledger-without-time.json'),
NotValidated: require('./tx/not-validated.json')
NotValidated: require('./tx/not-validated.json'),
OfferWithExpiration: require('./tx/order-with-expiration.json')
}
};

View File

@@ -0,0 +1,98 @@
{
"id": 0,
"status": "success",
"type": "response",
"result": {
"Account": "rBSZe33F5oxHTbxSF1nZJooVDpcrrqNFp3",
"Fee": "11000",
"Flags": 2147483648,
"LastLedgerSequence": 11119601,
"OfferSequence": 1122978,
"Sequence": 1122979,
"SigningPubKey": "03FD8927D4450E5B6C060BF7E46D1DDA2B24C547A45D43926741095D8FCA6A71DB",
"TransactionType": "OfferCancel",
"TxnSignature": "304402207758C80B90667A407299B2D8A16F8D6DF51E7103B562529AB8242B14B737D9B10220431095B7881C4363C3A2AB966C95190DF2E438FBB394F65014B6436E56F4F6E6",
"date": 474575220,
"hash": "097B9491CC76B64831F1FEA82EAA93BCD728106D90B65A072C933888E946C40B",
"inLedger": 11119599,
"ledger_index": 11119599,
"meta": {
"AffectedNodes": [
{
"DeletedNode": {
"FinalFields": {
"Account": "rBSZe33F5oxHTbxSF1nZJooVDpcrrqNFp3",
"BookDirectory": "94A08655B7E5C048769B82A900C085FD1D8A28B2A9E7939C4D20C32421605AB5",
"BookNode": "0000000000000000",
"Expiration": 474575812,
"Flags": 0,
"OwnerNode": "0000000000000003",
"PreviousTxnID": "40FA69EF2F42729DEE5F3BE0D43FAAB63C35FF5A28C3221A385EAFE84733C208",
"PreviousTxnLgrSeq": 11119599,
"Sequence": 1122978,
"TakerGets": "34700537395",
"TakerPays": {
"currency": "CNY",
"issuer": "rnuF96W4SZoCJmbHYBFoJZpR8eCaxNvekK",
"value": "3200"
}
},
"LedgerEntryType": "Offer",
"LedgerIndex": "40A3657C011B5E1EACBEECB40B1BEAA1220645EA89EA8AEC2D562192B8E60095"
}
},
{
"ModifiedNode": {
"FinalFields": {
"Flags": 0,
"IndexPrevious": "0000000000000001",
"Owner": "rBSZe33F5oxHTbxSF1nZJooVDpcrrqNFp3",
"RootIndex": "3D3DA923D48E02DB1C0B667FA9E2777C348CBE229C7E4E83CBBDE5851D80FF32"
},
"LedgerEntryType": "DirectoryNode",
"LedgerIndex": "8EB5EC4A94AB9D4142DB695F9503CEB4E471E803A76FD563C9B0A598281D085A"
}
},
{
"ModifiedNode": {
"FinalFields": {
"ExchangeRate": "4D20C32421605AB5",
"Flags": 0,
"RootIndex": "94A08655B7E5C048769B82A900C085FD1D8A28B2A9E7939C4D20C32421605AB5",
"TakerGetsCurrency": "0000000000000000000000000000000000000000",
"TakerGetsIssuer": "0000000000000000000000000000000000000000",
"TakerPaysCurrency": "000000000000000000000000434E590000000000",
"TakerPaysIssuer": "35DD7DF146893456296BF4061FBE68735D28F328"
},
"LedgerEntryType": "DirectoryNode",
"LedgerIndex": "94A08655B7E5C048769B82A900C085FD1D8A28B2A9E7939C4D20C32421605AB5"
}
},
{
"ModifiedNode": {
"FinalFields": {
"Account": "rBSZe33F5oxHTbxSF1nZJooVDpcrrqNFp3",
"Balance": "266777347375",
"Flags": 0,
"OwnerCount": 18,
"RegularKey": "rDpVpTMogkwzoq2mkNRBmMCxbmUAwPvoFt",
"Sequence": 1122980
},
"LedgerEntryType": "AccountRoot",
"LedgerIndex": "9DE2C31C24122AEDCD6CBE74567B2AF1CE9A5B31795E60F7A6BBD48BA1304E37",
"PreviousFields": {
"Balance": "266777358375",
"OwnerCount": 19,
"Sequence": 1122979
},
"PreviousTxnID": "40FA69EF2F42729DEE5F3BE0D43FAAB63C35FF5A28C3221A385EAFE84733C208",
"PreviousTxnLgrSeq": 11119599
}
}
],
"TransactionIndex": 15,
"TransactionResult": "tesSUCCESS"
},
"validated": true
}
}