Skip to content

Commit

Permalink
feat(send): apply fee for bch custodial
Browse files Browse the repository at this point in the history
  • Loading branch information
plondon committed Apr 21, 2021
1 parent 0fc7153 commit e698343
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,20 @@ export default ({
payment = yield payment.from(payloadT.xpub, fromType)
break
case 'CUSTODIAL':
const response: ReturnType<typeof api.getWithdrawalFees> = yield call(
api.getWithdrawalFees,
'mercury',
'DEFAULT'
)
const fee =
response.fees.find(({ symbol }) => symbol === 'BTC')
?.minorValue || '0'
payment = yield payment.from(
payloadT.label,
fromType,
payloadT.withdrawable
new BigNumber(payloadT.withdrawable).minus(fee).toString()
)
payment = yield payment.fee(new BigNumber(fee).toNumber())
yield put(A.sendBchPaymentUpdatedSuccess(payment.value()))
yield put(change(FORM, 'to', null))
break
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,21 +258,19 @@ const FirstStep = props => {
)}
</FormItem>
</FormGroup>
{!isFromCustody && (
<FormGroup inline margin={isPayPro ? '10px' : '30px'}>
<FormItem>
<FormLabel>
<FormattedMessage
id='modals.sendBch.firststep.networkfee'
defaultMessage='Network Fee'
/>
</FormLabel>
<ComboDisplay size='13px' coin='BCH' weight={500}>
{totalFee}
</ComboDisplay>
</FormItem>
</FormGroup>
)}
<FormGroup inline margin={isPayPro ? '10px' : '30px'}>
<FormItem>
<FormLabel>
<FormattedMessage
id='modals.sendBch.firststep.networkfee'
defaultMessage='Network Fee'
/>
</FormLabel>
<ComboDisplay size='13px' coin='BCH' weight={500}>
{totalFee}
</ComboDisplay>
</FormItem>
</FormGroup>
{isPayPro && invalid && (
<Text
size='13px'
Expand Down
2 changes: 2 additions & 0 deletions packages/blockchain-wallet-v4/src/redux/payment/bch/sagas.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,8 @@ export default ({ api }) => {
},

* fee(value) {
if (p.fromType === 'CUSTODIAL')
return makePayment(merge(p, { selection: { fee: value } }))
let fee = yield call(calculateFee, value, p.fees)
let effectiveBalance = yield call(calculateEffectiveBalance, {
coins: p.coins,
Expand Down

0 comments on commit e698343

Please sign in to comment.