Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expect full ILP packet & add disallowOverPayment #16

Merged
merged 3 commits into from
Aug 3, 2016

Conversation

emschwartz
Copy link
Member

The receiver should expect the full ilp packet (request) in the incoming transfer data field.

This also adds an option to require that incoming transfer amounts exactly match the requested amount.

before interledgerjs/ilp-connector#195 the connector would strip the
ilp packet and only pass on the data field. this change makes the receiver expect and validate the
full request packet. it also keeps the old behavior because *.ilpdemo.org has not yet been updated
with the latest connector

fixes #15
by default the receiver will accept incoming transfers where the amount is greater than requested.
this adds an option to require that transfer amounts exactly match the requested amount
@@ -24,6 +24,7 @@ const BigNumber = require('bignumber.js')
* @param {ilp-core.Client} [opts.client] [ilp-core](https://github.com/interledger/js-ilp-core) Client, which can optionally be supplied instead of the previous options
* @param {Buffer} [opts.hmacKey=crypto.randomBytes(32)] 32-byte secret used for generating request conditions
* @param {Number} [opts.defaultRequestTimeout=30] Default time in seconds that requests will be valid for
* @param {Boolean} [opts.disallowOverPayment=false] Require that incoming transfer amounts exactly match the requested amount
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would reverse this: allowOverPayment=false.

I get that overpayment is theoretically good for the recipient, but in practice isn't it just going to mean that some error happened and if you don't decline the payment you're going to have to manually go in an fix it later?

At least in ITP it seems like overpayment would be an indicator of a serious problem and should be rejected. And if somebody truly needs it they can set allowOverPayment.

Also, I think it should be allowOverpayment, see overpayment.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new commit changes this behavior

add allowOverPayment option to allow incoming transfers where the amount is greater than requested
@codecov-io
Copy link

Current coverage is 99.13% (diff: 100%)

Merging #16 into master will increase coverage by 0.13%

@@             master        #16   diff @@
==========================================
  Files             3          3          
  Lines           100        116    +16   
  Methods           9          9          
  Messages          0          0          
  Branches         17         23     +6   
==========================================
+ Hits             99        115    +16   
  Misses            1          1          
  Partials          0          0          

Powered by Codecov. Last update 83d1aed...fbd2628

@emschwartz
Copy link
Member Author

@justmoon note that one result of requiring the incoming amount to exactly match the requested amount is that we'll need to round the amount given by the user to the receiving ledger's precision when creating the request. Otherwise, you could have a request that would be impossible to fulfill.

@emschwartz
Copy link
Member Author

Alternatively, we could allow transfer amounts that are greater than the requested amount because of rounding

@justmoon
Copy link
Contributor

justmoon commented Aug 3, 2016

note that one result of requiring the incoming amount to exactly match the requested amount is that we'll need to round the amount given by the user to the receiving ledger's precision when creating the request. Otherwise, you could have a request that would be impossible to fulfill.

Good observation. Should be doable since the receiver is guaranteed to have a relationship to their ledger. We probably want to always round up to avoid weird exploits. (I can create money by depositing 0.00499 into a wallet a million times.)

LGTM

@emschwartz emschwartz merged commit 24f76d7 into master Aug 3, 2016
@emschwartz emschwartz deleted the es-full-packet branch August 3, 2016 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants