mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2024-11-20 10:12:01 +01:00
6f581a2f2e
* OPS: randombytes work * OPS: porting to RN android: added prompt, refactoring * OPS: better android prompt * FIX: scan qr callback * FIX: correct fee sat calculation for HD & classic segwit wallets * FIX: Fixed height for button in empty transaction list * FIX: keyboard issue on fee selection modal * FIX: slow QR code generation for HD backup screen * ADD: wallet reorder * FIX: TypeError: undefined is not an object (evaluating 'recommendedFees.halfHourFee') #133 * FIX: android appstore link * OPS: Code to Migrate Expo json * REF: renamed blitzhub to lndhub * OPS: Migration: move expo files instead of parsing * FIX: lndhub uri usage * FIX: no security alert on android (it was ios specific) * REF: better tx list rendering and sorting * ADD: verify tx on coinb.in * FIX: Tap to dismiss is not working #137 * REF: Removed Wallet gradients duplication. * REF: about screen * FIX: bech32 qr scan in send screen * FIX: better bip21 handling * Use of dayjs for transaction details * REF: QR code content follows BIP21 * ADD: fee in local currency when send * FIX: Refresh wallet info on page focus
133 lines
3.8 KiB
JavaScript
133 lines
3.8 KiB
JavaScript
import React, { Component } from 'react';
|
|
import { Animated, Linking, StyleSheet, View, TouchableOpacity, Clipboard } from 'react-native';
|
|
import { BlueNavigationStyle, BlueLoading, SafeBlueArea, BlueButton, BlueText, BlueSpacing40 } from '../../BlueComponents';
|
|
import PropTypes from 'prop-types';
|
|
/** @type {AppStorage} */
|
|
let BlueApp = require('../../BlueApp');
|
|
let loc = require('../../loc');
|
|
|
|
export default class BuyBitcoin extends Component {
|
|
static navigationOptions = ({ navigation }) => ({
|
|
...BlueNavigationStyle(navigation, true),
|
|
title: loc.buyBitcoin.header,
|
|
headerLeft: null,
|
|
});
|
|
|
|
constructor(props) {
|
|
super(props);
|
|
let address = props.navigation.state.params.address;
|
|
let secret = props.navigation.state.params.secret;
|
|
|
|
this.state = {
|
|
isLoading: true,
|
|
address: address,
|
|
secret: secret,
|
|
addressText: '',
|
|
};
|
|
}
|
|
|
|
async componentDidMount() {
|
|
console.log('buyBitcoin/details - componentDidMount');
|
|
|
|
/** @type {AbstractWallet} */
|
|
let wallet;
|
|
let address = this.state.address;
|
|
for (let w of BlueApp.getWallets()) {
|
|
if ((address && w.getAddress() === this.state.address) || w.getSecret() === this.state.secret) {
|
|
// found our wallet
|
|
wallet = w;
|
|
}
|
|
}
|
|
|
|
if (wallet && wallet.getAddressAsync) {
|
|
setTimeout(async () => {
|
|
address = await wallet.getAddressAsync();
|
|
BlueApp.saveToDisk(); // caching whatever getAddressAsync() generated internally
|
|
this.setState({
|
|
address: address,
|
|
addressText: address,
|
|
isLoading: false,
|
|
});
|
|
}, 1);
|
|
} else {
|
|
this.setState({
|
|
isLoading: false,
|
|
address,
|
|
addressText: address,
|
|
});
|
|
}
|
|
}
|
|
|
|
copyToClipboard = () => {
|
|
this.setState({ addressText: loc.buyBitcoin.copied }, () => {
|
|
Clipboard.setString(this.state.address);
|
|
setTimeout(() => this.setState({ addressText: this.state.address }), 1000);
|
|
});
|
|
};
|
|
|
|
render() {
|
|
console.log('render() receive/details, address,secret=', this.state.address, ',', this.state.secret);
|
|
if (this.state.isLoading) {
|
|
return <BlueLoading />;
|
|
}
|
|
|
|
return (
|
|
<SafeBlueArea style={{ flex: 1 }}>
|
|
<View style={{ flex: 1, justifyContent: 'space-between', alignItems: 'center' }}>
|
|
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center', paddingHorizontal: 16 }}>
|
|
<BlueText>{loc.buyBitcoin.tap_your_address}</BlueText>
|
|
|
|
<TouchableOpacity onPress={this.copyToClipboard}>
|
|
<Animated.Text style={styles.address} numberOfLines={0}>
|
|
{this.state.addressText}
|
|
</Animated.Text>
|
|
</TouchableOpacity>
|
|
|
|
<BlueButton
|
|
icon={{
|
|
name: 'shopping-cart',
|
|
type: 'font-awesome',
|
|
color: BlueApp.settings.buttonTextColor,
|
|
}}
|
|
onPress={() => {
|
|
Linking.openURL(
|
|
'https://payments.changelly.com/?crypto=USD&fiat=USD&ref_id=rtagfcvnwiwvhm99&address=' + this.state.address,
|
|
);
|
|
}}
|
|
title="Buy from Changelly"
|
|
/>
|
|
|
|
<BlueSpacing40 />
|
|
<BlueSpacing40 />
|
|
<BlueSpacing40 />
|
|
<BlueSpacing40 />
|
|
<BlueSpacing40 />
|
|
<BlueSpacing40 />
|
|
</View>
|
|
</View>
|
|
</SafeBlueArea>
|
|
);
|
|
}
|
|
}
|
|
|
|
const styles = StyleSheet.create({
|
|
address: {
|
|
marginVertical: 32,
|
|
fontSize: 15,
|
|
color: '#9aa0aa',
|
|
textAlign: 'center',
|
|
},
|
|
});
|
|
|
|
BuyBitcoin.propTypes = {
|
|
navigation: PropTypes.shape({
|
|
goBack: PropTypes.function,
|
|
state: PropTypes.shape({
|
|
params: PropTypes.shape({
|
|
address: PropTypes.string,
|
|
secret: PropTypes.string,
|
|
}),
|
|
}),
|
|
}),
|
|
};
|