Browse Source

new signer test

feature/dockerfile-arm
Evan Feenstra 4 years ago
parent
commit
f384b4779b
  1. 57
      Dockerfile
  2. 13
      api/controllers/payment.ts
  3. 35
      api/grpc/index.ts
  4. 5
      api/helpers.ts
  5. 19
      api/network/receive.ts
  6. 19
      api/network/send.ts
  7. 6
      api/utils/ldat.ts
  8. 19
      api/utils/lightning.ts
  9. 1
      api/utils/nodeinfo.ts
  10. 137
      api/utils/signer.ts
  11. 2
      app.ts
  12. 10
      dist/api/controllers/payment.js
  13. 2
      dist/api/controllers/payment.js.map
  14. 29
      dist/api/grpc/index.js
  15. 2
      dist/api/grpc/index.js.map
  16. 5
      dist/api/helpers.js
  17. 2
      dist/api/helpers.js.map
  18. 11
      dist/api/network/receive.js
  19. 2
      dist/api/network/receive.js.map
  20. 18
      dist/api/network/send.js
  21. 2
      dist/api/network/send.js.map
  22. 4
      dist/api/utils/ldat.js
  23. 2
      dist/api/utils/ldat.js.map
  24. 21
      dist/api/utils/lightning.js
  25. 2
      dist/api/utils/lightning.js.map
  26. 1
      dist/api/utils/nodeinfo.js
  27. 2
      dist/api/utils/nodeinfo.js.map
  28. 157
      dist/api/utils/signer.js
  29. 1
      dist/api/utils/signer.js.map
  30. 2
      dist/app.js
  31. 2
      dist/app.js.map
  32. 8
      dist/public/js/app.js
  33. 5
      docker/aliases.sh
  34. 38
      docker/create_wallet.sh
  35. 54
      docker/entrypoint.sh
  36. 3
      docker/instance_aliases.sh
  37. 8
      docker/lnd.conf.sample
  38. 10
      docker/lnd_supervisor.conf
  39. 10
      docker/relay_supervisor.conf
  40. 0
      docker/supervisord.conf
  41. 2
      init.sh
  42. 96
      install_guide_myNode_and_Raspiblitz.md
  43. 6
      lnd_supervisor.conf
  44. 20
      package-lock.json
  45. 1
      package.json
  46. 8
      public/js/app.js
  47. 6
      relay_supervisor.conf
  48. 2580
      rpc.proto
  49. 228
      signer.proto

57
Dockerfile

@ -8,18 +8,12 @@ ENV GODEBUG netdns=cgo
# Pass a tag, branch or a commit using build-arg. This allows a docker
# image to be built from a specified Git state. The default image
# will use the Git tip of master by default.
ARG checkout="v0.9.0-beta"
ARG checkout="v0.10.0-beta"
# ARG checkout="master"
# Install dependencies and build the binaries.
RUN apk add --no-cache --update alpine-sdk git make gcc openssh-client
# RUN mkdir /root/.ssh/
# ADD id_rsa /root/.ssh/id_rsa
# RUN touch /root/.ssh/known_hosts
# RUN ssh-keyscan github.com >> /root/.ssh/known_hosts
# RUN git clone git@github.com:stakwork/lnd-lean.git /go/src/github.com/lightningnetwork/lnd
RUN git clone https://github.com/lightningnetwork/lnd /go/src/github.com/lightningnetwork/lnd
RUN cd /go/src/github.com/lightningnetwork/lnd \
&& git checkout $checkout \
@ -30,52 +24,67 @@ RUN cd /go/src/github.com/lightningnetwork/lnd \
FROM alpine as final
EXPOSE 80
EXPOSE 9735/tcp
EXPOSE 9735/udp
EXPOSE 10009/tcp
EXPOSE 10009/udp
EXPOSE 9735
ENV NODE_ENV production
ENV NODE_SCHEME http
# Add bash and ca-certs, for quality of life and SSL-related reasons.
RUN apk --no-cache add \
bash \
ca-certificates
RUN apk --no-cache add bash ca-certificates
# Copy the binaries from the builder image.
COPY --from=builder /go/bin/lncli /bin/
COPY --from=builder /go/bin/lnd /bin/
RUN apk add --update nodejs nodejs-npm sqlite git supervisor
RUN apk add --no-cache --update nodejs nodejs-npm sqlite git supervisor
RUN git clone https://github.com/stakwork/sphinx-relay /relay/
WORKDIR /relay/
RUN git checkout feature/docker
ARG sphinx_checkout="master"
RUN git checkout $sphinx_checkout
RUN npm install
RUN npm install nodemon --save-dev
RUN npm install express --save-dev
RUN npm install webpack webpack-cli --save-dev
RUN apk --no-cache add g++ gcc libgcc libstdc++ linux-headers make python jq git
RUN apk --no-cache add g++ gcc libgcc libstdc++ linux-headers make python jq git curl
RUN npm install --quiet node-gyp -g
RUN npm install sqlite3 --build-from-source --save-dev
RUN npm install --save-dev sequelize
RUN npm rebuild
RUN npm run tsc
RUN npm cache clean --force
VOLUME /relay/.lnd
COPY ./lnd.conf.sample /relay/.lnd/lnd.conf
COPY ./docker/lnd.conf.sample /relay/.lnd/lnd.conf
#Uncomment if you have a copy of the channel.db you want to use.
#COPY ./channel.db /relay/.lnd/data/graph/mainnet/
COPY init.sh /etc/profile.d/
RUN sudo chmod +x /etc/profile.d/init.sh
RUN git clone https://github.com/stakwork/sphinx-keysend-test/ /sphinx-keysend/
WORKDIR /sphinx-keysend/
ARG sphinx_keysend_checkout="binary"
RUN git checkout $sphinx_keysend_checkout
RUN npm install
WORKDIR /relay/
RUN apk --no-cache add expect bash
RUN mkdir -p /var/log/supervisor
COPY ./supervisord.conf /etc/supervisord.conf
COPY ./lnd_supervisor.conf /etc/supervisor.d/lnd_supervisor.ini
COPY ./relay_supervisor.conf /etc/supervisor.d/relay_supervisor.ini
CMD ["/usr/bin/supervisord"]
COPY ./docker/supervisord.conf /etc/supervisord.conf
COPY ./docker/lnd_supervisor.conf /etc/supervisor.d/lnd_supervisor.ini
COPY ./docker/relay_supervisor.conf /etc/supervisor.d/relay_supervisor.ini
COPY ./docker/aliases.sh /etc/profile.d/aliases.sh
ENV ENV="/etc/profile"
ENTRYPOINT [ "bash", "/relay/docker/entrypoint.sh" ]

13
api/controllers/payment.ts

