| Commit message (Collapse) | Author | Age | Files | Lines | |
|---|---|---|---|---|---|
| * | es6 migration | Adam Soltys | 2022-09-02 | 1 | -1/+1 |
| | | |||||
| * | es6 migration | Adam Soltys | 2022-09-02 | 1 | -3/+3 |
| | | |||||
| * | update normalized models | Ran Guin | 2021-07const fs = require("fs");
const grpc = require("grpc");
const createLnrpc = require("lnrpc");
const { promisify } = require("util");
module.exports = async ({ server, tls, macaroon }) => {
const lnrpc = await createLnrpc({ server, tls, macaroonPath: macaroon });
// Resolve proxy instance
return new Proxy(lnrpc, {
/**
* Promisify each lightning RPC method
* @param {lnrpc.Lightning} target
* @param {String} key
* @return {Promise} {Any}
*/
get(target, key) {
const method = target[key];
if (typeof key === "string" && typeof method === "function") {
const streaming = key.match(/openChannel$|sendPayment|subscribe.*/);
let fn;
if (streaming) {
if (key === "sendPayment" || key === "sendToRoute") {
fn = params => method.call(lnrpc, target.meta, params);
} else {
fn = params => method.call(lnrpc, params, target.meta);
}
} else {
fn = params => promisify(method).call(lnrpc, params, target.meta);
}
return fn;
}
return target[key]; // forward
}
});
};
| ||
