Skip to content

Commit

Permalink
add recreate macaroon action (#99)
Browse files Browse the repository at this point in the history
* add macaroon action

* fix race condition

---------

Co-authored-by: islandbitcoin <dread@start9.com>
Co-authored-by: Aiden McClelland <me@drbonez.dev>
  • Loading branch information
3 people authored Apr 14, 2023
1 parent 4eeaadd commit fcc6c9d
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
20 changes: 20 additions & 0 deletions actions/recreate-macaroons.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh

set -e

rm /root/.lnd/data/chain/bitcoin/mainnet/*.macaroon
action_result_running=" {
\"version\": \"0\",
\"message\": \"Restarting LND to recreate macaroons.\",
\"value\": null,
\"copyable\": false,
\"qr\": false
}"
action_result_stopped=" {
\"version\": \"0\",
\"message\": \"LND macaroons will be recreated the next time the service is started\",
\"value\": null,
\"copyable\": false,
\"qr\": false
}"
lncli --rpcserver=lnd.embassy stop >/dev/null 2>/dev/null && echo $action_result_running || echo $action_result_stopped
7 changes: 7 additions & 0 deletions docker_entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ mkdir -p /root/.lnd/start9/ && mkdir -p /root/.lnd/public
echo $PEER_TOR_ADDRESS > /root/.lnd/start9/peerTorAddress
echo $CONTROL_TOR_ADDRESS > /root/.lnd/start9/controlTorAddress

while ! openssl x509 -text -noout -in /mnt/cert/control.cert.pem -ext subjectAltName \
-certopt no_subject,no_header,no_version,no_serial,no_signame,no_validity,no_issuer,no_pubkey,no_sigdump,no_aux \
| grep "IP Address:$(ip -4 -o addr show eth0 | awk '{print $4}' | sed -e 's/\/[0-9]\+//g')"; do
>&2 echo Cert is not yet signed for current IP...
sleep 1;
done

# copy system cert
openssl x509 -outform der -in /mnt/cert/control.cert.pem -out /root/.lnd/start9/control.cert.der
cat /root/.lnd/start9/control.cert.der | basenc --base64url -w0 > /root/.lnd/start9/control.cert.pem.base64url
Expand Down
19 changes: 18 additions & 1 deletion manifest.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
id: lnd
title: LND
version: 0.16.0
version: 0.16.0.1
release-notes: |-
* LND v0.16.0 [Release Notes](https://github.com/lightningnetwork/lnd/blob/master/docs/release-notes/release-notes-0.16.0.md)
* Start9 packaging performance updates and bugfixes
* Added action to recreate LND macaroons
license: mit
wrapper-repo: "https://github.com/Start9Labs/lnd-wrapper"
upstream-repo: "https://github.com/lightningnetwork/lnd"
Expand Down Expand Up @@ -269,3 +270,19 @@ actions:
mounts:
main: /root/.lnd
io-format: json
recreate-macaroons:
name: "Recreate Macaroons"
description: "Deletes current macaroons, and restarts LND to recreate all macaroons."
warning: ~
allowed-statuses:
- running
- stopped
implementation:
type: docker
image: main
system: false
entrypoint: recreate-macaroons.sh
args: []
mounts:
main: /root/.lnd
io-format: json
2 changes: 1 addition & 1 deletion scripts/services/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,5 @@ export const migration: T.ExpectedExports.migration = compat.migrations
down: () => { throw new Error('Cannot downgrade') },
},
},
"0.16.0",
"0.16.0.1",
);

0 comments on commit fcc6c9d

Please sign in to comment.