XRPLF / xrpl.js

A JavaScript/TypeScript API for interacting with the XRP Ledger in Node.js and the browser
https://xrpl.org/
1.2k stars 511 forks source link

ValidationError when running script for RippleAPI's escrowCreation transaction #933

Closed surferwat closed 6 years ago

surferwat commented 6 years ago

I am writing a script for an escrowCreation transaction using the RippleAPI and XRP Test Net Faucet.

When I go to run the script, I get the following error.

[ValidationError("CancelAfter" must be after "FinishAfter" for EscrowCreate)]
(node:4754) [DEP0079] DeprecationWarning: Custom inspection function on Objects via .inspect() is deprecated

I am puzzled by this error message given that I am using the RippleAPI, not the rippled API. The RippleAPI escrowCreation transaction type takes the fields: amount, destination, allowCancelAfter, allowExecuteAfter, condition, destination tag, memos, sourceTag. The escrowCreation object is pasted below.

const escrowCreation = {
  "destination": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
  "amount": "100",
  "allowExecuteAfter": "2018-08-20T16:30:00.000Z",
  "allowCancelAfter":  "2018-08-20T16:30:00.000Z",
};

I've written scripts for the get account info and send payment transactions using the RippleAPI boilerplate without issue. However, I've hit a roadblock in writing the script for the escrowCreation transaction because of this validation error which I cannot fix. If you've experienced this error or know how to fix it, I would really appreciate your guidance.

intelliot commented 6 years ago

Good point about the mix-up between RippleAPI and the rippled API. I'll look at improving the error message.

It doesn't make sense to have both of these times be the same. If you want to specify only one time, then it should be allowExecuteAfter. After this time, the escrow can be released to the recipient.

allowCancelAfter typically makes sense when used with a condition. If the condition is not met, then the escrow eventually expires (at the allowCancelAfter time) so that it can be canceled (returning the funds to the sender).

Does that help?

surferwat commented 6 years ago

Yes, it does. Thank you for the explanation. I now better understand both allowCancelAfter and allowExecuteAfter. By specifying only allowExecuteAfter, the script runs without error. I will have to test out other scenarios.