use RN RandomBytes synchronously
Keysend now working end-to-end
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
import {AppRegistry} from 'react-native';
|
||||
import 'react-native-gesture-handler';
|
||||
import './shim.js'
|
||||
import App from './App.tsx';
|
||||
import {name as appName} from './app.json';
|
||||
|
||||
|
||||
Generated
+1147
-27
File diff suppressed because it is too large
Load Diff
+83
-1
@@ -4,6 +4,7 @@
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start": "react-native start",
|
||||
"postinstall": "rn-nodeify --install --hack",
|
||||
"patch": "git apply patches/RCTHTTPRequestHandler.mm.patch",
|
||||
"patch-android-release": "git apply patches/rnck-build.gradle.patch",
|
||||
"test": "jest",
|
||||
@@ -12,25 +13,43 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@react-native-community/masked-view": "^0.1.6",
|
||||
"@tradle/react-native-http": "^2.0.1",
|
||||
"assert": "^1.5.0",
|
||||
"axios": "^0.19.2",
|
||||
"base-64": "0.1.0",
|
||||
"browserify-zlib": "^0.1.4",
|
||||
"buffer": "^5.6.0",
|
||||
"console-browserify": "^1.2.0",
|
||||
"constants-browserify": "^1.0.0",
|
||||
"dateformat": "3.0.3",
|
||||
"dns.js": "^1.0.1",
|
||||
"domain-browser": "^1.2.0",
|
||||
"events": "^1.1.1",
|
||||
"hash.js": "1.1.7",
|
||||
"https-browserify": "0.0.1",
|
||||
"identicon.js": "2.3.3",
|
||||
"js-lnurl": "0.0.8",
|
||||
"js-sha256": "^0.9.0",
|
||||
"jsc-android": "^241213.1.0",
|
||||
"lodash": "4.17.15",
|
||||
"mobx": "^5.15.3",
|
||||
"mobx-react": "^6.1.4",
|
||||
"object-hash": "1.3.1",
|
||||
"path-browserify": "0.0.0",
|
||||
"process": "^0.11.10",
|
||||
"punycode": "^1.4.1",
|
||||
"querystring-es3": "^0.2.1",
|
||||
"react": "^16.12.0",
|
||||
"react-native": "^0.61.5",
|
||||
"react-native-activity-result-fork": "0.1.3",
|
||||
"react-native-camera-kit": "^8.0.4",
|
||||
"react-native-crypto": "^2.2.0",
|
||||
"react-native-data-table": "^0.2.1",
|
||||
"react-native-elements": "^1.2.7",
|
||||
"react-native-gesture-handler": "^1.5.3",
|
||||
"react-native-level-fs": "^3.0.1",
|
||||
"react-native-linear-gradient": "^2.5.3",
|
||||
"react-native-os": "^1.2.6",
|
||||
"react-native-paper": "^3.4.0",
|
||||
"react-native-permissions": "^2.0.9",
|
||||
"react-native-qrcode-svg": "^6.0.1",
|
||||
@@ -40,12 +59,22 @@
|
||||
"react-native-screens": "^2.0.0-alpha.29",
|
||||
"react-native-secure-key-store": "^2.0.5",
|
||||
"react-native-svg": "^9.13.6",
|
||||
"react-native-tcp": "^3.3.2",
|
||||
"react-native-udp": "^2.7.0",
|
||||
"react-native-unimodules": "^0.7.0",
|
||||
"react-native-vector-icons": "^6.6.0",
|
||||
"react-navigation": "^4.0.10",
|
||||
"react-navigation-stack": "^2.0.16",
|
||||
"readable-stream": "^1.0.33",
|
||||
"realm": "^3.6.0",
|
||||
"sha.js": "^2.4.11"
|
||||
"sha.js": "^2.4.11",
|
||||
"stream-browserify": "^1.0.0",
|
||||
"string_decoder": "^0.10.31",
|
||||
"timers-browserify": "^1.4.2",
|
||||
"tty-browserify": "0.0.0",
|
||||
"url": "^0.10.3",
|
||||
"util": "^0.10.4",
|
||||
"vm-browserify": "0.0.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.6.2",
|
||||
@@ -67,6 +96,59 @@
|
||||
"metro-react-native-babel-preset": "^0.58.0",
|
||||
"prettier": "1.18.2",
|
||||
"react-test-renderer": "16.6.3",
|
||||
"rn-nodeify": "^10.2.0",
|
||||
"typescript": "^3.7.5"
|
||||
},
|
||||
"react-native": {
|
||||
"zlib": "browserify-zlib",
|
||||
"console": "console-browserify",
|
||||
"constants": "constants-browserify",
|
||||
"crypto": "react-native-crypto",
|
||||
"dns": "dns.js",
|
||||
"net": "react-native-tcp",
|
||||
"domain": "domain-browser",
|
||||
"http": "@tradle/react-native-http",
|
||||
"https": "https-browserify",
|
||||
"os": "react-native-os",
|
||||
"path": "path-browserify",
|
||||
"querystring": "querystring-es3",
|
||||
"fs": "react-native-level-fs",
|
||||
"_stream_transform": "readable-stream/transform",
|
||||
"_stream_readable": "readable-stream/readable",
|
||||
"_stream_writable": "readable-stream/writable",
|
||||
"_stream_duplex": "readable-stream/duplex",
|
||||
"_stream_passthrough": "readable-stream/passthrough",
|
||||
"dgram": "react-native-udp",
|
||||
"stream": "stream-browserify",
|
||||
"timers": "timers-browserify",
|
||||
"tty": "tty-browserify",
|
||||
"vm": "vm-browserify",
|
||||
"tls": false
|
||||
},
|
||||
"browser": {
|
||||
"zlib": "browserify-zlib",
|
||||
"console": "console-browserify",
|
||||
"constants": "constants-browserify",
|
||||
"crypto": "react-native-crypto",
|
||||
"dns": "dns.js",
|
||||
"net": "react-native-tcp",
|
||||
"domain": "domain-browser",
|
||||
"http": "@tradle/react-native-http",
|
||||
"https": "https-browserify",
|
||||
"os": "react-native-os",
|
||||
"path": "path-browserify",
|
||||
"querystring": "querystring-es3",
|
||||
"fs": "react-native-level-fs",
|
||||
"_stream_transform": "readable-stream/transform",
|
||||
"_stream_readable": "readable-stream/readable",
|
||||
"_stream_writable": "readable-stream/writable",
|
||||
"_stream_duplex": "readable-stream/duplex",
|
||||
"_stream_passthrough": "readable-stream/passthrough",
|
||||
"dgram": "react-native-udp",
|
||||
"stream": "stream-browserify",
|
||||
"timers": "timers-browserify",
|
||||
"tty": "tty-browserify",
|
||||
"vm": "vm-browserify",
|
||||
"tls": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
if (typeof __dirname === 'undefined') global.__dirname = '/'
|
||||
if (typeof __filename === 'undefined') global.__filename = ''
|
||||
if (typeof process === 'undefined') {
|
||||
global.process = require('process')
|
||||
} else {
|
||||
const bProcess = require('process')
|
||||
for (var p in bProcess) {
|
||||
if (!(p in process)) {
|
||||
process[p] = bProcess[p]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
process.browser = false
|
||||
if (typeof Buffer === 'undefined') global.Buffer = require('buffer').Buffer
|
||||
|
||||
// global.location = global.location || { port: 80 }
|
||||
const isDev = typeof __DEV__ === 'boolean' && __DEV__
|
||||
process.env['NODE_ENV'] = isDev ? 'development' : 'production'
|
||||
if (typeof localStorage !== 'undefined') {
|
||||
localStorage.debug = isDev ? '*' : ''
|
||||
}
|
||||
|
||||
// If using the crypto shim, uncomment the following line to ensure
|
||||
// crypto is loaded first, so it can populate global.crypto
|
||||
// require('crypto')
|
||||
+21
-12
@@ -5,8 +5,9 @@ import ErrorUtils from './../utils/ErrorUtils';
|
||||
import SettingsStore from './SettingsStore';
|
||||
import RESTUtils from './../utils/RESTUtils';
|
||||
import { randomBytes } from 'react-native-randombytes';
|
||||
import { NativeModules } from 'react-native';
|
||||
const { RNRandomBytes } = NativeModules;
|
||||
import { sha256 } from 'js-sha256';
|
||||
import Base64Utils from './../utils/Base64Utils';
|
||||
import { Buffer } from 'buffer';
|
||||
|
||||
const keySendPreimageType = '5482373484';
|
||||
const preimageByteLength = 32;
|
||||
@@ -84,7 +85,11 @@ export default class TransactionsStore {
|
||||
});
|
||||
};
|
||||
|
||||
sendPayment = (payment_request: string, amount?: string, pubkey?: string) => {
|
||||
sendPayment = (
|
||||
payment_request: string,
|
||||
amount?: string,
|
||||
pubkey?: string
|
||||
) => {
|
||||
const { implementation } = this.settingsStore;
|
||||
|
||||
this.loading = true;
|
||||
@@ -104,15 +109,19 @@ export default class TransactionsStore {
|
||||
};
|
||||
} else {
|
||||
if (pubkey) {
|
||||
RNRandomBytes.randomBytes(preimageByteLength, (err, preimage) => {
|
||||
const secret = preimage.toString('hex');
|
||||
const preimage = randomBytes(preimageByteLength);
|
||||
const secret = preimage.toString('base64');
|
||||
const payment_hash = Buffer.from(
|
||||
sha256(preimage),
|
||||
'hex'
|
||||
).toString('base64');
|
||||
|
||||
data = {
|
||||
amt: amount,
|
||||
dest_string: pubkey,
|
||||
dest_custom_records: { [keySendPreimageType]: secret }
|
||||
};
|
||||
});
|
||||
data = {
|
||||
amt: amount,
|
||||
dest_string: pubkey,
|
||||
dest_custom_records: { [keySendPreimageType]: secret },
|
||||
payment_hash
|
||||
};
|
||||
} else {
|
||||
if (amount) {
|
||||
data = {
|
||||
@@ -135,7 +144,7 @@ export default class TransactionsStore {
|
||||
this.payment_route = data.payment_route;
|
||||
this.payment_preimage = data.payment_preimage;
|
||||
this.payment_hash = data.payment_hash;
|
||||
if (data.payment_error !== "") {
|
||||
if (data.payment_error !== '') {
|
||||
this.payment_error = data.payment_error;
|
||||
}
|
||||
this.status = data.status;
|
||||
|
||||
+2
-3
@@ -84,15 +84,14 @@ class RESTUtils {
|
||||
method: any,
|
||||
cancelToken?: any,
|
||||
data?: any
|
||||
) => {
|
||||
return axios.request({
|
||||
) =>
|
||||
axios.request({
|
||||
method,
|
||||
url,
|
||||
headers,
|
||||
cancelToken,
|
||||
data
|
||||
});
|
||||
};
|
||||
|
||||
getHeaders = (implementation: string, macaroonHex: string) => {
|
||||
if (implementation === 'c-lightning-REST') {
|
||||
|
||||
Reference in New Issue
Block a user