Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
gruve-p committed Feb 6, 2024
2 parents 3c7bbdd + fa6d606 commit b88eaf7
Show file tree
Hide file tree
Showing 36 changed files with 396 additions and 314 deletions.
2 changes: 1 addition & 1 deletion App.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ const App = () => {
useEffect(() => {
if (Platform.OS === 'ios') {
// Call hide to setup the listener on the native side
SplashScreen.addObserver();
SplashScreen?.addObserver();
}
}, []);

Expand Down
6 changes: 3 additions & 3 deletions BlueComponents.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
Keyboard,
KeyboardAvoidingView,
Platform,
SafeAreaView,
StyleSheet,
TextInput,
TouchableOpacity,
Expand All @@ -26,6 +25,7 @@ import AsyncStorage from '@react-native-async-storage/async-storage';
import { BlueCurrentTheme, useTheme } from './components/themes';
import PlusIcon from './components/icons/PlusIcon';
import loc, { formatStringAddTwoWhiteSpaces } from './loc';
import SafeArea from './components/SafeArea';

const { height, width } = Dimensions.get('window');
const aspectRatio = height / width;
Expand Down Expand Up @@ -395,7 +395,7 @@ export const BlueHeaderDefaultSub = props => {
const { colors } = useTheme();

return (
<SafeAreaView>
<SafeArea>
<Header
backgroundColor={colors.background}
leftContainerStyle={{ minWidth: '100%' }}
Expand All @@ -417,7 +417,7 @@ export const BlueHeaderDefaultSub = props => {
}
{...props}
/>
</SafeAreaView>
</SafeArea>
);
};

Expand Down
2 changes: 1 addition & 1 deletion Navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { createDrawerNavigator } from '@react-navigation/drawer';
import { Platform, useWindowDimensions, Dimensions, I18nManager } from 'react-native';

import Settings from './screen/settings/settings';
import Settings from './screen/settings/Settings';
import About from './screen/settings/about';
import ReleaseNotes from './screen/settings/releasenotes';
import Licensing from './screen/settings/licensing';
Expand Down
10 changes: 5 additions & 5 deletions UnlockWith.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import React, { useContext, useEffect, useState } from 'react';
import { View, Image, TouchableOpacity, StyleSheet, ActivityIndicator, useColorScheme, NativeModules } from 'react-native';
import { Icon } from 'react-native-elements';
import Biometric from './class/biometrics';
import { SafeAreaView } from 'react-native-safe-area-context';
import { StackActions, useNavigation, useRoute } from '@react-navigation/native';
import { BlueStorageContext } from './blue_modules/storage-context';
import { isHandset } from './blue_modules/environment';
import triggerHapticFeedback, { HapticFeedbackTypes } from './blue_modules/hapticFeedback';
import SafeArea from './components/SafeArea';

const styles = StyleSheet.create({
root: {
Expand Down Expand Up @@ -121,19 +121,19 @@ const UnlockWith = () => {
}

setBiometricType(bt);
if (!biometricType || storageIsEncrypted) {
if (!bt || storageIsEncrypted) {
unlockWithKey();
} else if (typeof biometricType === 'string') unlockWithBiometrics();
} else if (typeof bt === 'string') unlockWithBiometrics();
}
};

return (
<SafeAreaView style={styles.root}>
<SafeArea style={styles.root}>
<View style={styles.container}>
<Image source={require('./img/icon.png')} style={styles.logoImage} resizeMode="contain" />
</View>
<View style={styles.biometricRow}>{renderUnlockOptions()}</View>
</SafeAreaView>
</SafeArea>
);
};

Expand Down
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "6.4.17"
versionName "6.5.2"
testBuildType System.getProperty('testBuildType', 'debug')
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
Expand Down
4 changes: 0 additions & 4 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
android:windowSoftInputMode="adjustResize"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
Expand Down
8 changes: 8 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ subprojects {
}
}
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
if (project.plugins.hasPlugin("com.android.application") || project.plugins.hasPlugin("com.android.library")) {
kotlinOptions.jvmTarget = android.compileOptions.sourceCompatibility
} else {
kotlinOptions.jvmTarget = sourceCompatibility
}
}

}
}

Expand Down
7 changes: 5 additions & 2 deletions blue_modules/BlueElectrum.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ const ElectrumClient = require('electrum-client');
const reverse = require('buffer-reverse');
const BigNumber = require('bignumber.js');

const net = require('net');
const tls = require('tls');

const Realm = require('realm');

