bitpay / jsonPaymentProtocol

JSON Payment Protocol Interface
46 stars 57 forks source link

Second clause of if statement cannot hit #26

Closed micahriggan closed 5 years ago

micahriggan commented 5 years ago

https://github.com/bitpay/jsonPaymentProtocol/blob/972eaa88894716298e1227ad14e656d80c5e821d/index.js#L213

If the first clause of this statement fails, then the second clause will be impossible with !==

If the goal is to make sure the parameter is a number, I think we should remove the second clause or change it to

parseInt(weightedSize.toString()) !== weightedSize
unusualbob commented 5 years ago

If it was an AND then yes, it would fail, but this is an OR statement. Specifically this if is designed to catch things if the input is not a number or if it is not an integer. Something like '1' or 1.1 would be example payloads which would trigger it, and 1 would be ignored.

micahriggan commented 5 years ago

Thanks. Did not realize you could call parseInt on a float. Thought it had to be a string.