Skip to content

Commit

Permalink
feat: expose LND REST API on simnet image
Browse files Browse the repository at this point in the history
  • Loading branch information
michael1011 committed Feb 6, 2019
1 parent f596149 commit 86bc8d1
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 30 deletions.
4 changes: 2 additions & 2 deletions docker/btcd/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.11.4-alpine as builder
FROM golang:1.11.5-alpine as builder

# Install git
RUN apk update && apk upgrade && apk add --no-cache git
Expand All @@ -7,7 +7,7 @@ RUN apk update && apk upgrade && apk add --no-cache git
RUN go get github.com/btcsuite/btcd/...

# Start again with a new image to reduce the size
FROM alpine:3.8 as final
FROM alpine:3.9 as final

# Expose testnet ports (server, rpc)
EXPOSE 18333 18334
Expand Down
4 changes: 2 additions & 2 deletions docker/lnd/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.11.4-alpine as builder
FROM golang:1.11.5-alpine as builder

# Install git
RUN apk update && apk upgrade && apk add --no-cache git make
Expand All @@ -10,7 +10,7 @@ WORKDIR $GOPATH/src/github.com/lightningnetwork/lnd
RUN git checkout resolver+simnet-ltcd && make dep && make install

# Start again with a new image to reduce the size
FROM alpine:3.8 as final
FROM alpine:3.9 as final

# Expose LND ports (server, gRPC)
EXPOSE 9735 10009
Expand Down
4 changes: 2 additions & 2 deletions docker/ltcd/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.11.4-alpine as builder
FROM golang:1.11.5-alpine as builder

# Install git
RUN apk update && apk upgrade && apk add --no-cache git
Expand All @@ -7,7 +7,7 @@ RUN apk update && apk upgrade && apk add --no-cache git
RUN go get github.com/ltcsuite/ltcd/...

# Start again with a new image to reduce the size
FROM alpine:3.8 as final
FROM alpine:3.9 as final

# Expose testnet ports (server, rpc)
EXPOSE 19335 19334
Expand Down
5 changes: 4 additions & 1 deletion docker/simnet/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This image contains a SegWit activated BTCD and LTCD simnet environment
# with two LNDs on each chain that have a channel to eachother
FROM alpine:3.8
FROM alpine:3.9

# Install jq to parse JSON
RUN apk update && apk upgrade && apk add --no-cache jq
Expand Down Expand Up @@ -56,6 +56,9 @@ EXPOSE 18556 19556
# Expose gRPC ports of the LNDs
EXPOSE 10009 10010 11009 11010

# Expose REST API ports of the LNDs
EXPOSE 8080 8081 9080 9081

# Start the BTCD, LTCD and LND nodes
RUN setup.sh