const ELECTRUM_HOST = 'electrum_host';
Expand Down Expand Up @@ -147,7 +150,7 @@ async function connectMain() {

try {
console.log('begin connection:', JSON.stringify(usingPeer));
mainClient = new ElectrumClient(global.net, global.tls, usingPeer.ssl || usingPeer.tcp, usingPeer.host, usingPeer.ssl ? 'tls' : 'tcp');
mainClient = new ElectrumClient(net, tls, usingPeer.ssl || usingPeer.tcp, usingPeer.host, usingPeer.ssl ? 'tls' : 'tcp');

mainClient.onError = function (e) {
console.log('electrum mainClient.onError():', e.message);
Expand Down Expand Up @@ -960,7 +963,7 @@ module.exports.calculateBlockTime = function (height) {
* @returns {Promise<boolean>} Whether provided host:port is a valid electrum-grs server
*/
module.exports.testConnection = async function (host, tcpPort, sslPort) {
const client = new ElectrumClient(global.net, global.tls, sslPort || tcpPort, host, sslPort ? 'tls' : 'tcp');
const client = new ElectrumClient(net, tls, sslPort || tcpPort, host, sslPort ? 'tls' : 'tcp');

client.onError = () => {}; // mute
let timeoutId = false;
Expand Down
110 changes: 0 additions & 110 deletions blue_modules/net.js

This file was deleted.

46 changes: 0 additions & 46 deletions blue_modules/tls.js

This file was deleted.

26 changes: 23 additions & 3 deletions class/biometrics.js → class/biometrics.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import FingerprintScanner from 'react-native-fingerprint-scanner';
import { Platform, Alert } from 'react-native';
// @ts-ignore react-native-passcode-auth wants d.ts
import PasscodeAuth from 'react-native-passcode-auth';
import * as NavigationService from '../NavigationService';
import { StackActions, CommonActions } from '@react-navigation/native';
Expand All @@ -9,7 +10,26 @@ import { useContext } from 'react';
import { BlueStorageContext } from '../blue_modules/storage-context';
import alert from '../components/Alert';

function Biometric() {
// Define a function type with properties
type DescribableFunction = {
(): void; // Call signature
STORAGEKEY: string; // Property
FaceID: string; // Property etc...
TouchID: string;
Biometrics: string;
isBiometricUseCapableAndEnabled: () => Promise<undefined | boolean>;
isDeviceBiometricCapable: () => Promise<boolean | undefined>;
setBiometricUseEnabled: (arg: boolean) => Promise<void>;
biometricType: () => Promise<boolean | 'Touch ID' | 'Face ID' | 'Biometrics'>;
isBiometricUseEnabled: () => Promise<boolean>;
unlockWithBiometrics: () => Promise<unknown>;
clearKeychain: () => Promise<void>;
requestDevicePasscode: () => Promise<void>;
showKeychainWipeAlert: () => void;
};

// @ts-ignore Bastard component/module. All properties are added in runtime, not at definition phase
const Biometric: DescribableFunction = function () {
const { getItem, setItem } = useContext(BlueStorageContext);
Biometric.STORAGEKEY = 'Biometrics';
Biometric.FaceID = 'Face ID';
Expand Down Expand Up @@ -85,7 +105,7 @@ function Biometric() {
};

Biometric.requestDevicePasscode = async () => {
let isDevicePasscodeSupported = false;
let isDevicePasscodeSupported: boolean | undefined = false;
try {
isDevicePasscodeSupported = await PasscodeAuth.isSupported();
if (isDevicePasscodeSupported) {
Expand Down Expand Up @@ -142,6 +162,6 @@ function Biometric() {
}
};
return null;
}
};

export default Biometric;
2 changes: 1 addition & 1 deletion class/lnurl.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export default class Lnurl {
const decoded = this.decodeInvoice(this._lnurlPayServiceBolt11Payload.pr);
const metadataHash = createHash('sha256').update(this._lnurlPayServicePayload.metadata).digest('hex');
if (metadataHash !== decoded.description_hash) {
throw new Error(`Invoice description_hash doesn't match metadata.`);
console.log(`Invoice description_hash doesn't match metadata.`);
}
if (parseInt(decoded.num_satoshis, 10) !== Math.round(amountSat)) {
throw new Error(`Invoice doesn't match specified amount, got ${decoded.num_satoshis}, expected ${Math.round(amountSat)}`);
Expand Down
Loading

0 comments on commit b88eaf7

Please sign in to comment.