byteball / ocore

Core library for Obyte
https://obyte.org
MIT License
144 stars 93 forks source link

did not check whether the amount is real #169

Open ClareLau61803 opened 5 years ago

ClareLau61803 commented 5 years ago

wallet.js -sendMultiPayment(): did not check whether the amount is real. The decimal part will be lost when the data is stored into database. Verification failed when other nodes(like headless) synchronize unit and verify.

ClareLau61803 commented 5 years ago

issue code: if (amount){ if (typeof amount !== 'number') throw Error('amount must be a number'); if (amount < 0) throw Error('amount must be positive'); }

Papabyte commented 5 years ago

Such a try should result on a validation error at this point of code: https://github.com/byteball/ocore/blob/master/composer.js#L651 with something like Validation error: amount must be positive integer, found 996741.7 returned as error. It's before broadcasting or writing into database so I don't understand the consequences you are talking about. It should be appropriate though to add a check for integer directly in sendMultiPayment function.

tarmo888 commented 4 years ago

All amounts are integer, in the smallest unit (bytes). There is no decimals.