Expand Down
21 changes: 10 additions & 11 deletions docker/simnet/data/certs/lnd/tls.cert
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
-----BEGIN CERTIFICATE-----
MIICXjCCAgSgAwIBAgIRANHAJHqvqtgAGJ1AaN8y5mswCgYIKoZIzj0EAwIwLjEf
MIICGjCCAcGgAwIBAgIRAMO1I7IKswqBvnDuuQX9kakwCgYIKoZIzj0EAwIwLjEf
MB0GA1UEChMWbG5kIGF1dG9nZW5lcmF0ZWQgY2VydDELMAkGA1UEAxMCcGMwHhcN
MTgxMDEzMDcwNDA3WhcNMTkxMjA4MDcwNDA3WjAuMR8wHQYDVQQKExZsbmQgYXV0
MTkwMjA1MTUyMzIxWhcNMjAwNDAxMTUyMzIxWjAuMR8wHQYDVQQKExZsbmQgYXV0
b2dlbmVyYXRlZCBjZXJ0MQswCQYDVQQDEwJwYzBZMBMGByqGSM49AgEGCCqGSM49
AwEHA0IABBD0/sTsE04aHlyYuUnvEeIpklid3LfTlEbBEEmJF+7gCKGtsJbQchgI
MRhl9puZ14ScZJxNPuRWsuav1mVYRb6jggEBMIH+MA4GA1UdDwEB/wQEAwICpDAP
BgNVHRMBAf8EBTADAQH/MIHaBgNVHREEgdIwgc+CAnBjgglsb2NhbGhvc3SCBHVu
aXiCCnVuaXhwYWNrZXSHBH8AAAGHEAAAAAAAAAAAAAAAAAAAAAGHBAoAARCHBMCo
egGHBKwRAAGHBMCoIAGHEP6AAAAAAAAAbfZ4y33VRNGHEP6AAAAAAAAAAEJh//7L
T++HEP6AAAAAAAAAAELi//7Wj4iHEP6AAAAAAAAACP40//5MJryHEP6AAAAAAAAA
vOcU//7tFUCHEP6AAAAAAAAAoBpR//4+JsCHEP6AAAAAAAAA0Bcf//6Lj/swCgYI
KoZIzj0EAwIDSAAwRQIgAzxjx5Wd514AW4uyunGbUNEHU0eDzDL61mirHLA6rz0C
IQDBcyhpM4hX7GQ8Fl4WmYGp7ohr5CvntbflXnZPSStm/g==
AwEHA0IABJUhctO5kWeHhjcHsbiRwcDb7eS2SWpo7t3l9dYxrqjeGNe6ZznyvG/R
UcqTWWl2+8O1L3iLznhR4MtZg17K1wOjgb8wgbwwDgYDVR0PAQH/BAQDAgKkMA8G
A1UdEwEB/wQFMAMBAf8wgZgGA1UdEQSBkDCBjYICcGOCCWxvY2FsaG9zdIIEdW5p
eIIKdW5peHBhY2tldIcEfwAAAYcQAAAAAAAAAAAAAAAAAAAAAYcECgABEocEwKh6
AYcErBEAAYcEwKhgAYcQ/oAAAAAAAABt9njLfdVE0YcQ/oAAAAAAAAAAQuT//lrG
GYcQ/oAAAAAAAADIn5D//mBmTYcEAAAAADAKBggqhkjOPQQDAgNHADBEAiAwYpI7
xkmAWQVdU19dHB5iYGgoRV6TkFceSUAflIha8gIgFee500G19W2FsbKn7Dy2/ob1
FvZRZlofn7W/sztyFwc=
-----END CERTIFICATE-----
6 changes: 3 additions & 3 deletions docker/simnet/data/certs/lnd/tls.key
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-----BEGIN EC PRIVATE KEY-----
MHcCAQEEIMlr66J3CLot0Ji9mLaUNLHmOFg2ehkFZBASJnK3dSx/oAoGCCqGSM49
AwEHoUQDQgAEEPT+xOwTThoeXJi5Se8R4imSWJ3ct9OURsEQSYkX7uAIoa2wltBy
GAgxGGX2m5nXhJxknE0+5Fay5q/WZVhFvg==
MHcCAQEEIMNtnPegDw+9VMRB2jRlAkjuHO9keR/AS+ZNFkU6FXAPoAoGCCqGSM49
AwEHoUQDQgAElSFy07mRZ4eGNwexuJHBwNvt5LZJamju3eX11jGuqN4Y17pnOfK8
b9FRypNZaXb7w7UveIvOeFHgy1mDXsrXAw==
-----END EC PRIVATE KEY-----
8 changes: 4 additions & 4 deletions docker/simnet/scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ done
echo "Starting LNDs"

# Start the BTCD LNDs
nohup lnd --lnddir=/root/.lnd-btc --listen=127.0.0.1:9735 --rpclisten=0.0.0.0:10009 --restlisten=127.0.0.1:8080 --bitcoin.active --bitcoin.simnet --btcd.rpchost 127.0.0.1:18556 --btcd.rpcuser user --btcd.rpcpass user > /dev/null 2>&1 & num="0"
nohup lnd --lnddir=/root/.lnd-btc2 --listen=127.0.0.1:9736 --rpclisten=0.0.0.0:10010 --restlisten=127.0.0.1:8081 --bitcoin.active --bitcoin.simnet --btcd.rpchost 127.0.0.1:18556 --btcd.rpcuser user --btcd.rpcpass user > /dev/null 2>&1 & num="0"
nohup lnd --lnddir=/root/.lnd-btc --listen=127.0.0.1:9735 --rpclisten=0.0.0.0:10009 --restlisten=0.0.0.0:8080 --bitcoin.active --bitcoin.simnet --btcd.rpchost 127.0.0.1:18556 --btcd.rpcuser user --btcd.rpcpass user > /dev/null 2>&1 & num="0"
nohup lnd --lnddir=/root/.lnd-btc2 --listen=127.0.0.1:9736 --rpclisten=0.0.0.0:10010 --restlisten=0.0.0.0:8081 --bitcoin.active --bitcoin.simnet --btcd.rpchost 127.0.0.1:18556 --btcd.rpcuser user --btcd.rpcpass user > /dev/null 2>&1 & num="0"

