mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-02-20 14:05:27 +01:00
FIX: Lightning wallet was throwing error with Tor
This commit is contained in:
parent
38ca642a8c
commit
995a529e2d
6 changed files with 40 additions and 30 deletions
|
@ -67,17 +67,17 @@ export class LightningCustodianWallet extends LegacyWallet {
|
|||
return obj;
|
||||
}
|
||||
|
||||
init() {
|
||||
async init() {
|
||||
this._api = new Frisbee({
|
||||
baseURI: this.baseURI,
|
||||
});
|
||||
isTorDaemonDisabled().then(isDisabled => {
|
||||
if (!isDisabled && this.baseURI && this.baseURI?.indexOf('.onion') !== -1) {
|
||||
this._api = new torrific.Torsbee({
|
||||
baseURI: this.baseURI,
|
||||
});
|
||||
}
|
||||
});
|
||||
const isTorDisabled = await isTorDaemonDisabled();
|
||||
|
||||
if (!isTorDisabled && this.baseURI && this.baseURI?.indexOf('.onion') !== -1) {
|
||||
this._api = new torrific.Torsbee({
|
||||
baseURI: this.baseURI,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
accessTokenExpired() {
|
||||
|
@ -582,14 +582,16 @@ export class LightningCustodianWallet extends LegacyWallet {
|
|||
}
|
||||
|
||||
static async isValidNodeAddress(address) {
|
||||
const isTorDisabled = await isTorDaemonDisabled();
|
||||
const isTor = address.indexOf('.onion') !== -1;
|
||||
const apiCall = isTor
|
||||
? new torrific.Torsbee({
|
||||
baseURI: address,
|
||||
})
|
||||
: new Frisbee({
|
||||
baseURI: address,
|
||||
});
|
||||
const apiCall =
|
||||
isTor && !isTorDisabled
|
||||
? new torrific.Torsbee({
|
||||
baseURI: address,
|
||||
})
|
||||
: new Frisbee({
|
||||
baseURI: address,
|
||||
});
|
||||
const response = await apiCall.get('/getinfo', {
|
||||
headers: {
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
|
|
|
@ -559,11 +559,15 @@ export class LightningLdkWallet extends LightningCustodianWallet {
|
|||
}
|
||||
|
||||
async getLogs() {
|
||||
return RnLdk.getLogs().map(log => log.line).join('\n');
|
||||
return RnLdk.getLogs()
|
||||
.map(log => log.line)
|
||||
.join('\n');
|
||||
}
|
||||
|
||||
async getLogsWithTs() {
|
||||
return RnLdk.getLogs().map(log => log.ts + ' ' + log.line).join('\n');
|
||||
return RnLdk.getLogs()
|
||||
.map(log => log.ts + ' ' + log.line)
|
||||
.join('\n');
|
||||
}
|
||||
|
||||
async fetchPendingTransactions() {}
|
||||
|
|
|
@ -367,7 +367,7 @@ PODS:
|
|||
- React
|
||||
- RemobileReactNativeQrcodeLocalImage (1.0.4):
|
||||
- React
|
||||
- rn-ldk (0.2.16):
|
||||
- rn-ldk (0.3.0):
|
||||
- React-Core
|
||||
- RNCAsyncStorage (1.15.8):
|
||||
- React-Core
|
||||
|
@ -377,7 +377,7 @@ PODS:
|
|||
- React-Core
|
||||
- RNDefaultPreference (1.4.3):
|
||||
- React
|
||||
- RNDeviceInfo (8.3.3):
|
||||
- RNDeviceInfo (8.4.0):
|
||||
- React-Core
|
||||
- RNFS (2.18.0):
|
||||
- React
|
||||
|
@ -765,12 +765,12 @@ SPEC CHECKSUMS:
|
|||
ReactCommon: 149906e01aa51142707a10665185db879898e966
|
||||
RealmJS: 7271bc9f8579716260511cb43b0fb6b0321ce206
|
||||
RemobileReactNativeQrcodeLocalImage: 57aadc12896b148fb5e04bc7c6805f3565f5c3fa
|
||||
rn-ldk: 154c61e76904229ce339f2ca44c84ab59618be22
|
||||
rn-ldk: 1c2f11f1dfb63f680b40964f2adb51f4df7b8578
|
||||
RNCAsyncStorage: 0f655864a81214d1c5a9bf0faf79d86dc25c383e
|
||||
RNCClipboard: 5df122bc31f95f2b37de9bbadc1dbef5a79cb1b0
|
||||
RNCPushNotificationIOS: 089da3b657e1e3d464f38195fd2e3069608ef5af
|
||||
RNDefaultPreference: 21816c0a6f61a2829ccc0cef034392e9b509ee5f
|
||||
RNDeviceInfo: 0d6865ab0a57d9192bdd4e4f5894340b846c3e53
|
||||
RNDeviceInfo: 99b0a4fc191808e58e0a045640706100fc3d771c
|
||||
RNFS: 3ab21fa6c56d65566d1fb26c2228e2b6132e5e32
|
||||
RNGestureHandler: a479ebd5ed4221a810967000735517df0d2db211
|
||||
RNHandoff: d3b0754cca3a6bcd9b25f544f733f7f033ccf5fa
|
||||
|
|
6
package-lock.json
generated
6
package-lock.json
generated
|
@ -19723,9 +19723,9 @@
|
|||
"integrity": "sha512-sQDYwGEdxwKwXKP/8Intc81FyH33Rv8ZvOxdmPX4NM75RAIVeBc13pdabEqycAimNZoY5IDvGp4o1cTTa5gNrA=="
|
||||
},
|
||||
"react-native-device-info": {
|
||||
"version": "8.3.3",
|
||||
"resolved": "https://registry.npmjs.org/react-native-device-info/-/react-native-device-info-8.3.3.tgz",
|
||||
"integrity": "sha512-l8/3MHq6O9PRWSrKwy63WvDCnt8IXOce86AEkJFVVtKR9cAGLLaFyXUGyqIc5T/kpCyOqofOattVDjZGUn/zAQ=="
|
||||
"version": "8.4.0",
|
||||
"resolved": "https://registry.npmjs.org/react-native-device-info/-/react-native-device-info-8.4.0.tgz",
|
||||
"integrity": "sha512-/ZHDJajkEmjNmjvm52o7pqIpR2uKocD66iH00GMe5QpUdM9u9vDxS2hgcRbgrVaKEfA5IRIBctpalYMrrbQU+Q=="
|
||||
},
|
||||
"react-native-document-picker": {
|
||||
"version": "git+https://github.com/BlueWallet/react-native-document-picker.git#3684d4fcc2bc0b47c32be39024e4796004c3e428",
|
||||
|
|
|
@ -10,18 +10,15 @@ import { BlueButton, BlueButtonLink, BlueCard, BlueLoading, BlueSpacing20, BlueT
|
|||
import { AppStorage } from '../../class';
|
||||
import { LightningCustodianWallet } from '../../class/wallets/lightning-custodian-wallet';
|
||||
import loc from '../../loc';
|
||||
import { BlueCurrentTheme, useTheme } from '../../components/themes';
|
||||
import { useTheme } from '../../components/themes';
|
||||
import DeeplinkSchemaMatch from '../../class/deeplink-schema-match';
|
||||
import { isTorCapable } from '../../blue_modules/environment';
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
uri: {
|
||||
flexDirection: 'row',
|
||||
borderColor: BlueCurrentTheme.colors.formBorder,
|
||||
borderBottomColor: BlueCurrentTheme.colors.formBorder,
|
||||
borderWidth: 1,
|
||||
borderBottomWidth: 0.5,
|
||||
backgroundColor: BlueCurrentTheme.colors.inputBackgroundColor,
|
||||
minHeight: 44,
|
||||
height: 44,
|
||||
alignItems: 'center',
|
||||
|
@ -59,6 +56,13 @@ const LightningSettings: React.FC & { navigationOptions: NavigationOptionsGetter
|
|||
const { colors } = useTheme();
|
||||
const route = useRoute();
|
||||
const navigation = useNavigation();
|
||||
const styleHook = StyleSheet.create({
|
||||
uri: {
|
||||
borderColor: colors.formBorder,
|
||||
borderBottomColor: colors.formBorder,
|
||||
backgroundColor: colors.inputBackgroundColor,
|
||||
},
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
AsyncStorage.getItem(AppStorage.LNDHUB)
|
||||
|
@ -144,7 +148,7 @@ const LightningSettings: React.FC & { navigationOptions: NavigationOptionsGetter
|
|||
/>
|
||||
|
||||
<BlueCard>
|
||||
<View style={styles.uri}>
|
||||
<View style={[styles.uri, styleHook.uri]}>
|
||||
<TextInput
|
||||
value={URI}
|
||||
placeholder={
|
||||
|
|
|
@ -201,7 +201,7 @@ const WalletsAdd = () => {
|
|||
const isValidNodeAddress = await LightningCustodianWallet.isValidNodeAddress(lndhub);
|
||||
if (isValidNodeAddress) {
|
||||
wallet.setBaseURI(lndhub);
|
||||
wallet.init();
|
||||
await wallet.init();
|
||||
} else {
|
||||
throw new Error('The provided node address is not valid LNDHub node.');
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue