Browse Source

ADD: Read clipboard for transactions

icloud
Marcos Rodriguez Vélez 6 years ago
committed by Igor Korsakov
parent
commit
3f651960e0
  1. 24
      App.js
  2. 2
      android/app/build.gradle
  3. 4
      class/walletGradient.js
  4. BIN
      img/addWallet/bitcoin.png
  5. BIN
      img/addWallet/bitcoin@2x.png
  6. BIN
      img/addWallet/bitcoin@3x.png
  7. BIN
      img/addWallet/lightning.png
  8. BIN
      img/addWallet/lightning@2x.png
  9. BIN
      img/addWallet/lightning@3x.png
  10. 2
      ios/BlueWallet/Info.plist
  11. 6
      loc/en.js
  12. 68
      package-lock.json
  13. 8
      package.json
  14. 3
      screen/send/confirm.js

24
App.js

@ -5,10 +5,13 @@ import { NavigationActions } from 'react-navigation';
import MainBottomTabs from './MainBottomTabs';
import NavigationService from './NavigationService';
import { BlueTextCentered, BlueButton } from './BlueComponents';
import ReactNativeHapticFeedback from 'react-native-haptic-feedback';
const bitcoin = require('bitcoinjs-lib');
const bitcoinModalString = 'Bitcoin address';
const lightningModalString = 'Lightning Invoice';
let loc = require('./loc');
const loc = require('./loc');
/** @type {AppStorage} */
const BlueApp = require('./BlueApp');
export default class App extends React.Component {
navigator = null;
@ -27,6 +30,7 @@ export default class App extends React.Component {
Linking.addEventListener('url', this.handleOpenURL);
AppState.addEventListener('change', this._handleAppStateChange);
this._handleAppStateChange(this.state.appState, true);
}
componentWillUnmount() {
@ -34,16 +38,17 @@ export default class App extends React.Component {
AppState.removeEventListener('change', this._handleAppStateChange);
}
_handleAppStateChange = async nextAppState => {
if (this.state.appState.match(/inactive|background/) && nextAppState === 'active') {
const clipboard = await Clipboard.getString();
if (this.state.clipboardContent !== clipboard && (this.isBitcoinAddress(clipboard) || this.isLightningInvoice(clipboard))) {
this.setState({ isClipboardContentModalVisible: true });
_handleAppStateChange = async (nextAppState, force = false) => {
if (BlueApp.getWallets().length > 0) {
if ((this.state.appState.match(/inactive|background/) && nextAppState === 'active') || force) {
const clipboard = await Clipboard.getString();
if (this.state.clipboardContent !== clipboard && (this.isBitcoinAddress(clipboard) || this.isLightningInvoice(clipboard))) {
this.setState({ isClipboardContentModalVisible: true });
}
this.setState({ clipboardContent: clipboard });
}
this.setState({ clipboardContent: clipboard });
this.setState({ appState: nextAppState });
}
this.setState({ appState: nextAppState });
};
isBitcoinAddress(address) {
@ -106,6 +111,7 @@ export default class App extends React.Component {
renderClipboardContentModal = () => {
return (
<Modal
onModalShow={() => ReactNativeHapticFeedback.trigger('impactLight', false)}
isVisible={this.state.isClipboardContentModalVisible}
style={styles.bottomModal}
onBackdropPress={() => {

2
android/app/build.gradle

@ -102,7 +102,7 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "3.8.2"
versionName "3.8.3"
ndk {
abiFilters "armeabi-v7a", "x86"
}

4
class/walletGradient.js

@ -6,12 +6,12 @@ import { HDLegacyP2PKHWallet } from './hd-legacy-p2pkh-wallet';
import { WatchOnlyWallet } from './watch-only-wallet';
export default class WalletGradient {
static defaultGradients = ['#65ceef', '#68bbe1'];
static hdSegwitP2SHWallet = ['#65ceef', '#68bbe1'];
static watchOnlyWallet = ['#7d7d7d', '#4a4a4a'];
static legacyWallet = ['#40fad1', '#15be98'];
static hdLegacyP2PKHWallet = ['#e36dfa', '#bd10e0'];
static hdLegacyBreadWallet = ['#fe6381', '#f99c42'];
static hdSegwitP2SHWallet = ['#c65afb', '#9053fe'];
static defaultGradients = ['#c65afb', '#9053fe'];
static lightningCustodianWallet = ['#f1be07', '#f79056'];
static createWallet = ['#eef0f4', '#eef0f4'];

BIN
img/addWallet/bitcoin.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
img/addWallet/bitcoin@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
img/addWallet/bitcoin@3x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

BIN
img/addWallet/lightning.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
img/addWallet/lightning@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

BIN
img/addWallet/lightning@3x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

2
ios/BlueWallet/Info.plist

@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>3.8.2</string>
<string>3.8.3</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>

6
loc/en.js

@ -36,7 +36,7 @@ module.exports = {
create: 'Create',
label_new_segwit: 'New SegWit',
label_new_lightning: 'New Lightning',
wallet_name: 'wallet name',
wallet_name: 'name',
wallet_type: 'type',
or: 'or',
import_wallet: 'Import wallet',
@ -182,8 +182,8 @@ module.exports = {
lightning_settings: 'Lightning Settings',
lightning_settings_explain:
'To connect to your own LND node please install LndHub' +
' and put its URL here in settings. Leave blank to use default LndHub (lndhub.io)',
save: 'save',
" and put its URL here in settings. Leave blank to use BlueWallet's LNDHub (lndhub.io). Wallets created after saving changes will connect to the specified LNDHub.",
save: 'Save',
about: 'About',
language: 'Language',
currency: 'Currency',

68
package-lock.json

@ -1,6 +1,6 @@
{
"name": "BlueWallet",
"version": "3.8.2",
"version": "3.8.3",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -897,9 +897,9 @@
}
},
"@react-navigation/core": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/@react-navigation/core/-/core-3.0.3.tgz",
"integrity": "sha512-cE0hfOrh+qbAs0tjvlek99gas6+ecW5rtORhTdfZQ1byDGYBKjYZnDTEMImbWqAaAobyXOLEzK7A/zNrpDfiYA==",
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/@react-navigation/core/-/core-3.1.1.tgz",
"integrity": "sha512-vVPUIpCWO3VKVvE5zYDDR/lOy5hHvRm60rQAHTF19vmt3Jqnbs3qqgYovfUAnTBm0crGLcuIwzOuprRIhC4bfQ==",
"requires": {
"create-react-context": "0.2.2",
"hoist-non-react-statics": "^3.0.1",
@ -920,13 +920,13 @@
}
},
"@react-navigation/native": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/@react-navigation/native/-/native-3.1.3.tgz",
"integrity": "sha512-rXGpnkBWJM1K9iVMlRJdDzYb9zDHymwl16E0IKB0vQ9odaSHtNyfbfo6R2RLrNEXBcR9OPqoAnJoKpYoQeFG+Q==",
"version": "3.1.5",
"resolved": "https://registry.npmjs.org/@react-navigation/native/-/native-3.1.5.tgz",
"integrity": "sha512-sDqgNCx98XmiJR4lF8xCMVdADR4NBrx10TkTYbYcwFJ6SJ2LzrfxAW+FwUsESXr5TcSu3/6rGrLGr4rTGjkvRQ==",
"requires": {
"hoist-non-react-statics": "^3.0.1",
"react-native-gesture-handler": "~1.0.14",
"react-native-safe-area-view": "^0.12.0",
"react-native-safe-area-view": "^0.13.0",
"react-native-screens": "^1.0.0 || ^1.0.0-alpha"
},
"dependencies": {
@ -10911,9 +10911,9 @@
"integrity": "sha512-KIJqT9jQJDQx5h5uAVPimw6yVg2SekOKu959OCtktD3FjzbpvaPr8i4zzg07DOMz+igA4W/aNM7OV8H37pFYfA=="
},
"query-string": {
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/query-string/-/query-string-6.2.0.tgz",
"integrity": "sha512-5wupExkIt8RYL4h/FE+WTg3JHk62e6fFPWtAZA9J5IWK1PfTfKkMS93HBUHcFpeYi9KsY5pFbh+ldvEyaz5MyA==",
"version": "6.3.0",
"resolved": "https://registry.npmjs.org/query-string/-/query-string-6.3.0.tgz",
"integrity": "sha512-jkpCkoHiAA2BYZvni5GieU3x860QDfkh2+M6bPnrYUywqOWbGwPq5VzntTS06ixX4GVHEiq2ZhlmGy/e9LQ3zA==",
"requires": {
"decode-uri-component": "^0.2.0",
"strict-uri-encode": "^2.0.0"
@ -11372,9 +11372,9 @@
}
},
"react-native-device-info": {
"version": "0.26.1",
"resolved": "https://registry.npmjs.org/react-native-device-info/-/react-native-device-info-0.26.1.tgz",
"integrity": "sha512-775TMZcJAybqtjHDTqkkIoRs9HH5szzyDaHqI5ipPmLfKD48nI1QfkcpfwDmjXIEtU33gXWnXr+Hdj4dMnNHtw=="
"version": "0.26.4",
"resolved": "https://registry.npmjs.org/react-native-device-info/-/react-native-device-info-0.26.4.tgz",
"integrity": "sha512-gQo/hSk26E/gK0W3QvkSv+mrBbceFszezxLfUriK3JbiUwvaOlXm6kru2jAu1XGJzfxo/JUO0Mc0lopqiPgw+A=="
},
"react-native-elements": {
"version": "0.19.0",
@ -11417,9 +11417,9 @@
"integrity": "sha512-PifW2VXYqH92u6GyJfEZAiZQYHmXuJvN7eouuC9ZWadfz+m4MFJbsVFAAsTQ1JzMiuo8B5KwK97hpY0cp7HD9w=="
},
"react-native-haptic-feedback": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/react-native-haptic-feedback/-/react-native-haptic-feedback-1.5.0.tgz",
"integrity": "sha512-0iEeqrHT39s5bnXEOUhkkdZnsGVe66hN7VPlDnjKkUy7i6tocODZNRzFrzdWZc+0Z7sQ3+wovXoylTsdoSL4Pw=="
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/react-native-haptic-feedback/-/react-native-haptic-feedback-1.6.0.tgz",
"integrity": "sha512-caZ0q5UqJQVYXeGvJPt8YMrrWXJ9a+uLNu6ilvSgc61ydjw3BY2fObvOTognJnV9aNn53LjJ7AAhsaVAsbW28g=="
},
"react-native-image-picker": {
"version": "0.28.0",
@ -11510,9 +11510,9 @@
"integrity": "sha512-/vnGkMTsxI+5y1togItXd2l/6JZzlUjsvQjCj9RWsOja9mVJxWdDacCrVHTf041k83fwX2Nw6ru6xxOWyU8Y+w=="
},
"react-native-safe-area-view": {
"version": "0.12.0",
"resolved": "https://registry.npmjs.org/react-native-safe-area-view/-/react-native-safe-area-view-0.12.0.tgz",
"integrity": "sha512-UrAXmBC4KNR5K2eczIDZgqceWyKsgG9gmWFerHCvoyApfei8ceBB9u/c//PWCpS5Gt8MRLTmX5jPtzdXo2yNqg==",
"version": "0.13.1",
"resolved": "https://registry.npmjs.org/react-native-safe-area-view/-/react-native-safe-area-view-0.13.1.tgz",
"integrity": "sha512-d/pu2866jApSwLtK/xWAvMXZkNTIQcFrjjbcTATBrmIfFNnu8TNFUcMRFpfJ+eOn5nmx7uGmDvs9B53Ft7JGpQ==",
"requires": {
"hoist-non-react-statics": "^2.3.1"
}
@ -11796,29 +11796,29 @@
}
},
"react-navigation": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/react-navigation/-/react-navigation-3.1.2.tgz",
"integrity": "sha512-Nj0Mu8D6ywL8TvThTTRMsMg8mBgqjWPb4Spanyq91ANXJHw5IQSlKHjtCcWvNW9ptFl5ExlkOG9y/jETM2LMOw==",
"requires": {
"@react-navigation/core": "3.0.3",
"@react-navigation/native": "3.1.3",
"react-navigation-drawer": "1.1.0",
"react-navigation-stack": "1.0.6",
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/react-navigation/-/react-navigation-3.3.2.tgz",
"integrity": "sha512-XETRxwPGHvJh3LKkAhX5b2sg2u9QiMegmEd0H5O0GWjqYrfJ7LcwzeM0273OfwcpR5lyl+hkCVPMkM+i1xFnVw==",
"requires": {
"@react-navigation/core": "3.1.1",
"@react-navigation/native": "3.1.5",
"react-navigation-drawer": "1.2.0",
"react-navigation-stack": "1.0.10",
"react-navigation-tabs": "1.0.2"
}
},
"react-navigation-drawer": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/react-navigation-drawer/-/react-navigation-drawer-1.1.0.tgz",
"integrity": "sha512-OtO8g+t0pufbL0aiyZ9y2+j7cWIu9+agiaJfOiE2vPDOqGimpVfEYEuWj0xodKVRrEC4xrb8flqoxMxpE0wjdg==",
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/react-navigation-drawer/-/react-navigation-drawer-1.2.0.tgz",
"integrity": "sha512-78idNMJpOGzn0jHej69yTIiqJWdCVdMy2sBtppcdnT+DHeZXQDamTuGurjluf/2WyNB2xAXipIk4N4NnvqRfvw==",
"requires": {
"react-native-tab-view": "^1.2.0"
}
},
"react-navigation-stack": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/react-navigation-stack/-/react-navigation-stack-1.0.6.tgz",
"integrity": "sha512-7vnoceO6d/KYvtOSi3Ui3u1gvZEF/dBrOn+Gb1zqiZ3t+0oWRPpU36OmXAh/SwI5aokQyoihAlH9UBMfp+fbEA=="
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/react-navigation-stack/-/react-navigation-stack-1.0.10.tgz",
"integrity": "sha512-p+1oJ6lQYzblidOopIX0Tt+0ZvzaTyoPrBU9erMI04LEoa37BovYpWd1NXBIkV5+wfRt/o5R2x+RZ3LUeWpjeA=="
},
"react-navigation-tabs": {
"version": "1.0.2",

8
package.json

@ -1,6 +1,6 @@
{
"name": "BlueWallet",
"version": "3.8.2",
"version": "3.8.3",
"devDependencies": {
"babel-eslint": "^10.0.1",
"babel-jest": "^24.0.0",
@ -64,13 +64,13 @@
"react-localization": "1.0.10",
"react-native": "0.58.6",
"react-native-camera": "1.10.0",
"react-native-device-info": "0.26.1",
"react-native-device-info": "^0.26.4",
"react-native-elements": "0.19.0",
"react-native-flexi-radio-button": "0.2.2",
"react-native-fs": "2.13.3",
"react-native-gesture-handler": "1.0.15",
"react-native-google-analytics-bridge": "7.0.0",
"react-native-haptic-feedback": "1.5.0",
"react-native-haptic-feedback": "^1.6.0",
"react-native-image-picker": "0.28.0",
"react-native-level-fs": "3.0.1",
"react-native-linear-gradient": "2.5.3",
@ -92,7 +92,7 @@
"react-native-vector-icons": "6.2.0",
"react-native-webview": "4.1.0",
"react-native-wkwebview-reborn": "2.0.0",
"react-navigation": "3.1.2",
"react-navigation": "^3.3.2",
"react-test-render": "1.1.1",
"readable-stream": "3.1.1",
"secure-random": "1.1.1",

3
screen/send/confirm.js

@ -5,6 +5,7 @@ import { Text } from 'react-native-elements';
import { BlueButton, SafeBlueArea, BlueCard, BlueSpacing40, BlueNavigationStyle } from '../../BlueComponents';
import { BitcoinUnit } from '../../models/bitcoinUnits';
import PropTypes from 'prop-types';
import ReactNativeHapticFeedback from 'react-native-haptic-feedback';
let loc = require('../../loc');
let EV = require('../../events');
let currency = require('../../currency');
@ -45,7 +46,6 @@ export default class Confirm extends Component {
if (result && result.code) {
if (result.code === 1) {
const message = result.message.split('\n');
console.warn(message);
throw new Error(`${message[0]}: ${message[2]}`);
}
} else {
@ -59,6 +59,7 @@ export default class Confirm extends Component {
});
}
} catch (error) {
ReactNativeHapticFeedback.trigger('notificationError', false);
this.setState({ isLoading: false });
alert(error.message);
}

Loading…
Cancel
Save