stellar-deprecated / account-viewer

DEPRECATED. Go to https://github.com/stellar/account-viewer-v2
Apache License 2.0
62 stars 65 forks source link

Fix checking the maximum amount user can send #42

Open bartekn opened 7 years ago

bartekn commented 7 years ago

https://github.com/stellar/account-viewer/blob/master/controllers/send-widget.controller.es6

        let minimumBalance = 20 + (account.subentry_count) * 10;
        let nativeBalance = _(account.balances).find(balance => balance.asset_type === 'native').balance;
        let maxSend = new BigNumber(nativeBalance).minus(minimumBalance);
        if (maxSend.lt(this.amount)) {
          throw new BasicClientError('InsufficientBalanceError', {maxSend});
        }

We're not subtracting transaction fee from maxSend. Thanks @briangale for catching this!

AmodD commented 7 years ago

A simple fix for subtracting Txn fee would be to hard code .minus(0.00001) assuming single operation.

But an improvement in the code should involve fetching base fee.

single send operation account-viewer_send-widget-controller

Base Fee hard coded in stellar-base_transactionBuilder class stellar-base_transactionbuilder