Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: validate node id #2275

Merged
merged 3 commits into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ android {
applicationId "to.bitkit"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 135
versionName "1.0.4"
versionCode 136
versionName "1.0.5"
multiDexEnabled true
missingDimensionStrategy 'react-native-camera', 'general'
testBuildType System.getProperty('testBuildType', 'debug')
Expand Down
9 changes: 7 additions & 2 deletions ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ end
node_require('react-native/scripts/react_native_pods.rb')
node_require('react-native-permissions/scripts/setup.rb')

# Read min iOS version from Xcode project and set as min iOS version for Podfile
require 'xcodeproj'
project_path = File.expand_path('bitkit.xcodeproj', __dir__)
project = Xcodeproj::Project.open(project_path)
min_ios_version_supported = project.build_configurations.first.build_settings['IPHONEOS_DEPLOYMENT_TARGET']
puts "Set minimum iOS version supported using Xcode project: #{min_ios_version_supported}"

platform :ios, min_ios_version_supported
prepare_react_native_project!

Expand All @@ -27,8 +34,6 @@ if linkage != nil
end

target 'bitkit' do
# lock OpenSSL otherwise it breaks react-native-quick-crypto
pod "OpenSSL-Universal", "= 1.1.1100"
config = use_native_modules!

use_react_native!(
Expand Down
23 changes: 11 additions & 12 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ PODS:
- MMKV (1.3.7):
- MMKVCore (~> 1.3.7)
- MMKVCore (1.3.7)
- OpenSSL-Universal (1.1.1100)
- OpenSSL-Universal (3.3.2000)
- RCT-Folly (2024.01.01.00):
- boost
- DoubleConversion
Expand Down Expand Up @@ -1849,13 +1849,13 @@ PODS:
- React-Core
- RNSVG (15.2.0):
- React-Core
- RNZipArchive (6.1.0):
- RNZipArchive (7.0.1):
- React-Core
- RNZipArchive/Core (= 6.1.0)
- SSZipArchive (~> 2.2)
- RNZipArchive/Core (6.1.0):
- RNZipArchive/Core (= 7.0.1)
- SSZipArchive (~> 2.5.5)
- RNZipArchive/Core (7.0.1):
- React-Core
- SSZipArchive (~> 2.2)
- SSZipArchive (~> 2.5.5)
- SocketRocket (0.7.0)
- sodium-react-native-direct (0.4.2):
- DoubleConversion
Expand All @@ -1878,7 +1878,7 @@ PODS:
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- SSZipArchive (2.4.3)
- SSZipArchive (2.5.5)
- Yoga (0.0.0)
- ZXingObjC (3.6.9):
- ZXingObjC/All (= 3.6.9)
Expand All @@ -1892,7 +1892,6 @@ DEPENDENCIES:
- glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`)
- hermes-engine (from `../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec`)
- lottie-react-native (from `../node_modules/lottie-react-native`)
- OpenSSL-Universal (= 1.1.1100)
- RCT-Folly (from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`)
- RCT-Folly/Fabric (from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`)
- RCTDeprecation (from `../node_modules/react-native/ReactApple/Libraries/RCTFoundation/RCTDeprecation`)
Expand Down Expand Up @@ -2200,7 +2199,7 @@ SPEC CHECKSUMS:
lottie-react-native: 31197e5c65aa7cb59e6affcefaf901588bb708c4
MMKV: 36a22a9ec84c9bb960613a089ddf6f48be9312b0
MMKVCore: 158e61c8516401a9fac730288acb29e6fc19bbf9
OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c
OpenSSL-Universal: b60a3702c9fea8b3145549d421fdb018e53ab7b4
RCT-Folly: 4464f4d875961fce86008d45f4ecf6cef6de0740
RCTDeprecation: 34cbf122b623037ea9facad2e92e53434c5c7422
RCTRequired: 24c446d7bcd0f517d516b6265d8df04dc3eb1219
Expand Down Expand Up @@ -2286,13 +2285,13 @@ SPEC CHECKSUMS:
RNScreens: 19719a9c326e925498ac3b2d35c4e50fe87afc06
RNShare: 554a91f5cfbe4adac4cfe3654826ee8b299fe365
RNSVG: 43b64ed39c14ce830d840903774154ca0c1f27ec
RNZipArchive: ef9451b849c45a29509bf44e65b788829ab07801
RNZipArchive: 7bb4c70d6aa2dd235212c0a4a3de0a4e237e2569
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
sodium-react-native-direct: 8feb9a6d0d88ce65efa305d6cc774c11c62d9a15
SSZipArchive: fe6a26b2a54d5a0890f2567b5cc6de5caa600aef
SSZipArchive: c69881e8ac5521f0e622291387add5f60f30f3c4
Yoga: 2a45d7e59592db061217551fd3bbe2dd993817ae
ZXingObjC: 8898711ab495761b2dbbdec76d90164a6d7e14c5

PODFILE CHECKSUM: 8c2c3949d19327675be00d5f066e8eab99dd1e04
PODFILE CHECKSUM: b1ff2276b558626bd07bddd66e26b06f3fc76609

COCOAPODS: 1.15.2
20 changes: 10 additions & 10 deletions ios/bitkit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@
"$(inherited)",
);
INFOPLIST_FILE = bitkitTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.4;
IPHONEOS_DEPLOYMENT_TARGET = 16.6;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand All @@ -495,7 +495,7 @@
BUNDLE_LOADER = "$(TEST_HOST)";
COPY_PHASE_STRIP = NO;
INFOPLIST_FILE = bitkitTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.4;
IPHONEOS_DEPLOYMENT_TARGET = 16.6;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand All @@ -519,18 +519,18 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIconOrange;
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 135;
CURRENT_PROJECT_VERSION = 136;
DEVELOPMENT_TEAM = KYH47R284B;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = bitkit/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = Bitkit;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
IPHONEOS_DEPLOYMENT_TARGET = 13.4;
IPHONEOS_DEPLOYMENT_TARGET = 15.6;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.4;
MARKETING_VERSION = 1.0.5;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand All @@ -551,18 +551,18 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIconOrange;
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 135;
CURRENT_PROJECT_VERSION = 136;
DEVELOPMENT_TEAM = KYH47R284B;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = bitkit/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = Bitkit;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
IPHONEOS_DEPLOYMENT_TARGET = 13.4;
IPHONEOS_DEPLOYMENT_TARGET = 15.6;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.4;
MARKETING_VERSION = 1.0.5;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down Expand Up @@ -627,7 +627,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 13.4;
IPHONEOS_DEPLOYMENT_TARGET = 15.6;
LD = "";
LDPLUSPLUS = "";
LD_RUNPATH_SEARCH_PATHS = (
Expand Down Expand Up @@ -706,7 +706,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 13.4;
IPHONEOS_DEPLOYMENT_TARGET = 15.6;
LD = "";
LDPLUSPLUS = "";
LD_RUNPATH_SEARCH_PATHS = (
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "bitkit",
"author": "Synonym",
"version": "1.0.4",
"version": "1.0.5",
"scripts": {
"start": "react-native start",
"android": "react-native run-android",
Expand Down Expand Up @@ -112,7 +112,7 @@
"react-native-svg": "15.2.0",
"react-native-tcp-socket": "6.0.6",
"react-native-toast-message": "2.2.0",
"react-native-zip-archive": "6.1.0",
"react-native-zip-archive": "7.0.1",
"react-redux": "9.1.2",
"readable-stream": "4.5.2",
"redux": "5.0.1",
Expand Down
22 changes: 22 additions & 0 deletions src/utils/lightning/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { EmitterSubscription } from 'react-native';
import Keychain from '@synonymdev/react-native-keychain';
import * as bitcoin from 'bitcoinjs-lib';
import ecc from '@bitcoinerlab/secp256k1';
import RNFS from 'react-native-fs';
import { err, ok, Result } from '@synonymdev/result';
import { EPaymentType, TGetAddressHistory } from 'beignet';
Expand Down Expand Up @@ -1039,6 +1040,23 @@ export const parseUri = (
return ok({ publicKey, ip, port });
};

const isValidLightningNodePublicKey = (pubkey: string): boolean => {
const pubkeyBytes = new Uint8Array(Buffer.from(pubkey, 'hex'));
if (pubkeyBytes.length !== 33) {
return false;
}

if (!ecc.isPoint(pubkeyBytes)) {
return false;
}

if (!ecc.isPointCompressed(pubkeyBytes)) {
return false;
}

return true;
};

/**
* Prompt LDK to add a specified peer.
* @param {string} peer
Expand All @@ -1056,6 +1074,10 @@ export const addPeer = async ({
return err(parsedUri.error.message);
}

if (!isValidLightningNodePublicKey(parsedUri.value.publicKey)) {
return err(i18n.t('lightning:error_add_msg'));
}

const res = await lm.addPeer({
pubKey: parsedUri.value.publicKey,
address: parsedUri.value.ip,
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6695,7 +6695,7 @@ __metadata:
react-native-svg-transformer: ^1.3.0
react-native-tcp-socket: 6.0.6
react-native-toast-message: 2.2.0
react-native-zip-archive: 6.1.0
react-native-zip-archive: 7.0.1
react-redux: 9.1.2
reactotron-react-native: ^5.1.6
reactotron-react-native-mmkv: ^0.2.6
Expand Down Expand Up @@ -14606,13 +14606,13 @@ __metadata:
languageName: node
linkType: hard

"react-native-zip-archive@npm:6.1.0":
version: 6.1.0
resolution: "react-native-zip-archive@npm:6.1.0"
"react-native-zip-archive@npm:7.0.1":
version: 7.0.1
resolution: "react-native-zip-archive@npm:7.0.1"
peerDependencies:
react: ">=16.8.6"
react-native: ">=0.60.0"
checksum: bb329e3dde9550a1ca51076034f912c1210df8c1697c8522329a16bd1980c9084dc29c3fda52418b1c6bf8423cca7dec3d0f8a7f6f999278a4111f07d7cdbb80
checksum: 2f7747d2ed903102e0d097921d1a019311f0c23c9ceb15304c39d699fba380e60b70cb1474b1fb516d114514af2a3c8a88ee5690f83d0a92d87500d095ba2b39
languageName: node
linkType: hard

Expand Down
Loading