opt dep, fix lihsmd embed

This commit is contained in:
Evanfeenstra 2021-07-21 10:12:22 -07:00
parent 1a7dff58ea
commit 64509f1ebd
8 changed files with 131 additions and 10 deletions

82
build/config.gypi Normal file
View file

@ -0,0 +1,82 @@
# Do not edit. File was generated by node-gyp's "configure" step
{
"target_defaults": {
"cflags": [],
"default_configuration": "Release",
"defines": [],
"include_dirs": [],
"libraries": []
},
"variables": {
"asan": 0,
"coverage": "false",
"dcheck_always_on": 0,
"debug_nghttp2": "false",
"debug_node": "false",
"enable_lto": "false",
"enable_pgo_generate": "false",
"enable_pgo_use": "false",
"error_on_warn": "false",
"experimental_quic": "false",
"force_dynamic_crt": 0,
"host_arch": "x64",
"icu_data_in": "../../deps/icu-tmp/icudt68l.dat",
"icu_endianness": "l",
"icu_gyp_path": "tools/icu/icu-generic.gyp",
"icu_path": "deps/icu-small",
"icu_small": "false",
"icu_ver_major": "68",
"is_debug": 0,
"llvm_version": "11.0",
"napi_build_version": "7",
"node_byteorder": "little",
"node_debug_lib": "false",
"node_enable_d8": "false",
"node_install_npm": "true",
"node_module_version": 88,
"node_no_browser_globals": "false",
"node_prefix": "/",
"node_release_urlbase": "https://nodejs.org/download/release/",
"node_shared": "false",
"node_shared_brotli": "false",
"node_shared_cares": "false",
"node_shared_http_parser": "false",
"node_shared_libuv": "false",
"node_shared_nghttp2": "false",
"node_shared_openssl": "false",
"node_shared_zlib": "false",
"node_tag": "",
"node_target_type": "executable",
"node_use_bundled_v8": "true",
"node_use_dtrace": "true",
"node_use_etw": "false",
"node_use_node_code_cache": "true",
"node_use_node_snapshot": "true",
"node_use_openssl": "true",
"node_use_v8_platform": "true",
"node_with_ltcg": "false",
"node_without_node_options": "false",
"openssl_fips": "",
"openssl_is_fips": "false",
"ossfuzz": "false",
"shlib_suffix": "88.dylib",
"target_arch": "x64",
"v8_enable_31bit_smis_on_64bit_arch": 0,
"v8_enable_gdbjit": 0,
"v8_enable_i18n_support": 1,
"v8_enable_inspector": 1,
"v8_enable_lite_mode": 0,
"v8_enable_object_print": 1,
"v8_enable_pointer_compression": 0,
"v8_no_strict_aliasing": 1,
"v8_optimized_debug": 1,
"v8_promise_internal_field_count": 1,
"v8_random_seed": 0,
"v8_trace_maps": 0,
"v8_use_siphash": 1,
"want_separate_host_toolset": 0,
"xcode_version": "11.0",
"nodedir": "/Users/evanfeenstra/Library/Caches/node-gyp/15.5.1",
"standalone_static_library": 1
}
}

View file

