2018-10-09 06:25:36 +02:00
|
|
|
import React, { Component } from 'react';
|
2018-12-28 01:44:41 +01:00
|
|
|
import { Text, View, Image, FlatList, RefreshControl, TouchableOpacity, StatusBar } from 'react-native';
|
2018-12-11 23:52:46 +01:00
|
|
|
import LinearGradient from 'react-native-linear-gradient';
|
2018-10-09 06:25:36 +02:00
|
|
|
import PropTypes from 'prop-types';
|
2018-12-11 23:52:46 +01:00
|
|
|
import { NavigationEvents } from 'react-navigation';
|
2018-10-09 06:25:36 +02:00
|
|
|
import {
|
|
|
|
BlueText,
|
|
|
|
BlueTransactionOnchainIcon,
|
|
|
|
ManageFundsBigButton,
|
2018-12-28 22:43:38 +01:00
|
|
|
BlueTransactionExpiredIcon,
|
2018-10-09 06:25:36 +02:00
|
|
|
BlueTransactionIncommingIcon,
|
|
|
|
BlueTransactionOutgoingIcon,
|
|
|
|
BlueTransactionPendingIcon,
|
|
|
|
BlueTransactionOffchainIcon,
|
|
|
|
BlueSendButtonIcon,
|
|
|
|
BlueReceiveButtonIcon,
|
|
|
|
BlueListItem,
|
2018-12-25 20:07:43 +01:00
|
|
|
BlueTransactionOffchainIncomingIcon,
|
2018-10-09 06:25:36 +02:00
|
|
|
} from '../../BlueComponents';
|
|
|
|
import { Icon } from 'react-native-elements';
|
2018-10-20 23:10:21 +02:00
|
|
|
import { BitcoinUnit } from '../../models/bitcoinUnits';
|
2018-12-22 04:23:52 +01:00
|
|
|
import { LightningCustodianWallet } from '../../class';
|
2018-10-09 06:25:36 +02:00
|
|
|
/** @type {AppStorage} */
|
|
|
|
let BlueApp = require('../../BlueApp');
|
|
|
|
let loc = require('../../loc');
|
|
|
|
let EV = require('../../events');
|
|
|
|
|
|
|
|
export default class WalletTransactions extends Component {
|
|
|
|
static navigationOptions = ({ navigation }) => {
|
|
|
|
return {
|
|
|
|
headerRight: (
|
2018-11-02 14:53:35 +01:00
|
|
|
<TouchableOpacity
|
2018-12-22 06:26:52 +01:00
|
|
|
style={{ marginHorizontal: 8, minWidth: 150 }}
|
2018-10-09 06:25:36 +02:00
|
|
|
onPress={() =>
|
|
|
|
navigation.navigate('WalletDetails', {
|
2019-01-07 05:54:22 +01:00
|
|
|
wallet: navigation.state.params.wallet,
|
2018-10-09 06:25:36 +02:00
|
|
|
})
|
|
|
|
}
|
2018-11-02 14:53:35 +01:00
|
|
|
>
|
2018-12-22 06:26:52 +01:00
|
|
|
<Text style={{ color: '#fff', fontSize: 20, fontWeight: '500', textAlign: 'right' }}>{loc.wallets.options}</Text>
|
2018-11-02 14:53:35 +01:00
|
|
|
</TouchableOpacity>
|
2018-10-09 06:25:36 +02:00
|
|
|
),
|
|
|
|
headerStyle: {
|
2018-12-18 07:01:51 +01:00
|
|
|
backgroundColor: navigation.getParam('gradients')[0] || '#65ceef',
|
2018-10-09 06:25:36 +02:00
|
|
|
borderBottomWidth: 0,
|
2018-11-02 14:53:35 +01:00
|
|
|
elevation: 0,
|
|
|
|
shadowRadius: 0,
|
2018-10-09 06:25:36 +02:00
|
|
|
},
|
|
|
|
headerTintColor: '#FFFFFF',
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
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
|
|
|
|
EV(EV.enum.REMOTE_TRANSACTIONS_COUNT_CHANGED, this.refreshTransactionsFunction.bind(this));
|
|
|
|
const wallet = props.navigation.getParam('wallet');
|
|
|
|
this.props.navigation.setParams({ wallet: wallet });
|
2018-10-09 06:25:36 +02:00
|
|
|
this.state = {
|
|
|
|
isLoading: true,
|
|
|
|
isTransactionsLoading: false,
|
2018-12-11 23:52:46 +01:00
|
|
|
wallet: wallet,
|
|
|
|
dataSource: wallet.getTransactions(),
|
2018-12-22 04:23:52 +01:00
|
|
|
walletPreviousPreferredUnit: wallet.getPreferredBalanceUnit(),
|
2018-10-09 06:25:36 +02:00
|
|
|
};
|
2018-12-11 23:52:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
this.refreshFunction();
|
2018-10-09 06:25:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Forcefully fetches TXs and balance for wallet
|
|
|
|
*/
|
|
|
|
refreshTransactionsFunction() {
|
|
|
|
let that = this;
|
|
|
|
setTimeout(function() {
|
|
|
|
that.refreshTransactions();
|
|
|
|
}, 4000); // giving a chance to remote server to propagate
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Redraws the screen
|
|
|
|
*/
|
|
|
|
refreshFunction() {
|
|
|
|
setTimeout(() => {
|
|
|
|
console.log('wallets/transactions refreshFunction()');
|
|
|
|
let showSend = false;
|
|
|
|
let showReceive = false;
|
|
|
|
const wallet = this.state.wallet;
|
|
|
|
if (wallet) {
|
|
|
|
showSend = wallet.allowSend();
|
|
|
|
showReceive = wallet.allowReceive();
|
|
|
|
}
|
|
|
|
let showManageFundsBigButton = false;
|
|
|
|
let showManageFundsSmallButton = false;
|
2019-01-12 04:54:53 +01:00
|
|
|
if (wallet && wallet.type === LightningCustodianWallet.type && wallet.getBalance() * 1 <= 0) {
|
2018-10-09 06:25:36 +02:00
|
|
|
showManageFundsBigButton = true;
|
|
|
|
showManageFundsSmallButton = false;
|
2018-12-28 16:52:06 +01:00
|
|
|
} else if (wallet && wallet.type === LightningCustodianWallet.type && wallet.getBalance() > 0) {
|
2018-10-09 06:25:36 +02:00
|
|
|
showManageFundsSmallButton = true;
|
|
|
|
showManageFundsBigButton = false;
|
|
|
|
}
|
|
|
|
|
2018-12-11 23:52:46 +01:00
|
|
|
let txs = wallet.getTransactions();
|
|
|
|
for (let tx of txs) {
|
|
|
|
tx.sort_ts = +new Date(tx.received);
|
|
|
|
}
|
|
|
|
txs = txs.sort(function(a, b) {
|
|
|
|
return b.sort_ts - a.sort_ts;
|
|
|
|
});
|
|
|
|
|
2018-10-09 06:25:36 +02:00
|
|
|
this.setState({
|
|
|
|
isLoading: false,
|
|
|
|
isTransactionsLoading: false,
|
|
|
|
showReceiveButton: showReceive,
|
|
|
|
showSendButton: showSend,
|
|
|
|
showManageFundsBigButton,
|
|
|
|
showManageFundsSmallButton,
|
2018-12-11 23:52:46 +01:00
|
|
|
dataSource: txs,
|
2018-10-09 06:25:36 +02:00
|
|
|
});
|
|
|
|
}, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
isLightning() {
|
|
|
|
let w = this.state.wallet;
|
2018-12-28 16:52:06 +01:00
|
|
|
if (w && w.type === LightningCustodianWallet.type) {
|
2018-10-09 06:25:36 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Forcefully fetches TXs and balance for wallet
|
|
|
|
*/
|
|
|
|
refreshTransactions() {
|
|
|
|
this.setState(
|
|
|
|
{
|
|
|
|
isTransactionsLoading: true,
|
|
|
|
},
|
|
|
|
async function() {
|
|
|
|
let that = this;
|
|
|
|
setTimeout(async function() {
|
|
|
|
// more responsive
|
|
|
|
let noErr = true;
|
|
|
|
try {
|
|
|
|
/** @type {LegacyWallet} */
|
|
|
|
let wallet = that.state.wallet;
|
|
|
|
await wallet.fetchBalance();
|
|
|
|
let start = +new Date();
|
|
|
|
await wallet.fetchTransactions();
|
2018-12-11 23:52:46 +01:00
|
|
|
if (wallet.fetchPendingTransactions) {
|
|
|
|
await wallet.fetchPendingTransactions();
|
|
|
|
}
|
2018-12-25 20:07:43 +01:00
|
|
|
if (wallet.fetchUserInvoices) {
|
|
|
|
await wallet.fetchUserInvoices();
|
|
|
|
}
|
2018-10-09 06:25:36 +02:00
|
|
|
let end = +new Date();
|
|
|
|
console.log(wallet.getLabel(), 'fetch tx took', (end - start) / 1000, 'sec');
|
|
|
|
} catch (err) {
|
|
|
|
noErr = false;
|
|
|
|
console.warn(err);
|
|
|
|
}
|
|
|
|
if (noErr) {
|
|
|
|
await BlueApp.saveToDisk(); // caching
|
|
|
|
EV(EV.enum.TRANSACTIONS_COUNT_CHANGED); // let other components know they should redraw
|
|
|
|
}
|
|
|
|
|
|
|
|
that.refreshFunction(); // Redraws the screen
|
|
|
|
}, 1);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-10-20 23:10:21 +02:00
|
|
|
changeWalletBalanceUnit() {
|
2018-12-22 04:23:52 +01:00
|
|
|
let walletPreviousPreferredUnit = this.state.wallet.getPreferredBalanceUnit();
|
|
|
|
const wallet = this.state.wallet;
|
|
|
|
if (walletPreviousPreferredUnit === BitcoinUnit.BTC) {
|
|
|
|
wallet.preferredBalanceUnit = BitcoinUnit.SATS;
|
|
|
|
walletPreviousPreferredUnit = BitcoinUnit.BTC;
|
|
|
|
} else if (walletPreviousPreferredUnit === BitcoinUnit.SATS) {
|
|
|
|
wallet.preferredBalanceUnit = BitcoinUnit.LOCAL_CURRENCY;
|
|
|
|
walletPreviousPreferredUnit = BitcoinUnit.SATS;
|
|
|
|
} else if (walletPreviousPreferredUnit === BitcoinUnit.LOCAL_CURRENCY) {
|
|
|
|
wallet.preferredBalanceUnit = BitcoinUnit.BTC;
|
2018-12-22 04:43:49 +01:00
|
|
|
walletPreviousPreferredUnit = BitcoinUnit.BTC;
|
2018-12-20 04:03:15 +01:00
|
|
|
} else {
|
2018-12-22 04:23:52 +01:00
|
|
|
wallet.preferredBalanceUnit = BitcoinUnit.BTC;
|
|
|
|
walletPreviousPreferredUnit = BitcoinUnit.BTC;
|
2018-10-20 23:10:21 +02:00
|
|
|
}
|
2018-12-22 04:23:52 +01:00
|
|
|
|
2018-12-23 14:05:33 +01:00
|
|
|
this.setState({ wallet: wallet, walletPreviousPreferredUnit: walletPreviousPreferredUnit });
|
2018-10-20 23:10:21 +02:00
|
|
|
}
|
|
|
|
|
2018-10-09 06:25:36 +02:00
|
|
|
renderWalletHeader = () => {
|
2018-12-18 07:01:51 +01:00
|
|
|
const gradients = this.props.navigation.getParam('gradients') || ['#65ceef', '#68bbe1'];
|
2018-10-09 06:25:36 +02:00
|
|
|
return (
|
2018-12-11 23:52:46 +01:00
|
|
|
<LinearGradient colors={[gradients[0], gradients[1]]} style={{ padding: 15, minHeight: 164 }}>
|
2018-10-09 06:25:36 +02:00
|
|
|
<Image
|
|
|
|
source={
|
2018-12-28 16:52:06 +01:00
|
|
|
(LightningCustodianWallet.type === this.state.wallet.type && require('../../img/lnd-shape.png')) ||
|
2018-10-09 06:25:36 +02:00
|
|
|
require('../../img/btc-shape.png')
|
|
|
|
}
|
|
|
|
style={{
|
|
|
|
width: 99,
|
|
|
|
height: 94,
|
|
|
|
position: 'absolute',
|
|
|
|
bottom: 0,
|
|
|
|
right: 0,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
|
|
|
|
<Text style={{ backgroundColor: 'transparent' }} />
|
|
|
|
<Text
|
|
|
|
numberOfLines={1}
|
|
|
|
style={{
|
|
|
|
backgroundColor: 'transparent',
|
|
|
|
fontSize: 19,
|
|
|
|
color: '#fff',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{this.state.wallet.getLabel()}
|
|
|
|
</Text>
|
2018-10-20 23:10:21 +02:00
|
|
|
<TouchableOpacity onPress={() => this.changeWalletBalanceUnit()}>
|
|
|
|
<Text
|
|
|
|
numberOfLines={1}
|
|
|
|
adjustsFontSizeToFit
|
|
|
|
style={{
|
|
|
|
backgroundColor: 'transparent',
|
|
|
|
fontWeight: 'bold',
|
|
|
|
fontSize: 36,
|
|
|
|
color: '#fff',
|
|
|
|
}}
|
|
|
|
>
|
2019-01-06 22:23:14 +01:00
|
|
|
{loc.formatBalance(this.state.wallet.getBalance(), this.state.wallet.getPreferredBalanceUnit(), true).toString()}
|
2018-10-20 23:10:21 +02:00
|
|
|
</Text>
|
|
|
|
</TouchableOpacity>
|
2018-10-09 06:25:36 +02:00
|
|
|
<Text style={{ backgroundColor: 'transparent' }} />
|
|
|
|
<Text
|
|
|
|
numberOfLines={1}
|
|
|
|
style={{
|
|
|
|
backgroundColor: 'transparent',
|
|
|
|
fontSize: 13,
|
|
|
|
color: '#fff',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{loc.wallets.list.latest_transaction}
|
|
|
|
</Text>
|
|
|
|
<Text
|
|
|
|
numberOfLines={1}
|
|
|
|
style={{
|
|
|
|
backgroundColor: 'transparent',
|
|
|
|
fontWeight: 'bold',
|
|
|
|
fontSize: 16,
|
|
|
|
color: '#fff',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{loc.transactionTimeToReadable(this.state.wallet.getLatestTransactionTime())}
|
|
|
|
</Text>
|
|
|
|
</LinearGradient>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
txMemo(hash) {
|
|
|
|
if (BlueApp.tx_metadata[hash] && BlueApp.tx_metadata[hash]['memo']) {
|
|
|
|
return BlueApp.tx_metadata[hash]['memo'];
|
|
|
|
}
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
2018-11-01 20:44:39 +01:00
|
|
|
_keyExtractor = (_item, index) => index.toString();
|
2018-10-09 06:25:36 +02:00
|
|
|
|
|
|
|
renderListHeaderComponent = () => {
|
|
|
|
return (
|
|
|
|
<View style={{ flexDirection: 'row', height: 50 }}>
|
|
|
|
<Text
|
|
|
|
style={{
|
|
|
|
paddingLeft: 15,
|
|
|
|
paddingTop: 15,
|
|
|
|
fontWeight: 'bold',
|
|
|
|
fontSize: 24,
|
|
|
|
color: BlueApp.settings.foregroundColor,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{loc.transactions.list.title}
|
|
|
|
</Text>
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2018-12-23 14:05:33 +01:00
|
|
|
async onWillBlur() {
|
2018-12-28 01:44:41 +01:00
|
|
|
StatusBar.setBarStyle('dark-content');
|
2018-12-23 14:05:33 +01:00
|
|
|
await BlueApp.saveToDisk();
|
|
|
|
}
|
|
|
|
|
2018-12-28 02:32:48 +01:00
|
|
|
componentWillUnmount() {
|
|
|
|
this.onWillBlur();
|
|
|
|
}
|
|
|
|
|
2018-12-27 07:12:19 +01:00
|
|
|
rowTitle = item => {
|
|
|
|
if (item.type === 'user_invoice' || item.type === 'payment_request') {
|
2019-01-06 10:44:08 +01:00
|
|
|
if (isNaN(item.value)) {
|
2019-01-06 17:48:58 +01:00
|
|
|
item.value = 0;
|
2019-01-06 10:44:08 +01:00
|
|
|
}
|
2018-12-27 07:12:19 +01:00
|
|
|
const currentDate = new Date();
|
|
|
|
const now = (currentDate.getTime() / 1000) | 0;
|
|
|
|
const invoiceExpiration = item.timestamp + item.expire_time;
|
2019-01-06 17:48:58 +01:00
|
|
|
|
2018-12-27 07:12:19 +01:00
|
|
|
if (invoiceExpiration > now) {
|
2019-01-06 20:34:01 +01:00
|
|
|
return loc.formatBalanceWithoutSuffix(item.value && item.value, this.state.wallet.getPreferredBalanceUnit(), true).toString();
|
2018-12-27 07:12:19 +01:00
|
|
|
} else if (invoiceExpiration < now) {
|
|
|
|
if (item.ispaid) {
|
2019-01-06 20:34:01 +01:00
|
|
|
return loc.formatBalanceWithoutSuffix(item.value && item.value, this.state.wallet.getPreferredBalanceUnit(), true).toString();
|
2018-12-27 07:12:19 +01:00
|
|
|
} else {
|
|
|
|
return loc.lnd.expired;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2019-01-06 20:34:01 +01:00
|
|
|
return loc.formatBalanceWithoutSuffix(item.value && item.value, this.state.wallet.getPreferredBalanceUnit(), true).toString();
|
2018-12-27 07:12:19 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
rowTitleStyle = item => {
|
|
|
|
let color = '#37c0a1';
|
|
|
|
|
|
|
|
if (item.type === 'user_invoice' || item.type === 'payment_request') {
|
|
|
|
const currentDate = new Date();
|
|
|
|
const now = (currentDate.getTime() / 1000) | 0;
|
|
|
|
const invoiceExpiration = item.timestamp + item.expire_time;
|
|
|
|
|
|
|
|
if (invoiceExpiration > now) {
|
|
|
|
color = '#37c0a1';
|
|
|
|
} else if (invoiceExpiration < now) {
|
|
|
|
if (item.ispaid) {
|
|
|
|
color = '#37c0a1';
|
|
|
|
} else {
|
|
|
|
color = '#FF0000';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (item.value / 100000000 < 0) {
|
|
|
|
color = BlueApp.settings.foregroundColor;
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
fontWeight: '600',
|
|
|
|
fontSize: 16,
|
|
|
|
color: color,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2018-10-09 06:25:36 +02:00
|
|
|
render() {
|
|
|
|
const { navigate } = this.props.navigation;
|
|
|
|
return (
|
|
|
|
<View style={{ flex: 1 }}>
|
2018-12-12 04:33:28 +01:00
|
|
|
<NavigationEvents
|
|
|
|
onWillFocus={() => {
|
2018-12-28 01:44:41 +01:00
|
|
|
StatusBar.setBarStyle('light-content');
|
2018-12-12 04:33:28 +01:00
|
|
|
this.refreshFunction();
|
|
|
|
}}
|
2018-12-23 14:05:33 +01:00
|
|
|
onWillBlur={() => this.onWillBlur()}
|
2018-12-12 04:33:28 +01:00
|
|
|
/>
|
2018-10-09 06:25:36 +02:00
|
|
|
{this.renderWalletHeader()}
|
|
|
|
<View style={{ flex: 1, backgroundColor: '#FFFFFF' }}>
|
|
|
|
{(() => {
|
|
|
|
if (this.state.showManageFundsSmallButton) {
|
|
|
|
return (
|
2019-01-12 01:23:32 +01:00
|
|
|
<React.Fragment>
|
|
|
|
<TouchableOpacity
|
|
|
|
style={{ alignSelf: 'flex-start', left: 10, top: 15, flexDirection: 'row' }}
|
|
|
|
onPress={() => {
|
|
|
|
console.log('navigating to LappBrowser');
|
|
|
|
navigate('LappBrowser', { fromSecret: this.state.wallet.getSecret() });
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<BlueText style={{ fontWeight: '600', fontSize: 16 }}>{'marketplace'}</BlueText>
|
|
|
|
<Icon
|
|
|
|
style={{ position: 'relative' }}
|
|
|
|
name="shopping-cart"
|
|
|
|
type="font-awesome"
|
|
|
|
size={14}
|
|
|
|
color={BlueApp.settings.foregroundColor}
|
|
|
|
iconStyle={{ left: 5 }}
|
|
|
|
/>
|
|
|
|
</TouchableOpacity>
|
|
|
|
|
|
|
|
<TouchableOpacity
|
|
|
|
style={{ alignSelf: 'flex-end', right: 10, top: -5, flexDirection: 'row' }}
|
|
|
|
onPress={() => {
|
|
|
|
console.log('navigating to', this.state.wallet.getLabel());
|
2019-01-12 03:08:03 +01:00
|
|
|
navigate('ManageFunds', { fromWallet: this.state.wallet });
|
2019-01-12 01:23:32 +01:00
|
|
|
}}
|
|
|
|
>
|
|
|
|
<BlueText style={{ fontWeight: '600', fontSize: 16 }}>{loc.lnd.title}</BlueText>
|
|
|
|
<Icon
|
|
|
|
style={{ position: 'relative' }}
|
|
|
|
name="link"
|
|
|
|
type="font-awesome"
|
|
|
|
size={14}
|
|
|
|
color={BlueApp.settings.foregroundColor}
|
|
|
|
iconStyle={{ left: 5, transform: [{ rotate: '90deg' }] }}
|
|
|
|
/>
|
|
|
|
</TouchableOpacity>
|
|
|
|
</React.Fragment>
|
2018-10-09 06:25:36 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
})()}
|
2018-11-01 20:44:39 +01:00
|
|
|
<FlatList
|
|
|
|
ListHeaderComponent={this.renderListHeaderComponent}
|
|
|
|
ListEmptyComponent={
|
2018-12-11 23:52:46 +01:00
|
|
|
<View style={{ top: 50, minHeight: 200 }}>
|
2018-11-01 20:44:39 +01:00
|
|
|
<Text
|
|
|
|
style={{
|
|
|
|
fontSize: 18,
|
|
|
|
color: '#9aa0aa',
|
|
|
|
textAlign: 'center',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{(this.isLightning() &&
|
|
|
|
'Lightning wallet should be used for your daily\ntransactions. Fees are unfairly cheap and\nspeed is blazing fast.') ||
|
|
|
|
loc.wallets.list.empty_txs1}
|
|
|
|
</Text>
|
|
|
|
<Text
|
|
|
|
style={{
|
|
|
|
fontSize: 18,
|
|
|
|
color: '#9aa0aa',
|
|
|
|
textAlign: 'center',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{(this.isLightning() && '\nTo start using it tap on "manage funds"\nand topup your balance') ||
|
|
|
|
loc.wallets.list.empty_txs2}
|
|
|
|
</Text>
|
|
|
|
|
|
|
|
<Text />
|
|
|
|
<Text />
|
|
|
|
|
|
|
|
{!this.isLightning() && (
|
2018-10-10 21:36:32 +02:00
|
|
|
<Text
|
|
|
|
style={{
|
|
|
|
fontSize: 18,
|
|
|
|
color: '#9aa0aa',
|
|
|
|
textAlign: 'center',
|
2018-11-01 20:44:39 +01:00
|
|
|
textDecorationLine: 'underline',
|
2018-10-10 21:36:32 +02:00
|
|
|
}}
|
2018-11-01 20:44:39 +01:00
|
|
|
onPress={() =>
|
|
|
|
this.props.navigation.navigate('BuyBitcoin', {
|
|
|
|
address: this.state.wallet.getAddress(),
|
|
|
|
secret: this.state.wallet.getSecret(),
|
|
|
|
})
|
|
|
|
}
|
2018-10-10 21:36:32 +02:00
|
|
|
>
|
2018-11-01 20:44:39 +01:00
|
|
|
{loc.wallets.list.tap_here_to_buy}
|
2018-10-10 21:36:32 +02:00
|
|
|
</Text>
|
2018-11-01 20:44:39 +01:00
|
|
|
)}
|
|
|
|
</View>
|
|
|
|
}
|
|
|
|
refreshControl={<RefreshControl onRefresh={() => this.refreshTransactions()} refreshing={this.state.isTransactionsLoading} />}
|
|
|
|
data={this.state.dataSource}
|
|
|
|
keyExtractor={this._keyExtractor}
|
|
|
|
renderItem={rowData => {
|
|
|
|
return (
|
|
|
|
<BlueListItem
|
|
|
|
avatar={(() => {
|
|
|
|
// is it lightning refill tx?
|
|
|
|
if (rowData.item.category === 'receive' && rowData.item.confirmations < 3) {
|
|
|
|
return (
|
|
|
|
<View style={{ width: 25 }}>
|
|
|
|
<BlueTransactionPendingIcon />
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
2018-10-28 02:11:07 +02:00
|
|
|
|
2018-11-01 20:44:39 +01:00
|
|
|
if (rowData.item.type && rowData.item.type === 'bitcoind_tx') {
|
|
|
|
return (
|
|
|
|
<View style={{ width: 25 }}>
|
|
|
|
<BlueTransactionOnchainIcon />
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if (rowData.item.type === 'paid_invoice') {
|
|
|
|
// is it lightning offchain payment?
|
|
|
|
return (
|
|
|
|
<View style={{ width: 25 }}>
|
|
|
|
<BlueTransactionOffchainIcon />
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
2018-10-09 06:25:36 +02:00
|
|
|
|
2018-12-28 23:16:30 +01:00
|
|
|
if (rowData.item.type === 'user_invoice' || rowData.item.type === 'payment_request') {
|
|
|
|
if (!rowData.item.ispaid) {
|
|
|
|
const currentDate = new Date();
|
|
|
|
const now = (currentDate.getTime() / 1000) | 0;
|
|
|
|
const invoiceExpiration = rowData.item.timestamp + rowData.item.expire_time;
|
|
|
|
if (invoiceExpiration < now) {
|
|
|
|
return (
|
|
|
|
<View style={{ width: 25 }}>
|
|
|
|
<BlueTransactionExpiredIcon />
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} else {
|
2018-12-28 22:43:38 +01:00
|
|
|
return (
|
|
|
|
<View style={{ width: 25 }}>
|
2018-12-28 23:16:30 +01:00
|
|
|
<BlueTransactionOffchainIncomingIcon />
|
2018-12-28 22:43:38 +01:00
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
2018-12-25 20:07:43 +01:00
|
|
|
}
|
|
|
|
|
2018-11-01 20:44:39 +01:00
|
|
|
if (!rowData.item.confirmations) {
|
|
|
|
return (
|
|
|
|
<View style={{ width: 25 }}>
|
|
|
|
<BlueTransactionPendingIcon />
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
} else if (rowData.item.value < 0) {
|
|
|
|
return (
|
|
|
|
<View style={{ width: 25 }}>
|
|
|
|
<BlueTransactionOutgoingIcon />
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return (
|
|
|
|
<View style={{ width: 25 }}>
|
|
|
|
<BlueTransactionIncommingIcon />
|
|
|
|
</View>
|
|
|
|
);
|
2018-10-09 06:25:36 +02:00
|
|
|
}
|
2018-11-01 20:44:39 +01:00
|
|
|
})()}
|
|
|
|
title={loc.transactionTimeToReadable(rowData.item.received)}
|
|
|
|
subtitle={
|
|
|
|
(rowData.item.confirmations < 7 ? loc.transactions.list.conf + ': ' + rowData.item.confirmations + ' ' : '') +
|
|
|
|
this.txMemo(rowData.item.hash) +
|
|
|
|
(rowData.item.memo || '')
|
|
|
|
}
|
|
|
|
onPress={() => {
|
|
|
|
if (rowData.item.hash) {
|
|
|
|
navigate('TransactionDetails', {
|
|
|
|
hash: rowData.item.hash,
|
|
|
|
});
|
2019-01-01 23:31:42 +01:00
|
|
|
} else if (
|
|
|
|
rowData.item.type === 'user_invoice' ||
|
|
|
|
rowData.item.type === 'payment_request' ||
|
|
|
|
rowData.item.type === 'paid_invoice'
|
|
|
|
) {
|
2018-12-30 04:33:41 +01:00
|
|
|
this.props.navigation.navigate('LNDViewExistingInvoice', {
|
2018-12-27 07:12:19 +01:00
|
|
|
invoice: rowData.item,
|
|
|
|
fromWallet: this.state.wallet,
|
2018-12-26 07:29:37 +01:00
|
|
|
});
|
2018-11-01 20:44:39 +01:00
|
|
|
}
|
|
|
|
}}
|
|
|
|
badge={{
|
|
|
|
value: 3,
|
|
|
|
textStyle: { color: 'orange' },
|
|
|
|
containerStyle: { marginTop: 0 },
|
|
|
|
}}
|
|
|
|
hideChevron
|
2018-12-27 07:12:19 +01:00
|
|
|
rightTitle={this.rowTitle(rowData.item)}
|
|
|
|
rightTitleStyle={this.rowTitleStyle(rowData.item)}
|
2018-11-01 20:44:39 +01:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
}}
|
|
|
|
/>
|
2018-10-09 06:25:36 +02:00
|
|
|
</View>
|
|
|
|
<View
|
|
|
|
style={{
|
|
|
|
flexDirection: 'row',
|
|
|
|
alignSelf: 'center',
|
|
|
|
backgroundColor: 'transparent',
|
|
|
|
position: 'absolute',
|
|
|
|
bottom: 30,
|
2019-01-05 03:14:23 +01:00
|
|
|
borderRadius: 30,
|
|
|
|
minHeight: 48,
|
2019-01-05 03:46:10 +01:00
|
|
|
flex: 0.84,
|
2018-10-09 06:25:36 +02:00
|
|
|
overflow: 'hidden',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{(() => {
|
|
|
|
if (this.state.showReceiveButton) {
|
|
|
|
return (
|
|
|
|
<BlueReceiveButtonIcon
|
|
|
|
onPress={() => {
|
2018-12-25 17:34:51 +01:00
|
|
|
if (this.state.wallet.type === new LightningCustodianWallet().type) {
|
|
|
|
navigate('LNDCreateInvoice', { fromWallet: this.state.wallet });
|
|
|
|
} else {
|
|
|
|
navigate('ReceiveDetails', { address: this.state.wallet.getAddress(), secret: this.state.wallet.getSecret() });
|
2018-10-09 06:25:36 +02:00
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
})()}
|
|
|
|
|
|
|
|
{(() => {
|
|
|
|
if (this.state.showSendButton) {
|
|
|
|
return (
|
|
|
|
<BlueSendButtonIcon
|
|
|
|
onPress={() => {
|
2018-12-28 16:52:06 +01:00
|
|
|
if (this.state.wallet.type === LightningCustodianWallet.type) {
|
2018-10-09 06:25:36 +02:00
|
|
|
navigate('ScanLndInvoice', { fromSecret: this.state.wallet.getSecret() });
|
|
|
|
} else {
|
|
|
|
navigate('SendDetails', { fromAddress: this.state.wallet.getAddress(), fromSecret: this.state.wallet.getSecret() });
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
})()}
|
|
|
|
|
|
|
|
{(() => {
|
|
|
|
if (this.state.showManageFundsBigButton) {
|
|
|
|
return (
|
|
|
|
<ManageFundsBigButton
|
|
|
|
onPress={() => {
|
2018-10-09 20:48:32 +02:00
|
|
|
console.log('navigating to', this.state.wallet.getLabel());
|
2018-12-30 07:10:16 +01:00
|
|
|
navigate('ManageFunds', { fromWallet: this.state.wallet });
|
2018-10-09 06:25:36 +02:00
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
})()}
|
|
|
|
</View>
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
WalletTransactions.propTypes = {
|
|
|
|
navigation: PropTypes.shape({
|
|
|
|
navigate: PropTypes.func,
|
|
|
|
goBack: PropTypes.func,
|
|
|
|
getParam: PropTypes.func,
|
|
|
|
setParams: PropTypes.func,
|
|
|
|
}),
|
|
|
|
};
|