Skip to content

Commit

Permalink
fix(BCH QR): add notes and fix issues around bch scan
Browse files Browse the repository at this point in the history
  • Loading branch information
plondon committed Jun 24, 2018
1 parent 57d9a27 commit 9ba2546
Showing 1 changed file with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,8 @@ class QRCodeCaptureContainer extends React.PureComponent {
}

handleScanBchAddress (data) {
// try bitcoincash:qruaxzyr4wcxyuxg2qnteajhgnq2nsmzccuc6d4r5u
try {
if (utils.bch.isCashAddr(data) || utils.bitcoin.isValidBitcoinAddress(data)) {
this.props.formActions.change('sendBch', 'to', data)
this.props.updateUI({ bchAddress: { toggled: false } })
return
}
const {address, options} = bip21.decode(data, 'bitcoincash')
const {amount, message} = options
this.props.formActions.change('sendBch', 'to', address)
Expand All @@ -62,12 +58,20 @@ class QRCodeCaptureContainer extends React.PureComponent {
this.props.updateUI({ bchAddress: { toggled: false } })
} catch (e) {
try {
const {address, options} = bip21.decode(data)
const {amount, message} = options
this.props.formActions.change('sendBch', 'to', address)
this.props.formActions.change('sendBch', 'amount', amount)
this.props.formActions.change('sendBch', 'message', message)
this.props.updateUI({ bchAddress: { toggled: false } })
// try qruaxzyr4wcxyuxg2qnteajhgnq2nsmzccuc6d4r5u
if (utils.bch.isCashAddr(data)) {
this.props.formActions.change('sendBch', 'to', data)
this.props.updateUI({ bchAddress: { toggled: false } })
return
}
// try legacy addr
if (utils.bitcoin.isValidBitcoinAddress(data)) {
this.props.formActions.change('sendBch', 'to', data)
this.props.updateUI({ bchAddress: { toggled: false } })
return
}
// throw error
throw Error('invalid_bch_addr')
} catch (e) {
this.props.alertActions.displayError(C.BCH_ADDRESS_INVALID)
this.props.updateUI({bchAddress: {toggled: false}})
Expand Down

0 comments on commit 9ba2546

Please sign in to comment.