Merge pull request #6744 from BlueWallet/fix-subscripbe-bip47-addresses-to-push-notifications

FIX: BIP47 addresses subscribed to push notifications
This commit is contained in:
GLaDOS 2024-06-26 22:09:41 +00:00 committed by GitHub
commit 379d7e316a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 36 additions and 0 deletions

View file

@ -1438,6 +1438,17 @@ export class AbstractHDElectrumWallet extends AbstractHDWallet {
ret.push(this._getExternalAddressByIndex(c));
}
if (this.allowBIP47() && this.isBIP47Enabled()) {
// returning BIP47 joint addresses with everyone who can pay us because they are kinda our 'external' aka 'receive' addresses
for (const pc of this._receive_payment_codes) {
for (let c = 0; c < this._getNextFreePaymentCodeIndexReceive(pc) + this.gap_limit / 4; c++) {
// ^^^ not full gap limit to reduce computation (theoretically, there should not be gaps at all)
ret.push(this._getBIP47AddressReceive(pc, c));
}
}
}
return ret;
}

View file

@ -205,6 +205,7 @@ describe('BlueWallet UI Tests - no wallets', () => {
// in case emulator has no google services and doesnt support pushes
// we just dont show this popup
await element(by.text(`No, and do not ask me again.`)).tap();
await element(by.text(`No, and do not ask me again.`)).tap(); // sometimes the first click doesnt work (detox issue, not app's)
} catch (_) {}
await yo('BitcoinAddressQRCodeContainer');
await yo('CopyTextToClipboard');
@ -517,6 +518,7 @@ describe('BlueWallet UI Tests - no wallets', () => {
// in case emulator has no google services and doesnt support pushes
// we just dont show this popup
await element(by.text(`No, and do not ask me again.`)).tap();
await element(by.text(`No, and do not ask me again.`)).tap(); // sometimes the first click doesnt work (detox issue, not app's)
} catch (_) {}
await sup('bc1qmf06nt4jhvzz4387ak8fecs42k6jqygr2unumetfc7xkdup7ah9s8phlup');

View file

@ -35,6 +35,7 @@ describe('BlueWallet UI Tests - import Watch-only wallet (zpub)', () => {
// in case emulator has no google services and doesnt support pushes
// we just dont show this popup
await element(by.text(`No, and do not ask me again.`)).tap();
await element(by.text(`No, and do not ask me again.`)).tap(); // sometimes the first click doesnt work (detox issue, not app's)
} catch (_) {}
await expect(element(by.id('BitcoinAddressQRCodeContainer'))).toBeVisible();
await expect(element(by.text('bc1qc8wun6lf9vcajpddtgdpd2pdrp0kwp29j6upgv'))).toBeVisible();

View file

@ -340,5 +340,27 @@ describe('Bech32 Segwit HD (BIP84) with BIP47', () => {
);
assert.strictEqual(addr2, 'bc1qaxxc4gwx6rd6rymq08qwpxhesd4jqu93lvjsyt');
assert.strictEqual(w.getAllExternalAddresses().length, 20); // exactly gap limit for external addresses
assert.ok(!w.getAllExternalAddresses().includes(addr)); // joint address to _receive_ is not included
// since we dont do network calls in unit test we cant get counterparties payment codes from our notif address,
// and thus, dont know collaborative addresses with our payers. lets hardcode our counterparty payment code to test
// this functionality
assert.deepStrictEqual(w.getBIP47SenderPaymentCodes(), []);
w.switchBIP47(true);
w._receive_payment_codes = [
'PM8TJi1RuCrgSHTzGMoayUf8xUW6zYBGXBPSWwTiMhMMwqto7G6NA4z9pN5Kn8Pbhryo2eaHMFRRcidCGdB3VCDXJD4DdPD2ZyG3ScLMEvtStAetvPMo',
];
assert.deepStrictEqual(w.getBIP47SenderPaymentCodes(), [
'PM8TJi1RuCrgSHTzGMoayUf8xUW6zYBGXBPSWwTiMhMMwqto7G6NA4z9pN5Kn8Pbhryo2eaHMFRRcidCGdB3VCDXJD4DdPD2ZyG3ScLMEvtStAetvPMo',
]);
assert.ok(w.getAllExternalAddresses().includes(addr)); // joint address to _receive_ is included
assert.ok(w.getAllExternalAddresses().length > 20);
});
});