2019-03-05 02:14:28 +01:00
|
|
|
/* global alert */
|
2018-10-09 06:25:36 +02:00
|
|
|
import React, { Component } from 'react';
|
2019-08-14 05:12:42 +02:00
|
|
|
import { Chain } from '../../models/bitcoinUnits';
|
2019-09-19 01:26:28 +02:00
|
|
|
import {
|
|
|
|
Text,
|
|
|
|
Platform,
|
2019-09-29 22:01:27 +02:00
|
|
|
StyleSheet,
|
2019-09-19 01:26:28 +02:00
|
|
|
View,
|
2019-09-29 22:01:27 +02:00
|
|
|
Keyboard,
|
2019-09-19 01:26:28 +02:00
|
|
|
ActivityIndicator,
|
|
|
|
InteractionManager,
|
|
|
|
FlatList,
|
2019-11-02 21:58:55 +01:00
|
|
|
ScrollView,
|
2019-09-19 01:26:28 +02:00
|
|
|
RefreshControl,
|
|
|
|
TouchableOpacity,
|
|
|
|
StatusBar,
|
2019-09-29 22:01:27 +02:00
|
|
|
Linking,
|
|
|
|
KeyboardAvoidingView,
|
2020-01-01 04:31:04 +01:00
|
|
|
Alert,
|
2020-04-05 22:09:53 +02:00
|
|
|
Clipboard,
|
2019-09-19 01:26:28 +02:00
|
|
|
} from 'react-native';
|
2018-10-09 06:25:36 +02:00
|
|
|
import PropTypes from 'prop-types';
|
2020-04-03 05:53:53 +02:00
|
|
|
import ImagePicker from 'react-native-image-picker';
|
2019-09-29 22:01:27 +02:00
|
|
|
import {
|
|
|
|
BlueSendButtonIcon,
|
|
|
|
BlueListItem,
|
|
|
|
BlueReceiveButtonIcon,
|
|
|
|
BlueTransactionListItem,
|
|
|
|
BlueWalletNavigationHeader,
|
2019-12-25 04:35:47 +01:00
|
|
|
BlueAlertWalletExportReminder,
|
2019-09-29 22:01:27 +02:00
|
|
|
} from '../../BlueComponents';
|
2020-05-24 12:27:08 +02:00
|
|
|
import WalletGradient from '../../class/wallet-gradient';
|
2018-10-09 06:25:36 +02:00
|
|
|
import { Icon } from 'react-native-elements';
|
2020-02-26 15:39:19 +01:00
|
|
|
import { LightningCustodianWallet, WatchOnlyWallet } from '../../class';
|
2019-09-29 22:01:27 +02:00
|
|
|
import Modal from 'react-native-modal';
|
2020-06-19 02:24:26 +02:00
|
|
|
import * as NavigationService from '../../NavigationService';
|
2020-03-29 04:06:45 +02:00
|
|
|
import HandoffSettings from '../../class/handoff';
|
|
|
|
import Handoff from 'react-native-handoff';
|
2020-04-03 05:53:53 +02:00
|
|
|
import ActionSheet from '../ActionSheet';
|
2018-10-09 06:25:36 +02:00
|
|
|
/** @type {AppStorage} */
|
2020-06-01 14:54:23 +02:00
|
|
|
const BlueApp = require('../../BlueApp');
|
|
|
|
const loc = require('../../loc');
|
|
|
|
const EV = require('../../events');
|
|
|
|
const BlueElectrum = require('../../BlueElectrum');
|
2020-04-03 05:53:53 +02:00
|
|
|
const LocalQRCode = require('@remobile/react-native-qrcode-local-image');
|
2018-10-09 06:25:36 +02:00
|
|
|
|
2020-05-24 11:17:26 +02:00
|
|
|
const styles = StyleSheet.create({
|
|
|
|
flex: {
|
|
|
|
flex: 1,
|
|
|
|
},
|
|
|
|
scrollViewContent: {
|
|
|
|
flex: 1,
|
|
|
|
justifyContent: 'center',
|
|
|
|
paddingHorizontal: 16,
|
|
|
|
paddingVertical: 40,
|
|
|
|
},
|
|
|
|
modalContent: {
|
|
|
|
backgroundColor: '#FFFFFF',
|
|
|
|
padding: 22,
|
|
|
|
justifyContent: 'center',
|
|
|
|
alignItems: 'center',
|
|
|
|
borderTopLeftRadius: 16,
|
|
|
|
borderTopRightRadius: 16,
|
|
|
|
borderColor: 'rgba(0, 0, 0, 0.1)',
|
|
|
|
minHeight: 200,
|
|
|
|
height: 200,
|
|
|
|
},
|
|
|
|
advancedTransactionOptionsModalContent: {
|
|
|
|
backgroundColor: '#FFFFFF',
|
|
|
|
padding: 22,
|
|
|
|
borderTopLeftRadius: 16,
|
|
|
|
borderTopRightRadius: 16,
|
|
|
|
borderColor: 'rgba(0, 0, 0, 0.1)',
|
|
|
|
minHeight: 130,
|
|
|
|
},
|
|
|
|
bottomModal: {
|
|
|
|
justifyContent: 'flex-end',
|
|
|
|
margin: 0,
|
|
|
|
},
|
|
|
|
walletDetails: {
|
|
|
|
marginHorizontal: 16,
|
|
|
|
minWidth: 150,
|
|
|
|
justifyContent: 'center',
|
|
|
|
alignItems: 'flex-end',
|
|
|
|
},
|
|
|
|
activityIndicator: {
|
|
|
|
marginVertical: 20,
|
|
|
|
},
|
|
|
|
listHeader: {
|
|
|
|
flexDirection: 'row',
|
|
|
|
margin: 16,
|
|
|
|
justifyContent: 'space-evenly',
|
|
|
|
},
|
|
|
|
listHeaderText: {
|
|
|
|
flex: 1,
|
|
|
|
marginLeft: 16,
|
|
|
|
marginTop: 8,
|
|
|
|
marginBottom: 8,
|
|
|
|
fontWeight: 'bold',
|
|
|
|
fontSize: 24,
|
|
|
|
color: BlueApp.settings.foregroundColor,
|
|
|
|
},
|
|
|
|
marketplaceButton1: {
|
|
|
|
backgroundColor: '#f2f2f2',
|
|
|
|
borderRadius: 9,
|
|
|
|
minHeight: 49,
|
|
|
|
flex: 1,
|
|
|
|
paddingHorizontal: 8,
|
|
|
|
justifyContent: 'center',
|
|
|
|
flexDirection: 'row',
|
|
|
|
alignItems: 'center',
|
|
|
|
},
|
|
|
|
marketplaceButton2: {
|
|
|
|
marginLeft: 5,
|
|
|
|
backgroundColor: '#f2f2f2',
|
|
|
|
borderRadius: 9,
|
|
|
|
minHeight: 49,
|
|
|
|
flex: 1,
|
|
|
|
paddingHorizontal: 8,
|
|
|
|
justifyContent: 'center',
|
|
|
|
flexDirection: 'row',
|
|
|
|
alignItems: 'center',
|
|
|
|
},
|
|
|
|
marketpalceText1: {
|
|
|
|
color: '#062453',
|
|
|
|
fontSize: 18,
|
|
|
|
},
|
|
|
|
marketpalceText2: {
|
|
|
|
color: '#062453',
|
|
|
|
fontSize: 18,
|
|
|
|
marginHorizontal: 8,
|
|
|
|
},
|
|
|
|
list: {
|
|
|
|
backgroundColor: '#FFFFFF',
|
|
|
|
flex: 1,
|
|
|
|
},
|
|
|
|
emptyTxs: {
|
|
|
|
fontSize: 18,
|
|
|
|
color: '#9aa0aa',
|
|
|
|
textAlign: 'center',
|
|
|
|
marginVertical: 16,
|
|
|
|
},
|
|
|
|
emptyTxsLightning: {
|
|
|
|
fontSize: 18,
|
|
|
|
color: '#9aa0aa',
|
|
|
|
textAlign: 'center',
|
|
|
|
fontWeight: '600',
|
|
|
|
},
|
|
|
|
buyBitcoin: {
|
|
|
|
backgroundColor: '#007AFF',
|
|
|
|
minWidth: 260,
|
|
|
|
borderRadius: 8,
|
|
|
|
alignSelf: 'center',
|
|
|
|
paddingVertical: 14,
|
|
|
|
paddingHorizontal: 32,
|
|
|
|
},
|
|
|
|
buyBitcoinText: {
|
|
|
|
fontSize: 15,
|
|
|
|
color: '#fff',
|
|
|
|
textAlign: 'center',
|
|
|
|
fontWeight: '600',
|
|
|
|
},
|
|
|
|
floatButtons: {
|
|
|
|
flexDirection: 'row',
|
|
|
|
alignSelf: 'center',
|
|
|
|
backgroundColor: 'transparent',
|
|
|
|
position: 'absolute',
|
|
|
|
bottom: 30,
|
|
|
|
borderRadius: 30,
|
|
|
|
minHeight: 48,
|
|
|
|
overflow: 'hidden',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2018-10-09 06:25:36 +02:00
|
|
|
export default class WalletTransactions extends Component {
|
2020-05-27 13:12:17 +02:00
|
|
|
static navigationOptions = ({ navigation, route }) => {
|
2019-10-06 13:40:21 +02:00
|
|
|
return {
|
2020-05-27 13:12:17 +02:00
|
|
|
headerRight: () => (
|
2018-11-02 14:53:35 +01:00
|
|
|
<TouchableOpacity
|
2020-05-27 13:12:17 +02:00
|
|
|
disabled={route.params.isLoading === true}
|
2020-05-24 11:17:26 +02:00
|
|
|
style={styles.walletDetails}
|
2018-10-09 06:25:36 +02:00
|
|
|
onPress={() =>
|
|
|
|
navigation.navigate('WalletDetails', {
|
2020-05-27 13:12:17 +02:00
|
|
|
wallet: route.params.wallet,
|
2018-10-09 06:25:36 +02:00
|
|
|
})
|
|
|
|
}
|
2018-11-02 14:53:35 +01:00
|
|
|
>
|
2019-08-06 17:30:56 +02:00
|
|
|
<Icon name="kebab-horizontal" type="octicon" size={22} color="#FFFFFF" />
|
2018-11-02 14:53:35 +01:00
|
|
|
</TouchableOpacity>
|
2018-10-09 06:25:36 +02:00
|
|
|
),
|
2020-05-27 13:12:17 +02:00
|
|
|
headerTitle: () => null,
|
2018-10-09 06:25:36 +02:00
|
|
|
headerStyle: {
|
2020-05-27 13:12:17 +02:00
|
|
|
backgroundColor: WalletGradient.headerColorFor(route.params.wallet.type),
|
2018-10-09 06:25:36 +02:00
|
|
|
borderBottomWidth: 0,
|
2018-11-02 14:53:35 +01:00
|
|
|
elevation: 0,
|
2020-05-27 13:12:17 +02:00
|
|
|
// shadowRadius: 0,
|
|
|
|
shadowOffset: { height: 0, width: 0 },
|
2018-10-09 06:25:36 +02:00
|
|
|
},
|
|
|
|
headerTintColor: '#FFFFFF',
|
2020-05-27 13:12:17 +02:00
|
|
|
headerBackTitleVisible: false,
|
2019-10-06 13:40:21 +02:00
|
|
|
};
|
2018-10-09 06:25:36 +02:00
|
|
|
};
|
|
|
|
|
2019-02-23 16:48:20 +01:00
|
|
|
walletBalanceText = null;
|
|
|
|
|
2018-10-09 06:25:36 +02:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
2018-12-11 23:52:46 +01:00
|
|
|
|
|
|
|
// here, when we receive REMOTE_TRANSACTIONS_COUNT_CHANGED we fetch TXs and balance for current wallet
|
2020-05-28 10:44:15 +02:00
|
|
|
EV(EV.enum.REMOTE_TRANSACTIONS_COUNT_CHANGED, this.refreshTransactionsFunction.bind(this), true);
|
2020-05-27 13:12:17 +02:00
|
|
|
const wallet = props.route.params.wallet;
|
2019-03-05 02:14:28 +01:00
|
|
|
this.props.navigation.setParams({ wallet: wallet, isLoading: true });
|
2018-10-09 06:25:36 +02:00
|
|
|
this.state = {
|
2020-03-29 04:06:45 +02:00
|
|
|
isHandOffUseEnabled: false,
|
2018-10-09 06:25:36 +02:00
|
|
|
isLoading: true,
|
2019-09-29 22:01:27 +02:00
|
|
|
isManageFundsModalVisible: false,
|
2019-02-17 02:22:14 +01:00
|
|
|
showShowFlatListRefreshControl: false,
|
2018-12-11 23:52:46 +01:00
|
|
|
wallet: wallet,
|
2020-06-26 21:27:13 +02:00
|
|
|
itemPriceUnit: wallet.getPreferredBalanceUnit(),
|
2019-02-19 00:37:53 +01:00
|
|
|
dataSource: this.getTransactions(15),
|
2020-06-26 21:27:13 +02:00
|
|
|
timeElapsed: 0, // this is to force a re-render for FlatList items.
|
2019-02-19 00:37:53 +01:00
|
|
|
limit: 15,
|
|
|
|
pageSize: 20,
|
2018-10-09 06:25:36 +02:00
|
|
|
};
|
2018-12-11 23:52:46 +01:00
|
|
|
}
|
|
|
|
|
2020-06-03 04:04:18 +02:00
|
|
|
componentDidMount() {
|
2020-05-31 11:18:38 +02:00
|
|
|
this._unsubscribeFocus = this.props.navigation.addListener('focus', this.onFocus);
|
2019-03-05 02:14:28 +01:00
|
|
|
this.props.navigation.setParams({ isLoading: false });
|
2020-06-27 13:10:11 +02:00
|
|
|
this.interval = setInterval(() => {
|
|
|
|
this.setState(prev => ({ timeElapsed: prev.timeElapsed + 1 }));
|
|
|
|
}, 60000);
|
2020-06-03 04:04:18 +02:00
|
|
|
HandoffSettings.isHandoffUseEnabled().then(enabled => this.setState({ isHandOffUseEnabled: enabled }));
|
|
|
|
this.setState({ isLoading: false });
|
2018-10-09 06:25:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Forcefully fetches TXs and balance for wallet
|
|
|
|
*/
|
|
|
|
refreshTransactionsFunction() {
|
2020-06-01 14:54:23 +02:00
|
|
|
const that = this;
|
|
|
|
setTimeout(function () {
|
2018-10-09 06:25:36 +02:00
|
|
|
that.refreshTransactions();
|
|
|
|
}, 4000); // giving a chance to remote server to propagate
|
|
|
|
}
|
|
|
|
|
2019-02-19 00:37:53 +01:00
|
|
|
/**
|
|
|
|
* Simple wrapper for `wallet.getTransactions()`, where `wallet` is current wallet.
|
|
|
|
* Sorts. Provides limiting.
|
|
|
|
*
|
|
|
|
* @param limit {Integer} How many txs return, starting from the earliest. Default: all of them.
|
|
|
|
* @returns {Array}
|
|
|
|
*/
|
|
|
|
getTransactions(limit = Infinity) {
|
2020-06-01 14:54:23 +02:00
|
|
|
const wallet = this.props.route.params.wallet;
|
2019-12-25 21:53:53 +01:00
|
|
|
|
2019-02-19 00:37:53 +01:00
|
|
|
let txs = wallet.getTransactions();
|
2020-06-01 14:54:23 +02:00
|
|
|
for (const tx of txs) {
|
2019-02-19 00:37:53 +01:00
|
|
|
tx.sort_ts = +new Date(tx.received);
|
|
|
|
}
|
2020-06-01 14:54:23 +02:00
|
|
|
txs = txs.sort(function (a, b) {
|
2019-02-19 00:37:53 +01:00
|
|
|
return b.sort_ts - a.sort_ts;
|
|
|
|
});
|
|
|
|
return txs.slice(0, limit);
|
|
|
|
}
|
|
|
|
|
2019-02-17 02:22:14 +01:00
|
|
|
redrawScreen() {
|
|
|
|
InteractionManager.runAfterInteractions(async () => {
|
|
|
|
console.log('wallets/transactions redrawScreen()');
|
2018-10-09 06:25:36 +02:00
|
|
|
|
|
|
|
this.setState({
|
|
|
|
isLoading: false,
|
2019-02-17 02:22:14 +01:00
|
|
|
showShowFlatListRefreshControl: false,
|
2019-02-19 00:37:53 +01:00
|
|
|
dataSource: this.getTransactions(this.state.limit),
|
2018-10-09 06:25:36 +02:00
|
|
|
});
|
2019-02-17 02:22:14 +01:00
|
|
|
});
|
2018-10-09 06:25:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
isLightning() {
|
2020-06-01 14:54:23 +02:00
|
|
|
const w = this.state.wallet;
|
2019-12-25 21:53:53 +01:00
|
|
|
if (w && w.chain === Chain.OFFCHAIN) {
|
2018-10-09 06:25:36 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Forcefully fetches TXs and balance for wallet
|
|
|
|
*/
|
|
|
|
refreshTransactions() {
|
2019-02-17 02:22:14 +01:00
|
|
|
if (this.state.isLoading) return;
|
2018-10-09 06:25:36 +02:00
|
|
|
this.setState(
|
|
|
|
{
|
2019-02-17 02:22:14 +01:00
|
|
|
showShowFlatListRefreshControl: true,
|
|
|
|
isLoading: true,
|
2018-10-09 06:25:36 +02:00
|
|
|
},
|
2019-02-17 02:22:14 +01:00
|
|
|
async () => {
|
|
|
|
let noErr = true;
|
|
|
|
let smthChanged = false;
|
|
|
|
try {
|
2019-07-13 17:21:03 +02:00
|
|
|
await BlueElectrum.ping();
|
|
|
|
await BlueElectrum.waitTillConnected();
|
2019-02-17 02:22:14 +01:00
|
|
|
/** @type {LegacyWallet} */
|
2020-06-01 14:54:23 +02:00
|
|
|
const wallet = this.state.wallet;
|
|
|
|
const balanceStart = +new Date();
|
2019-02-17 02:22:14 +01:00
|
|
|
const oldBalance = wallet.getBalance();
|
|
|
|
await wallet.fetchBalance();
|
|
|
|
if (oldBalance !== wallet.getBalance()) smthChanged = true;
|
2020-06-01 14:54:23 +02:00
|
|
|
const balanceEnd = +new Date();
|
2019-02-17 02:22:14 +01:00
|
|
|
console.log(wallet.getLabel(), 'fetch balance took', (balanceEnd - balanceStart) / 1000, 'sec');
|
2020-06-01 14:54:23 +02:00
|
|
|
const start = +new Date();
|
2019-02-17 02:22:14 +01:00
|
|
|
const oldTxLen = wallet.getTransactions().length;
|
|
|
|
await wallet.fetchTransactions();
|
|
|
|
if (wallet.fetchPendingTransactions) {
|
|
|
|
await wallet.fetchPendingTransactions();
|
2018-10-09 06:25:36 +02:00
|
|
|
}
|
2019-02-17 02:22:14 +01:00
|
|
|
if (wallet.fetchUserInvoices) {
|
|
|
|
await wallet.fetchUserInvoices();
|
2018-10-09 06:25:36 +02:00
|
|
|
}
|
2019-11-11 07:26:39 +01:00
|
|
|
if (oldTxLen !== wallet.getTransactions().length) smthChanged = true;
|
2020-06-01 14:54:23 +02:00
|
|
|
const end = +new Date();
|
2019-02-17 02:22:14 +01:00
|
|
|
console.log(wallet.getLabel(), 'fetch tx took', (end - start) / 1000, 'sec');
|
|
|
|
} catch (err) {
|
|
|
|
noErr = false;
|
2019-03-05 02:14:28 +01:00
|
|
|
alert(err.message);
|
2019-02-17 02:22:14 +01:00
|
|
|
this.setState({
|
|
|
|
isLoading: false,
|
|
|
|
showShowFlatListRefreshControl: false,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if (noErr && smthChanged) {
|
|
|
|
console.log('saving to disk');
|
|
|
|
await BlueApp.saveToDisk(); // caching
|
|
|
|
EV(EV.enum.TRANSACTIONS_COUNT_CHANGED); // let other components know they should redraw
|
|
|
|
}
|
|
|
|
this.redrawScreen();
|
2018-10-09 06:25:36 +02:00
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-11-01 20:44:39 +01:00
|
|
|
_keyExtractor = (_item, index) => index.toString();
|
2018-10-09 06:25:36 +02:00
|
|
|
|
2019-02-19 21:32:45 +01:00
|
|
|
renderListFooterComponent = () => {
|
|
|
|
// if not all txs rendered - display indicator
|
2020-05-24 11:17:26 +02:00
|
|
|
return (this.getTransactions(Infinity).length > this.state.limit && <ActivityIndicator style={styles.activityIndicator} />) || <View />;
|
2019-02-19 21:32:45 +01:00
|
|
|
};
|
|
|
|
|
2018-10-09 06:25:36 +02:00
|
|
|
renderListHeaderComponent = () => {
|
|
|
|
return (
|
2020-05-24 11:17:26 +02:00
|
|
|
<View style={styles.flex}>
|
|
|
|
<View style={styles.listHeader}>
|
2020-04-29 15:59:47 +02:00
|
|
|
{/*
|
2020-04-29 17:40:55 +02:00
|
|
|
Current logic - Onchain:
|
|
|
|
- Shows buy button on middle when empty
|
|
|
|
- Show buy button on top when not empty
|
|
|
|
- Shows Marketplace button on details screen, open in browser (iOS)
|
|
|
|
- Shows Marketplace button on details screen, open in in-app (android)
|
|
|
|
Current logic - Offchain:
|
|
|
|
- Shows Lapp Browser empty (iOS)
|
|
|
|
- Shows Lapp Browser with marketplace (android)
|
|
|
|
- Shows Marketplace button to open in browser (iOS)
|
|
|
|
|
|
|
|
The idea is to avoid showing on iOS an appstore/market style app that goes against the TOS.
|
2020-05-27 13:12:17 +02:00
|
|
|
|
2020-04-29 15:59:47 +02:00
|
|
|
*/}
|
2020-04-29 16:00:33 +02:00
|
|
|
{this.state.wallet.getTransactions().length > 0 &&
|
|
|
|
this.state.wallet.type !== LightningCustodianWallet.type &&
|
|
|
|
this.renderSellFiat()}
|
2020-04-16 13:41:12 +02:00
|
|
|
{this.state.wallet.type === LightningCustodianWallet.type && this.renderMarketplaceButton()}
|
2019-12-25 21:53:53 +01:00
|
|
|
{this.state.wallet.type === LightningCustodianWallet.type && Platform.OS === 'ios' && this.renderLappBrowserButton()}
|
|
|
|
</View>
|
2020-05-24 11:17:26 +02:00
|
|
|
<Text style={styles.listHeaderText}>{loc.transactions.list.title}</Text>
|
2018-10-09 06:25:36 +02:00
|
|
|
</View>
|
|
|
|
);
|
|
|
|
};
|
2019-09-29 22:01:27 +02:00
|
|
|
|
|
|
|
renderManageFundsModal = () => {
|
|
|
|
return (
|
|
|
|
<Modal
|
|
|
|
isVisible={this.state.isManageFundsModalVisible}
|
|
|
|
style={styles.bottomModal}
|
|
|
|
onBackdropPress={() => {
|
|
|
|
Keyboard.dismiss();
|
|
|
|
this.setState({ isManageFundsModalVisible: false });
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'position' : null}>
|
|
|
|
<View style={styles.advancedTransactionOptionsModalContent}>
|
|
|
|
<BlueListItem
|
|
|
|
hideChevron
|
|
|
|
component={TouchableOpacity}
|
|
|
|
onPress={a => {
|
|
|
|
const wallets = [...BlueApp.getWallets().filter(item => item.chain === Chain.ONCHAIN && item.allowSend())];
|
|
|
|
if (wallets.length === 0) {
|
|
|
|
alert('In order to proceed, please create a Bitcoin wallet to refill with.');
|
|
|
|
} else {
|
|
|
|
this.setState({ isManageFundsModalVisible: false });
|
2019-10-01 00:13:22 +02:00
|
|
|
this.props.navigation.navigate('SelectWallet', { onWalletSelect: this.onWalletSelect, chainType: Chain.ONCHAIN });
|
2019-09-29 22:01:27 +02:00
|
|
|
}
|
|
|
|
}}
|
2019-10-01 00:13:22 +02:00
|
|
|
title={loc.lnd.refill}
|
2019-09-29 22:01:27 +02:00
|
|
|
/>
|
|
|
|
<BlueListItem
|
|
|
|
hideChevron
|
|
|
|
component={TouchableOpacity}
|
|
|
|
onPress={a => {
|
2019-10-01 00:13:22 +02:00
|
|
|
this.setState({ isManageFundsModalVisible: false }, () =>
|
2019-09-29 22:01:27 +02:00
|
|
|
this.props.navigation.navigate('ReceiveDetails', {
|
|
|
|
secret: this.state.wallet.getSecret(),
|
2019-10-01 00:13:22 +02:00
|
|
|
}),
|
|
|
|
);
|
2019-09-29 22:01:27 +02:00
|
|
|
}}
|
2020-06-01 14:54:23 +02:00
|
|
|
title="Refill with External Wallet"
|
2019-09-29 22:01:27 +02:00
|
|
|
/>
|
|
|
|
|
2020-04-17 16:41:35 +02:00
|
|
|
<BlueListItem
|
|
|
|
hideChevron
|
|
|
|
component={TouchableOpacity}
|
|
|
|
onPress={a => {
|
|
|
|
this.setState({ isManageFundsModalVisible: false }, async () => {
|
|
|
|
this.props.navigation.navigate('BuyBitcoin', {
|
|
|
|
wallet: this.state.wallet,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}}
|
2020-06-01 14:54:23 +02:00
|
|
|
title="Refill with bank card"
|
2020-04-17 16:41:35 +02:00
|
|
|
/>
|
|
|
|
|
2019-09-29 22:01:27 +02:00
|
|
|
<BlueListItem
|
2020-06-16 17:08:25 +02:00
|
|
|
title={loc.lnd.exchange}
|
2019-09-29 22:01:27 +02:00
|
|
|
hideChevron
|
|
|
|
component={TouchableOpacity}
|
|
|
|
onPress={a => {
|
|
|
|
this.setState({ isManageFundsModalVisible: false });
|
|
|
|
Linking.openURL('https://zigzag.io/?utm_source=integration&utm_medium=bluewallet&utm_campaign=withdrawLink');
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</View>
|
|
|
|
</KeyboardAvoidingView>
|
|
|
|
</Modal>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2019-10-17 03:51:22 +02:00
|
|
|
renderMarketplaceButton = () => {
|
|
|
|
return Platform.select({
|
|
|
|
android: (
|
|
|
|
<TouchableOpacity
|
|
|
|
onPress={() => {
|
2020-04-29 17:40:55 +02:00
|
|
|
if (this.state.wallet.type === LightningCustodianWallet.type) {
|
|
|
|
this.props.navigation.navigate('LappBrowser', { fromSecret: this.state.wallet.getSecret(), fromWallet: this.state.wallet });
|
|
|
|
} else {
|
|
|
|
this.props.navigation.navigate('Marketplace', { fromWallet: this.state.wallet });
|
|
|
|
}
|
2019-10-17 03:51:22 +02:00
|
|
|
}}
|
2020-05-24 11:17:26 +02:00
|
|
|
style={styles.marketplaceButton1}
|
2019-10-17 03:51:22 +02:00
|
|
|
>
|
2020-05-24 11:17:26 +02:00
|
|
|
<Text style={styles.marketpalceText1}>marketplace</Text>
|
2019-10-17 03:51:22 +02:00
|
|
|
</TouchableOpacity>
|
|
|
|
),
|
|
|
|
ios:
|
|
|
|
this.state.wallet.getBalance() > 0 ? (
|
|
|
|
<TouchableOpacity
|
|
|
|
onPress={async () => {
|
2020-04-16 13:41:12 +02:00
|
|
|
Linking.openURL('https://bluewallet.io/marketplace/');
|
2019-10-17 03:51:22 +02:00
|
|
|
}}
|
2020-05-24 11:17:26 +02:00
|
|
|
style={styles.marketplaceButton1}
|
2019-10-17 03:51:22 +02:00
|
|
|
>
|
2019-10-17 04:08:09 +02:00
|
|
|
<Icon name="external-link" size={18} type="font-awesome" color="#9aa0aa" />
|
2020-05-24 11:17:26 +02:00
|
|
|
<Text style={styles.marketpalceText2}>marketplace</Text>
|
2019-10-17 03:51:22 +02:00
|
|
|
</TouchableOpacity>
|
|
|
|
) : null,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2019-10-21 13:52:38 +02:00
|
|
|
renderLappBrowserButton = () => {
|
|
|
|
return (
|
|
|
|
<TouchableOpacity
|
|
|
|
onPress={() => {
|
|
|
|
this.props.navigation.navigate('LappBrowser', {
|
|
|
|
fromSecret: this.state.wallet.getSecret(),
|
|
|
|
fromWallet: this.state.wallet,
|
2019-10-23 23:54:09 +02:00
|
|
|
url: 'https://duckduckgo.com',
|
2019-10-21 13:52:38 +02:00
|
|
|
});
|
|
|
|
}}
|
2020-05-24 11:17:26 +02:00
|
|
|
style={styles.marketplaceButton2}
|
2019-10-21 13:52:38 +02:00
|
|
|
>
|
2020-05-24 11:17:26 +02:00
|
|
|
<Text style={styles.marketpalceText1}>LApp Browser</Text>
|
2019-10-21 13:52:38 +02:00
|
|
|
</TouchableOpacity>
|
|
|
|
);
|
|
|
|
};
|
2020-06-01 14:54:23 +02:00
|
|
|
|
2020-04-16 15:43:53 +02:00
|
|
|
renderSellFiat = () => {
|
|
|
|
return (
|
|
|
|
<TouchableOpacity
|
|
|
|
onPress={() =>
|
|
|
|
this.props.navigation.navigate('BuyBitcoin', {
|
2020-04-29 14:37:09 +02:00
|
|
|
wallet: this.state.wallet,
|
2020-04-16 15:43:53 +02:00
|
|
|
})
|
|
|
|
}
|
2020-05-24 11:17:26 +02:00
|
|
|
style={styles.marketplaceButton2}
|
2020-04-16 15:43:53 +02:00
|
|
|
>
|
2020-05-24 11:17:26 +02:00
|
|
|
<Text style={styles.marketpalceText1}>{loc.wallets.list.tap_here_to_buy}</Text>
|
2020-04-16 15:43:53 +02:00
|
|
|
</TouchableOpacity>
|
|
|
|
);
|
|
|
|
};
|
2020-03-23 17:32:51 +01:00
|
|
|
|
2019-09-29 22:01:27 +02:00
|
|
|
onWalletSelect = async wallet => {
|
2019-11-03 01:25:55 +01:00
|
|
|
if (wallet) {
|
|
|
|
NavigationService.navigate('WalletTransactions', {
|
|
|
|
key: `WalletTransactions-${wallet.getID()}`,
|
|
|
|
});
|
|
|
|
/** @type {LightningCustodianWallet} */
|
|
|
|
let toAddress = false;
|
|
|
|
if (this.state.wallet.refill_addressess.length > 0) {
|
2019-09-29 22:01:27 +02:00
|
|
|
toAddress = this.state.wallet.refill_addressess[0];
|
2019-11-03 01:25:55 +01:00
|
|
|
} else {
|
|
|
|
try {
|
|
|
|
await this.state.wallet.fetchBtcAddress();
|
|
|
|
toAddress = this.state.wallet.refill_addressess[0];
|
|
|
|
} catch (Err) {
|
|
|
|
return alert(Err.message);
|
|
|
|
}
|
2019-09-29 22:01:27 +02:00
|
|
|
}
|
2020-05-27 13:12:17 +02:00
|
|
|
this.props.navigation.navigate('SendDetailsRoot', {
|
|
|
|
screen: 'SendDetails',
|
|
|
|
params: {
|
|
|
|
memo: loc.lnd.refill_lnd_balance,
|
|
|
|
address: toAddress,
|
|
|
|
fromWallet: wallet,
|
|
|
|
},
|
2019-09-29 22:01:27 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-05-31 11:18:38 +02:00
|
|
|
onFocus = () => {
|
|
|
|
this.redrawScreen();
|
|
|
|
this.props.navigation.setParams({ isLoading: false });
|
|
|
|
};
|
|
|
|
|
2018-12-28 02:32:48 +01:00
|
|
|
componentWillUnmount() {
|
2020-06-26 21:27:13 +02:00
|
|
|
clearInterval(this.interval);
|
2020-05-27 13:12:17 +02:00
|
|
|
this._unsubscribeFocus();
|
2018-12-28 02:32:48 +01:00
|
|
|
}
|
|
|
|
|
2020-01-01 04:31:04 +01:00
|
|
|
navigateToSendScreen = () => {
|
2020-05-27 13:12:17 +02:00
|
|
|
this.props.navigation.navigate('SendDetailsRoot', {
|
|
|
|
screen: 'SendDetails',
|
|
|
|
params: {
|
|
|
|
fromWallet: this.state.wallet,
|
|
|
|
},
|
2020-01-01 04:31:04 +01:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2020-06-26 21:27:13 +02:00
|
|
|
renderItem = item => (
|
|
|
|
<BlueTransactionListItem item={item.item} itemPriceUnit={this.state.itemPriceUnit} timeElapsed={this.state.timeElapsed} />
|
|
|
|
);
|
2018-12-27 07:12:19 +01:00
|
|
|
|
2020-04-03 05:53:53 +02:00
|
|
|
onBarCodeRead = ret => {
|
|
|
|
if (!this.state.isLoading) {
|
|
|
|
this.setState({ isLoading: true }, () => {
|
|
|
|
this.setState({ isLoading: false });
|
2020-05-27 13:12:17 +02:00
|
|
|
const params = {
|
2020-04-03 05:53:53 +02:00
|
|
|
fromSecret: this.state.wallet.getSecret(),
|
2020-04-29 16:27:07 +02:00
|
|
|
// ScanLndInvoice actrually uses `fromSecret` so keeping it for now
|
2020-04-03 05:53:53 +02:00
|
|
|
uri: ret.data ? ret.data : ret,
|
|
|
|
fromWallet: this.state.wallet,
|
2020-05-27 13:12:17 +02:00
|
|
|
};
|
|
|
|
if (this.state.wallet.chain === Chain.ONCHAIN) {
|
|
|
|
this.props.navigation.navigate('SendDetailsRoot', { screen: 'SendDetails', params });
|
|
|
|
} else {
|
|
|
|
this.props.navigation.navigate('ScanLndInvoiceRoot', { screen: 'ScanLndInvoice', params });
|
|
|
|
}
|
2020-04-03 05:53:53 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
choosePhoto = () => {
|
|
|
|
ImagePicker.launchImageLibrary(
|
|
|
|
{
|
|
|
|
title: null,
|
|
|
|
mediaType: 'photo',
|
|
|
|
takePhotoButtonTitle: null,
|
|
|
|
},
|
|
|
|
response => {
|
|
|
|
if (response.uri) {
|
|
|
|
const uri = Platform.OS === 'ios' ? response.uri.toString().replace('file://', '') : response.path.toString();
|
|
|
|
LocalQRCode.decode(uri, (error, result) => {
|
|
|
|
if (!error) {
|
|
|
|
this.onBarCodeRead({ data: result });
|
|
|
|
} else {
|
|
|
|
alert('The selected image does not contain a QR Code.');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2020-04-05 22:09:53 +02:00
|
|
|
copyFromClipbard = async () => {
|
|
|
|
this.onBarCodeRead({ data: await Clipboard.getString() });
|
|
|
|
};
|
|
|
|
|
2020-05-28 10:44:15 +02:00
|
|
|
sendButtonLongPress = async () => {
|
|
|
|
const isClipboardEmpty = (await Clipboard.getString()).replace(' ', '').length === 0;
|
2020-04-03 05:53:53 +02:00
|
|
|
if (Platform.OS === 'ios') {
|
2020-06-01 14:54:23 +02:00
|
|
|
const options = [loc.send.details.cancel, 'Choose Photo', 'Scan QR Code'];
|
2020-05-28 10:44:15 +02:00
|
|
|
if (!isClipboardEmpty) {
|
|
|
|
options.push('Copy from Clipboard');
|
|
|
|
}
|
|
|
|
ActionSheet.showActionSheetWithOptions({ options, cancelButtonIndex: 0 }, buttonIndex => {
|
|
|
|
if (buttonIndex === 1) {
|
|
|
|
this.choosePhoto();
|
|
|
|
} else if (buttonIndex === 2) {
|
|
|
|
this.props.navigation.navigate('ScanQRCode', {
|
|
|
|
launchedBy: this.props.route.name,
|
|
|
|
onBarScanned: this.onBarCodeRead,
|
|
|
|
showFileImportButton: false,
|
|
|
|
});
|
|
|
|
} else if (buttonIndex === 3) {
|
|
|
|
this.copyFromClipbard();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else if (Platform.OS === 'android') {
|
2020-06-01 14:54:23 +02:00
|
|
|
const buttons = [
|
2020-05-28 10:44:15 +02:00
|
|
|
{
|
|
|
|
text: loc.send.details.cancel,
|
|
|
|
onPress: () => {},
|
|
|
|
style: 'cancel',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: 'Choose Photo',
|
|
|
|
onPress: this.choosePhoto,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: 'Scan QR Code',
|
|
|
|
onPress: () =>
|
2020-04-03 05:53:53 +02:00
|
|
|
this.props.navigation.navigate('ScanQRCode', {
|
2020-05-27 13:12:17 +02:00
|
|
|
launchedBy: this.props.route.name,
|
2020-04-03 05:53:53 +02:00
|
|
|
onBarScanned: this.onBarCodeRead,
|
|
|
|
showFileImportButton: false,
|
2020-05-28 10:44:15 +02:00
|
|
|
}),
|
2020-04-03 05:53:53 +02:00
|
|
|
},
|
2020-05-28 10:44:15 +02:00
|
|
|
];
|
|
|
|
if (!isClipboardEmpty) {
|
|
|
|
buttons.push({
|
|
|
|
text: 'Copy From Clipboard',
|
|
|
|
onPress: this.copyFromClipbard,
|
|
|
|
});
|
|
|
|
}
|
2020-04-03 05:53:53 +02:00
|
|
|
ActionSheet.showActionSheetWithOptions({
|
|
|
|
title: '',
|
|
|
|
message: '',
|
2020-05-28 10:44:15 +02:00
|
|
|
buttons,
|
2020-04-03 05:53:53 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-10-09 06:25:36 +02:00
|
|
|
render() {
|
|
|
|
const { navigate } = this.props.navigation;
|
|
|
|
return (
|
2020-05-24 11:17:26 +02:00
|
|
|
<View style={styles.flex}>
|
2020-06-11 05:54:47 +02:00
|
|
|
<StatusBar barStyle="light-content" backgroundColor={WalletGradient.headerColorFor(this.props.route.params.wallet.type)} />
|
2020-03-29 04:06:45 +02:00
|
|
|
{this.state.wallet.chain === Chain.ONCHAIN && this.state.isHandOffUseEnabled && (
|
2019-08-14 05:12:42 +02:00
|
|
|
<Handoff
|
|
|
|
title={`Bitcoin Wallet ${this.state.wallet.getLabel()}`}
|
|
|
|
type="io.bluewallet.bluewallet"
|
|
|
|
url={`https://blockpath.com/search/addr?q=${this.state.wallet.getXpub()}`}
|
|
|
|
/>
|
|
|
|
)}
|
2019-08-04 08:42:05 +02:00
|
|
|
<BlueWalletNavigationHeader
|
|
|
|
wallet={this.state.wallet}
|
|
|
|
onWalletUnitChange={wallet =>
|
|
|
|
InteractionManager.runAfterInteractions(async () => {
|
2019-08-31 08:37:34 +02:00
|
|
|
this.setState({ wallet }, () => InteractionManager.runAfterInteractions(() => BlueApp.saveToDisk()));
|
2019-08-04 08:42:05 +02:00
|
|
|
})
|
|
|
|
}
|
2019-12-25 04:35:47 +01:00
|
|
|
onManageFundsPressed={() => {
|
|
|
|
if (this.state.wallet.getUserHasSavedExport()) {
|
|
|
|
this.setState({ isManageFundsModalVisible: true });
|
|
|
|
} else {
|
|
|
|
BlueAlertWalletExportReminder({
|
|
|
|
onSuccess: async () => {
|
|
|
|
this.state.wallet.setUserHasSavedExport(true);
|
|
|
|
await BlueApp.saveToDisk();
|
|
|
|
this.setState({ isManageFundsModalVisible: true });
|
|
|
|
},
|
|
|
|
onFailure: () =>
|
|
|
|
this.props.navigation.navigate('WalletExport', {
|
2020-03-12 18:26:05 +01:00
|
|
|
wallet: this.state.wallet,
|
2019-12-25 04:35:47 +01:00
|
|
|
}),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}}
|
2019-08-04 08:42:05 +02:00
|
|
|
/>
|
2020-05-24 11:17:26 +02:00
|
|
|
<View style={styles.list}>
|
2018-11-01 20:44:39 +01:00
|
|
|
<FlatList
|
2019-12-25 21:53:53 +01:00
|
|
|
ListHeaderComponent={this.renderListHeaderComponent}
|
2019-02-19 00:37:53 +01:00
|
|
|
onEndReachedThreshold={0.3}
|
2019-12-25 21:53:53 +01:00
|
|
|
onEndReached={async () => {
|
2019-02-19 00:37:53 +01:00
|
|
|
// pagination in works. in this block we will add more txs to flatlist
|
|
|
|
// so as user scrolls closer to bottom it will render mode transactions
|
|
|
|
|
|
|
|
if (this.getTransactions(Infinity).length < this.state.limit) {
|
2019-02-19 21:32:45 +01:00
|
|
|
// all list rendered. nop
|
2019-02-19 00:37:53 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
dataSource: this.getTransactions(this.state.limit + this.state.pageSize),
|
|
|
|
limit: this.state.limit + this.state.pageSize,
|
|
|
|
pageSize: this.state.pageSize * 2,
|
|
|
|
});
|
|
|
|
}}
|
2019-02-19 21:32:45 +01:00
|
|
|
ListFooterComponent={this.renderListFooterComponent}
|
2018-11-01 20:44:39 +01:00
|
|
|
ListEmptyComponent={
|
2020-05-24 11:17:26 +02:00
|
|
|
<ScrollView style={styles.flex} contentContainerStyle={styles.scrollViewContent}>
|
|
|
|
<Text numberOfLines={0} style={styles.emptyTxs}>
|
2019-03-30 20:32:58 +01:00
|
|
|
{(this.isLightning() && loc.wallets.list.empty_txs1_lightning) || loc.wallets.list.empty_txs1}
|
2018-11-01 20:44:39 +01:00
|
|
|
</Text>
|
2020-05-24 11:17:26 +02:00
|
|
|
{this.isLightning() && <Text style={styles.emptyTxsLightning}>{loc.wallets.list.empty_txs2_lightning}</Text>}
|
2020-04-16 15:43:53 +02:00
|
|
|
|
|
|
|
{!this.isLightning() && (
|
|
|
|
<TouchableOpacity
|
2018-11-01 20:44:39 +01:00
|
|
|
onPress={() =>
|
|
|
|
this.props.navigation.navigate('BuyBitcoin', {
|
2020-04-17 16:41:35 +02:00
|
|
|
wallet: this.state.wallet,
|
2018-11-01 20:44:39 +01:00
|
|
|
})
|
|
|
|
}
|
2020-05-24 11:17:26 +02:00
|
|
|
style={styles.buyBitcoin}
|
2018-10-10 21:36:32 +02:00
|
|
|
>
|
2020-05-24 11:17:26 +02:00
|
|
|
<Text style={styles.buyBitcoinText}>{loc.wallets.list.tap_here_to_buy}</Text>
|
2020-04-16 15:43:53 +02:00
|
|
|
</TouchableOpacity>
|
2018-11-01 20:44:39 +01:00
|
|
|
)}
|
2019-08-31 08:27:43 +02:00
|
|
|
</ScrollView>
|
2018-11-01 20:44:39 +01:00
|
|
|
}
|
2019-02-17 02:22:14 +01:00
|
|
|
refreshControl={
|
|
|
|
<RefreshControl onRefresh={() => this.refreshTransactions()} refreshing={this.state.showShowFlatListRefreshControl} />
|
|
|
|
}
|
2018-11-01 20:44:39 +01:00
|
|
|
data={this.state.dataSource}
|
2020-06-26 21:27:13 +02:00
|
|
|
extraData={this.state.timeElapsed}
|
2018-11-01 20:44:39 +01:00
|
|
|
keyExtractor={this._keyExtractor}
|
2019-01-30 03:13:45 +01:00
|
|
|
renderItem={this.renderItem}
|
2019-08-31 08:27:43 +02:00
|
|
|
contentInset={{ top: 0, left: 0, bottom: 90, right: 0 }}
|
2018-11-01 20:44:39 +01:00
|
|
|
/>
|
2019-09-29 22:01:27 +02:00
|
|
|
{this.renderManageFundsModal()}
|
2018-10-09 06:25:36 +02:00
|
|
|
</View>
|
2020-05-24 11:17:26 +02:00
|
|
|
<View style={styles.floatButtons}>
|
2018-10-09 06:25:36 +02:00
|
|
|
{(() => {
|
2019-02-19 01:37:34 +01:00
|
|
|
if (this.state.wallet.allowReceive()) {
|
2018-10-09 06:25:36 +02:00
|
|
|
return (
|
|
|
|
<BlueReceiveButtonIcon
|
|
|
|
onPress={() => {
|
2019-12-25 21:53:53 +01:00
|
|
|
if (this.state.wallet.chain === Chain.OFFCHAIN) {
|
2020-05-27 13:12:17 +02:00
|
|
|
navigate('LNDCreateInvoiceRoot', { screen: 'LNDCreateInvoice', params: { fromWallet: this.state.wallet } });
|
2018-12-25 17:34:51 +01:00
|
|
|
} else {
|
2019-09-27 16:49:56 +02:00
|
|
|
navigate('ReceiveDetails', { secret: this.state.wallet.getSecret() });
|
2018-10-09 06:25:36 +02:00
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
})()}
|
|
|
|
|
|
|
|
{(() => {
|
2020-01-01 04:31:04 +01:00
|
|
|
if (
|
|
|
|
this.state.wallet.allowSend() ||
|
2020-02-26 15:39:19 +01:00
|
|
|
(this.state.wallet.type === WatchOnlyWallet.type &&
|
|
|
|
this.state.wallet.isHd() &&
|
|
|
|
this.state.wallet.getSecret().startsWith('zpub'))
|
2020-01-01 04:31:04 +01:00
|
|
|
) {
|
2018-10-09 06:25:36 +02:00
|
|
|
return (
|
|
|
|
<BlueSendButtonIcon
|
2020-04-03 05:53:53 +02:00
|
|
|
onLongPress={this.sendButtonLongPress}
|
2018-10-09 06:25:36 +02:00
|
|
|
onPress={() => {
|
2019-12-25 21:53:53 +01:00
|
|
|
if (this.state.wallet.chain === Chain.OFFCHAIN) {
|
2020-05-27 13:12:17 +02:00
|
|
|
navigate('ScanLndInvoiceRoot', { screen: 'ScanLndInvoice', params: { fromSecret: this.state.wallet.getSecret() } });
|
2018-10-09 06:25:36 +02:00
|
|
|
} else {
|
2020-01-01 04:31:04 +01:00
|
|
|
if (
|
2020-02-26 15:39:19 +01:00
|
|
|
this.state.wallet.type === WatchOnlyWallet.type &&
|
|
|
|
this.state.wallet.isHd() &&
|
|
|
|
this.state.wallet.getSecret().startsWith('zpub')
|
2020-01-01 04:31:04 +01:00
|
|
|
) {
|
2020-02-26 15:39:19 +01:00
|
|
|
if (this.state.wallet.useWithHardwareWalletEnabled()) {
|
2020-01-01 04:31:04 +01:00
|
|
|
this.navigateToSendScreen();
|
|
|
|
} else {
|
|
|
|
Alert.alert(
|
|
|
|
'Wallet',
|
|
|
|
'This wallet is not being used in conjunction with a hardwarde wallet. Would you like to enable hardware wallet use?',
|
|
|
|
[
|
|
|
|
{
|
|
|
|
text: loc._.ok,
|
2020-01-05 02:03:02 +01:00
|
|
|
onPress: () => {
|
|
|
|
const wallet = this.state.wallet;
|
2020-02-26 15:39:19 +01:00
|
|
|
wallet.setUseWithHardwareWalletEnabled(true);
|
2020-01-05 02:03:02 +01:00
|
|
|
this.setState({ wallet }, async () => {
|
|
|
|
await BlueApp.saveToDisk();
|
|
|
|
this.navigateToSendScreen();
|
2020-02-24 22:45:14 +01:00
|
|
|
});
|
2020-01-01 04:31:04 +01:00
|
|
|
},
|
|
|
|
style: 'default',
|
|
|
|
},
|
|
|
|
|
|
|
|
{ text: loc.send.details.cancel, onPress: () => {}, style: 'cancel' },
|
|
|
|
],
|
|
|
|
{ cancelable: false },
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this.navigateToSendScreen();
|
|
|
|
}
|
2018-10-09 06:25:36 +02:00
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
})()}
|
|
|
|
</View>
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
WalletTransactions.propTypes = {
|
|
|
|
navigation: PropTypes.shape({
|
|
|
|
navigate: PropTypes.func,
|
|
|
|
goBack: PropTypes.func,
|
|
|
|
setParams: PropTypes.func,
|
2020-05-27 13:12:17 +02:00
|
|
|
addListener: PropTypes.func,
|
|
|
|
}),
|
|
|
|
route: PropTypes.shape({
|
|
|
|
name: PropTypes.string,
|
|
|
|
params: PropTypes.object,
|
2018-10-09 06:25:36 +02:00
|
|
|
}),
|
2019-08-14 05:12:42 +02:00
|
|
|
};
|