Skip to content
This repository has been archived by the owner on Nov 30, 2020. It is now read-only.

Fix checking the maximum amount user can send #42

Open
bartekn opened this issue Jul 20, 2017 · 1 comment
Open

Fix checking the maximum amount user can send #42

bartekn opened this issue Jul 20, 2017 · 1 comment

Comments

@bartekn
Copy link
Contributor

bartekn commented Jul 20, 2017

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
Copy link

AmodD commented Jul 26, 2017

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants