LedgerHQ / ledger-wallet-chrome

Ledger Wallet Chrome application
http://www.ledgerwallet.com/apps/bitcoin
MIT License
161 stars 118 forks source link

Wildly incorrect fee calculation in CPFP dialog #80

Closed MannyC closed 6 years ago

MannyC commented 6 years ago

The fee calculation on the CPFP dialog can be wildly inflated.

suggested_fees

This is not a cosmetic bug.

Whatever method this dialog uses to obtain its fee per byte estimates can return values with a fractional component, as seen above.

There is an attempt to calculate the size of the all transactions in bytes and multiply it by this fee per byte figure. Unfortunately when the fee per byte is converted into a BigInteger, BigInteger seems to basically ignore the decimal point which can inflate the value by multiple orders of magnitude.

new BigInteger("1.000000001").toString()
>  "1000000001"
this.ledger.Amount.fromSatoshi(1.000000001).toString();
>  "1000000001"

I see the main Send panel just doesn't allow decimal places. However, this seems like quite scary behaviour from BigInteger, and allowing it to continue is asking for trouble.

MannyC commented 6 years ago

This looks like it was fixed here: https://github.com/LedgerHQ/ledger-wallet-chrome/commit/967fbd13e9812164368e1dc4c9c6949524681949#diff-ef7bc7a9ad17608c761793ce1fc816d4