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

Commit

Permalink
fix(wallet): convert bip21 amount to active crypto unit
Browse files Browse the repository at this point in the history
  • Loading branch information
mrfelton committed May 4, 2020
1 parent 34df9d3 commit 1bc4d68
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions renderer/reducers/pay/ipc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { showError } from 'reducers/notification'
import { walletSelectors } from 'reducers/wallet'
import { showAutopayNotification, autopaySelectors } from 'reducers/autopay'
import { payInvoice } from 'reducers/payment'
import { tickerSelectors } from 'reducers/ticker'
import { setRedirectPayReq, setLnurlWithdrawalParams } from './reducer'
import messages from './messages'

Expand Down Expand Up @@ -63,15 +64,17 @@ export const lightningPaymentUri = (event, { address }) => (dispatch, getState)
* @param {{ address, options }} options Decoded bip21 payment url
* @returns {Function} Thunk
*/
export const bitcoinPaymentUri = (event, { address, options = {} }) => dispatch => {
export const bitcoinPaymentUri = (event, { address, options = {} }) => (dispatch, getState) => {
// If the bip21 data includes a bolt11 invoice in the `lightning` key handle as a lightning payment.
const { lightning } = options
if (lightning) {
dispatch(lightningPaymentUri(event, { address: lightning }))
}
// Otherwise, use the bitcoin address for on-chain payment.
else {
const { amount } = options
const { amount: amountInBtc } = options
const cryptoUnit = tickerSelectors.cryptoUnit(getState())
const amount = convert('btc', cryptoUnit, amountInBtc)
dispatch(setRedirectPayReq({ address, amount }))
}
}
Expand Down

0 comments on commit 1bc4d68

Please sign in to comment.