Marcos Rodriguez
5 years ago
committed by
Overtorment
11 changed files with 578 additions and 747 deletions
@ -0,0 +1,31 @@ |
|||
import { AbstractWallet } from './abstract-wallet'; |
|||
|
|||
export class PlaceholderWallet extends AbstractWallet { |
|||
static type = 'placeholder'; |
|||
static typeReadable = 'Placeholder'; |
|||
|
|||
constructor() { |
|||
super(); |
|||
this._isFailure = false; |
|||
} |
|||
|
|||
allowSend() { |
|||
return false; |
|||
} |
|||
|
|||
getLabel() { |
|||
return this.getIsFailure() ? 'Wallet Import' : 'Importing Wallet...'; |
|||
} |
|||
|
|||
allowReceive() { |
|||
return false; |
|||
} |
|||
|
|||
getIsFailure() { |
|||
return this._isFailure; |
|||
} |
|||
|
|||
setIsFailure(value) { |
|||
this._isFailure = value; |
|||
} |
|||
} |
@ -0,0 +1,228 @@ |
|||
/* global alert */ |
|||
import { |
|||
SegwitP2SHWallet, |
|||
LegacyWallet, |
|||
WatchOnlyWallet, |
|||
HDLegacyBreadwalletWallet, |
|||
HDSegwitP2SHWallet, |
|||
HDLegacyP2PKHWallet, |
|||
HDSegwitBech32Wallet, |
|||
LightningCustodianWallet, |
|||
PlaceholderWallet, |
|||
} from '../class'; |
|||
import ReactNativeHapticFeedback from 'react-native-haptic-feedback'; |
|||
const EV = require('../events'); |
|||
const A = require('../analytics'); |
|||
/** @type {AppStorage} */ |
|||
const BlueApp = require('../BlueApp'); |
|||
const loc = require('../loc'); |
|||
|
|||
export default class WalletImport { |
|||
static async _saveWallet(w) { |
|||
try { |
|||
const wallet = BlueApp.getWallets().some(wallet => wallet.getSecret() === w.secret && wallet.type !== PlaceholderWallet.type); |
|||
if (wallet) { |
|||
alert('This wallet has been previously imported.'); |
|||
WalletImport.removePlaceholderWallet(); |
|||
} else { |
|||
alert(loc.wallets.import.success); |
|||
ReactNativeHapticFeedback.trigger('notificationSuccess', { ignoreAndroidSystemSettings: false }); |
|||
w.setLabel(loc.wallets.import.imported + ' ' + w.typeReadable); |
|||
WalletImport.removePlaceholderWallet(); |
|||
BlueApp.wallets.push(w); |
|||
await BlueApp.saveToDisk(); |
|||
A(A.ENUM.CREATED_WALLET); |
|||
} |
|||
EV(EV.enum.WALLETS_COUNT_CHANGED); |
|||
} catch (_e) {} |
|||
} |
|||
|
|||
static removePlaceholderWallet() { |
|||
const placeholderWalletIndex = BlueApp.wallets.findIndex(wallet => wallet.type === PlaceholderWallet.type); |
|||
if (placeholderWalletIndex > -1) { |
|||
BlueApp.wallets.splice(placeholderWalletIndex, 1); |
|||
} |
|||
} |
|||
|
|||
static addPlaceholderWallet(importText, isFailure = false) { |
|||
const wallet = new PlaceholderWallet(); |
|||
wallet.setSecret(importText); |
|||
wallet.setIsFailure(isFailure); |
|||
BlueApp.wallets.push(wallet); |
|||
EV(EV.enum.WALLETS_COUNT_CHANGED); |
|||
return wallet; |
|||
} |
|||
|
|||
static isCurrentlyImportingWallet() { |
|||
return BlueApp.getWallets().some(wallet => wallet.type === PlaceholderWallet.type); |
|||
} |
|||
|
|||
static async processImportText(importText) { |
|||
if (WalletImport.isCurrentlyImportingWallet()) { |
|||
return; |
|||
} |
|||
const placeholderWallet = WalletImport.addPlaceholderWallet(importText); |
|||
// Plan:
|
|||
// 0. check if its HDSegwitBech32Wallet (BIP84)
|
|||
// 1. check if its HDSegwitP2SHWallet (BIP49)
|
|||
// 2. check if its HDLegacyP2PKHWallet (BIP44)
|
|||
// 3. check if its HDLegacyBreadwalletWallet (no BIP, just "m/0")
|
|||
// 4. check if its Segwit WIF (P2SH)
|
|||
// 5. check if its Legacy WIF
|
|||
// 6. check if its address (watch-only wallet)
|
|||
// 7. check if its private key (segwit address P2SH) TODO
|
|||
// 7. check if its private key (legacy address) TODO
|
|||
|
|||
try { |
|||
// is it lightning custodian?
|
|||
if (importText.indexOf('blitzhub://') !== -1 || importText.indexOf('lndhub://') !== -1) { |
|||
let lnd = new LightningCustodianWallet(); |
|||
if (importText.includes('@')) { |
|||
const split = importText.split('@'); |
|||
lnd.setBaseURI(split[1]); |
|||
lnd.setSecret(split[0]); |
|||
} else { |
|||
lnd.setBaseURI(LightningCustodianWallet.defaultBaseUri); |
|||
lnd.setSecret(importText); |
|||
} |
|||
lnd.init(); |
|||
await lnd.authorize(); |
|||
await lnd.fetchTransactions(); |
|||
await lnd.fetchUserInvoices(); |
|||
await lnd.fetchPendingTransactions(); |
|||
await lnd.fetchBalance(); |
|||
return WalletImport._saveWallet(lnd); |
|||
} |
|||
|
|||
// trying other wallet types
|
|||
|
|||
let hd4 = new HDSegwitBech32Wallet(); |
|||
hd4.setSecret(importText); |
|||
if (hd4.validateMnemonic()) { |
|||
await hd4.fetchBalance(); |
|||
if (hd4.getBalance() > 0) { |
|||
await hd4.fetchTransactions(); |
|||
return WalletImport._saveWallet(hd4); |
|||
} |
|||
} |
|||
|
|||
let segwitWallet = new SegwitP2SHWallet(); |
|||
segwitWallet.setSecret(importText); |
|||
if (segwitWallet.getAddress()) { |
|||
// ok its a valid WIF
|
|||
|
|||
let legacyWallet = new LegacyWallet(); |
|||
legacyWallet.setSecret(importText); |
|||
|
|||
await legacyWallet.fetchBalance(); |
|||
if (legacyWallet.getBalance() > 0) { |
|||
// yep, its legacy we're importing
|
|||
await legacyWallet.fetchTransactions(); |
|||
return WalletImport._saveWallet(legacyWallet); |
|||
} else { |
|||
// by default, we import wif as Segwit P2SH
|
|||
await segwitWallet.fetchBalance(); |
|||
await segwitWallet.fetchTransactions(); |
|||
return WalletImport._saveWallet(segwitWallet); |
|||
} |
|||
} |
|||
|
|||
// case - WIF is valid, just has uncompressed pubkey
|
|||
|
|||
let legacyWallet = new LegacyWallet(); |
|||
legacyWallet.setSecret(importText); |
|||
if (legacyWallet.getAddress()) { |
|||
await legacyWallet.fetchBalance(); |
|||
await legacyWallet.fetchTransactions(); |
|||
return WalletImport._saveWallet(legacyWallet); |
|||
} |
|||
|
|||
// if we're here - nope, its not a valid WIF
|
|||
|
|||
let hd1 = new HDLegacyBreadwalletWallet(); |
|||
hd1.setSecret(importText); |
|||
if (hd1.validateMnemonic()) { |
|||
await hd1.fetchBalance(); |
|||
if (hd1.getBalance() > 0) { |
|||
await hd1.fetchTransactions(); |
|||
return WalletImport._saveWallet(hd1); |
|||
} |
|||
} |
|||
|
|||
let hd2 = new HDSegwitP2SHWallet(); |
|||
hd2.setSecret(importText); |
|||
if (hd2.validateMnemonic()) { |
|||
await hd2.fetchBalance(); |
|||
if (hd2.getBalance() > 0) { |
|||
await hd2.fetchTransactions(); |
|||
return WalletImport._saveWallet(hd2); |
|||
} |
|||
} |
|||
|
|||
let hd3 = new HDLegacyP2PKHWallet(); |
|||
hd3.setSecret(importText); |
|||
if (hd3.validateMnemonic()) { |
|||
await hd3.fetchBalance(); |
|||
if (hd3.getBalance() > 0) { |
|||
await hd3.fetchTransactions(); |
|||
return WalletImport._saveWallet(hd3); |
|||
} |
|||
} |
|||
|
|||
// no balances? how about transactions count?
|
|||
|
|||
if (hd1.validateMnemonic()) { |
|||
await hd1.fetchTransactions(); |
|||
if (hd1.getTransactions().length !== 0) { |
|||
return WalletImport._saveWallet(hd1); |
|||
} |
|||
} |
|||
if (hd2.validateMnemonic()) { |
|||
await hd2.fetchTransactions(); |
|||
if (hd2.getTransactions().length !== 0) { |
|||
return WalletImport._saveWallet(hd2); |
|||
} |
|||
} |
|||
if (hd3.validateMnemonic()) { |
|||
await hd3.fetchTransactions(); |
|||
if (hd3.getTransactions().length !== 0) { |
|||
return WalletImport._saveWallet(hd3); |
|||
} |
|||
} |
|||
if (hd4.validateMnemonic()) { |
|||
await hd4.fetchTransactions(); |
|||
if (hd4.getTransactions().length !== 0) { |
|||
return WalletImport._saveWallet(hd4); |
|||
} |
|||
} |
|||
|
|||
// is it even valid? if yes we will import as:
|
|||
if (hd4.validateMnemonic()) { |
|||
return WalletImport._saveWallet(hd4); |
|||
} |
|||
|
|||
// not valid? maybe its a watch-only address?
|
|||
|
|||
let watchOnly = new WatchOnlyWallet(); |
|||
watchOnly.setSecret(importText); |
|||
if (watchOnly.valid()) { |
|||
await watchOnly.fetchTransactions(); |
|||
await watchOnly.fetchBalance(); |
|||
return WalletImport._saveWallet(watchOnly); |
|||
} |
|||
|
|||
// nope?
|
|||
|
|||
// TODO: try a raw private key
|
|||
} catch (Err) { |
|||
WalletImport.removePlaceholderWallet(placeholderWallet); |
|||
EV(EV.enum.WALLETS_COUNT_CHANGED); |
|||
console.warn(Err); |
|||
} |
|||
WalletImport.removePlaceholderWallet(); |
|||
WalletImport.addPlaceholderWallet(importText, true); |
|||
ReactNativeHapticFeedback.trigger('notificationError', { ignoreAndroidSystemSettings: false }); |
|||
EV(EV.enum.WALLETS_COUNT_CHANGED); |
|||
alert(loc.wallets.import.error); |
|||
} |
|||
} |
@ -1,344 +0,0 @@ |
|||
/* global alert */ |
|||
import React from 'react'; |
|||
import { ActivityIndicator, Image, View, TouchableOpacity } from 'react-native'; |
|||
import { BlueText, SafeBlueArea, BlueButton } from '../../BlueComponents'; |
|||
import { RNCamera } from 'react-native-camera'; |
|||
import { SegwitP2SHWallet, LegacyWallet, WatchOnlyWallet, HDLegacyP2PKHWallet, HDSegwitBech32Wallet } from '../../class'; |
|||
import PropTypes from 'prop-types'; |
|||
import { HDSegwitP2SHWallet } from '../../class/hd-segwit-p2sh-wallet'; |
|||
import { LightningCustodianWallet } from '../../class/lightning-custodian-wallet'; |
|||
import bip21 from 'bip21'; |
|||
/** @type {AppStorage} */ |
|||
let BlueApp = require('../../BlueApp'); |
|||
let EV = require('../../events'); |
|||
let bip38 = require('../../bip38'); |
|||
let wif = require('wif'); |
|||
let prompt = require('../../prompt'); |
|||
let loc = require('../../loc'); |
|||
|
|||
export default class ScanQrWif extends React.Component { |
|||
static navigationOptions = { |
|||
header: null, |
|||
}; |
|||
|
|||
state = { isLoading: false }; |
|||
|
|||
onBarCodeScanned = async ret => { |
|||
if (RNCamera.Constants.CameraStatus === RNCamera.Constants.CameraStatus.READY) this.cameraRef.pausePreview(); |
|||
if (+new Date() - this.lastTimeIveBeenHere < 6000) { |
|||
this.lastTimeIveBeenHere = +new Date(); |
|||
return; |
|||
} |
|||
this.lastTimeIveBeenHere = +new Date(); |
|||
this.setState({ isLoading: true }); |
|||
if (ret.data[0] === '6') { |
|||
// password-encrypted, need to ask for password and decrypt
|
|||
console.log('trying to decrypt...'); |
|||
|
|||
this.setState({ |
|||
message: loc.wallets.scanQrWif.decoding, |
|||
}); |
|||
shold_stop_bip38 = undefined; // eslint-disable-line
|
|||
let password = await prompt(loc.wallets.scanQrWif.input_password, loc.wallets.scanQrWif.password_explain); |
|||
if (!password) { |
|||
return; |
|||
} |
|||
let that = this; |
|||
try { |
|||
let decryptedKey = await bip38.decrypt(ret.data, password, function(status) { |
|||
that.setState({ |
|||
message: loc.wallets.scanQrWif.decoding + '... ' + status.percent.toString().substr(0, 4) + ' %', |
|||
}); |
|||
}); |
|||
ret.data = wif.encode(0x80, decryptedKey.privateKey, decryptedKey.compressed); |
|||
} catch (e) { |
|||
console.log(e.message); |
|||
if (RNCamera.Constants.CameraStatus === RNCamera.Constants.CameraStatus.READY) this.cameraRef.resumePreview(); |
|||
this.setState({ message: false, isLoading: false }); |
|||
return alert(loc.wallets.scanQrWif.bad_password); |
|||
} |
|||
|
|||
this.setState({ message: false, isLoading: false }); |
|||
} |
|||
|
|||
for (let w of BlueApp.wallets) { |
|||
if (w.getSecret() === ret.data) { |
|||
// lookig for duplicates
|
|||
this.setState({ isLoading: false }); |
|||
if (RNCamera.Constants.CameraStatus === RNCamera.Constants.CameraStatus.READY) this.cameraRef.resumePreview(); |
|||
return alert(loc.wallets.scanQrWif.wallet_already_exists); // duplicate, not adding
|
|||
} |
|||
} |
|||
|
|||
// is it HD BIP49 mnemonic?
|
|||
let hd = new HDSegwitP2SHWallet(); |
|||
hd.setSecret(ret.data); |
|||
if (hd.validateMnemonic()) { |
|||
for (let w of BlueApp.wallets) { |
|||
if (w.getSecret() === hd.getSecret()) { |
|||
// lookig for duplicates
|
|||
this.setState({ isLoading: false }); |
|||
if (RNCamera.Constants.CameraStatus === RNCamera.Constants.CameraStatus.READY) this.cameraRef.resumePreview(); |
|||
return alert(loc.wallets.scanQrWif.wallet_already_exists); // duplicate, not adding
|
|||
} |
|||
} |
|||
this.setState({ isLoading: true }); |
|||
hd.setLabel(loc.wallets.import.imported + ' ' + hd.typeReadable); |
|||
await hd.fetchBalance(); |
|||
if (hd.getBalance() !== 0) { |
|||
await hd.fetchTransactions(); |
|||
BlueApp.wallets.push(hd); |
|||
await BlueApp.saveToDisk(); |
|||
alert(loc.wallets.import.success); |
|||
this.props.navigation.popToTop(); |
|||
setTimeout(() => EV(EV.enum.WALLETS_COUNT_CHANGED), 500); |
|||
this.setState({ isLoading: false }); |
|||
return; |
|||
} |
|||
} |
|||
// nope
|
|||
|
|||
// is it HD legacy (BIP44) mnemonic?
|
|||
hd = new HDLegacyP2PKHWallet(); |
|||
hd.setSecret(ret.data); |
|||
if (hd.validateMnemonic()) { |
|||
for (let w of BlueApp.wallets) { |
|||
if (w.getSecret() === hd.getSecret()) { |
|||
// lookig for duplicates
|
|||
this.setState({ isLoading: false }); |
|||
if (RNCamera.Constants.CameraStatus === RNCamera.Constants.CameraStatus.READY) this.cameraRef.resumePreview(); |
|||
return alert(loc.wallets.scanQrWif.wallet_already_exists); // duplicate, not adding
|
|||
} |
|||
} |
|||
await hd.fetchTransactions(); |
|||
if (hd.getTransactions().length !== 0) { |
|||
await hd.fetchBalance(); |
|||
hd.setLabel(loc.wallets.import.imported + ' ' + hd.typeReadable); |
|||
BlueApp.wallets.push(hd); |
|||
await BlueApp.saveToDisk(); |
|||
alert(loc.wallets.import.success); |
|||
this.props.navigation.popToTop(); |
|||
setTimeout(() => EV(EV.enum.WALLETS_COUNT_CHANGED), 500); |
|||
this.setState({ isLoading: false }); |
|||
return; |
|||
} |
|||
} |
|||
// nope
|
|||
|
|||
// is it HD BIP49 mnemonic?
|
|||
hd = new HDSegwitBech32Wallet(); |
|||
hd.setSecret(ret.data); |
|||
if (hd.validateMnemonic()) { |
|||
for (let w of BlueApp.wallets) { |
|||
if (w.getSecret() === hd.getSecret()) { |
|||
// lookig for duplicates
|
|||
this.setState({ isLoading: false }); |
|||
if (RNCamera.Constants.CameraStatus === RNCamera.Constants.CameraStatus.READY) this.cameraRef.resumePreview(); |
|||
return alert(loc.wallets.scanQrWif.wallet_already_exists); // duplicate, not adding
|
|||
} |
|||
} |
|||
this.setState({ isLoading: true }); |
|||
hd.setLabel(loc.wallets.import.imported + ' ' + hd.typeReadable); |
|||
BlueApp.wallets.push(hd); |
|||
await hd.fetchBalance(); |
|||
await hd.fetchTransactions(); |
|||
await BlueApp.saveToDisk(); |
|||
alert(loc.wallets.import.success); |
|||
this.props.navigation.popToTop(); |
|||
setTimeout(() => EV(EV.enum.WALLETS_COUNT_CHANGED), 500); |
|||
this.setState({ isLoading: false }); |
|||
return; |
|||
} |
|||
// nope
|
|||
|
|||
// is it lndhub?
|
|||
if (ret.data.indexOf('blitzhub://') !== -1 || ret.data.indexOf('lndhub://') !== -1) { |
|||
this.setState({ isLoading: true }); |
|||
let lnd = new LightningCustodianWallet(); |
|||
lnd.setSecret(ret.data); |
|||
if (ret.data.includes('@')) { |
|||
const split = ret.data.split('@'); |
|||
lnd.setBaseURI(split[1]); |
|||
lnd.init(); |
|||
lnd.setSecret(split[0]); |
|||
} |
|||
|
|||
try { |
|||
await lnd.authorize(); |
|||
await lnd.fetchTransactions(); |
|||
await lnd.fetchUserInvoices(); |
|||
await lnd.fetchPendingTransactions(); |
|||
await lnd.fetchBalance(); |
|||
} catch (Err) { |
|||
console.log(Err); |
|||
this.setState({ isLoading: false }); |
|||
if (RNCamera.Constants.CameraStatus === RNCamera.Constants.CameraStatus.READY) this.cameraRef.resumePreview(); |
|||
alert(Err.message); |
|||
return; |
|||
} |
|||
|
|||
BlueApp.wallets.push(lnd); |
|||
lnd.setLabel(loc.wallets.import.imported + ' ' + lnd.typeReadable); |
|||
this.props.navigation.popToTop(); |
|||
alert(loc.wallets.import.success); |
|||
await BlueApp.saveToDisk(); |
|||
setTimeout(() => EV(EV.enum.WALLETS_COUNT_CHANGED), 500); |
|||
this.setState({ isLoading: false }); |
|||
return; |
|||
} |
|||
// nope
|
|||
|
|||
// is it just address..?
|
|||
let watchOnly = new WatchOnlyWallet(); |
|||
let watchAddr = ret.data; |
|||
|
|||
// Is it BIP21 format?
|
|||
if (ret.data.indexOf('bitcoin:') === 0 || ret.data.indexOf('BITCOIN:') === 0) { |
|||
try { |
|||
watchAddr = bip21.decode(ret.data).address; |
|||
} catch (err) { |
|||
console.log(err); |
|||
} |
|||
} |
|||
|
|||
if (watchOnly.setSecret(watchAddr) && watchOnly.valid()) { |
|||
watchOnly.setLabel(loc.wallets.scanQrWif.imported_watchonly); |
|||
BlueApp.wallets.push(watchOnly); |
|||
alert(loc.wallets.scanQrWif.imported_watchonly + loc.wallets.scanQrWif.with_address + watchOnly.getAddress()); |
|||
await watchOnly.fetchBalance(); |
|||
await watchOnly.fetchTransactions(); |
|||
await BlueApp.saveToDisk(); |
|||
this.props.navigation.popToTop(); |
|||
setTimeout(() => EV(EV.enum.WALLETS_COUNT_CHANGED), 500); |
|||
this.setState({ isLoading: false }); |
|||
return; |
|||
} |
|||
// nope
|
|||
|
|||
let newWallet = new SegwitP2SHWallet(); |
|||
newWallet.setSecret(ret.data); |
|||
let newLegacyWallet = new LegacyWallet(); |
|||
newLegacyWallet.setSecret(ret.data); |
|||
|
|||
if (newWallet.getAddress() === false && newLegacyWallet.getAddress() === false) { |
|||
alert(loc.wallets.scanQrWif.bad_wif); |
|||
if (RNCamera.Constants.CameraStatus === RNCamera.Constants.CameraStatus.READY) this.cameraRef.resumePreview(); |
|||
this.setState({ isLoading: false }); |
|||
return; |
|||
} |
|||
|
|||
if (newWallet.getAddress() === false && newLegacyWallet.getAddress() !== false) { |
|||
// case - WIF is valid, just has uncompressed pubkey
|
|||
newLegacyWallet.setLabel(loc.wallets.scanQrWif.imported_legacy); |
|||
BlueApp.wallets.push(newLegacyWallet); |
|||
alert(loc.wallets.scanQrWif.imported_wif + ret.data + loc.wallets.scanQrWif.with_address + newLegacyWallet.getAddress()); |
|||
await newLegacyWallet.fetchBalance(); |
|||
await newLegacyWallet.fetchTransactions(); |
|||
await BlueApp.saveToDisk(); |
|||
this.props.navigation.popToTop(); |
|||
setTimeout(() => EV(EV.enum.WALLETS_COUNT_CHANGED), 500); |
|||
return; |
|||
} |
|||
|
|||
this.setState({ isLoading: true }); |
|||
await newLegacyWallet.fetchBalance(); |
|||
console.log('newLegacyWallet == ', newLegacyWallet.getBalance()); |
|||
|
|||
if (newLegacyWallet.getBalance()) { |
|||
newLegacyWallet.setLabel(loc.wallets.scanQrWif.imported_legacy); |
|||
BlueApp.wallets.push(newLegacyWallet); |
|||
alert(loc.wallets.scanQrWif.imported_wif + ret.data + loc.wallets.scanQrWif.with_address + newLegacyWallet.getAddress()); |
|||
await newLegacyWallet.fetchTransactions(); |
|||
} else { |
|||
await newWallet.fetchBalance(); |
|||
await newWallet.fetchTransactions(); |
|||
newWallet.setLabel(loc.wallets.scanQrWif.imported_segwit); |
|||
BlueApp.wallets.push(newWallet); |
|||
alert(loc.wallets.scanQrWif.imported_wif + ret.data + loc.wallets.scanQrWif.with_address + newWallet.getAddress()); |
|||
} |
|||
await BlueApp.saveToDisk(); |
|||
this.props.navigation.popToTop(); |
|||
setTimeout(() => EV(EV.enum.WALLETS_COUNT_CHANGED), 500); |
|||
}; // end
|
|||
|
|||
render() { |
|||
if (this.state.isLoading) { |
|||
return ( |
|||
<View style={{ flex: 1, paddingTop: 20, justifyContent: 'center', alignContent: 'center' }}> |
|||
<ActivityIndicator /> |
|||
</View> |
|||
); |
|||
} |
|||
return ( |
|||
<View style={{ flex: 1 }}> |
|||
{(() => { |
|||
if (this.state.message) { |
|||
return ( |
|||
<SafeBlueArea> |
|||
<View |
|||
style={{ |
|||
flex: 1, |
|||
flexDirection: 'column', |
|||
justifyContent: 'center', |
|||
alignItems: 'center', |
|||
}} |
|||
> |
|||
<BlueText>{this.state.message}</BlueText> |
|||
<BlueButton |
|||
icon={{ name: 'ban', type: 'font-awesome' }} |
|||
onPress={async () => { |
|||
this.setState({ message: false }); |
|||
shold_stop_bip38 = true; // eslint-disable-line
|
|||
}} |
|||
title={loc.wallets.scanQrWif.cancel} |
|||
/> |
|||
</View> |
|||
</SafeBlueArea> |
|||
); |
|||
} else { |
|||
return ( |
|||
<SafeBlueArea style={{ flex: 1 }}> |
|||
<RNCamera |
|||
captureAudio={false} |
|||
androidCameraPermissionOptions={{ |
|||
title: 'Permission to use camera', |
|||
message: 'We need your permission to use your camera', |
|||
buttonPositive: 'OK', |
|||
buttonNegative: 'Cancel', |
|||
}} |
|||
style={{ flex: 1, justifyContent: 'space-between' }} |
|||
onBarCodeRead={this.onBarCodeScanned} |
|||
ref={ref => (this.cameraRef = ref)} |
|||
barCodeTypes={[RNCamera.Constants.BarCodeType.qr]} |
|||
/> |
|||
<TouchableOpacity |
|||
style={{ |
|||
width: 40, |
|||
height: 40, |
|||
marginLeft: 24, |
|||
backgroundColor: '#FFFFFF', |
|||
justifyContent: 'center', |
|||
borderRadius: 20, |
|||
position: 'absolute', |
|||
top: 64, |
|||
}} |
|||
onPress={() => this.props.navigation.goBack(null)} |
|||
> |
|||
<Image style={{ alignSelf: 'center' }} source={require('../../img/close.png')} /> |
|||
</TouchableOpacity> |
|||
</SafeBlueArea> |
|||
); |
|||
} |
|||
})()} |
|||
</View> |
|||
); |
|||
} |
|||
} |
|||
|
|||
ScanQrWif.propTypes = { |
|||
navigation: PropTypes.shape({ |
|||
goBack: PropTypes.func, |
|||
popToTop: PropTypes.func, |
|||
navigate: PropTypes.func, |
|||
}), |
|||
}; |
Loading…
Reference in new issue