FIX: Connect to the same electrum server as the app.

This commit is contained in:
marcosrdz 2020-11-11 21:04:10 -05:00
parent ae2380e132
commit c986c557ac

View File

@ -44,6 +44,17 @@ async function connectMain() {
usingPeer = savedPeer;
}
try {
await DefaultPreference.setName('group.io.bluewallet.bluewallet');
await DefaultPreference.set(AppStorage.ELECTRUM_HOST, usingPeer.host);
await DefaultPreference.set(AppStorage.ELECTRUM_TCP_PORT, usingPeer.tcp);
await DefaultPreference.set(AppStorage.ELECTRUM_SSL_PORT, usingPeer.ssl);
RNWidgetCenter.reloadAllTimelines();
} catch (e) {
// Must be running on Android
console.log(e);
}
try {
console.log('begin connection:', JSON.stringify(usingPeer));
mainClient = new ElectrumClient(usingPeer.ssl || usingPeer.tcp, usingPeer.host, usingPeer.ssl ? 'tls' : 'tcp');
@ -105,17 +116,6 @@ async function getSavedPeer() {
const host = await AsyncStorage.getItem(AppStorage.ELECTRUM_HOST);
const port = await AsyncStorage.getItem(AppStorage.ELECTRUM_TCP_PORT);
const sslPort = await AsyncStorage.getItem(AppStorage.ELECTRUM_SSL_PORT);
try {
await DefaultPreference.setName('group.io.bluewallet.bluewallet');
await DefaultPreference.set(AppStorage.ELECTRUM_HOST, host);
await DefaultPreference.set(AppStorage.ELECTRUM_TCP_PORT, port);
await DefaultPreference.set(AppStorage.ELECTRUM_SSL_PORT, sslPort);
RNWidgetCenter.reloadAllTimelines();
} catch (e) {
// Must be running on Android
console.log(e);
}
return { host, tcp: port, ssl: sslPort };
}