Skip to content

Commit

Permalink
REF: coldcard support
Browse files Browse the repository at this point in the history
  • Loading branch information
Overtorment committed Feb 25, 2020
1 parent faead2f commit fb552b1
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 8 deletions.
13 changes: 13 additions & 0 deletions class/walletImport.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ const BlueApp = require('../BlueApp');
const loc = require('../loc');

export default class WalletImport {
/**
*
* @param w
* @param additionalProperties key-values passed from outside. Used only to set up `masterFingerprint` property for watch-only wallet
* @returns {Promise<void>}
* @private
*/
static async _saveWallet(w, additionalProperties) {
try {
const wallet = BlueApp.getWallets().some(wallet => wallet.getSecret() === w.secret && wallet.type !== PlaceholderWallet.type);
Expand Down Expand Up @@ -68,6 +75,12 @@ export default class WalletImport {
return BlueApp.getWallets().some(wallet => wallet.type === PlaceholderWallet.type);
}

/**
*
* @param importText
* @param additionalProperties key-values passed from outside. Used only to set up `masterFingerprint` property for watch-only wallet
* @returns {Promise<void>}
*/
static async processImportText(importText, additionalProperties) {
if (WalletImport.isCurrentlyImportingWallet()) {
return;
Expand Down
2 changes: 1 addition & 1 deletion ios/BlueWallet/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
<key>NSCameraUsageDescription</key>
<string>In order to quickly scan the recipient's address, we need your permission to use the camera to scan their QR Code.</string>
<key>NSFaceIDUsageDescription</key>
<string>In order to confirm your identity, we need your permission to use FaceID.</string>
<string>In order to use FaceID please confirm your permission.</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>This alert should not show up as we do not require this data</string>
<key>NSLocationWhenInUseUsageDescription</key>
Expand Down
2 changes: 1 addition & 1 deletion loc/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ module.exports = {
error: 'Failed to import. Please, make sure that the provided data is valid.',
success: 'Success',
do_import: 'Import',
scan_qr: 'or scan QR code instead?',
scan_qr: '...scan QR or import file instead?',
},
scanQrWif: {
go_back: 'Go Back',
Expand Down
11 changes: 6 additions & 5 deletions screen/send/details.js
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,8 @@ export default class SendDetails extends Component {
if (this.state.fromWallet.type === WatchOnlyWallet.type) {
// watch-only wallets with enabled HW wallet support have different flow. we have to show PSBT to user as QR code
// so he can scan it and sign it. then we have to scan it back from user (via camera and QR code), and ask
// user whether he wants to broadcast it
// user whether he wants to broadcast it.
// alternatively, user can export psbt file, sign it externally and then import it
this.props.navigation.navigate('PsbtWithHardwareWallet', {
memo: this.state.memo,
fromWallet: this.state.fromWallet,
Expand Down Expand Up @@ -786,10 +787,10 @@ export default class SendDetails extends Component {
onSwitch={this.onReplaceableFeeSwitchValueChanged}
/>
)}
{(this.state.fromWallet.type === HDSegwitBech32Wallet.type ||
this.state.fromWallet._hdWalletInstance instanceof HDSegwitBech32Wallet) && (
<BlueListItem title="Import Transaction" hideChevron component={TouchableOpacity} onPress={this.importTransaction} />
)}
{this.state.fromWallet.type === WatchOnlyWallet.type &&
this.state.fromWallet._hdWalletInstance instanceof HDSegwitBech32Wallet && (
<BlueListItem title="Import Transaction" hideChevron component={TouchableOpacity} onPress={this.importTransaction} />
)}
{this.state.fromWallet.allowBatchSend() && (
<>
<BlueListItem
Expand Down
12 changes: 11 additions & 1 deletion screen/wallets/import.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ const WalletsImport = () => {
importMnemonic(importText);
};

/**
*
* @param importText
* @param additionalProperties key-values passed from outside. Used only to set up `masterFingerprint` property for watch-only wallet
*/
const importMnemonic = (importText, additionalProperties) => {
try {
WalletImport.processImportText(importText, additionalProperties);
Expand All @@ -45,6 +50,11 @@ const WalletsImport = () => {
}
};

/**
*
* @param value
* @param additionalProperties key-values passed from outside. Used only to set up `masterFingerprint` property for watch-only wallet
*/
const onBarScanned = (value, additionalProperties) => {
setImportText(value);
importMnemonic(value, additionalProperties);
Expand Down Expand Up @@ -108,7 +118,7 @@ const WalletsImport = () => {
onPress={importButtonPressed}
/>
<BlueButtonLink
title="...or scan for wallet instead?"
title={loc.wallets.import.scan_qr}
onPress={() => {
navigate('ScanQrAddress', { launchedBy: 'ImportWallet', onBarScanned, showFileImportButton: true });
}}
Expand Down

0 comments on commit fb552b1

Please sign in to comment.