Browse Source

Merge branch 'master' of github.com:BlueWallet/BlueWallet

singleaddress
Overtorment 5 years ago
parent
commit
f9667c3722
  1. 26
      BlueComponents.js
  2. 4
      MainBottomTabs.js
  3. 16
      ios/Podfile.lock
  4. 12
      package-lock.json
  5. 4
      package.json
  6. 66
      screen/send/scanQrAddress.js
  7. 20
      screen/wallets/scanQrWif.js

26
BlueComponents.js

@ -1,5 +1,4 @@
/* eslint react/prop-types: 0 */
/* global alert */
/** @type {AppStorage} */
import React, { Component } from 'react';
import Ionicons from 'react-native-vector-icons/Ionicons';
@ -29,13 +28,11 @@ import { LightningCustodianWallet } from './class';
import Carousel from 'react-native-snap-carousel';
import { BitcoinUnit } from './models/bitcoinUnits';
import NavigationService from './NavigationService';
import ImagePicker from 'react-native-image-picker';
import WalletGradient from './class/walletGradient';
import ToolTip from 'react-native-tooltip';
import { BlurView } from '@react-native-community/blur';
import showPopupMenu from 'react-native-popup-menu-android';
import NetworkTransactionFees, { NetworkTransactionFeeType } from './models/networkTransactionFees';
const LocalQRCode = require('@remobile/react-native-qrcode-local-image');
let loc = require('./loc/');
/** @type {AppStorage} */
let BlueApp = require('./BlueApp');
@ -1986,29 +1983,8 @@ export class BlueAddressInput extends Component {
<TouchableOpacity
disabled={this.props.isLoading}
onPress={() => {
NavigationService.navigate('ScanQrAddress', { onBarScanned: this.props.onBarScanned });
Keyboard.dismiss();
ImagePicker.showImagePicker(
{
title: null,
mediaType: 'photo',
takePhotoButtonTitle: null,
customButtons: [{ name: 'navigatetoQRScan', title: 'Use Camera' }],
},
response => {
if (response.customButton) {
NavigationService.navigate('ScanQrAddress', { onBarScanned: this.props.onBarScanned });
} else if (response.uri) {
const uri = response.uri.toString().replace('file://', '');
LocalQRCode.decode(uri, (error, result) => {
if (!error) {
this.props.onBarScanned(result);
} else {
alert('The selected image does not contain a QR Code.');
}
});
}
},
);
}}
style={{
height: 36,

4
MainBottomTabs.js

@ -36,7 +36,7 @@ import receiveDetails from './screen/receive/details';
import setReceiveAmount from './screen/receive/receiveAmount';
import sendDetails from './screen/send/details';
import sendScanQrAddress from './screen/send/scanQrAddress';
import ScanQRCode from './screen/send/scanQrAddress';
import sendCreate from './screen/send/create';
import Confirm from './screen/send/confirm';
import Success from './screen/send/success';
@ -288,7 +288,7 @@ const MainBottomTabs = createStackNavigator(
},
},
ScanQrAddress: {
screen: sendScanQrAddress,
screen: ScanQRCode,
},
LappBrowser: {
screen: LappBrowser,

16
ios/Podfile.lock

@ -86,17 +86,17 @@ PODS:
- React-jsinspector (0.60.5)
- react-native-blur (0.8.0):
- React
- react-native-camera (2.11.1):
- react-native-camera (3.4.0):
- React
- react-native-camera/RCT (= 2.11.1)
- react-native-camera/RN (= 2.11.1)
- react-native-camera/RCT (2.11.1):
- react-native-camera/RCT (= 3.4.0)
- react-native-camera/RN (= 3.4.0)
- react-native-camera/RCT (3.4.0):
- React
- react-native-camera/RN (2.11.1):
- react-native-camera/RN (3.4.0):
- React
- react-native-haptic-feedback (1.7.1):
- React
- react-native-image-picker (0.28.1):
- react-native-image-picker (1.1.0):
- React
- react-native-randombytes (3.5.3):
- React
@ -339,9 +339,9 @@ SPEC CHECKSUMS:
React-jsiexecutor: 90ad2f9db09513fc763bc757fdc3c4ff8bde2a30
React-jsinspector: e08662d1bf5b129a3d556eb9ea343a3f40353ae4
react-native-blur: cad4d93b364f91e7b7931b3fa935455487e5c33c
react-native-camera: 96a3c81f27da57b816fbb6808dde20dc96d1431e
react-native-camera: 203091b4bf99d48b788a0682ad573e8718724893
react-native-haptic-feedback: 22c9dc85fd8059f83bf9edd9212ac4bd4ae6074d
react-native-image-picker: fd93361c666f397bdf72f9c6c23f13d2685b9173
react-native-image-picker: 3637d63fef7e32a230141ab4660d3ceb773c824f
react-native-randombytes: 991545e6eaaf700b4ee384c291ef3d572e0b2ca8
react-native-slider: 6d83f7b8076a84e965a43fbdcfcf9dac19cea42e
react-native-webview: f72ac4078e115dfa741cc588acb1cca25566457d

12
package-lock.json

@ -10687,9 +10687,9 @@
}
},
"react-native-camera": {
"version": "2.11.1",
"resolved": "https://registry.npmjs.org/react-native-camera/-/react-native-camera-2.11.1.tgz",
"integrity": "sha512-ZmPZHcY7UXEf7Z8PoJX/WhFtmLFtdRPBGDwemOLlPRVwTVyu/OXVINDUWCug4daBqV8Fs3X1O6V927+K2u2GfA==",
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/react-native-camera/-/react-native-camera-3.4.0.tgz",
"integrity": "sha512-EFaixLtQsd3Kjs2AnxPx4Qb1mNSlZRZBVoxXDUdWcSdCEE3CSvdeonTb3vWAT3ZlGMi1RTOggtBpI4StMtFNjw==",
"requires": {
"prop-types": "^15.6.2"
}
@ -10770,9 +10770,9 @@
"integrity": "sha512-iuXBEZsQbKOe5uOLXuzTEvrvUCV0a4AktAfJHlWK7Jb0t/ABUc4kUfclqx+la+yA1TKrauDp/6MjrP0OUDXA9Q=="
},
"react-native-image-picker": {
"version": "0.28.1",
"resolved": "https://registry.npmjs.org/react-native-image-picker/-/react-native-image-picker-0.28.1.tgz",
"integrity": "sha512-CW2dm+cjsdW2fjBW2WD/cSufNG0x0UpljwGHrjSzyB0TckoW+tjYv44UWtckCWxr1JtCg+QrYDO/MzlRyFcjwQ=="
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/react-native-image-picker/-/react-native-image-picker-1.1.0.tgz",
"integrity": "sha512-/KjHf4NNAjl6XM7FQuqvGDz1wB9sRdLf86+2yksLW/QTRR7CitX4TLCM8ZF9CX6Y0MsCTndkZia3zWE+nt/GiA=="
},
"react-native-level-fs": {
"version": "3.0.1",

4
package.json

@ -84,7 +84,7 @@
"react": "16.8.6",
"react-localization": "1.0.13",
"react-native": "0.60.5",
"react-native-camera": "2.11.1",
"react-native-camera": "3.4.0",
"react-native-device-info": "2.2.2",
"react-native-elements": "0.19.0",
"react-native-flexi-radio-button": "0.2.2",
@ -92,7 +92,7 @@
"react-native-gesture-handler": "1.3.0",
"react-native-handoff": "git+https://github.com/marcosrdz/react-native-handoff.git",
"react-native-haptic-feedback": "1.7.1",
"react-native-image-picker": "0.28.1",
"react-native-image-picker": "1.1.0",
"react-native-level-fs": "3.0.1",
"react-native-linear-gradient": "2.5.4",
"react-native-modal": "11.1.0",

66
screen/send/scanQrAddress.js

@ -1,25 +1,25 @@
/* global alert */
import React from 'react';
import { Image, TouchableOpacity } from 'react-native';
import PropTypes from 'prop-types';
import { RNCamera } from 'react-native-camera';
import { SafeBlueArea } from '../../BlueComponents';
import { Icon } from 'react-native-elements';
import ImagePicker from 'react-native-image-picker';
const LocalQRCode = require('@remobile/react-native-qrcode-local-image');
export default class CameraExample extends React.Component {
export default class ScanQRCode extends React.Component {
static navigationOptions = {
header: null,
};
state = {
isLoading: false,
};
cameraRef = null;
onBarCodeScanned = ret => {
if (this.state.isLoading) return;
this.setState({ isLoading: true }, () => {
const onBarScannedProp = this.props.navigation.getParam('onBarScanned');
this.props.navigation.goBack();
onBarScannedProp(ret.data);
});
onBarCodeRead = ret => {
if (RNCamera.Constants.CameraStatus === RNCamera.Constants.CameraStatus.READY) this.cameraRef.pausePreview();
const onBarScannedProp = this.props.navigation.getParam('onBarScanned');
this.props.navigation.goBack();
onBarScannedProp(ret.data);
}; // end
render() {
@ -33,8 +33,9 @@ export default class CameraExample extends React.Component {
buttonPositive: 'OK',
buttonNegative: 'Cancel',
}}
ref={ref => (this.cameraRef = ref)}
style={{ flex: 1, justifyContent: 'space-between' }}
onBarCodeRead={this.onBarCodeScanned}
onBarCodeRead={this.onBarCodeRead}
barCodeTypes={[RNCamera.Constants.BarCodeType.qr]}
/>
<TouchableOpacity
@ -52,12 +53,51 @@ export default class CameraExample extends React.Component {
>
<Image style={{ alignSelf: 'center' }} source={require('../../img/close-white.png')} />
</TouchableOpacity>
<TouchableOpacity
style={{
width: 40,
height: 40,
backgroundColor: '#FFFFFF',
justifyContent: 'center',
borderRadius: 20,
position: 'absolute',
left: 24,
bottom: 48,
}}
onPress={() => {
if (RNCamera.Constants.CameraStatus === RNCamera.Constants.CameraStatus.READY) this.cameraRef.pausePreview();
ImagePicker.launchImageLibrary(
{
title: null,
mediaType: 'photo',
takePhotoButtonTitle: null,
},
response => {
if (response.uri) {
const uri = response.uri.toString().replace('file://', '');
LocalQRCode.decode(uri, (error, result) => {
if (!error) {
this.onBarCodeRead({ data: result });
} else {
if (RNCamera.Constants.CameraStatus === RNCamera.Constants.CameraStatus.READY) this.cameraRef.resumePreview();
alert('The selected image does not contain a QR Code.');
}
});
} else {
if (RNCamera.Constants.CameraStatus === RNCamera.Constants.CameraStatus.READY) this.cameraRef.resumePreview();
}
},
);
}}
>
<Icon name="image" type="font-awesome" color="#0c2550" />
</TouchableOpacity>
</SafeBlueArea>
);
}
}
CameraExample.propTypes = {
ScanQRCode.propTypes = {
navigation: PropTypes.shape({
goBack: PropTypes.func,
dismiss: PropTypes.func,

20
screen/wallets/scanQrWif.js

@ -21,18 +21,10 @@ export default class ScanQrWif extends React.Component {
header: null,
};
state = {
isLoading: false,
};
state = { isLoading: false };
onBarCodeScanned = async ret => {
if (+new Date() - this.lastTimeIveBeenHere < 6000) {
this.lastTimeIveBeenHere = +new Date();
return;
}
this.lastTimeIveBeenHere = +new Date();
this.setState({ isLoading: true });
if (RNCamera.Constants.CameraStatus === RNCamera.Constants.CameraStatus.READY) this.cameraRef.pausePreview();
if (ret.data[0] === '6') {
// password-encrypted, need to ask for password and decrypt
console.log('trying to decrypt...');
@ -55,6 +47,7 @@ export default class ScanQrWif extends React.Component {
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);
}
@ -66,6 +59,7 @@ export default class ScanQrWif extends React.Component {
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
}
}
@ -78,6 +72,7 @@ export default class ScanQrWif extends React.Component {
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
}
}
@ -105,6 +100,7 @@ export default class ScanQrWif extends React.Component {
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
}
}
@ -131,6 +127,7 @@ export default class ScanQrWif extends React.Component {
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
}
}
@ -169,6 +166,7 @@ export default class ScanQrWif extends React.Component {
} catch (Err) {
console.log(Err);
this.setState({ isLoading: false });
if (RNCamera.Constants.CameraStatus === RNCamera.Constants.CameraStatus.READY) this.cameraRef.resumePreview();
alert(Err.message);
return;
}
@ -218,6 +216,7 @@ export default class ScanQrWif extends React.Component {
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;
}
@ -303,6 +302,7 @@ export default class ScanQrWif extends React.Component {
}}
style={{ flex: 1, justifyContent: 'space-between' }}
onBarCodeRead={this.onBarCodeScanned}
ref={ref => (this.cameraRef = ref)}
barCodeTypes={[RNCamera.Constants.BarCodeType.qr]}
/>
<TouchableOpacity

Loading…
Cancel
Save