You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

145 lines
3.8 KiB

7 years ago
/** @type {AppStorage} */
7 years ago
let BlueApp = require('../../BlueApp');
7 years ago
import React, { Component } from 'react';
7 years ago
import { ActivityIndicator, View } from 'react-native';
7 years ago
import Ionicons from 'react-native-vector-icons/Ionicons';
7 years ago
import { SafeAreaView } from 'react-navigation';
import { Icon, Card, Header } from 'react-native-elements';
import { List, Button, ListItem, Text } from 'react-native-elements';
7 years ago
import {
7 years ago
BlueList,
BlueButton,
SafeBlueArea,
BlueCard,
BlueText,
BlueListItem,
BlueHeader,
BlueSpacing,
BlueLoading,
BlueSpacing20,
} from '../../BlueComponents';
7 years ago
export default class TransactionsDetails extends Component {
static navigationOptions = {
tabBarIcon: ({ tintColor, focused }) => (
<Ionicons
name={focused ? 'ios-list-box' : 'ios-list-box-outline'}
size={26}
style={{ color: tintColor }}
/>
),
7 years ago
};
7 years ago
constructor(props) {
super(props);
7 years ago
let hash = props.navigation.state.params.hash;
let foundTx = {};
let from = [];
let to = [];
7 years ago
for (let tx of BlueApp.getTransactions()) {
if (tx.hash === hash) {
console.log(tx);
foundTx = tx;
for (let input of foundTx.inputs) {
7 years ago
from = from.concat(input.addresses);
7 years ago
}
for (let output of foundTx.outputs) {
7 years ago
to = to.concat(output.addresses);
7 years ago
}
}
}
this.state = {
isLoading: true,
tx: foundTx,
from,
to,
7 years ago
};
7 years ago
}
async componentDidMount() {
7 years ago
console.log('transactions/details - componentDidMount');
7 years ago
this.setState({
isLoading: false,
7 years ago
});
7 years ago
}
render() {
7 years ago
const { navigate } = this.props.navigation;
7 years ago
if (this.state.isLoading) {
7 years ago
return <BlueLoading />;
7 years ago
}
return (
7 years ago
<SafeBlueArea
forceInset={{ horizontal: 'always' }}
style={{ flex: 1, paddingTop: 20 }}
>
<BlueSpacing />
<BlueCard
title={'Transaction details'}
style={{ alignItems: 'center', flex: 1 }}
>
7 years ago
{(() => {
7 years ago
let memo;
7 years ago
if (BlueApp.tx_metadata[this.state.tx.hash]) {
7 years ago
if (BlueApp.tx_metadata[this.state.tx.hash]['memo']) {
7 years ago
return (
<View>
7 years ago
<BlueText h4>
{BlueApp.tx_metadata[this.state.tx.hash]['memo']}
</BlueText>
<BlueSpacing20 />
7 years ago
</View>
);
}
}
})()}
<BlueText h4>From:</BlueText>
7 years ago
<BlueText style={{ marginBottom: 10 }}>
{this.state.from.join(', ')}
</BlueText>
7 years ago
<BlueText h4>To:</BlueText>
7 years ago
<BlueText style={{ marginBottom: 10 }}>
{this.state.to.join(', ')}
</BlueText>
7 years ago
<BlueText>Txid: {this.state.tx.hash}</BlueText>
<BlueText>received: {this.state.tx.received}</BlueText>
<BlueText>confirmed: {this.state.tx.confirmed}</BlueText>
<BlueText>confirmations: {this.state.tx.confirmations}</BlueText>
<BlueText>inputs: {this.state.tx.inputs.length}</BlueText>
<BlueText>outputs: {this.state.tx.outputs.length}</BlueText>
7 years ago
<BlueText style={{ marginBottom: 10 }} />
7 years ago
</BlueCard>
{(() => {
7 years ago
if (this.state.tx.confirmations === 0) {
7 years ago
return (
<BlueButton
onPress={() =>
7 years ago
this.props.navigation.navigate('RBF', {
txid: this.state.tx.hash,
})
7 years ago
}
title="Replace-By-Fee (RBF)"
/>
);
}
})()}
<BlueButton
7 years ago
icon={{ name: 'arrow-left', type: 'octicon' }}
onPress={() => this.props.navigation.goBack()}
7 years ago
title="Go back"
/>
</SafeBlueArea>
);
}
}