mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-01-19 05:45:15 +01:00
Merge branch 'show-wallet-xpub' of https://github.com/pajasevi/BlueWallet into receiveBase
This commit is contained in:
commit
59f4a25b4b
@ -14,6 +14,7 @@ import AddWallet from './screen/wallets/add';
|
||||
import ImportWallet from './screen/wallets/import';
|
||||
import WalletDetails from './screen/wallets/details';
|
||||
import WalletExport from './screen/wallets/export';
|
||||
import WalletXpub from './screen/wallets/xpub';
|
||||
import BuyBitcoin from './screen/wallets/buyBitcoin';
|
||||
import scanQrWif from './screen/wallets/scanQrWif';
|
||||
import ReorderWallets from './screen/wallets/reorderWallets';
|
||||
@ -170,6 +171,9 @@ const MainBottomTabs = createStackNavigator(
|
||||
WalletExport: {
|
||||
screen: WalletExport,
|
||||
},
|
||||
WalletXpub: {
|
||||
screen: WalletXpub,
|
||||
},
|
||||
BuyBitcoin: {
|
||||
screen: BuyBitcoin,
|
||||
},
|
||||
|
@ -60,10 +60,15 @@ module.exports = {
|
||||
delete_this_wallet: 'Delete this wallet',
|
||||
export_backup: 'Export / backup',
|
||||
buy_bitcoin: 'Buy Bitcoin',
|
||||
show_xpub: 'Show wallet XPUB',
|
||||
},
|
||||
export: {
|
||||
title: 'wallet export',
|
||||
},
|
||||
xpub: {
|
||||
title: 'wallet XPUB',
|
||||
copiedToClipboard: 'Copied to clipboard.',
|
||||
},
|
||||
import: {
|
||||
title: 'import',
|
||||
explanation:
|
||||
|
@ -60,10 +60,15 @@ module.exports = {
|
||||
delete_this_wallet: 'Eliminar esta carterqa',
|
||||
export_backup: 'Exportar / Guardar',
|
||||
buy_bitcoin: 'Buy Bitcoin',
|
||||
show_xpub: 'Show wallet XPUB',
|
||||
},
|
||||
export: {
|
||||
title: 'Exportacion de billetera',
|
||||
},
|
||||
xpub: {
|
||||
title: 'wallet XPUB',
|
||||
copiedToClipboard: 'Copiado a portapapeles.',
|
||||
},
|
||||
import: {
|
||||
title: 'importar',
|
||||
explanation:
|
||||
|
@ -59,12 +59,17 @@ module.exports = {
|
||||
delete_this_wallet: 'Apagar esta wallet',
|
||||
export_backup: 'Exportar / backup',
|
||||
buy_bitcoin: 'Buy Bitcoin',
|
||||
show_xpub: 'Show wallet XPUB',
|
||||
delete: 'Delete',
|
||||
save: 'Save',
|
||||
},
|
||||
export: {
|
||||
title: 'Exportar Wallet',
|
||||
},
|
||||
xpub: {
|
||||
title: 'wallet XPUB',
|
||||
copiedToClipboard: 'copiado para clip board',
|
||||
},
|
||||
import: {
|
||||
title: 'importar',
|
||||
explanation:
|
||||
|
@ -60,10 +60,15 @@ module.exports = {
|
||||
delete_this_wallet: 'Apagar esta wallet',
|
||||
export_backup: 'Exportar / backup',
|
||||
buy_bitcoin: 'Buy Bitcoin',
|
||||
show_xpub: 'Show wallet XPUB',
|
||||
},
|
||||
export: {
|
||||
title: 'Exportar Wallet',
|
||||
},
|
||||
xpub: {
|
||||
title: 'wallet XPUB',
|
||||
copiedToClipboard: 'copiado para clip board',
|
||||
},
|
||||
import: {
|
||||
title: 'importar',
|
||||
explanation:
|
||||
|
@ -60,10 +60,15 @@ module.exports = {
|
||||
delete_this_wallet: 'Удалить этот кошелек',
|
||||
export_backup: 'Экспорт / резервная копия',
|
||||
buy_bitcoin: 'Buy Bitcoin',
|
||||
show_xpub: 'Show wallet XPUB',
|
||||
},
|
||||
export: {
|
||||
title: 'Экспорт Кошелька',
|
||||
},
|
||||
xpub: {
|
||||
title: 'wallet XPUB',
|
||||
copiedToClipboard: 'скопировано',
|
||||
},
|
||||
import: {
|
||||
title: 'import',
|
||||
explanation: 'Напишите тут вашу мнемонику, приватный ключ, WIF, что угодно, BlueWallet постарается угадать верный формат',
|
||||
|
@ -60,10 +60,15 @@ module.exports = {
|
||||
delete_this_wallet: 'Видалити цей гаманець',
|
||||
export_backup: 'Експорт / резервна копія',
|
||||
buy_bitcoin: 'Buy Bitcoin',
|
||||
show_xpub: 'Show wallet XPUB',
|
||||
},
|
||||
export: {
|
||||
title: 'Експорт Гаманця',
|
||||
},
|
||||
xpub: {
|
||||
title: 'wallet XPUB',
|
||||
copiedToClipboard: 'Зкопіювано',
|
||||
},
|
||||
import: {
|
||||
title: 'імпорт',
|
||||
explanation: 'Мнемоніка, приватний ключ, чи будь що. BlueWallet спробуе вгадати вірний формат',
|
||||
|
@ -4,6 +4,9 @@ import { ActivityIndicator, View, Text, TextInput, Alert, TouchableOpacity, Keyb
|
||||
import { BlueButton, SafeBlueArea, BlueCard, BlueSpacing20, BlueNavigationStyle } from '../../BlueComponents';
|
||||
import PropTypes from 'prop-types';
|
||||
import { LightningCustodianWallet } from '../../class/lightning-custodian-wallet';
|
||||
import { HDLegacyBreadwalletWallet } from '../../class/hd-legacy-breadwallet-wallet';
|
||||
import { HDLegacyP2PKHWallet } from '../../class/hd-legacy-p2pkh-wallet';
|
||||
import { HDSegwitP2SHWallet } from '../../class/hd-segwit-p2sh-wallet';
|
||||
import ReactNativeHapticFeedback from 'react-native-haptic-feedback';
|
||||
let EV = require('../../events');
|
||||
/** @type {AppStorage} */
|
||||
@ -138,6 +141,21 @@ export default class WalletDetails extends Component {
|
||||
|
||||
<BlueSpacing20 />
|
||||
|
||||
{(this.state.wallet.type === new HDLegacyBreadwalletWallet().type ||
|
||||
this.state.wallet.type === new HDLegacyP2PKHWallet().type ||
|
||||
this.state.wallet.type === new HDSegwitP2SHWallet().type) && (
|
||||
<BlueButton
|
||||
onPress={() =>
|
||||
this.props.navigation.navigate('WalletXpub', {
|
||||
secret: this.state.wallet.getSecret(),
|
||||
})
|
||||
}
|
||||
title={loc.wallets.details.show_xpub}
|
||||
/>
|
||||
)}
|
||||
|
||||
<BlueSpacing20 />
|
||||
|
||||
{this.state.wallet.type !== new LightningCustodianWallet().type && (
|
||||
<BlueButton
|
||||
icon={{
|
||||
|
144
screen/wallets/xpub.js
Normal file
144
screen/wallets/xpub.js
Normal file
@ -0,0 +1,144 @@
|
||||
import React, { Component } from 'react';
|
||||
import { Dimensions, Platform, ActivityIndicator, View, Clipboard, Animated, TouchableOpacity } 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 WalletXpub extends Component {
|
||||
static navigationOptions = {
|
||||
header: ({ navigation }) => {
|
||||
return <BlueHeaderDefaultSub leftText={loc.wallets.xpub.title} onClose={() => navigation.goBack(null)} />;
|
||||
},
|
||||
};
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
let secret = props.navigation.state.params.secret;
|
||||
let wallet;
|
||||
|
||||
for (let w of BlueApp.getWallets()) {
|
||||
if (w.getSecret() === secret) {
|
||||
// found our wallet
|
||||
wallet = w;
|
||||
}
|
||||
}
|
||||
|
||||
this.state = {
|
||||
isLoading: true,
|
||||
wallet,
|
||||
xpub: wallet.getXpub(),
|
||||
xpubText: wallet.getXpub(),
|
||||
};
|
||||
}
|
||||
|
||||
async componentDidMount() {
|
||||
this.setState({
|
||||
isLoading: false,
|
||||
showQr: false,
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
this.setState({ showQr: true });
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
determineSize = () => {
|
||||
if (width > 312) {
|
||||
return width - 48;
|
||||
}
|
||||
return 312;
|
||||
};
|
||||
|
||||
copyToClipboard = () => {
|
||||
this.setState({ xpubText: loc.wallets.xpub.copiedToClipboard }, () => {
|
||||
Clipboard.setString(this.state.xpub);
|
||||
setTimeout(() => this.setState({ xpubText: this.state.xpub }), 1000);
|
||||
});
|
||||
};
|
||||
|
||||
render() {
|
||||
if (this.state.isLoading) {
|
||||
return (
|
||||
<View style={{ flex: 1, paddingTop: 20 }}>
|
||||
<ActivityIndicator />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<SafeBlueArea style={{ flex: 1, paddingTop: 20 }}>
|
||||
{isIpad && (
|
||||
<BlueSpacing40 />
|
||||
)}
|
||||
<BlueCard style={{ alignItems: 'center', flex: 1 }}>
|
||||
<View>
|
||||
<BlueText>{this.state.wallet.getTypeReadable()}</BlueText>
|
||||
</View>
|
||||
|
||||
{(() => {
|
||||
if (this.state.showQr) {
|
||||
if (Platform.OS === 'ios' || this.state.xpub.length < 54) {
|
||||
return (
|
||||
<QRSlow
|
||||
content={this.state.xpub}
|
||||
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.xpub}
|
||||
size={this.determineSize()}
|
||||
fgColor={BlueApp.settings.brandingColor}
|
||||
bgColor={BlueApp.settings.foregroundColor}
|
||||
/>
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return (
|
||||
<View>
|
||||
<ActivityIndicator />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
})()}
|
||||
|
||||
<TouchableOpacity onPress={this.copyToClipboard}>
|
||||
<Animated.Text style={{ marginVertical: 8, textAlign: 'center' }} numberOfLines={0}>
|
||||
{this.state.xpubText}
|
||||
</Animated.Text>
|
||||
</TouchableOpacity>
|
||||
</BlueCard>
|
||||
</SafeBlueArea>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
WalletXpub.propTypes = {
|
||||
navigation: PropTypes.shape({
|
||||
state: PropTypes.shape({
|
||||
params: PropTypes.shape({
|
||||
secret: PropTypes.string,
|
||||
}),
|
||||
}),
|
||||
navigate: PropTypes.func,
|
||||
goBack: PropTypes.func,
|
||||
}),
|
||||
};
|
Loading…
Reference in New Issue
Block a user