mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-01-19 05:45:15 +01:00
REF: bump ldk to 0.106
This commit is contained in:
parent
d77fc6e579
commit
f5e64c9944
@ -449,7 +449,7 @@ export class AppStorage {
|
||||
if (wallet.type === LightningLdkWallet.type) {
|
||||
/** @type {LightningLdkWallet} */
|
||||
const ldkwallet = wallet;
|
||||
ldkwallet.stop().catch(alert);
|
||||
ldkwallet.stop().then(ldkwallet.purgeLocalStorage).catch(alert);
|
||||
}
|
||||
|
||||
for (const value of this.wallets) {
|
||||
|
@ -127,6 +127,14 @@ export default class SyncedAsyncStorage {
|
||||
return (await AsyncStorage.getItem(this.namespace + '_' + 'seqnum')) || '0';
|
||||
}
|
||||
|
||||
async purgeLocalStorage() {
|
||||
if (!this.namespace) throw new Error('No namespace');
|
||||
const keys = (await AsyncStorage.getAllKeys()).filter(key => key.startsWith(this.namespace));
|
||||
for (const key of keys) {
|
||||
await AsyncStorage.removeItem(key);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Should be called at init.
|
||||
* Checks remote sequence number, and if remote is ahead - we sync all keys with local storage.
|
||||
|
@ -21,15 +21,14 @@ export class LightningLdkWallet extends LightningCustodianWallet {
|
||||
private _refundAddressScriptHex: string = '';
|
||||
private _lastTimeBlockchainCheckedTs: number = 0;
|
||||
private _unwrapFirstExternalAddressFromMnemonicsCache: string = '';
|
||||
private static _predefinedNodes: any = {
|
||||
Bitrefill: '030c3f19d742ca294a55c00376b3b355c3c90d61c6b6b39554dbc7ac19b141c14f@52.50.244.44:9735',
|
||||
'OpenNode.com': '028d98b9969fbed53784a36617eb489a59ab6dc9b9d77fcdca9ff55307cd98e3c4@18.222.70.85:9735',
|
||||
private static _predefinedNodes: Record<string, string> = {
|
||||
Bitrefill: '03d607f3e69fd032524a867b288216bfab263b6eaee4e07783799a6fe69bb84fac@3.237.23.179:9735',
|
||||
'OpenNode.com': '03abf6f44c355dec0d5aa155bdbdd6e0c8fefe318eff402de65c6eb2e1be55dc3e@3.132.230.42:9735',
|
||||
Fold: '02816caed43171d3c9854e3b0ab2cf0c42be086ff1bd4005acc2a5f7db70d83774@35.238.153.25:9735',
|
||||
'Moon (paywithmoon.com)': '025f1456582e70c4c06b61d5c8ed3ce229e6d0db538be337a2dc6d163b0ebc05a5@52.86.210.65:9735',
|
||||
'coingate.com': '0242a4ae0c5bef18048fbecf995094b74bfb0f7391418d71ed394784373f41e4f3@3.124.63.44:9735',
|
||||
'Blockstream Store': '02df5ffe895c778e10f7742a6c5b8a0cefbe9465df58b92fadeb883752c8107c8f@35.232.170.67:9735',
|
||||
'lnd2.bluewallet.io': '037cc5f9f1da20ac0d60e83989729a204a33cc2d8e80438969fadf35c1c5f1233b@165.227.103.83:9735',
|
||||
ACINQ: '03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f@34.239.230.56:9735',
|
||||
ACINQ: '03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f@3.33.236.230:9735',
|
||||
};
|
||||
|
||||
static getPredefinedNodes() {
|
||||
@ -301,12 +300,16 @@ export class LightningLdkWallet extends LightningCustodianWallet {
|
||||
async payInvoice(invoice: string, freeAmount = 0) {
|
||||
const decoded = this.decodeInvoice(invoice);
|
||||
|
||||
// if its NOT zero amount invoice, we forcefully reset passed amount argument so underlying LDK code
|
||||
// would extract amount from bolt11
|
||||
if (decoded.num_satoshis && parseInt(decoded.num_satoshis) > 0) freeAmount = 0;
|
||||
|
||||
if (await this.channelsNeedReestablish()) {
|
||||
await this.reestablishChannels();
|
||||
await this.waitForAtLeastOneChannelBecomeActive();
|
||||
}
|
||||
|
||||
const result = await this.sendPayment(invoice, freeAmount);
|
||||
const result = await RnLdk.payInvoice(invoice, freeAmount);
|
||||
if (!result) throw new Error('Failed');
|
||||
|
||||
// ok, it was sent. now, waiting for an event that it was _actually_ paid:
|
||||
@ -339,10 +342,6 @@ export class LightningLdkWallet extends LightningCustodianWallet {
|
||||
throw new Error('Payment timeout');
|
||||
}
|
||||
|
||||
async sendPayment(invoice: string, freeAmount: number) {
|
||||
return RnLdk.payInvoice(invoice, freeAmount);
|
||||
}
|
||||
|
||||
/**
|
||||
* In case user initiated channel opening, and then lost peer connection (i.e. app went in background for an
|
||||
* extended period of time), when user gets back to the app the channel might already have enough confirmations,
|
||||
@ -626,6 +625,14 @@ export class LightningLdkWallet extends LightningCustodianWallet {
|
||||
await this.connectPeer(pubkey, host, port);
|
||||
connectedInThisRun[pubkey] = true;
|
||||
}
|
||||
|
||||
// now, reconnecting peers
|
||||
for (const uri of Object.values(LightningLdkWallet._predefinedNodes)) {
|
||||
const pk = uri.split('@')[0];
|
||||
if (connectedInThisRun[pk]) continue;
|
||||
const { pubkey, host, port } = await this.lookupNodeConnectionDetailsByPubkey(pk);
|
||||
await this.connectPeer(pubkey, host, port);
|
||||
}
|
||||
}
|
||||
|
||||
async channelsNeedReestablish() {
|
||||
@ -668,6 +675,10 @@ export class LightningLdkWallet extends LightningCustodianWallet {
|
||||
return RnLdk.channelsClosed;
|
||||
}
|
||||
|
||||
async purgeLocalStorage() {
|
||||
return RnLdk.getStorage().purgeLocalStorage();
|
||||
}
|
||||
|
||||
/**
|
||||
* executes async function in background, so calling code can return immediately, while catching all thrown exceptions
|
||||
* and showing them in alert() instead of propagating them up
|
||||
|
@ -388,7 +388,7 @@ PODS:
|
||||
- React
|
||||
- RemobileReactNativeQrcodeLocalImage (1.0.4):
|
||||
- React
|
||||
- rn-ldk (0.7.5):
|
||||
- rn-ldk (0.7.6):
|
||||
- React-Core
|
||||
- RNCAsyncStorage (1.17.3):
|
||||
- React-Core
|
||||
@ -801,7 +801,7 @@ SPEC CHECKSUMS:
|
||||
ReactCommon: 07d0c460b9ba9af3eaf1b8f5abe7daaad28c9c4e
|
||||
RealmJS: 8a3478957315c29cdc0b3f958f2e370d22330b2d
|
||||
RemobileReactNativeQrcodeLocalImage: 57aadc12896b148fb5e04bc7c6805f3565f5c3fa
|
||||
rn-ldk: cd7e176c2cc131402cbeaa603f0e9991cd27a896
|
||||
rn-ldk: c820f3926e6df986ca30349a6a70b5ada86e4d82
|
||||
RNCAsyncStorage: 005c0e2f09575360f142d0d1f1f15e4ec575b1af
|
||||
RNCClipboard: 99fc8ad669a376b756fbc8098ae2fd05c0ed0668
|
||||
RNCPushNotificationIOS: 87b8d16d3ede4532745e05b03c42cff33a36cc45
|
||||
|
18
package-lock.json
generated
18
package-lock.json
generated
@ -93,7 +93,7 @@
|
||||
"react-native-secure-key-store": "https://github.com/BlueWallet/react-native-secure-key-store#63ab38c9d382a819844a086a69cc204c46aa93f9",
|
||||
"react-native-share": "7.3.9",
|
||||
"react-native-svg": "12.3.0",
|
||||
"react-native-tcp-socket": "5.5.0",
|
||||
"react-native-tcp-socket": "5.6.1",
|
||||
"react-native-tor": "0.1.8",
|
||||
"react-native-vector-icons": "9.1.0",
|
||||
"react-native-watch-connectivity": "1.0.4",
|
||||
@ -103,7 +103,7 @@
|
||||
"react-test-render": "1.1.2",
|
||||
"readable-stream": "3.6.0",
|
||||
"realm": "10.16.0",
|
||||
"rn-ldk": "github:BlueWallet/rn-ldk#v0.7.5",
|
||||
"rn-ldk": "github:BlueWallet/rn-ldk#v0.8.0",
|
||||
"rn-nodeify": "10.3.0",
|
||||
"scryptsy": "2.1.0",
|
||||
"secure-random": "1.1.2",
|
||||
@ -23997,9 +23997,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/react-native-tcp-socket": {
|
||||
"version": "5.5.0",
|
||||
"resolved": "https://registry.npmjs.org/react-native-tcp-socket/-/react-native-tcp-socket-5.5.0.tgz",
|
||||
"integrity": "sha512-UgcDweEaZzLPK4N3O39ESE5J0UvSC1rFqveM57mS2euv9wXwmWbSIOPN//Fx0VzxnxY9cpwCrMh5DnYv5HOiKg==",
|
||||
"version": "5.6.1",
|
||||
"resolved": "https://registry.npmjs.org/react-native-tcp-socket/-/react-native-tcp-socket-5.6.1.tgz",
|
||||
"integrity": "sha512-uY+ippntATk9w62pHo2q8E03+ZGnqefIAMFeiyDBkO5MmT4lxqPgIoPIbVApnlrBp4T6gFTh5ULHLVtSy65u1g==",
|
||||
"dependencies": {
|
||||
"buffer": "^5.4.3",
|
||||
"eventemitter3": "^4.0.7"
|
||||
@ -47010,9 +47010,9 @@
|
||||
}
|
||||
},
|
||||
"react-native-tcp-socket": {
|
||||
"version": "5.5.0",
|
||||
"resolved": "https://registry.npmjs.org/react-native-tcp-socket/-/react-native-tcp-socket-5.5.0.tgz",
|
||||
"integrity": "sha512-UgcDweEaZzLPK4N3O39ESE5J0UvSC1rFqveM57mS2euv9wXwmWbSIOPN//Fx0VzxnxY9cpwCrMh5DnYv5HOiKg==",
|
||||
"version": "5.6.1",
|
||||
"resolved": "https://registry.npmjs.org/react-native-tcp-socket/-/react-native-tcp-socket-5.6.1.tgz",
|
||||
"integrity": "sha512-uY+ippntATk9w62pHo2q8E03+ZGnqefIAMFeiyDBkO5MmT4lxqPgIoPIbVApnlrBp4T6gFTh5ULHLVtSy65u1g==",
|
||||
"requires": {
|
||||
"buffer": "^5.4.3",
|
||||
"eventemitter3": "^4.0.7"
|
||||
@ -47987,7 +47987,7 @@
|
||||
},
|
||||
"rn-ldk": {
|
||||
"version": "git+ssh://git@github.com/BlueWallet/rn-ldk.git#ff9e26d7fca0e11c8c7d274ef3417104cc7480d8",
|
||||
"from": "rn-ldk@github:BlueWallet/rn-ldk#v0.7.5",
|
||||
"from": "rn-ldk@github:BlueWallet/rn-ldk#v0.8.0",
|
||||
"requires": {}
|
||||
},
|
||||
"rn-nodeify": {
|
||||
|
@ -189,7 +189,7 @@
|
||||
"react-test-render": "1.1.2",
|
||||
"readable-stream": "3.6.0",
|
||||
"realm": "10.16.0",
|
||||
"rn-ldk": "github:BlueWallet/rn-ldk#v0.7.5",
|
||||
"rn-ldk": "github:BlueWallet/rn-ldk#v0.8.0",
|
||||
"rn-nodeify": "10.3.0",
|
||||
"scryptsy": "2.1.0",
|
||||
"secure-random": "1.1.2",
|
||||
|
Loading…
Reference in New Issue
Block a user