@ -26,8 +26,11 @@ const sendPayment = async (req, res) => {
console.log('[send payment]', req.body)
const owner = await models.Contact.findOne({ where: { isOwner: true }})
if (destination_key && !contact_id && !chat_id) {
return helpers.performKeysendMessage({
sender:owner,
destination_key,
amount,
msg:{},
@ -43,8 +46,6 @@ const sendPayment = async (req, res) => {
})
}
const owner = await models.Contact.findOne({ where: { isOwner: true }})
const chat = await helpers.findOrCreateChat({
chat_id,
owner_id: owner.id,
@ -164,11 +165,13 @@ const listPayments = async (req, res) => {
const payments: any[] = []
const MIN_VAL=3
const invs:any = await lightning.listAllInvoices()
if(invs && invs.length){
invs.forEach(inv=>{
const val = inv.value && parseInt(inv.value)
if(val && val>1) {
if(val && val>MIN_VAL) {
let payment_hash=''
if(inv.r_hash){
payment_hash = Buffer.from(inv.r_hash).toString('hex')
@ -188,12 +191,12 @@ const listPayments = async (req, res) => {
if(pays && pays.length){
pays.forEach(pay=>{
const val = pay.value && parseInt(pay.value)
if(val && val>1) {
if(val && val>MIN_VAL) {
payments.push({
type:'payment',
amount:parseInt(pay.value),
date:parseInt(pay.creation_date),
pubkey:pay.path[pay.path.length-1],
// pubkey:pay.path[pay.path.length-1],
payment_hash: pay.payment_hash,
})
}

35
api/grpc/index.ts

@ -9,14 +9,15 @@ import * as moment from 'moment'
import * as path from 'path'
const constants = require(path.join(__dirname,'../../config/constants.json'))
const ERR_CODE_UNAVAILABLE = 14
const ERR_CODE_STREAM_REMOVED = 2
function subscribeInvoices(parseKeysendInvoice) {
return new Promise(async(resolve,reject)=>{
const lightning = await loadLightning()
var call = lightning.subscribeInvoices();
var call = lightning.subscribeInvoices()
call.on('data', async function(response) {
// console.log('subscribeInvoices received')
if (response['state'] !== 'SETTLED') {
return
}
@ -83,18 +84,30 @@ function subscribeInvoices(parseKeysendInvoice) {
});
call.on('status', function(status) {
console.log("Status", status);
resolve(status)
});
// The server is unavailable, trying to reconnect.
if (status.code == ERR_CODE_UNAVAILABLE || status.code == ERR_CODE_STREAM_REMOVED) {
i = 0
reconnectToLND(Math.random());
} else {
resolve(status);
}
})
call.on('error', function(err){
// console.log(err)
console.error(err)
if (err.code == ERR_CODE_UNAVAILABLE || err.code == ERR_CODE_STREAM_REMOVED) {
i = 0
reconnectToLND(Math.random());
} else {
reject(err)
}
})
call.on('end', function() {
const now = moment().format('YYYY-MM-DD HH:mm:ss').trim();
console.log(`Closed stream ${now}`);
// The server has closed the stream.
reconnectToLND()
});
i = 0
reconnectToLND(Math.random())
})
setTimeout(()=>{
resolve(null)
},100)
@ -102,7 +115,9 @@ function subscribeInvoices(parseKeysendInvoice) {
}
var i = 0
async function reconnectToLND(){
var ctx = 0
async function reconnectToLND(innerCtx:number){
ctx = innerCtx
i++
console.log(`=> [lnd] reconnecting... attempt #${i}`)
try {
@ -111,7 +126,9 @@ async function reconnectToLND(){
console.log(`=> [lnd] reconnected! ${now}`)
} catch(e) {
setTimeout(async()=>{ // retry each 2 secs
await reconnectToLND()
if(ctx===innerCtx) { // if another retry fires, then this will not run
await reconnectToLND(innerCtx)
}
},2000)
}
}

5
api/helpers.ts

@ -56,6 +56,7 @@ const sendContactKeys = async (args) => {
destination_key = contact.publicKey
}
performKeysendMessage({
sender,
destination_key,
amount: 3,
msg,
@ -75,14 +76,14 @@ const sendContactKeys = async (args) => {
}
}
const performKeysendMessage = async ({ destination_key, amount, msg, success, failure }) => {
const performKeysendMessage = async ({ destination_key, amount, msg, success, failure, sender }) => {
const opts = {
dest: destination_key,
data: msg || {},
amt: Math.max(amount, 3)
}
try {
const r = await network.signAndSend(opts)
const r = await network.signAndSend(opts, sender.publicKey)
console.log("=> external keysend")
if (success) success(r)
} catch (e) {

19
api/network/receive.ts

@ -3,7 +3,8 @@ import * as lndService from '../grpc'
import {getInfo} from '../utils/lightning'
import {controllers} from '../controllers'
import * as tribes from '../utils/tribes'
import {SPHINX_CUSTOM_RECORD_KEY, verifyAscii} from '../utils/lightning'
import {SPHINX_CUSTOM_RECORD_KEY} from '../utils/lightning'
import * as signer from '../utils/signer'
import { models } from '../models'
import {sendMessage} from './send'
import {modifyPayload} from './modify'
@ -132,11 +133,14 @@ async function parseAndVerifyPayload(data){
let payload
const li = data.lastIndexOf('}')
const msg = data.substring(0,li+1)
const sig = data.substring(li+1)
const pubkeyandsig = data.substring(li+1)
const ci = pubkeyandsig.indexOf(':')
const pubkeyb64 = pubkeyandsig.substring(0,ci+1)
const sigb64 = pubkeyandsig.substring(ci+1)
try {
payload = JSON.parse(msg)
if(payload) {
const v = await verifyAscii(msg, sig)
const v = await signer.verifyAscii(msg, Buffer.from(sigb64,'base64'), b64toHex(pubkeyb64))
if(v && v.valid && v.pubkey) {
payload.sender = payload.sender||{}
payload.sender.pub_key=v.pubkey
@ -193,3 +197,12 @@ function weave(p){
return payload
}
}
function b64toHex(b64){
return Buffer.from(b64,'base64').toString('hex')
}

19
api/network/send.ts

@ -1,5 +1,6 @@
import { models } from '../models'
import * as LND from '../utils/lightning'
import * as signer from '../utils/signer'
import {personalizeMessage, decryptMessage} from '../utils/msg'
import * as path from 'path'
import * as tribes from '../utils/tribes'
@ -14,7 +15,7 @@ export async function sendMessage(params) {
let msg = m
// console.log(type,message)
if(!sender) {
if(!(sender&&sender.publicKey)) {
console.log("NO SENDER?????")
return
}
@ -74,7 +75,7 @@ export async function sendMessage(params) {
try {
const mqttTopic = networkType==='mqtt' ? `${destkey}/${chatUUID}` : ''
const r = await signAndSend(opts, mqttTopic)
const r = await signAndSend(opts, sender.publicKey, mqttTopic)
yes = r
} catch (e) {
console.log("KEYSEND ERROR", e)
@ -89,7 +90,7 @@ export async function sendMessage(params) {
}
}
export function signAndSend(opts, mqttTopic?:string){
export function signAndSend(opts, pubkey, mqttTopic?:string){
// console.log('sign and send!!!!',opts.data)
return new Promise(async function(resolve, reject) {
if(!opts.data || typeof opts.data!=='object') {
@ -97,8 +98,9 @@ export function signAndSend(opts, mqttTopic?:string){
}
let data = JSON.stringify(opts.data)
const sig = await LND.signAscii(data)
data = data + sig
const sig = await signer.signAscii(data)
console.log("BASE 64 PUBKEY",urlBase64FromHex(pubkey),urlBase64FromHex(pubkey).length)
data = data + urlBase64FromHex(pubkey) + ':' + urlBase64FromBytes(sig)
// console.log("ACTUALLY SEND", mqttTopic)
try {
@ -144,3 +146,10 @@ async function asyncForEach(array, callback) {
async function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms))
}
function urlBase64FromHex(ascii){
return Buffer.from(ascii,'hex').toString('base64').replace(/\//g, '_').replace(/\+/g, '-')
}
function urlBase64FromBytes(buf){
return Buffer.from(buf).toString('base64').replace(/\//g, '_').replace(/\+/g, '-')
}

6
api/utils/ldat.ts

@ -87,7 +87,8 @@ function parseLDAT(ldat){
export {
startLDAT, parseLDAT, tokenFromTerms,
urlBase64, urlBase64FromAscii,
urlBase64FromBytes, testLDAT
urlBase64FromBytes, testLDAT,
urlBase64FromHex
}
async function testLDAT(){
@ -152,3 +153,6 @@ function urlBase64FromBytes(buf){
function urlBase64FromAscii(ascii){
return Buffer.from(ascii,'ascii').toString('base64').replace(/\//g, '_').replace(/\+/g, '-')
}
function urlBase64FromHex(ascii){
return Buffer.from(ascii,'hex').toString('base64').replace(/\//g, '_').replace(/\+/g, '-')
}

19
api/utils/lightning.ts

@ -243,18 +243,20 @@ function listInvoicesPaginated(limit, offset) {
}
// need to upgrade to .10 for this
async function listAllPaymentsPaginated(){
const invs = await paginatePayments(40) // max num
return invs
async function listAllPayments(){
console.log("=> list all payments")
const pays = await paginatePayments(40) // max num
console.log('pays', pays && pays.length)
return pays
}
async function paginatePayments(limit,i=0){
try{
const r:any = await listPaymentsPaginated(limit,i)
const lastOffset = parseInt(r.first_index_offset) // this is "first" cuz its in reverse (lowest index)
if(lastOffset>0) {
return r.invoices.concat(await paginatePayments(limit,lastOffset))
return r.payments.concat(await paginatePayments(limit,lastOffset))
}
return r.invoices
return r.payments
}catch(e){
return []
}
@ -263,7 +265,7 @@ function listPaymentsPaginated(limit, offset) {
return new Promise(async(resolve, reject)=> {
const lightning = await loadLightning()
lightning.listPayments({
num_max_payments: limit,
max_payments: limit,
index_offset: offset,
reversed: true,
}, (err, response) => {
@ -273,7 +275,7 @@ function listPaymentsPaginated(limit, offset) {
})
}
function listAllPayments() {
function listAllPaymentsFull() {
console.log('=> list all payments')
return new Promise(async(resolve, reject)=> {
const lightning = await loadLightning()
@ -340,6 +342,7 @@ function verifyMessage(msg,sig): Promise<{[k:string]:any}> {
signature:sig, // zbase32 encoded string
}
lightning.verifyMessage(options, function(err,res){
console.log("VERIFY MESSAGE",err,res)
if(err || !res.pubkey) {
reject(err)
} else {
@ -403,5 +406,5 @@ export {
listAllPayments,
getInfo,
listAllInvoices,
listAllPaymentsPaginated,
listAllPaymentsFull,
}

1
api/utils/nodeinfo.ts

@ -43,6 +43,7 @@ function nodeinfo(){
const node = {
node_alias: process.env.NODE_ALIAS,
ip: process.env.NODE_IP,
lnd_port: process.env.NODE_LND_PORT,
relay_commit: commitHash,
public_ip: public_ip,
pubkey: owner.publicKey,

137
api/utils/signer.ts

@ -0,0 +1,137 @@
import * as grpc from 'grpc'
import {loadCredentials} from './lightning'
import * as path from 'path'
import * as ByteBuffer from 'bytebuffer'
// var protoLoader = require('@grpc/proto-loader')
const env = process.env.NODE_ENV || 'development';
const config = require(path.join(__dirname,'../../config/app.json'))[env]
var signerClient = <any> null;
function urlBase64FromHex(ascii){
return Buffer.from(ascii,'hex').toString('base64').replace(/\//g, '_').replace(/\+/g, '-')
}
export async function testSigner(){
try{
console.log("TEST SIGNER")
const sig:any = await signAscii("hello")
console.log("SIG",sig)
const pubkey = '02df97eb735e185e066fd617f813aed25babd03eb0a06ee58424e67e3d036a8897'
const v = await verifyAscii("hello", sig, pubkey)
console.log("VERIFY",v)
const b64 = urlBase64FromHex(pubkey)
console.log(b64.length)
}catch(e){
console.log("ERROR",e)
}
}
export const loadSigner = () => {
console.log("LOAD SIGNER RRRRRR",signerClient?true:false)
if (signerClient) {
return signerClient
} else {
console.log("LOAD SIGNER AGAIN!!!!")
try{
var credentials = loadCredentials()
var lnrpcDescriptor = grpc.load("signer.proto");
var signer: any = lnrpcDescriptor.signrpc
signerClient = new signer.Signer(config.node_ip + ':' + config.lnd_port, credentials);
console.log("SIGNER CLIENT",signerClient)
return signerClient
} catch(e) {
throw e
}
}
}
export const signMessage = (msg) => {
return new Promise(async(resolve, reject)=> {
let signer = await loadSigner()
try {
const options = {
msg:ByteBuffer.fromHex(msg),
key_loc:{key_family:6, key_index:0},
}
signer.signMessage(options, function(err,sig){
if(err || !sig.signature) {
reject(err)
} else {
resolve(sig.signature)
}
})
} catch(e) {
reject(e)
}
})
}
export const signBuffer = (msg) => {
return new Promise(async (resolve, reject)=> {
let signer = await loadSigner()
try {
const options = {msg}
signer.signMessage(options, function(err,sig){
if(err || !sig.signature) {
reject(err)
} else {
resolve(sig.signature)
}
})
} catch(e) {
reject(e)
}
})
}
function verifyMessage(msg,sig,pubkey): Promise<{[k:string]:any}> {
return new Promise(async(resolve, reject)=> {
let signer = await loadSigner()
try {
const options = {
msg:ByteBuffer.fromHex(msg),
signature:sig,
pubkey:ByteBuffer.fromHex(pubkey),
}
signer.verifyMessage(options, function(err,res){
if(err) {
reject(err)
} else {
resolve(res)
}
})
} catch(e) {
reject(e)
}
})
}
export async function signAscii(ascii) {
try {
const sig = await signMessage(ascii_to_hexa(ascii))
return sig
} catch(e) {
throw e
}
}
export async function verifyAscii(ascii:string,sig:Buffer,pubkey:string): Promise<{[k:string]:any}>{
try {
const r = await verifyMessage(ascii_to_hexa(ascii),sig,pubkey)
return r
} catch(e) {
throw e
}
}
function ascii_to_hexa(str){
var arr1 = <string[]> [];
for (var n = 0, l = str.length; n < l; n ++) {
var hex = Number(str.charCodeAt(n)).toString(16);
arr1.push(hex);
}
return arr1.join('');
}

2
app.ts

@ -11,6 +11,7 @@ import {setupDatabase, setupDone} from './api/utils/setup'
import * as controllers from './api/controllers'
import * as socket from './api/utils/socket'
import * as network from './api/network'
import * as signer from './api/utils/signer'
let server: any = null
const port = process.env.PORT || 3001;
@ -49,6 +50,7 @@ async function mainSetup(){
}
await setupApp()
setupDone()
signer.testSigner()
}
async function setupApp(){

10
dist/api/controllers/payment.js

@ -22,8 +22,10 @@ const network = require("../network");
const sendPayment = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
const { amount, chat_id, contact_id, destination_key, media_type, muid, text, remote_text, dimensions, remote_text_map, contact_ids, } = req.body;
console.log('[send payment]', req.body);
const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } });
if (destination_key && !contact_id && !chat_id) {
return helpers.performKeysendMessage({
sender: owner,
destination_key,
amount,
msg: {},
@ -38,7 +40,6 @@ const sendPayment = (req, res) => __awaiter(void 0, void 0, void 0, function* ()
}
});
}
const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } });
const chat = yield helpers.findOrCreateChat({
chat_id,
owner_id: owner.id,
@ -150,11 +151,12 @@ const listPayments = (req, res) => __awaiter(void 0, void 0, void 0, function* (
const limit = (req.query.limit && parseInt(req.query.limit)) || 100;
const offset = (req.query.offset && parseInt(req.query.offset)) || 0;
const payments = [];
const MIN_VAL = 3;
const invs = yield lightning.listAllInvoices();
if (invs && invs.length) {
invs.forEach(inv => {
const val = inv.value && parseInt(inv.value);
if (val && val > 1) {
if (val && val > MIN_VAL) {
let payment_hash = '';
if (inv.r_hash) {
payment_hash = Buffer.from(inv.r_hash).toString('hex');
@ -173,12 +175,12 @@ const listPayments = (req, res) => __awaiter(void 0, void 0, void 0, function* (
if (pays && pays.length) {
pays.forEach(pay => {
const val = pay.value && parseInt(pay.value);
if (val && val > 1) {
if (val && val > MIN_VAL) {
payments.push({
type: 'payment',
amount: parseInt(pay.value),
date: parseInt(pay.creation_date),
pubkey: pay.path[pay.path.length - 1],
// pubkey:pay.path[pay.path.length-1],
payment_hash: pay.payment_hash,
});
}

2
dist/api/controllers/payment.js.map

File diff suppressed because one or more lines are too long

29
dist/api/grpc/index.js

@ -19,13 +19,14 @@ const network = require("../network");
const moment = require("moment");
const path = require("path");
const constants = require(path.join(__dirname, '../../config/constants.json'));
const ERR_CODE_UNAVAILABLE = 14;
const ERR_CODE_STREAM_REMOVED = 2;
function subscribeInvoices(parseKeysendInvoice) {
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
const lightning = yield lightning_1.loadLightning();
var call = lightning.subscribeInvoices();
call.on('data', function (response) {
return __awaiter(this, void 0, void 0, function* () {
// console.log('subscribeInvoices received')
if (response['state'] !== 'SETTLED') {
return;
}
@ -86,17 +87,31 @@ function subscribeInvoices(parseKeysendInvoice) {
});
call.on('status', function (status) {
console.log("Status", status);
// The server is unavailable, trying to reconnect.
if (status.code == ERR_CODE_UNAVAILABLE || status.code == ERR_CODE_STREAM_REMOVED) {
i = 0;
reconnectToLND(Math.random());
}
else {
resolve(status);
}
});
call.on('error', function (err) {
// console.log(err)
console.error(err);
if (err.code == ERR_CODE_UNAVAILABLE || err.code == ERR_CODE_STREAM_REMOVED) {
i = 0;
reconnectToLND(Math.random());
}
else {
reject(err);
}
});
call.on('end', function () {
const now = moment().format('YYYY-MM-DD HH:mm:ss').trim();
console.log(`Closed stream ${now}`);
// The server has closed the stream.
reconnectToLND();
i = 0;
reconnectToLND(Math.random());
});
setTimeout(() => {
resolve(null);
@ -105,8 +120,10 @@ function subscribeInvoices(parseKeysendInvoice) {
}
exports.subscribeInvoices = subscribeInvoices;
var i = 0;
function reconnectToLND() {
var ctx = 0;
function reconnectToLND(innerCtx) {
return __awaiter(this, void 0, void 0, function* () {
ctx = innerCtx;
i++;
console.log(`=> [lnd] reconnecting... attempt #${i}`);
try {
@ -116,7 +133,9 @@ function reconnectToLND() {
}
catch (e) {
setTimeout(() => __awaiter(this, void 0, void 0, function* () {
yield reconnectToLND();
if (ctx === innerCtx) { // if another retry fires, then this will not run
yield reconnectToLND(innerCtx);
}
}), 2000);
}
});

2
dist/api/grpc/index.js.map

@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../api/grpc/index.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,sCAAgC;AAChC,0CAAyC;AACzC,gCAAsD;AACtD,2CAA0C;AAC1C,+CAA8C;AAC9C,kDAAgD;AAChD,sCAAqC;AACrC,iCAAgC;AAChC,6BAA4B;AAE5B,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAC,6BAA6B,CAAC,CAAC,CAAA;AAE7E,SAAS,iBAAiB,CAAC,mBAAmB;IAC7C,OAAO,IAAI,OAAO,CAAC,CAAM,OAAO,EAAC,MAAM,EAAC,EAAE;QACzC,MAAM,SAAS,GAAG,MAAM,yBAAa,EAAE,CAAA;QAEvC,IAAI,IAAI,GAAG,SAAS,CAAC,iBAAiB,EAAE,CAAC;QACzC,IAAI,CAAC,EAAE,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C,GAAG,CAAC,iBAAiB,GAAG,EAAE,CAAC,CAAC;YACpC,oCAAoC;YACpC,CAAC,GAAG,CAAC,CAAA;YACL,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAA;QAC9B,CAAC,CAAC,CAAA;QACF,UAAU,CAAC,GAAE,EAAE;YACd,OAAO,CAAC,IAAI,CAAC,CAAA;QACd,CAAC,EAAC,GAAG,CAAC,CAAA;IACP,CAAC,CAAA,CAAC,CAAA;AACH,CAAC;AAsBA,8CAAiB;AApBlB,IAAI,CAAC,GAAG,CAAC,CAAA;AACT,IAAI,GAAG,GAAG,CAAC,CAAA;AACX,SAAe,cAAc,CAAC,QAAe;;QAC5C,GAAG,GAAG,QAAQ,CAAA;QACd,CAAC,EAAE,CAAA;QACH,OAAO,CAAC,GAAG,CAAC,qCAAqC,CAAC,EAAE,CAAC,CAAA;QACrD,IAAI;YACH,MAAM,OAAO,CAAC,qBAAqB,EAAE,CAAA;YACrC,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC,IAAI,EAAE,CAAC;YAC1D,OAAO,CAAC,GAAG,CAAC,yBAAyB,GAAG,EAAE,CAAC,CAAA;SAC3C;QAAC,OAAM,CAAC,EAAE;YACV,UAAU,CAAC,GAAO,EAAE;gBACnB,IAAG,GAAG,KAAG,QAAQ,EAAE,EAAE,iDAAiD;oBACrE,MAAM,cAAc,CAAC,QAAQ,CAAC,CAAA;iBAC9B;YACF,CAAC,CAAA,EAAC,IAAI,CAAC,CAAA;SACP;IACF,CAAC;CAAA"}

5
dist/api/helpers.js

@ -63,6 +63,7 @@ const sendContactKeys = (args) => __awaiter(void 0, void 0, void 0, function* ()
destination_key = contact.publicKey;
}
performKeysendMessage({
sender,
destination_key,
amount: 3,
msg,
@ -82,14 +83,14 @@ const sendContactKeys = (args) => __awaiter(void 0, void 0, void 0, function* ()
}
});
exports.sendContactKeys = sendContactKeys;
const performKeysendMessage = ({ destination_key, amount, msg, success, failure }) => __awaiter(void 0, void 0, void 0, function* () {
const performKeysendMessage = ({ destination_key, amount, msg, success, failure, sender }) => __awaiter(void 0, void 0, void 0, function* () {
const opts = {
dest: destination_key,
data: msg || {},
amt: Math.max(amount, 3)
};
try {
const r = yield network.signAndSend(opts);
const r = yield network.signAndSend(opts, sender.publicKey);
console.log("=> external keysend");
if (success)
success(r);

2
dist/api/helpers.js.map

File diff suppressed because one or more lines are too long

11
dist/api/network/receive.js

@ -15,6 +15,7 @@ const lightning_1 = require("../utils/lightning");
const controllers_1 = require("../controllers");
const tribes = require("../utils/tribes");
const lightning_2 = require("../utils/lightning");
const signer = require("../utils/signer");
const models_1 = require("../models");
const send_1 = require("./send");
const modify_1 = require("./modify");
@ -152,11 +153,14 @@ function parseAndVerifyPayload(data) {
let payload;
const li = data.lastIndexOf('}');
const msg = data.substring(0, li + 1);
const sig = data.substring(li + 1);
const pubkeyandsig = data.substring(li + 1);
const ci = pubkeyandsig.indexOf(':');
const pubkeyb64 = pubkeyandsig.substring(0, ci + 1);
const sigb64 = pubkeyandsig.substring(ci + 1);
try {
payload = JSON.parse(msg);
if (payload) {
const v = yield lightning_2.verifyAscii(msg, sig);
const v = yield signer.verifyAscii(msg, Buffer.from(sigb64, 'base64'), b64toHex(pubkeyb64));
if (v && v.valid && v.pubkey) {
payload.sender = payload.sender || {};
payload.sender.pub_key = v.pubkey;
@ -220,4 +224,7 @@ function weave(p) {
return payload;
}
}
function b64toHex(b64) {
return Buffer.from(b64, 'base64').toString('hex');
}
//# sourceMappingURL=receive.js.map

2
dist/api/network/receive.js.map

File diff suppressed because one or more lines are too long

18
dist/api/network/send.js

@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
Object.defineProperty(exports, "__esModule", { value: true });
const models_1 = require("../models");
const LND = require("../utils/lightning");
const signer = require("../utils/signer");
const msg_1 = require("../utils/msg");
const path = require("path");
const tribes = require("../utils/tribes");
@ -21,7 +22,7 @@ function sendMessage(params) {
const m = newmsg(type, chat, sender, message);
let msg = m;
// console.log(type,message)
if (!sender) {
if (!(sender && sender.publicKey)) {
console.log("NO SENDER?????");
return;
}
@ -77,7 +78,7 @@ function sendMessage(params) {
};
try {
const mqttTopic = networkType === 'mqtt' ? `${destkey}/${chatUUID}` : '';
const r = yield signAndSend(opts, mqttTopic);
const r = yield signAndSend(opts, sender.publicKey, mqttTopic);
yes = r;
}
catch (e) {
@ -97,7 +98,7 @@ function sendMessage(params) {
});
}
exports.sendMessage = sendMessage;
function signAndSend(opts, mqttTopic) {
function signAndSend(opts, pubkey, mqttTopic) {
// console.log('sign and send!!!!',opts.data)
return new Promise(function (resolve, reject) {
return __awaiter(this, void 0, void 0, function* () {
@ -105,8 +106,9 @@ function signAndSend(opts, mqttTopic) {
return reject('object plz');
}
let data = JSON.stringify(opts.data);
const sig = yield LND.signAscii(data);
data = data + sig;
const sig = yield signer.signAscii(data);
console.log("BASE 64 PUBKEY", urlBase64FromHex(pubkey), urlBase64FromHex(pubkey).length);
data = data + urlBase64FromHex(pubkey) + ':' + urlBase64FromBytes(sig);
// console.log("ACTUALLY SEND", mqttTopic)
try {
if (mqttTopic) {
@ -146,4 +148,10 @@ function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
});
}
function urlBase64FromHex(ascii) {
return Buffer.from(ascii, 'hex').toString('base64').replace(/\//g, '_').replace(/\+/g, '-');
}
function urlBase64FromBytes(buf) {
return Buffer.from(buf).toString('base64').replace(/\//g, '_').replace(/\+/g, '-');
}
//# sourceMappingURL=send.js.map

2
dist/api/network/send.js.map

File diff suppressed because one or more lines are too long

4
dist/api/utils/ldat.js

@ -154,4 +154,8 @@ function urlBase64FromAscii(ascii) {
return Buffer.from(ascii, 'ascii').toString('base64').replace(/\//g, '_').replace(/\+/g, '-');
}
exports.urlBase64FromAscii = urlBase64FromAscii;
function urlBase64FromHex(ascii) {
return Buffer.from(ascii, 'hex').toString('base64').replace(/\//g, '_').replace(/\+/g, '-');
}
exports.urlBase64FromHex = urlBase64FromHex;
//# sourceMappingURL=ldat.js.map

2
dist/api/utils/ldat.js.map

File diff suppressed because one or more lines are too long

21
dist/api/utils/lightning.js

@ -270,22 +270,24 @@ function listInvoicesPaginated(limit, offset) {
}));
}
// need to upgrade to .10 for this
function listAllPaymentsPaginated() {
function listAllPayments() {
return __awaiter(this, void 0, void 0, function* () {
const invs = yield paginatePayments(40); // max num
return invs;
console.log("=> list all payments");
const pays = yield paginatePayments(40); // max num
console.log('pays', pays && pays.length);
return pays;
});
}
exports.listAllPaymentsPaginated = listAllPaymentsPaginated;
exports.listAllPayments = listAllPayments;
function paginatePayments(limit, i = 0) {
return __awaiter(this, void 0, void 0, function* () {
try {
const r = yield listPaymentsPaginated(limit, i);
const lastOffset = parseInt(r.first_index_offset); // this is "first" cuz its in reverse (lowest index)
if (lastOffset > 0) {
return r.invoices.concat(yield paginatePayments(limit, lastOffset));
return r.payments.concat(yield paginatePayments(limit, lastOffset));
}
return r.invoices;
return r.payments;
}
catch (e) {
return [];
@ -296,7 +298,7 @@ function listPaymentsPaginated(limit, offset) {
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
const lightning = yield loadLightning();
lightning.listPayments({
num_max_payments: limit,
max_payments: limit,
index_offset: offset,
reversed: true,
}, (err, response) => {
@ -307,7 +309,7 @@ function listPaymentsPaginated(limit, offset) {
});
}));
}
function listAllPayments() {
function listAllPaymentsFull() {
console.log('=> list all payments');
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
const lightning = yield loadLightning();
@ -321,7 +323,7 @@ function listAllPayments() {
});
}));
}
exports.listAllPayments = listAllPayments;
exports.listAllPaymentsFull = listAllPaymentsFull;
const signMessage = (msg) => {
return new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
let lightning = yield loadLightning();
@ -383,6 +385,7 @@ function verifyMessage(msg, sig) {
signature: sig,
};
lightning.verifyMessage(options, function (err, res) {
console.log("VERIFY MESSAGE", err, res);
if (err || !res.pubkey) {
reject(err);
}

2
dist/api/utils/lightning.js.map

File diff suppressed because one or more lines are too long

1
dist/api/utils/nodeinfo.js

@ -51,6 +51,7 @@ function nodeinfo() {
const node = {
node_alias: process.env.NODE_ALIAS,
ip: process.env.NODE_IP,
lnd_port: process.env.NODE_LND_PORT,
relay_commit: commitHash,
public_ip: public_ip,
pubkey: owner.publicKey,

2
dist/api/utils/nodeinfo.js.map

@ -1 +1 @@
{"version":3,"file":"nodeinfo.js","sourceRoot":"","sources":["../../../api/utils/nodeinfo.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,kDAAgD;AAChD,sCAAqC;AACrC,8CAA0D;AAC1D,sCAAgC;AAEhC,SAAS,QAAQ;IACf,OAAO,IAAI,OAAO,CAAC,CAAO,OAAO,EAAE,MAAM,EAAC,EAAE;QAC1C,IAAI,SAAS,GAAG,EAAE,CAAA;QAClB,IAAI;YACF,SAAS,GAAG,MAAM,QAAQ,CAAC,EAAE,EAAE,CAAA;SAChC;QAAC,OAAM,CAAC,EAAC,GAAE;QAEZ,MAAM,UAAU,GAAG,MAAM,yBAAe,EAAE,CAAA;QAE1C,MAAM,GAAG,GAAG,MAAM,kBAAQ,EAAE,CAAA;QAE5B,MAAM,SAAS,GAAG,yBAAa,EAAE,CAAA;QACjC,MAAM,KAAK,GAAG,MAAM,eAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAC,CAAC,CAAA;QAEvE,MAAM,KAAK,GAAG,MAAM,OAAO,EAAE,CAAA;QAE7B,IAAI;YACF,SAAS,CAAC,cAAc,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE,cAAc,EAAE,EAAE;gBACnD,IAAG,GAAG;oBAAE,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;gBACxB,2DAA2D;gBAC3D,SAAS,CAAC,YAAY,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE,WAAW,EAAE,EAAE;o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M,CAAC,OAAO,CAAC,OAAO,EAAE,CAAA;QAClD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,KAAG,CAAC,CAAA;QAC9B,MAAM,cAAc,GAAG,WAAW,CAAC,MAAM,KAAG,CAAC,CAAA;QAC7C,IAAG,UAAU,IAAI,MAAM,IAAI,cAAc;YAAE,OAAO,IAAI,CAAA;QACtD,OAAO,KAAK,CAAA;IACd,CAAC;CAAA"}

157
dist/api/utils/signer.js

@ -0,0 +1,157 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const grpc = require("grpc");
const lightning_1 = require("./lightning");
const path = require("path");
const ByteBuffer = require("bytebuffer");
// var protoLoader = require('@grpc/proto-loader')
const env = process.env.NODE_ENV || 'development';
const config = require(path.join(__dirname, '../../config/app.json'))[env];
var signerClient = null;
function urlBase64FromHex(ascii) {
return Buffer.from(ascii, 'hex').toString('base64').replace(/\//g, '_').replace(/\+/g, '-');
}
function testSigner() {
return __awaiter(this, void 0, void 0, function* () {
try {
console.log("TEST SIGNER");
const sig = yield signAscii("hello");
console.log("SIG", sig);
const pubkey = '02df97eb735e185e066fd617f813aed25babd03eb0a06ee58424e67e3d036a8897';
const v = yield verifyAscii("hello", sig, pubkey);
console.log("VERIFY", v);
const b64 = urlBase64FromHex(pubkey);
console.log(b64.length);
}
catch (e) {
console.log("ERROR", e);
}
});
}
exports.testSigner = testSigner;
exports.loadSigner = () => {
console.log("LOAD SIGNER RRRRRR", signerClient ? true : false);
if (signerClient) {
return signerClient;
}
else {
console.log("LOAD SIGNER AGAIN!!!!");
try {
var credentials = lightning_1.loadCredentials();
var lnrpcDescriptor = grpc.load("signer.proto");
var signer = lnrpcDescriptor.signrpc;
signerClient = new signer.Signer(config.node_ip + ':' + config.lnd_port, credentials);
console.log("SIGNER CLIENT", signerClient);
return signerClient;
}
catch (e) {
throw e;
}
}
};
exports.signMessage = (msg) => {
return new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
let signer = yield exports.loadSigner();
try {
const options = {
msg: ByteBuffer.fromHex(msg),
key_loc: { key_family: 6, key_index: 0 },
};
signer.signMessage(options, function (err, sig) {
if (err || !sig.signature) {
reject(err);
}
else {
resolve(sig.signature);
}
});
}
catch (e) {
reject(e);
}
}));
};
exports.signBuffer = (msg) => {
return new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
let signer = yield exports.loadSigner();
try {
const options = { msg };
signer.signMessage(options, function (err, sig) {
if (err || !sig.signature) {
reject(err);
}
else {
resolve(sig.signature);
}
});
}
catch (e) {
reject(e);
}
}));
};
function verifyMessage(msg, sig, pubkey) {
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
let signer = yield exports.loadSigner();
try {
const options = {
msg: ByteBuffer.fromHex(msg),
signature: sig,
pubkey: ByteBuffer.fromHex(pubkey),
};
signer.verifyMessage(options, function (err, res) {
if (err) {
reject(err);
}
else {
resolve(res);
}
});
}
catch (e) {
reject(e);
}
}));
}
function signAscii(ascii) {
return __awaiter(this, void 0, void 0, function* () {
try {
const sig = yield exports.signMessage(ascii_to_hexa(ascii));
return sig;
}
catch (e) {
throw e;
}
});
}
exports.signAscii = signAscii;
function verifyAscii(ascii, sig, pubkey) {
return __awaiter(this, void 0, void 0, function* () {
try {
const r = yield verifyMessage(ascii_to_hexa(ascii), sig, pubkey);
return r;
}
catch (e) {
throw e;
}
});
}
exports.verifyAscii = verifyAscii;
function ascii_to_hexa(str) {
var arr1 = [];
for (var n = 0, l = str.length; n < l; n++) {
var hex = Number(str.charCodeAt(n)).toString(16);
arr1.push(hex);
}
return arr1.join('');
}
//# sourceMappingURL=signer.js.map

1
dist/api/utils/signer.js.map

@ -0,0 +1 @@
{"version":3,"file":"signer.js","sourceRoot":"","sources":["../../../api/utils/signer.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,6BAA4B;AAC5B,2CAA2C;AAC3C,6BAA4B;AAC5B,yCAAwC;AAExC,kDAAkD;AAClD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,aAAa,CAAC;AAClD,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAC,uBAAuB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;AAEzE,IAAI,YAAY,GAAS,IAAI,CAAC;AAC9B,SAAS,gBAAgB,CAAC,KAAK;IAC7B,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,EAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;AAC5F,CAAC;AACD,SAAsB,UAAU;;QAC9B,IAAG;YACD,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAA;YAC1B,MAAM,GAAG,GAAO,MAAM,SAAS,CAAC,OAAO,CAAC,CAAA;YACxC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAC,GAAG,CAAC,CAAA;YACtB,MAAM,MAAM,GAAG,oEAAoE,CAAA;YACnF,MAAM,CAAC,GAAG,MAAM,WAAW,CAAC,OAAO,EAAE,GAAG,EAAE,MAAM,CAAC,CAAA;YACjD,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAC,CAAC,CAAC,CAAA;YAEvB,MAAM,GAAG,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAA;YACpC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;SAExB;Q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AAI,CAAC,EAAE,CAAC,CAAC;AACtB,CAAC"}

2
dist/app.js

@ -22,6 +22,7 @@ const setup_1 = require("./api/utils/setup");
const controllers = require("./api/controllers");
const socket = require("./api/utils/socket");
const network = require("./api/network");
const signer = require("./api/utils/signer");
let server = null;
const port = process.env.PORT || 3001;
const env = process.env.NODE_ENV || 'development';
@ -58,6 +59,7 @@ function mainSetup() {
}
yield setupApp();
setup_1.setupDone();
signer.testSigner();
});
}
function setupApp() {

2
dist/app.js.map

@ -1 +1 @@
{"version":3,"file":"app.js","sourceRoot":"","sources":["../app.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,mCAAkC;AAClC,0CAAyC;AACzC,iCAAgC;AAChC,8CAA6C;AAC7C,iCAAgC;AAChC,6BAA4B;AAC5B,yCAAmC;AACnC,+CAAuC;AACvC,mCAAkE;AAClE,6CAA0D;AAC1D,iDAAgD;AAChD,6CAA4C;AAC5C,yCAAwC;AAExC,IAAI,MAAM,GAAQ,IAAI,CAAA;AACtB,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,IAAI,CAAC;AACtC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,aAAa,CAAC;AAClD,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AAErE,OAAO,CAAC,GAAG,CAAC,sBAAsB,GAAG,YAAY,CAAA;AAEjD,IAAI,CAAC,GAAG,CAAC,CAAA;AAET,eAAe;AACf,YAAY,EAAE,CAAA;AAEd,SAAe,YAAY;;QAC1B,CAAC,EAAE,CAAA;QACH,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,EAAE,CAAC,CAAA;QACnD,IAAI;YACH,MAAM,OAAO,CAAC,qBAAqB,EAAE,CAAA,CAAG,MAAM;YAC9C,MAAM,SAAS,EAAE,CAAA,CAAM,eAAe;YACtC,MA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AC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC/E,IAAI,IAAI,CAAC,SAAS,IAAI,IAAI,IAAI,IAAI,CAAC,SAAS,IAAI,WAAW,EAAE;gBAC5D,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE,yBAAyB,EAAE,EAAC,cAAc,EAAG,YAAY,EAAC,CAAC,CAAC;gBAC/E,GAAG,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;aAC/B;iBAAM;gBACN,IAAI,EAAE,CAAC;aACP;SACD;IACF,CAAC;CAAA;AAED,kBAAe,MAAM,CAAA"}

8
dist/public/js/app.js

@ -85321,8 +85321,7 @@ function Media(props) {
file = files[0] || {};
start = new Date();
_context2.next = 5;
return api_media.UPLOAD('upload/attachment', file, {
chat_uuid: '1234567890',
return api_media.UPLOAD('file', file, {
name: file.name || 'filename',
description: description || 'description',
ttl: ttl
@ -85332,14 +85331,15 @@ function Media(props) {
r = _context2.sent;
end = new Date();
time = end.getTime() - start.getTime();
console.log('Upload Timer: finished in', time, 'ms'); // await api.relay.POST('attachment', {
console.log('Upload Timer: finished in', time, 'ms');
console.log(r); // await api.relay.POST('attachment', {
// muid: r.muid,
// file_name: r.filename,
// chat_id: 13,
// ttl: ttl,
// })
case 9:
case 10:
case "end":
return _context2.stop();
}

5
docker/aliases.sh

@ -0,0 +1,5 @@
#!/bin/bash
alias lncli='command lncli --lnddir=/relay/.lnd/ "$@"'
alias lnd='command lnd --lnddir=/relay/.lnd/ "$@"'

38
docker/create_wallet.sh

@ -0,0 +1,38 @@
#!/usr/bin/expect -f
set WALLET_PASSWORD [lindex $argv 0]
set WALLET_PASSPHRASE [lindex $argv 1]
set force_conservative 0 ;# set to 1 to force conservative mode even if
;# script wasn't run conservatively originally
if {$force_conservative} {
set send_slow {1 .1}
proc send {ignore arg} {
sleep .1
exp_send -s -- $arg
}
}
set timeout -1
spawn lncli --lnddir=/relay/.lnd/ create
match_max 100000
expect -exact "Input wallet password: "
send -- "$WALLET_PASSWORD\r"
expect -exact "\r
Confirm password:\r
"
send -- "$WALLET_PASSWORD\r"
expect -exact "\r
\r
Do you have an existing cipher seed mnemonic you want to use? (Enter y/n): "
send -- "n\r"
expect -exact "n\r
\r
Your cipher seed can optionally be encrypted.\r
Input your passphrase if you wish to encrypt it (or press enter to proceed without a cipher seed passphrase): "
send -- "$WALLET_PASSPHRASE\r"
expect -exact "\r
Confirm password:\r
"
send -- "$WALLET_PASSPHRASE\r"
expect eof

54
docker/entrypoint.sh

@ -0,0 +1,54 @@
#!/bin/bash
# turn on bash's job control
set -m
echo "Setting ENV vars..."
if [ ! -z ${ECS_CONTAINER_METADATA_URI+x} ]; then
echo "ECS environment found, setting domain..."
export NODE_DOMAIN=$(curl $ECS_CONTAINER_METADATA_URI | echo $(jq -r .DockerName).$NODE_DOMAIN)
fi
# For dev purposes only
# export NODE_DOMAIN=lvh.me
export NODE_ALIAS=$HOSTNAME
export NODE_IP=$NODE_SCHEME://$NODE_DOMAIN
if [[ ! -f "/var/run/docker.sock" ]]; then
echo "Docker socket found, pulling LND port..."
export NODE_LND_PORT=$(curl --unix-socket /var/run/docker.sock http://localhost/containers/$HOSTNAME/json | jq -r '.NetworkSettings.Ports."9735/tcp"[0].HostPort')
fi
echo "Starting supervisor..."
# Start the primary process and put it in the background
/usr/bin/supervisord &
sleep 5
if [[ -f "/relay/.lnd/.lndpwd" ]]; then
echo "Wallet file found..."
else
echo "Creating wallet..."
WALLET_PASSWORD=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c20)
WALLET_PASSPHRASE=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c20)
echo $WALLET_PASSWORD >> /relay/.lnd/.lndpwd
echo $WALLET_PASSPHRASE >> /relay/.lnd/.lndpwd
expect /relay/docker/create_wallet.sh $WALLET_PASSWORD $WALLET_PASSPHRASE >> /relay/.lnd/.tempseed
sed -e '2,14d' < /relay/.lnd/.tempseed >> /relay/.lnd/.lndseed
rm /relay/.lnd/.tempseed
sleep 5
fi
echo "Starting relay..."
supervisorctl start relay
# now we bring the primary process back into the foreground
# and leave it there
fg %1

3
docker/instance_aliases.sh

@ -0,0 +1,3 @@
#!/bin/bash
alias nodessh='_nodessh(){ docker exec -it "$1" /bin/bash;}; _nodessh'

8
lnd.conf.sample → docker/lnd.conf.sample

@ -1,12 +1,14 @@
listen=0.0.0.0:9735
rpclisten=0.0.0.0:10009
bitcoin.mainnet=1
bitcoin.active=1
bitcoin.node=neutrino
accept-keysend=1
listen=0.0.0.0:9735
rpclisten=0.0.0.0:10009
ignore-historical-gossip-filters=true
nobootstrap=true
numgraphsyncpeers=1
routing.assumechanvalid=1
autopilot.active=false

10
docker/lnd_supervisor.conf

@ -0,0 +1,10 @@
[program:lnd]
user=root
command=sh -c 'lnd --lnddir=/relay/.lnd/ --alias=$HOSTNAME --tlsextradomain=$NODE_DOMAIN --externalip=$NODE_DOMAIN'
startretries=999999999999999999999999999
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/%(program_name)s.log
stderr_logfile=/var/log/supervisor/%(program_name)s.log
stdout_logfile_maxbytes=10MB
stdout_logfile_backups=10

10
docker/relay_supervisor.conf

@ -0,0 +1,10 @@
[program:relay]
user=root
command=sh -c 'npm run start-ecs --prefix /relay/'
startretries=999999999999999999999999999
autostart=false
autorestart=true
stdout_logfile=/var/log/supervisor/%(program_name)s.log
stderr_logfile=/var/log/supervisor/%(program_name)s.log
stdout_logfile_maxbytes=10MB
stdout_logfile_backups=10

0
supervisord.conf → docker/supervisord.conf

2
init.sh

@ -1,2 +0,0 @@
NODE_IP=$(curl http://169.254.170.2/v4/e52231f4-0246-4fc5-bc3e-ac20df1b118e | echo $(jq -r .DockerName).$NODE_DOMAIN)
NODE_ALIAS=$(curl http://169.254.170.2/v4/e52231f4-0246-4fc5-bc3e-ac20df1b118e | echo $(jq -r .DockerName))

96
install_guide_myNode_and_Raspiblitz.md

@ -188,3 +188,99 @@ $ sudo systemctl status sphinx-relay.service
```sh
$ sudo systemctl stop sphinx-relay.service
```
# To update Sphinx-Relay
(This probably is not the most efficient way to update. But it works so we got that goin which is nice. Feel free to optimize the process and contribute. :) )
Login as Admin and stop the program.
```sh
$ sudo systemctl stop sphinx-relay.service
```
login as user bitcoin.
```sh
$ sudo su bitcoin
$ cd
```
## Remove the old version
```sh
$ rm -rf sphinx-relay
```
## Download the new version
Clone the repository from Github and install the package.
```sh
$ git clone https://github.com/stakwork/sphinx-relay
$ cd sphinx-relay
$ npm install
```
### Configure
Edit the "production" section of config/app.json.
```sh
$ cd
$ cd sphinx-relay/config/
$ nano app.json
```
Change the following 4 lines:
## myNode
```
"macaroon_location": "/home/bitcoin/.lnd/data/chain/bitcoin/mainnet/admin.macaroon",
"tls_location": "/mnt/hdd/mynode/lnd/tls.cert",
"lnd_log_location": "/home/bitcoin/.lnd/logs/bitcoin/mainnet/lnd.log",
"lncli_location": "/home/bitcoin/go/bin",
```
## Raspiblitz
```
"macaroon_location": "/home/bitcoin/.lnd/data/chain/bitcoin/mainnet/admin.macaroon",
"tls_location": "/mnt/hdd/lnd/tls.cert",
"lnd_log_location": "/home/bitcoin/.lnd/logs/bitcoin/mainnet/lnd.log",
"lncli_location": "/home/bitcoin/go/bin",
```
Save and exit:
`Ctrl + X`
`Y`
`Enter`
Edit the "production" section of config/config.json
```sh
$ nano config.json
```
Change to following line to:
```
"storage": "/home/bitcoin/sphinx.db"
```
Save and exit:
`Ctrl + X`
`Y`
`Enter`
To connect to your app:
(replace x.x.x.x with your IP - NOTE: This is your external IP)
```sh
$ cd
$ cd sphinx-relay/config/
$ export NODE_IP=x.x.x.x:3001
```
For extra security:
```sh
$ export USE_PASSWORD=true
```
### Turn on the service.
Login as admin.
```sh
$ su admin
```
Or
```sh
$ exit
```
Turn the service on and check the status.
```sh
$ sudo systemctl enable sphinx-relay.service
$ sudo systemctl start sphinx-relay.service
```

6
lnd_supervisor.conf

@ -1,6 +0,0 @@
[program:lnd]
user=root
command=lnd --lnddir=/relay/.lnd/
startretries=999999999999999999999999999
autostart=true
autorestart=true

20
package-lock.json

@ -7251,6 +7251,11 @@
"resolved": "https://registry.npmjs.org/nocache/-/nocache-2.1.0.tgz",
"integrity": "sha512-0L9FvHG3nfnnmaEQPjT9xhfN4ISk0A8/2j4M37Np4mcDesJjHgEUfgPhdCyZuFI954tjokaIj/A3NdpFNdEh4Q=="
},
"node-addon-api": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-2.0.0.tgz",
"integrity": "sha512-ASCL5U13as7HhOExbT6OlWJJUV/lLzL2voOSP1UVehpRD8FbSrSDjfScK/KwAvVTI5AS6r4VwbOMlIqtvRidnA=="
},
"node-environment-flags": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/node-environment-flags/-/node-environment-flags-1.0.5.tgz",
@ -7320,6 +7325,11 @@
}
}
},
"node-gyp-build": {
"version": "4.2.2",
"resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.2.2.tgz",
"integrity": "sha512-Lqh7mrByWCM8Cf9UPqpeoVBBo5Ugx+RKu885GAzmLBVYjeywScxHXPGLa4JfYNZmcNGwzR0Glu5/9GaQZMFqyA=="
},
"node-libs-browser": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/node-libs-browser/-/node-libs-browser-2.2.1.tgz",
@ -9541,6 +9551,16 @@
}
}
},
"secp256k1": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/secp256k1/-/secp256k1-4.0.1.tgz",
"integrity": "sha512-iGRjbGAKfXMqhtdkkuNxsgJQfJO8Oo78Rm7DAvsG3XKngq+nJIOGqrCSXcQqIVsmCj0wFanE5uTKFxV3T9j2wg==",
"requires": {
"elliptic": "^6.5.2",
"node-addon-api": "^2.0.0",
"node-gyp-build": "^4.2.0"
}
},
"select-hose": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/select-hose/-/select-hose-2.0.0.tgz",

1
package.json

@ -66,6 +66,7 @@
"request": "^2.88.0",
"request-promise": "^4.2.5",
"rncryptor-js": "0.0.1",
"secp256k1": "^4.0.1",
"semantic-ui-css": "^2.4.1",
"semantic-ui-react": "^0.88.1",
"sequelize": "^5.19.3",

8
public/js/app.js

@ -85321,8 +85321,7 @@ function Media(props) {
file = files[0] || {};
start = new Date();
_context2.next = 5;
return api_media.UPLOAD('upload/attachment', file, {
chat_uuid: '1234567890',
return api_media.UPLOAD('file', file, {
name: file.name || 'filename',
description: description || 'description',
ttl: ttl
@ -85332,14 +85331,15 @@ function Media(props) {
r = _context2.sent;
end = new Date();
time = end.getTime() - start.getTime();
console.log('Upload Timer: finished in', time, 'ms'); // await api.relay.POST('attachment', {
console.log('Upload Timer: finished in', time, 'ms');
console.log(r); // await api.relay.POST('attachment', {
// muid: r.muid,
// file_name: r.filename,
// chat_id: 13,
// ttl: ttl,
// })
case 9:
case 10:
case "end":
return _context2.stop();
}

6
relay_supervisor.conf

@ -1,6 +0,0 @@
[program:relay]
user=root
command=npm start --prefix /relay/
startretries=999999999999999999999999999
autostart=true
autorestart=true

2580
rpc.proto

File diff suppressed because it is too large

228
signer.proto

@ -0,0 +1,228 @@
syntax = "proto3";
package signrpc;
option go_package = "github.com/lightningnetwork/lnd/lnrpc/signrpc";
// Signer is a service that gives access to the signing functionality of the
// daemon's wallet.
service Signer {
/*
SignOutputRaw is a method that can be used to generated a signature for a
set of inputs/outputs to a transaction. Each request specifies details
concerning how the outputs should be signed, which keys they should be
signed with, and also any optional tweaks. The return value is a fixed
64-byte signature (the same format as we use on the wire in Lightning).
If we are unable to sign using the specified keys, then an error will be
returned.
*/
rpc SignOutputRaw (SignReq) returns (SignResp);
/*
ComputeInputScript generates a complete InputIndex for the passed
transaction with the signature as defined within the passed SignDescriptor.
This method should be capable of generating the proper input script for
both regular p2wkh output and p2wkh outputs nested within a regular p2sh
output.
Note that when using this method to sign inputs belonging to the wallet,
the only items of the SignDescriptor that need to be populated are pkScript
in the TxOut field, the value in that same field, and finally the input
index.
*/
rpc ComputeInputScript (SignReq) returns (InputScriptResp);
/*
SignMessage signs a message with the key specified in the key locator. The
returned signature is fixed-size LN wire format encoded.
The main difference to SignMessage in the main RPC is that a specific key is
used to sign the message instead of the node identity private key.
*/
rpc SignMessage (SignMessageReq) returns (SignMessageResp);
/*
VerifyMessage verifies a signature over a message using the public key
provided. The signature must be fixed-size LN wire format encoded.
The main difference to VerifyMessage in the main RPC is that the public key
used to sign the message does not have to be a node known to the network.
*/
rpc VerifyMessage (VerifyMessageReq) returns (VerifyMessageResp);
/*
DeriveSharedKey returns a shared secret key by performing Diffie-Hellman key
derivation between the ephemeral public key in the request and the node's
key specified in the key_loc parameter (or the node's identity private key
if no key locator is specified):
P_shared = privKeyNode * ephemeralPubkey
The resulting shared public key is serialized in the compressed format and
hashed with sha256, resulting in the final key length of 256bit.
*/
rpc DeriveSharedKey (SharedKeyRequest) returns (SharedKeyResponse);
}
message KeyLocator {
// The family of key being identified.
int32 key_family = 1;
// The precise index of the key being identified.
int32 key_index = 2;
}
message KeyDescriptor {
/*
The raw bytes of the key being identified. Either this or the KeyLocator
must be specified.
*/
bytes raw_key_bytes = 1;
/*
The key locator that identifies which key to use for signing. Either this
or the raw bytes of the target key must be specified.
*/
KeyLocator key_loc = 2;
}
message TxOut {
// The value of the output being spent.
int64 value = 1;
// The script of the output being spent.
bytes pk_script = 2;
}
message SignDescriptor {
/*
A descriptor that precisely describes *which* key to use for signing. This
may provide the raw public key directly, or require the Signer to re-derive
the key according to the populated derivation path.
*/
KeyDescriptor key_desc = 1;
/*
A scalar value that will be added to the private key corresponding to the
above public key to obtain the private key to be used to sign this input.
This value is typically derived via the following computation:
* derivedKey = privkey + sha256(perCommitmentPoint || pubKey) mod N
*/
bytes single_tweak = 2;
/*
A private key that will be used in combination with its corresponding
private key to derive the private key that is to be used to sign the target
input. Within the Lightning protocol, this value is typically the
commitment secret from a previously revoked commitment transaction. This
value is in combination with two hash values, and the original private key
to derive the private key to be used when signing.
* k = (privKey*sha256(pubKey || tweakPub) +
tweakPriv*sha256(tweakPub || pubKey)) mod N
*/
bytes double_tweak = 3;
/*
The full script required to properly redeem the output. This field will
only be populated if a p2wsh or a p2sh output is being signed.
*/
bytes witness_script = 4;
/*
A description of the output being spent. The value and script MUST be
provided.
*/
TxOut output = 5;
/*
The target sighash type that should be used when generating the final
sighash, and signature.
*/
uint32 sighash = 7;
/*
The target input within the transaction that should be signed.
*/
int32 input_index = 8;
}
message SignReq {
// The raw bytes of the transaction to be signed.
bytes raw_tx_bytes = 1;
// A set of sign descriptors, for each input to be signed.
repeated SignDescriptor sign_descs = 2;
}
message SignResp {
/*
A set of signatures realized in a fixed 64-byte format ordered in ascending
input order.
*/
repeated bytes raw_sigs = 1;
}
message InputScript {
// The serializes witness stack for the specified input.
repeated bytes witness = 1;
/*
The optional sig script for the specified witness that will only be set if
the input specified is a nested p2sh witness program.
*/
bytes sig_script = 2;
}
message InputScriptResp {
// The set of fully valid input scripts requested.
repeated InputScript input_scripts = 1;
}
message SignMessageReq {
// The message to be signed.
bytes msg = 1;
// The key locator that identifies which key to use for signing.
KeyLocator key_loc = 2;
}
message SignMessageResp {
/*
The signature for the given message in the fixed-size LN wire format.
*/
bytes signature = 1;
}
message VerifyMessageReq {
// The message over which the signature is to be verified.
bytes msg = 1;
/*
The fixed-size LN wire encoded signature to be verified over the given
message.
*/
bytes signature = 2;
// The public key the signature has to be valid for.
bytes pubkey = 3;
}
message VerifyMessageResp {
// Whether the signature was valid over the given message.
bool valid = 1;
}
message SharedKeyRequest {
// The ephemeral public key to use for the DH key derivation.
bytes ephemeral_pubkey = 1;
/*
The optional key locator of the local key that should be used. If this
parameter is not set then the node's identity private key will be used.
*/
KeyLocator key_loc = 2;
}
message SharedKeyResponse {
// The shared public key, hashed with sha256.
bytes shared_key = 1;
}
Loading…
Cancel
Save