# Start the LTCD LNDs
nohup lnd --lnddir=/root/.lnd-ltc --listen=127.0.0.1:10735 --rpclisten=0.0.0.0:11009 --restlisten=127.0.0.1:9080 --litecoin.active --litecoin.simnet --ltcd.rpchost 127.0.0.1:19556 --ltcd.rpcuser user --ltcd.rpcpass user > /dev/null 2>&1 & num="0"
nohup lnd --lnddir=/root/.lnd-ltc2 --listen=127.0.0.1:10736 --rpclisten=0.0.0.0:11010 --restlisten=127.0.0.1:9081 --litecoin.active --litecoin.simnet --ltcd.rpchost 127.0.0.1:19556 --ltcd.rpcuser user --ltcd.rpcpass user > /dev/null 2>&1 & num="0"
nohup lnd --lnddir=/root/.lnd-ltc --listen=127.0.0.1:10735 --rpclisten=0.0.0.0:11009 --restlisten=0.0.0.0:9080 --litecoin.active --litecoin.simnet --ltcd.rpchost 127.0.0.1:19556 --ltcd.rpcuser user --ltcd.rpcpass user > /dev/null 2>&1 & num="0"
nohup lnd --lnddir=/root/.lnd-ltc2 --listen=127.0.0.1:10736 --rpclisten=0.0.0.0:11010 --restlisten=0.0.0.0:9081 --litecoin.active --litecoin.simnet --ltcd.rpchost 127.0.0.1:19556 --ltcd.rpcuser user --ltcd.rpcpass user > /dev/null 2>&1 & num="0"

# Wait for the LNDs to start
while true; do
Expand Down
3 changes: 2 additions & 1 deletion lib/lightning/LndClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,11 @@ class LndClient extends BaseClient implements LightningClient {
await this.getInfo();

this.logger.info(`Reestablished connection to ${LndClient.serviceName} ${this.symbol}`);

this.setClientStatus(ClientStatus.Connected);
this.clearReconnectTimer();
this.subscribeInvoices();

this.subscribeInvoices();
} catch (err) {
this.logger.error(`Could not reconnect to ${LndClient.serviceName} ${this.symbol}: ${err}`);
this.logger.info(`Retrying in ${this.RECONNECT_INTERVAL} ms`);
Expand Down
2 changes: 0 additions & 2 deletions lib/swap/SwapNursery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ class SwapNursery {
currency.chainClient.on('block.connected', async (height: number) => {
const reverseSwaps = maps.reverseSwaps.get(height);

console.log(height);
console.log(reverseSwaps);
if (reverseSwaps) {
await this.refundSwap(currency, reverseSwaps, height);
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"nodemon:watch": "nodemon --watch dist -e js bin/boltzd",
"lint": "tslint --project tsconfig.json && tslint --config tslint-alt.json 'bin/*' 'test/**/*.ts'",
"lint:fix": "tslint --fix --project tsconfig.json && tslint --fix --config tslint-alt.json 'bin/*' 'test/**/*.ts'",
"docker:start": "docker run -d --name simnet -p 18556:18556 -p 19556:19556 -p 10009:10009 -p 10010:10010 -p 11009:11009 -p 11010:11010 boltz/simnet",
"docker:start": "docker run -d --name simnet -p 18556:18556 -p 19556:19556 -p 10009:10009 -p 10010:10010 -p 11009:11009 -p 11010:11010 -p 8081:8081 boltz/simnet",
"docker:stop": "docker kill simnet && docker rm simnet",
"test": "npm run test:unit && npm run test:int",
"test:unit": "mocha test/unit/*.spec.ts test/unit/wallet/*.spec.ts",
Expand Down
2 changes: 1 addition & 1 deletion test/integration/lightning/LndClient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('LndClient', () => {
}
}

return .1;
return -1;
};

setBtcManager(new UtxoManager(btcdClient, Networks.bitcoinSimnet, {
Expand Down
1 change: 1 addition & 0 deletions test/mocha.opts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
--require ts-node/register
--timeout 10000
--exit

0 comments on commit 86bc8d1

Please sign in to comment.