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
157 lines
4.1 KiB
JavaScript
157 lines
4.1 KiB
JavaScript
import React, { Component } from 'react';
|
|
import { Dimensions, Platform, ActivityIndicator, View } from 'react-native';
|
|
import { QRCode as QRSlow } from 'react-native-custom-qr-codes';
|
|
import { BlueSpacing40, SafeBlueArea, BlueCard, BlueText, BlueHeaderDefaultSub } from '../../BlueComponents';
|
|
import PropTypes from 'prop-types';
|
|
const QRFast = require('react-native-qrcode');
|
|
/** @type {AppStorage} */
|
|
let BlueApp = require('../../BlueApp');
|
|
let loc = require('../../loc');
|
|
const { height, width } = Dimensions.get('window');
|
|
const aspectRatio = height / width;
|
|
let isIpad;
|
|
if (aspectRatio > 1.6) {
|
|
isIpad = false;
|
|
} else {
|
|
isIpad = true;
|
|
}
|
|
|
|
export default class WalletExport extends Component {
|
|
static navigationOptions = {
|
|
header: ({ navigation }) => {
|
|
return <BlueHeaderDefaultSub leftText={loc.wallets.export.title} onClose={() => navigation.goBack(null)} />;
|
|
},
|
|
};
|
|
|
|
constructor(props) {
|
|
super(props);
|
|
|
|
let address = props.navigation.state.params.address;
|
|
let secret = props.navigation.state.params.secret;
|
|
let wallet;
|
|
|
|
for (let w of BlueApp.getWallets()) {
|
|
if ((address && w.getAddress() === address) || w.getSecret() === secret) {
|
|
// found our wallet
|
|
wallet = w;
|
|
}
|
|
}
|
|
|
|
this.state = {
|
|
isLoading: true,
|
|
wallet,
|
|
};
|
|
}
|
|
|
|
async componentDidMount() {
|
|
this.setState({
|
|
isLoading: false,
|
|
showQr: false,
|
|
});
|
|
|
|
let that = this;
|
|
setTimeout(function() {
|
|
that.setState({ showQr: true });
|
|
}, 1000);
|
|
}
|
|
|
|
determineSize = () => {
|
|
if (width > 312) {
|
|
return width - 48;
|
|
}
|
|
return 312;
|
|
};
|
|
|
|
render() {
|
|
if (this.state.isLoading) {
|
|
return (
|
|
<View style={{ flex: 1, paddingTop: 20 }}>
|
|
<ActivityIndicator />
|
|
</View>
|
|
);
|
|
}
|
|
|
|
/*
|
|
|
|
<BlueText style={{marginBottom: 10}}>
|
|
WIF stands for Wallet Import Format. Backup your WIF (also shown on QR) in a safe place.
|
|
</BlueText>
|
|
|
|
<Divider style={{ backgroundColor: '#ebebeb', marginBottom:20, }} />
|
|
|
|
*/
|
|
|
|
return (
|
|
<SafeBlueArea style={{ flex: 1, paddingTop: 20 }}>
|
|
{(() => {
|
|
if (isIpad) {
|
|
return <BlueSpacing40 />;
|
|
}
|
|
})()}
|
|
<BlueCard style={{ alignItems: 'center', flex: 1 }}>
|
|
<View>
|
|
<BlueText>{this.state.wallet.getTypeReadable()}</BlueText>
|
|
</View>
|
|
|
|
{(() => {
|
|
if (this.state.wallet.getAddress()) {
|
|
return (
|
|
<View>
|
|
<BlueText>{this.state.wallet.getAddress()}</BlueText>
|
|
</View>
|
|
);
|
|
}
|
|
})()}
|
|
|
|
{(() => {
|
|
if (this.state.showQr) {
|
|
if (Platform.OS === 'ios' || this.state.wallet.getSecret().length < 54) {
|
|
return (
|
|
<QRSlow
|
|
content={this.state.wallet.getSecret()}
|
|
size={this.determineSize()}
|
|
color={BlueApp.settings.foregroundColor}
|
|
backgroundColor={BlueApp.settings.brandingColor}
|
|
logo={require('../../img/qr-code.png')}
|
|
ecl={'Q'}
|
|
/>
|
|
);
|
|
} else {
|
|
return (
|
|
<QRFast
|
|
value={this.state.wallet.getSecret()}
|
|
size={this.determineSize()}
|
|
fgColor={BlueApp.settings.brandingColor}
|
|
bgColor={BlueApp.settings.foregroundColor}
|
|
/>
|
|
);
|
|
}
|
|
} else {
|
|
return (
|
|
<View>
|
|
<ActivityIndicator />
|
|
</View>
|
|
);
|
|
}
|
|
})()}
|
|
|
|
<BlueText style={{ marginVertical: 8 }}>{this.state.wallet.getSecret()}</BlueText>
|
|
</BlueCard>
|
|
</SafeBlueArea>
|
|
);
|
|
}
|
|
}
|
|
|
|
WalletExport.propTypes = {
|
|
navigation: PropTypes.shape({
|
|
state: PropTypes.shape({
|
|
params: PropTypes.shape({
|
|
address: PropTypes.string,
|
|
secret: PropTypes.string,
|
|
}),
|
|
}),
|
|
navigate: PropTypes.func,
|
|
goBack: PropTypes.func,
|
|
}),
|
|
};
|