Skip to content

Commit

Permalink
Merge branch 'master' into rtl
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosrdz committed Mar 26, 2021
2 parents 8c014d0 + c839c9a commit baa462b
Show file tree
Hide file tree
Showing 28 changed files with 556 additions and 252 deletions.
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "6.0.7"
versionName "6.0.8"
multiDexEnabled true
missingDimensionStrategy 'react-native-camera', 'general'
testBuildType System.getProperty('testBuildType', 'debug') // This will later be used to control the test apk build type
Expand Down
19 changes: 19 additions & 0 deletions class/wallets/abstract-hd-electrum-wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -1112,4 +1112,23 @@ export class AbstractHDElectrumWallet extends AbstractHDWallet {

return { tx };
}

/**
* @param mnemonic {string} Mnemonic seed phrase
* @returns {string} Hex string of fingerprint derived from mnemonics. Always has lenght of 8 chars and correct leading zeroes
*/
static seedToFingerprint(mnemonic) {
const seed = bip39.mnemonicToSeed(mnemonic);
const root = bitcoin.bip32.fromSeed(seed);
let hex = root.fingerprint.toString('hex');
while (hex.length < 8) hex = '0' + hex; // leading zeroes
return hex.toUpperCase();
}

/**
* @returns {string} Hex string of fingerprint derived from wallet mnemonics. Always has lenght of 8 chars and correct leading zeroes
*/
getMasterFingerprintHex() {
return AbstractHDElectrumWallet.seedToFingerprint(this.secret);
}
}
12 changes: 12 additions & 0 deletions class/wallets/abstract-wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export class AbstractWallet {
this.type = this.constructor.type;
this.typeReadable = this.constructor.typeReadable;
this.segwitType = this.constructor.segwitType;
this._derivationPath = this.constructor.derivationPath;
this.label = '';
this.secret = ''; // private key or recovery phrase
this.balance = 0;
Expand Down Expand Up @@ -128,6 +129,10 @@ export class AbstractWallet {
return false;
}

allowMasterFingerprint() {
return false;
}

weOwnAddress(address) {
throw Error('not implemented');
}
Expand Down Expand Up @@ -329,4 +334,11 @@ export class AbstractWallet {
if ('frozen' in opts) meta.frozen = opts.frozen;
this._utxoMetadata[`${txid}:${vout}`] = meta;
}

/**
* @returns {string} Root derivation path for wallet if any
*/
getDerivationPath() {
return this._derivationPath ?? '';
}
}
1 change: 1 addition & 0 deletions class/wallets/hd-aezeed-wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export class HDAezeedWallet extends AbstractHDElectrumWallet {
static type = 'HDAezeedWallet';
static typeReadable = 'HD Aezeed';
static segwitType = 'p2wpkh';
static derivationPath = "m/84'/0'/0'";

setSecret(newSecret) {
this.secret = newSecret.trim();
Expand Down
1 change: 1 addition & 0 deletions class/wallets/hd-legacy-breadwallet-wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const BlueElectrum = require('../../blue_modules/BlueElectrum');
export class HDLegacyBreadwalletWallet extends HDLegacyP2PKHWallet {
static type = 'HDLegacyBreadwallet';
static typeReadable = 'HD Legacy Breadwallet (P2PKH)';
static derivationPath = "m/0'";

// track address index at which wallet switched to segwit
_external_segwit_index = null; // eslint-disable-line camelcase
Expand Down
1 change: 1 addition & 0 deletions class/wallets/hd-legacy-electrum-seed-p2pkh-wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const MNEMONIC_TO_SEED_OPTS = {
export class HDLegacyElectrumSeedP2PKHWallet extends HDLegacyP2PKHWallet {
static type = 'HDlegacyElectrumSeedP2PKH';
static typeReadable = 'HD Legacy Electrum (BIP32 P2PKH)';
static derivationPath = 'm';

validateMnemonic() {
return mn.validateMnemonic(this.secret, PREFIX);
Expand Down
5 changes: 5 additions & 0 deletions class/wallets/hd-legacy-p2pkh-wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const BlueElectrum = require('../../blue_modules/BlueElectrum');
export class HDLegacyP2PKHWallet extends AbstractHDElectrumWallet {
static type = 'HDlegacyP2PKH';
static typeReadable = 'HD Legacy (BIP44 P2PKH)';
static derivationPath = "m/44'/0'/0'";

allowSend() {
return true;
Expand All @@ -29,6 +30,10 @@ export class HDLegacyP2PKHWallet extends AbstractHDElectrumWallet {
return true;
}

allowMasterFingerprint() {
return true;
}

getXpub() {
if (this._xpub) {
return this._xpub; // cache hit
Expand Down
5 changes: 5 additions & 0 deletions class/wallets/hd-segwit-bech32-wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export class HDSegwitBech32Wallet extends AbstractHDElectrumWallet {
static type = 'HDsegwitBech32';
static typeReadable = 'HD SegWit (BIP84 Bech32 Native)';
static segwitType = 'p2wpkh';
static derivationPath = "m/84'/0'/0'";

allowSend() {
return true;
Expand Down Expand Up @@ -41,4 +42,8 @@ export class HDSegwitBech32Wallet extends AbstractHDElectrumWallet {
allowSignVerifyMessage() {
return true;
}

allowMasterFingerprint() {
return true;
}
}
1 change: 1 addition & 0 deletions class/wallets/hd-segwit-electrum-seed-p2wpkh-wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const MNEMONIC_TO_SEED_OPTS = {
export class HDSegwitElectrumSeedP2WPKHWallet extends HDSegwitBech32Wallet {
static type = 'HDSegwitElectrumSeedP2WPKHWallet';
static typeReadable = 'HD Electrum (BIP32 P2WPKH)';
static derivationPath = "m/0'";

validateMnemonic() {
return mn.validateMnemonic(this.secret, PREFIX);
Expand Down
13 changes: 9 additions & 4 deletions class/wallets/hd-segwit-p2sh-wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export class HDSegwitP2SHWallet extends AbstractHDElectrumWallet {
static type = 'HDsegwitP2SH';
static typeReadable = 'HD SegWit (BIP49 P2SH)';
static segwitType = 'p2sh(p2wpkh)';
static derivationPath = "m/49'/0'/0'";

allowSend() {
return true;
Expand All @@ -30,6 +31,14 @@ export class HDSegwitP2SHWallet extends AbstractHDElectrumWallet {
return true;
}

allowHodlHodlTrading() {
return true;
}

allowMasterFingerprint() {
return true;
}

/**
* Get internal/external WIF by wallet index
* @param {Boolean} internal
Expand Down Expand Up @@ -142,8 +151,4 @@ export class HDSegwitP2SHWallet extends AbstractHDElectrumWallet {
});
return address;
}

allowHodlHodlTrading() {
return true;
}
}
16 changes: 0 additions & 16 deletions class/wallets/multisig-hd-wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,6 @@ export class MultisigHDWallet extends AbstractHDElectrumWallet {
}
}

getDerivationPath() {
return this._derivationPath;
}

getCustomDerivationPathForCosigner(index) {
if (index === 0) throw new Error('cosigners indexation starts from 1');
if (index > this.getN()) return false;
Expand Down Expand Up @@ -310,18 +306,6 @@ export class MultisigHDWallet extends AbstractHDElectrumWallet {
return child.toBase58();
}

/**
* @param mnemonic {string} Mnemonic seed phrase
* @returns {string} Hex string of fingerprint derived from mnemonics. Always has lenght of 8 chars and correct leading zeroes
*/
static seedToFingerprint(mnemonic) {
const seed = bip39.mnemonicToSeed(mnemonic);
const root = bitcoin.bip32.fromSeed(seed);
let hex = root.fingerprint.toString('hex');
while (hex.length < 8) hex = '0' + hex; // leading zeroes
return hex.toUpperCase();
}

/**
* Returns xpub with correct prefix accodting to this objects set derivation path, for example 'Zpub' (with
* capital Z) for bech32 multisig
Expand Down
4 changes: 4 additions & 0 deletions class/wallets/watch-only-wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ export class WatchOnlyWallet extends LegacyWallet {
return this.isHd();
}

allowMasterFingerprint() {
return this.getSecret().startsWith('zpub');
}

useWithHardwareWalletEnabled() {
return !!this.use_with_hardware_wallet;
}
Expand Down
36 changes: 18 additions & 18 deletions ios/BlueWallet.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1630,7 +1630,7 @@
"$(inherited)",
"$(PROJECT_DIR)",
);
MARKETING_VERSION = 6.0.7;
MARKETING_VERSION = 6.0.8;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down Expand Up @@ -1673,7 +1673,7 @@
"$(inherited)",
"$(PROJECT_DIR)",
);
MARKETING_VERSION = 6.0.7;
MARKETING_VERSION = 6.0.8;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down Expand Up @@ -1714,7 +1714,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 6.0.7;
MARKETING_VERSION = 6.0.8;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = io.bluewallet.bluewallet.TodayExtension;
Expand Down Expand Up @@ -1753,7 +1753,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 6.0.7;
MARKETING_VERSION = 6.0.8;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = io.bluewallet.bluewallet.TodayExtension;
PRODUCT_NAME = "BlueWallet - Bitcoin Price";
Expand Down Expand Up @@ -1785,7 +1785,7 @@
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = Stickers/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MARKETING_VERSION = 6.0.7;
MARKETING_VERSION = 6.0.8;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = io.bluewallet.bluewallet.Stickers;
Expand Down Expand Up @@ -1816,7 +1816,7 @@
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = Stickers/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MARKETING_VERSION = 6.0.7;
MARKETING_VERSION = 6.0.8;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = io.bluewallet.bluewallet.Stickers;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down Expand Up @@ -1852,7 +1852,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 6.0.7;
MARKETING_VERSION = 6.0.8;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = io.bluewallet.bluewallet.PriceWidget;
Expand Down Expand Up @@ -1894,7 +1894,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 6.0.7;
MARKETING_VERSION = 6.0.8;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = io.bluewallet.bluewallet.PriceWidget;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down Expand Up @@ -1934,7 +1934,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 6.0.7;
MARKETING_VERSION = 6.0.8;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = io.bluewallet.bluewallet.MarketWidget;
Expand Down Expand Up @@ -1977,7 +1977,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 6.0.7;
MARKETING_VERSION = 6.0.8;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = io.bluewallet.bluewallet.MarketWidget;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down Expand Up @@ -2018,7 +2018,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 6.0.7;
MARKETING_VERSION = 6.0.8;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = io.bluewallet.bluewallet.WalletInformationAndMarketWidget;
Expand Down Expand Up @@ -2062,7 +2062,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 6.0.7;
MARKETING_VERSION = 6.0.8;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = io.bluewallet.bluewallet.WalletInformationAndMarketWidget;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down Expand Up @@ -2102,7 +2102,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 6.0.7;
MARKETING_VERSION = 6.0.8;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = io.bluewallet.bluewallet.WalletInformationWidget;
Expand Down Expand Up @@ -2144,7 +2144,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 6.0.7;
MARKETING_VERSION = 6.0.8;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = io.bluewallet.bluewallet.WalletInformationWidget;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down Expand Up @@ -2286,7 +2286,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 6.0.7;
MARKETING_VERSION = 6.0.8;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = io.bluewallet.bluewallet.watch.extension;
Expand Down Expand Up @@ -2326,7 +2326,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 6.0.7;
MARKETING_VERSION = 6.0.8;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = io.bluewallet.bluewallet.watch.extension;
PRODUCT_NAME = "${TARGET_NAME}";
Expand Down Expand Up @@ -2362,7 +2362,7 @@
GCC_C_LANGUAGE_STANDARD = gnu11;
IBSC_MODULE = BlueWalletWatch_Extension;
INFOPLIST_FILE = BlueWalletWatch/Info.plist;
MARKETING_VERSION = 6.0.7;
MARKETING_VERSION = 6.0.8;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = io.bluewallet.bluewallet.watch;
Expand Down Expand Up @@ -2401,7 +2401,7 @@
GCC_C_LANGUAGE_STANDARD = gnu11;
IBSC_MODULE = BlueWalletWatch_Extension;
INFOPLIST_FILE = BlueWalletWatch/Info.plist;
MARKETING_VERSION = 6.0.7;
MARKETING_VERSION = 6.0.8;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = io.bluewallet.bluewallet.watch;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
Loading

0 comments on commit baa462b

Please sign in to comment.