Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Commit

Permalink
Merge pull request #686 from rsksmart/fix_btc_transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
patogallaiovlabs authored May 18, 2021
2 parents 4c93124 + 6d5ff79 commit a067354
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/pages/wallet/transfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -921,19 +921,23 @@ class Transfer extends Component {
this.setState({ loading: true });
const feeParams = this.getFeeParams();
const extraParams = { data: '', memo, gasFee: feeParams };
let finalToAddress = toAddress;
// In order to send all all balances, we cannot use the amount in the text box to calculate the amount sent, but use the coin balance.
// The amount of the text box is fixed decimal places
let value = new BigNumber(amount);
if (isRequestSendAll) {
if (symbol === 'BTC') {
value = balance.minus(common.convertUnitToCoinAmount(symbol, feeParams.fees, precision));
} else if (symbol === 'RBTC') {
finalToAddress = finalToAddress.toLowerCase();
value = balance.minus(common.convertUnitToCoinAmount(symbol, feeParams.gas.times(feeParams.gasPrice), precision));
} else {
finalToAddress = finalToAddress.toLowerCase();
value = balance;
}
}
let transaction = new Transaction(coin, toAddress.toLowerCase(), value, extraParams);

let transaction = new Transaction(coin, finalToAddress, value, extraParams);
await transaction.broadcast();
this.setState({ loading: false });
const completedParams = {
Expand All @@ -946,8 +950,12 @@ class Transfer extends Component {
this.setState({ loading: false });
console.log(`confirm, error: ${error.message}`);
const buttonText = 'button.retry';
const notification = getErrorNotification(error.code, buttonText) || getDefaultTxFailedErrorNotification(buttonText);
const decodedNotification = getErrorNotification(error.code, buttonText);
const notification = decodedNotification || getDefaultTxFailedErrorNotification(buttonText);
addNotification(notification);
if (!decodedNotification) {
reportErrorToServer({ developerComment: 'transfer.js->confirm()', errorObject: error });
}
if (error.code === ERROR_CODE.NOT_ENOUGH_BALANCE || ERROR_CODE.NOT_ENOUGH_BTC || ERROR_CODE.NOT_ENOUGH_RBTC) {
getBalance({
symbol, type, address, needFetch: true,
Expand Down Expand Up @@ -1217,7 +1225,7 @@ Transfer.propTypes = {
goBack: PropTypes.func.isRequired,
state: PropTypes.shape({
params: PropTypes.shape({
coin: PropTypes.string.isRequired,
coin: PropTypes.shape({}).isRequired,
toAddress: PropTypes.string.isRequired,
}).isRequired,
}).isRequired,
Expand Down

0 comments on commit a067354

Please sign in to comment.