mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2024-11-19 18:00:17 +01:00
Merge pull request #5405 from BlueWallet/ref-bip47
REF: hide bip47 behind backdoor; refactor
This commit is contained in:
commit
c000c3a55e
@ -602,6 +602,11 @@ export class AppStorage {
|
|||||||
keyCloned._hdWalletInstance._txs_by_external_index = {};
|
keyCloned._hdWalletInstance._txs_by_external_index = {};
|
||||||
keyCloned._hdWalletInstance._txs_by_internal_index = {};
|
keyCloned._hdWalletInstance._txs_by_internal_index = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (keyCloned._bip47_instance) {
|
||||||
|
delete keyCloned._bip47_instance; // since it wont be restored into a proper class instance
|
||||||
|
}
|
||||||
|
|
||||||
walletsToSave.push(JSON.stringify({ ...keyCloned, type: keyCloned.type }));
|
walletsToSave.push(JSON.stringify({ ...keyCloned, type: keyCloned.type }));
|
||||||
}
|
}
|
||||||
if (realm) realm.close();
|
if (realm) realm.close();
|
||||||
@ -730,7 +735,7 @@ export class AppStorage {
|
|||||||
console.log('fetchSenderPaymentCodes for wallet#', typeof index === 'undefined' ? '(all)' : index);
|
console.log('fetchSenderPaymentCodes for wallet#', typeof index === 'undefined' ? '(all)' : index);
|
||||||
if (index || index === 0) {
|
if (index || index === 0) {
|
||||||
try {
|
try {
|
||||||
if (!this.wallets[index].allowBIP47()) return;
|
if (!(this.wallets[index].allowBIP47() && this.wallets[index].isBIP47Enabled())) return;
|
||||||
await this.wallets[index].fetchBIP47SenderPaymentCodes();
|
await this.wallets[index].fetchBIP47SenderPaymentCodes();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to fetch sender payment codes for wallet', index, error);
|
console.error('Failed to fetch sender payment codes for wallet', index, error);
|
||||||
@ -738,7 +743,7 @@ export class AppStorage {
|
|||||||
} else {
|
} else {
|
||||||
for (const wallet of this.wallets) {
|
for (const wallet of this.wallets) {
|
||||||
try {
|
try {
|
||||||
if (!wallet.allowBIP47()) continue;
|
if (!(wallet.allowBIP47() && wallet.isBIP47Enabled())) continue;
|
||||||
await wallet.fetchBIP47SenderPaymentCodes();
|
await wallet.fetchBIP47SenderPaymentCodes();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to fetch sender payment codes for wallet', wallet.label, error);
|
console.error('Failed to fetch sender payment codes for wallet', wallet.label, error);
|
||||||
|
@ -1447,11 +1447,6 @@ export class AbstractHDElectrumWallet extends AbstractHDWallet {
|
|||||||
return AbstractHDElectrumWallet.seedToFingerprint(seed);
|
return AbstractHDElectrumWallet.seedToFingerprint(seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
prepareForSerialization() {
|
|
||||||
super.prepareForSerialization();
|
|
||||||
delete this._bip47_instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether BIP47 is enabled. This is per-wallet setting that can be changed, NOT a feature-flag
|
* Whether BIP47 is enabled. This is per-wallet setting that can be changed, NOT a feature-flag
|
||||||
* @returns boolean
|
* @returns boolean
|
||||||
@ -1465,7 +1460,7 @@ export class AbstractHDElectrumWallet extends AbstractHDWallet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getBIP47FromSeed(): BIP47Interface {
|
getBIP47FromSeed(): BIP47Interface {
|
||||||
if (!this._bip47_instance) {
|
if (!this._bip47_instance || !this._bip47_instance.getNotificationAddress) {
|
||||||
this._bip47_instance = bip47.fromBip39Seed(this.secret, undefined, this.passphrase);
|
this._bip47_instance = bip47.fromBip39Seed(this.secret, undefined, this.passphrase);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1481,7 +1476,7 @@ export class AbstractHDElectrumWallet extends AbstractHDWallet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fetchBIP47SenderPaymentCodes(): Promise<void> {
|
async fetchBIP47SenderPaymentCodes(): Promise<void> {
|
||||||
const bip47_instance = BIP47Factory(ecc).fromBip39Seed(this.secret, undefined, this.passphrase);
|
const bip47_instance = this.getBIP47FromSeed();
|
||||||
|
|
||||||
const address = bip47_instance.getNotificationAddress();
|
const address = bip47_instance.getNotificationAddress();
|
||||||
|
|
||||||
|
8
package-lock.json
generated
8
package-lock.json
generated
@ -21,7 +21,7 @@
|
|||||||
"@react-navigation/drawer": "5.12.9",
|
"@react-navigation/drawer": "5.12.9",
|
||||||
"@react-navigation/native": "5.9.8",
|
"@react-navigation/native": "5.9.8",
|
||||||
"@remobile/react-native-qrcode-local-image": "https://github.com/BlueWallet/react-native-qrcode-local-image",
|
"@remobile/react-native-qrcode-local-image": "https://github.com/BlueWallet/react-native-qrcode-local-image",
|
||||||
"@spsina/bip47": "1.0.1",
|
"@spsina/bip47": "github:BlueWallet/bip47#0a2f02c90350802f2ec93afa4e6c8843be2d687c",
|
||||||
"aez": "1.0.1",
|
"aez": "1.0.1",
|
||||||
"assert": "2.0.0",
|
"assert": "2.0.0",
|
||||||
"base-x": "3.0.9",
|
"base-x": "3.0.9",
|
||||||
@ -5904,7 +5904,7 @@
|
|||||||
},
|
},
|
||||||
"node_modules/@spsina/bip47": {
|
"node_modules/@spsina/bip47": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "git+ssh://git@github.com/abhishandy/bip47.git#1abcd4c20a387e43ed55bacc52726690bf417559",
|
"resolved": "git+ssh://git@github.com/BlueWallet/bip47.git#0a2f02c90350802f2ec93afa4e6c8843be2d687c",
|
||||||
"integrity": "sha512-lsgEpiEMDgpiYOA2kizOwiSS3vjTeLe2VnkOTIGnJ7Eu7Mkgl9dLES7oSLAjY64aQXr0VolqCRciRDc2nAC++w==",
|
"integrity": "sha512-lsgEpiEMDgpiYOA2kizOwiSS3vjTeLe2VnkOTIGnJ7Eu7Mkgl9dLES7oSLAjY64aQXr0VolqCRciRDc2nAC++w==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -28259,9 +28259,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@spsina/bip47": {
|
"@spsina/bip47": {
|
||||||
"version": "git+ssh://git@github.com/abhishandy/bip47.git#1abcd4c20a387e43ed55bacc52726690bf417559",
|
"version": "git+ssh://git@github.com/BlueWallet/bip47.git#0a2f02c90350802f2ec93afa4e6c8843be2d687c",
|
||||||
"integrity": "sha512-lsgEpiEMDgpiYOA2kizOwiSS3vjTeLe2VnkOTIGnJ7Eu7Mkgl9dLES7oSLAjY64aQXr0VolqCRciRDc2nAC++w==",
|
"integrity": "sha512-lsgEpiEMDgpiYOA2kizOwiSS3vjTeLe2VnkOTIGnJ7Eu7Mkgl9dLES7oSLAjY64aQXr0VolqCRciRDc2nAC++w==",
|
||||||
"from": "@spsina/bip47@1.0.1",
|
"from": "@spsina/bip47@https://github.com/BlueWallet/bip47#0a2f02c90350802f2ec93afa4e6c8843be2d687c",
|
||||||
"requires": {
|
"requires": {
|
||||||
"bip32": "^3.0.1",
|
"bip32": "^3.0.1",
|
||||||
"bip39": "^3.0.4",
|
"bip39": "^3.0.4",
|
||||||
|
@ -110,7 +110,7 @@
|
|||||||
"@react-navigation/drawer": "5.12.9",
|
"@react-navigation/drawer": "5.12.9",
|
||||||
"@react-navigation/native": "5.9.8",
|
"@react-navigation/native": "5.9.8",
|
||||||
"@remobile/react-native-qrcode-local-image": "https://github.com/BlueWallet/react-native-qrcode-local-image",
|
"@remobile/react-native-qrcode-local-image": "https://github.com/BlueWallet/react-native-qrcode-local-image",
|
||||||
"@spsina/bip47": "1.0.1",
|
"@spsina/bip47": "github:BlueWallet/bip47#0a2f02c90350802f2ec93afa4e6c8843be2d687c",
|
||||||
"aez": "1.0.1",
|
"aez": "1.0.1",
|
||||||
"assert": "2.0.0",
|
"assert": "2.0.0",
|
||||||
"base-x": "3.0.9",
|
"base-x": "3.0.9",
|
||||||
|
@ -123,6 +123,7 @@ const WalletDetails = () => {
|
|||||||
const { walletID } = useRoute().params;
|
const { walletID } = useRoute().params;
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [backdoorPressed, setBackdoorPressed] = useState(0);
|
const [backdoorPressed, setBackdoorPressed] = useState(0);
|
||||||
|
const [backdoorBip47Pressed, setBackdoorBip47Pressed] = useState(0);
|
||||||
const wallet = useRef(wallets.find(w => w.getID() === walletID)).current;
|
const wallet = useRef(wallets.find(w => w.getID() === walletID)).current;
|
||||||
const [walletName, setWalletName] = useState(wallet.getLabel());
|
const [walletName, setWalletName] = useState(wallet.getLabel());
|
||||||
const [useWithHardwareWallet, setUseWithHardwareWallet] = useState(wallet.useWithHardwareWalletEnabled());
|
const [useWithHardwareWallet, setUseWithHardwareWallet] = useState(wallet.useWithHardwareWalletEnabled());
|
||||||
@ -565,7 +566,7 @@ const WalletDetails = () => {
|
|||||||
{loc.transactions.list_title.toLowerCase()}
|
{loc.transactions.list_title.toLowerCase()}
|
||||||
</Text>
|
</Text>
|
||||||
<View style={styles.hardware}>
|
<View style={styles.hardware}>
|
||||||
<BlueText>{loc.wallets.details_display}</BlueText>
|
<BlueText onPress={() => setBackdoorBip47Pressed(prevState => prevState + 1)}>{loc.wallets.details_display}</BlueText>
|
||||||
<Switch value={hideTransactionsInWalletsList} onValueChange={setHideTransactionsInWalletsList} />
|
<Switch value={hideTransactionsInWalletsList} onValueChange={setHideTransactionsInWalletsList} />
|
||||||
</View>
|
</View>
|
||||||
</>
|
</>
|
||||||
@ -576,7 +577,7 @@ const WalletDetails = () => {
|
|||||||
<BlueText>{wallet.getTransactions().length}</BlueText>
|
<BlueText>{wallet.getTransactions().length}</BlueText>
|
||||||
</>
|
</>
|
||||||
|
|
||||||
{wallet.allowBIP47() ? (
|
{backdoorBip47Pressed >= 10 && wallet.allowBIP47() ? (
|
||||||
<>
|
<>
|
||||||
<Text style={[styles.textLabel2, stylesHook.textLabel2]}>{loc.bip47.payment_code}</Text>
|
<Text style={[styles.textLabel2, stylesHook.textLabel2]}>{loc.bip47.payment_code}</Text>
|
||||||
<View style={styles.hardware}>
|
<View style={styles.hardware}>
|
||||||
|
@ -178,7 +178,7 @@ const WalletTransactions = ({ navigation }) => {
|
|||||||
refreshLnNodeInfo();
|
refreshLnNodeInfo();
|
||||||
// await BlueElectrum.ping();
|
// await BlueElectrum.ping();
|
||||||
await BlueElectrum.waitTillConnected();
|
await BlueElectrum.waitTillConnected();
|
||||||
if (wallet.allowBIP47()) {
|
if (wallet.allowBIP47() && wallet.isBIP47Enabled()) {
|
||||||
const pcStart = +new Date();
|
const pcStart = +new Date();
|
||||||
await wallet.fetchBIP47SenderPaymentCodes();
|
await wallet.fetchBIP47SenderPaymentCodes();
|
||||||
const pcEnd = +new Date();
|
const pcEnd = +new Date();
|
||||||
|
Loading…
Reference in New Issue
Block a user