@ -251,10 +251,12 @@ function streamHsmRequests() {
let sig = '';
if (response.context) {
const dbid = parseInt(response.context.dbid);
const peer = response.context.node_id.toString('hex');
sig = libhsmd_1.default.Handle(capabilities_bitset, peer, dbid, response.raw.toString('hex'));
const peer = dbid ? response.context.node_id.toString('hex') : null;
sig = libhsmd_1.default.Handle(capabilities_bitset, dbid, peer, response.raw.toString('hex'));
}
else {
console.log("RAW ====== ");
console.log(response.raw.toString('hex'));
sig = libhsmd_1.default.Handle(capabilities_bitset, 0, null, response.raw.toString('hex'));
}
lightning.respondHsmRequest({

File diff suppressed because one or more lines are too long

View file

@ -4,8 +4,12 @@ const config_1 = require("../utils/config");
const config = config_1.loadConfig();
const IS_GREENLIGHT = config.lightning_provider === "GREENLIGHT";
var libhsmd = {
Init: function (rootkey, chain) { return ''; },
Handle: function (capabilities, peer, dbid, payload) { return ''; }
Init: function (rootkey, chain) {
return '';
},
Handle: function (capabilities, dbid, peer, payload) {
return '';
}
};
if (IS_GREENLIGHT) {
libhsmd = require('libhsmd');

View file

@ -1 +1 @@
{"version":3,"file":"libhsmd.js","sourceRoot":"","sources":["../../../src/grpc/libhsmd.ts"],"names":[],"mappings":";;AACA,4CAA4C;AAE5C,MAAM,MAAM,GAAG,mBAAU,EAAE,CAAA;AAC3B,MAAM,aAAa,GAAG,MAAM,CAAC,kBAAkB,KAAK,YAAY,CAAC;AAEjE,IAAI,OAAO,GAAG;IACV,IAAI,EAAE,UAAS,OAAc,EAAC,KAAY,IAAY,OAAO,EAAE,CAAA,CAAC,CAAC;IACjE,MAAM,EAAE,UAAS,YAAmB,EAAC,IAAI,EAAC,IAAI,EAAC,OAAc,IAAY,OAAO,EAAE,CAAA,CAAC,CAAC;CACvF,CAAA;AAED,IAAG,aAAa,EAAE;IACd,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAA;CAC/B;AAED,kBAAe,OAAO,CAAA"}
{"version":3,"file":"libhsmd.js","sourceRoot":"","sources":["../../../src/grpc/libhsmd.ts"],"names":[],"mappings":";;AACA,4CAA4C;AAE5C,MAAM,MAAM,GAAG,mBAAU,EAAE,CAAA;AAC3B,MAAM,aAAa,GAAG,MAAM,CAAC,kBAAkB,KAAK,YAAY,CAAC;AAEjE,IAAI,OAAO,GAAG;IAEV,IAAI,EAAE,UACF,OAAc,EACd,KAAY;QAEZ,OAAO,EAAE,CAAA;IACb,CAAC;IAED,MAAM,EAAE,UACJ,YAAmB,EACnB,IAAW,EACX,IAAgB,EAChB,OAAc;QAEd,OAAO,EAAE,CAAA;IACb,CAAC;CACJ,CAAA;AAED,IAAG,aAAa,EAAE;IACd,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAA;CAC/B;AAED,kBAAe,OAAO,CAAA"}

View file

@ -279,9 +279,11 @@ export async function streamHsmRequests() {
let sig = ''
if (response.context) {
const dbid = parseInt(response.context.dbid)
const peer = response.context.node_id.toString('hex')
sig = libhsmd.Handle(capabilities_bitset, peer, dbid, response.raw.toString('hex'))
const peer = dbid ? response.context.node_id.toString('hex') : null
sig = libhsmd.Handle(capabilities_bitset, dbid, peer, response.raw.toString('hex'))
} else {
console.log("RAW ====== ")
console.log(response.raw.toString('hex'))
sig = libhsmd.Handle(capabilities_bitset, 0, null, response.raw.toString('hex'))
}
lightning.respondHsmRequest(<HsmResponse>{

View file

@ -5,8 +5,22 @@ const config = loadConfig()
const IS_GREENLIGHT = config.lightning_provider === "GREENLIGHT";
var libhsmd = {
Init: function(rootkey:string,chain:string): string { return '' },
Handle: function(capabilities:number,peer,dbid,payload:string): string { return '' }
Init: function(
rootkey:string,
chain:string
): string {
return ''
},
Handle: function(
capabilities:number,
dbid:number,
peer:string|null,
payload:string
): string {
return ''
}
}
if(IS_GREENLIGHT) {

View file

@ -26,3 +26,20 @@ https://github.com/ElementsProject/lightning/blob/8167af553e3c9c95142caecc22030f
https://github.com/ElementsProject/lightning/blob/8167af553e3c9c95142caecc22030f78eacd6fca/plugins/bcli.c#L612-L617
./lightning
make
./configure
cd contrib/libhsmd_node
change to "Darwin" in the Makefile
make
change the npm install to "node-gyp rebuild binding-Darwin.gyp"
in relay, "npm link ../lightning/contrib/libhsmd_node"