Skip to content

Commit

Permalink
Disallow escrow of IOU
Browse files Browse the repository at this point in the history
  • Loading branch information
wilsonianb committed Mar 30, 2017
1 parent 917aae9 commit 9393adf
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 86 deletions.
14 changes: 5 additions & 9 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -546,16 +546,14 @@ memos | [memos](#transaction-memos) | *Optional* Array of memos to attach to the
"address": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
"maxAmount": {
"value": "0.01",
"currency": "USD",
"counterparty": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM"
"currency": "XRP"
}
},
"destination": {
"address": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
"amount": {
"value": "0.01",
"currency": "USD",
"counterparty": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM"
"currency": "XRP"
}
},
"allowCancelAfter": "2014-09-24T21:21:50.000Z"
Expand Down Expand Up @@ -3171,16 +3169,14 @@ const escrowCreation = {
"address": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
"maxAmount": {
"value": "0.01",
"currency": "USD",
"counterparty": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM"
"currency": "XRP"
}
},
"destination": {
"address": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
"amount": {
"value": "0.01",
"currency": "USD",
"counterparty": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM"
"currency": "XRP"
}
},
"allowCancelAfter": "2014-09-24T21:21:50.000Z"
Expand All @@ -3192,7 +3188,7 @@ return api.prepareEscrowCreation(address, escrowCreation).then(prepared =>

```json
{
"txJSON": "{\"Flags\":2147483648,\"TransactionType\":\"EscrowCreate\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Destination\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"Amount\":{\"value\":\"0.01\",\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\"},\"CancelAfter\":464908910,\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
"txJSON": "{\"Flags\":2147483648,\"TransactionType\":\"EscrowCreate\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Destination\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"Amount\":\"10000\",\"CancelAfter\":464908910,\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
"instructions": {
"fee": "0.000012",
"sequence": 23,
Expand Down
3 changes: 3 additions & 0 deletions src/transaction/escrow-creation.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ function createEscrowCreationTransaction(account: string,
Amount: toRippledAmount(payment.destination.amount)
}

if (txJSON.Amount.currency !== undefined) {
throw new ValidationError('"Amount" currency must be XRP')
}
if (payment.condition !== undefined) {
txJSON.Condition = payment.condition
}
Expand Down
9 changes: 0 additions & 9 deletions test/api-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -649,15 +649,6 @@ describe('RippleAPI', function() {
'getTransaction'));
});

it('getTransaction - EscrowCreation iou', function() {
const hash =
'144F272380BDB4F1BD92329A2178BABB70C20F59042C495E10BF72EBFB408EE2';
return this.api.getTransaction(hash).then(
_.partial(checkResult,
responses.getTransaction.EscrowCreationIOU,
'getTransaction'));
});

it('getTransaction - EscrowCancellation', function() {
const hash =
'F346E542FFB7A8398C30A87B952668DAB48B7D421094F8B71776DA19775A3B22';
Expand Down
6 changes: 2 additions & 4 deletions test/fixtures/requests/prepare-escrow-creation-full.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@
"address": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
"maxAmount": {
"value": "0.01",
"currency": "USD",
"counterparty": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM"
"currency": "XRP"
},
"tag": 1
},
"destination": {
"address": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
"amount": {
"value": "0.01",
"currency": "USD",
"counterparty": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM"
"currency": "XRP"
},
"tag": 2
},
Expand Down
6 changes: 2 additions & 4 deletions test/fixtures/requests/prepare-escrow-creation.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@
"address": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
"maxAmount": {
"value": "0.01",
"currency": "USD",
"counterparty": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM"
"currency": "XRP"
}
},
"destination": {
"address": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
"amount": {
"value": "0.01",
"currency": "USD",
"counterparty": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM"
"currency": "XRP"
}
},
"allowCancelAfter": "2014-09-24T21:21:50.000Z"
Expand Down
51 changes: 0 additions & 51 deletions test/fixtures/responses/get-transaction-escrow-create-iou.json

This file was deleted.

2 changes: 0 additions & 2 deletions test/fixtures/responses/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ module.exports = {
notValidated: require('./get-transaction-not-validated.json'),
escrowCreation:
require('./get-transaction-escrow-create.json'),
EscrowCreationIOU:
require('./get-transaction-escrow-create-iou.json'),
escrowCancellation:
require('./get-transaction-escrow-cancellation.json'),
escrowExecution:
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/responses/prepare-escrow-creation-full.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"txJSON": "{\"TransactionType\":\"EscrowCreate\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Destination\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"Amount\":{\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\",\"value\":\"0.01\"},\"Condition\":\"8F434346648F6B96DF89DDA901C5176B10A6D83961DD3C1AC88B59B2DC327AA4\",\"FinishAfter\":464908910,\"SourceTag\":1,\"DestinationTag\":2,\"Memos\":[{\"Memo\":{\"MemoData\":\"7465787465642064617461\",\"MemoType\":\"74657374\"}}],\"Flags\":2147483648,\"LastLedgerSequence\":8819954,\"Fee\":\"12\",\"Sequence\":23}",
"txJSON": "{\"TransactionType\":\"EscrowCreate\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Destination\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"Amount\":\"10000\",\"Condition\":\"8F434346648F6B96DF89DDA901C5176B10A6D83961DD3C1AC88B59B2DC327AA4\",\"FinishAfter\":464908910,\"SourceTag\":1,\"DestinationTag\":2,\"Memos\":[{\"Memo\":{\"MemoData\":\"7465787465642064617461\",\"MemoType\":\"74657374\"}}],\"Flags\":2147483648,\"LastLedgerSequence\":8819954,\"Fee\":\"12\",\"Sequence\":23}",
"instructions": {
"fee": "0.000012",
"sequence": 23,
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/responses/prepare-escrow-creation.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"txJSON": "{\"Flags\":2147483648,\"TransactionType\":\"EscrowCreate\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Destination\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"Amount\":{\"value\":\"0.01\",\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\"},\"CancelAfter\":464908910,\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
"txJSON": "{\"Flags\":2147483648,\"TransactionType\":\"EscrowCreate\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Destination\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"Amount\":\"10000\",\"CancelAfter\":464908910,\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
"instructions": {
"fee": "0.000012",
"sequence": 23,
Expand Down
2 changes: 0 additions & 2 deletions test/fixtures/rippled/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ module.exports = {
NotValidated: require('./tx/not-validated.json'),
OfferWithExpiration: require('./tx/order-with-expiration.json'),
EscrowCreation: require('./tx/escrow-creation.json'),
EscrowCreationIOU:
require('./tx/escrow-creation-iou.json'),
EscrowCancellation:
require('./tx/escrow-cancellation.json'),
EscrowExecution: require('./tx/escrow-execution.json'),
Expand Down
3 changes: 0 additions & 3 deletions test/mock-rippled.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,6 @@ module.exports = function createMockRippled(port) {
} else if (request.transaction ===
'144F272380BDB4F1BD92329A2178BABB70C20F59042C495E10BF72EBFB408EE1') {
conn.send(createResponse(request, fixtures.tx.EscrowCreation));
} else if (request.transaction ===
'144F272380BDB4F1BD92329A2178BABB70C20F59042C495E10BF72EBFB408EE2') {
conn.send(createResponse(request, fixtures.tx.EscrowCreationIOU));
} else if (request.transaction ===
'F346E542FFB7A8398C30A87B952668DAB48B7D421094F8B71776DA19775A3B22') {
conn.send(createResponse(request, fixtures.tx.EscrowCancellation));
Expand Down

0 comments on commit 9393adf

Please sign in to comment.