aboutsummaryrefslogtreecommitdiff
path: root/net-p2p/c-lightning
diff options
context:
space:
mode:
authorVasil Dimov <vd@FreeBSD.org>2020-03-17 17:23:45 +0000
committerVasil Dimov <vd@FreeBSD.org>2020-03-17 17:23:45 +0000
commitaedbb2b8ba7136b547873a0032c25943d6c3f8b5 (patch)
tree7478f8ce049abae50d8a8fe76a6547bce9be0d87 /net-p2p/c-lightning
parenta5f6343b6924e2dac668c18513b96e548e101f05 (diff)
downloadports-aedbb2b8ba7136b547873a0032c25943d6c3f8b5.tar.gz
ports-aedbb2b8ba7136b547873a0032c25943d6c3f8b5.zip
net-p2p/c-lightning: fix on head and wait bitcoind
* Fix compilation on FreeBSD 13-CURRENT * Instruct rc(8) to start lightningd after bitcoind, if the latter is to be started on this host. * Wait for bitcoind RPC to be available before starting lightningd because: - even though bitcoind would start and its rc script exit, it will not serve RPC requests immediately - lightningd would not start if bitcoind RPC is not available
Notes
Notes: svn path=/head/; revision=528588
Diffstat (limited to 'net-p2p/c-lightning')
-rw-r--r--net-p2p/c-lightning/Makefile4
-rw-r--r--net-p2p/c-lightning/distinfo4
-rw-r--r--net-p2p/c-lightning/files/lightningd.in42
3 files changed, 48 insertions, 2 deletions
diff --git a/net-p2p/c-lightning/Makefile b/net-p2p/c-lightning/Makefile
index cf4272aac22c..2c2559afb567 100644
--- a/net-p2p/c-lightning/Makefile
+++ b/net-p2p/c-lightning/Makefile
@@ -4,12 +4,16 @@
PORTNAME= c-lightning
# To build from an arbitrary git commit comment PORTVERSION and PORTREVISION (if present)
PORTVERSION= 0.8.1
+PORTREVISION= 1
DISTVERSIONPREFIX= v
# and uncomment the following two lines (use for example -git-HEAD or -git-f8d8348c)
#PORTVERSION= 0
#PKGNAMESUFFIX= -git-f8d8348c
CATEGORIES= net-p2p finance
+PATCH_SITES= https://github.com/${GH_ACCOUNT}/${GH_PROJECT}/commit/
+PATCHFILES+= 67fdc507.patch:-p1 # https://github.com/ElementsProject/lightning/pull/3594
+
MAINTAINER= vd@FreeBSD.org
COMMENT= Lightning Network implementation in C
diff --git a/net-p2p/c-lightning/distinfo b/net-p2p/c-lightning/distinfo
index 827e9d2620f0..7709ba12885d 100644
--- a/net-p2p/c-lightning/distinfo
+++ b/net-p2p/c-lightning/distinfo
@@ -1,4 +1,4 @@
-TIMESTAMP = 1582009617
+TIMESTAMP = 1584465209
SHA256 (ElementsProject-lightning-v0.8.1_GH0.tar.gz) = fee0ddaa23c4d143f5ce1d2c2c5a219891d69e0eca0ac636b2a42bf19cb42ede
SIZE (ElementsProject-lightning-v0.8.1_GH0.tar.gz) = 2683725
SHA256 (ElementsProject-libwally-core-release_0.7.5_GH0.tar.gz) = e37b30be66dff973ad979d176f0d8e87331304769214522a0782bbbb79c18ec6
@@ -7,3 +7,5 @@ SHA256 (ianlancetaylor-libbacktrace-5a99ff7fed66b8e_GH0.tar.gz) = 2aad59f02cb008
SIZE (ianlancetaylor-libbacktrace-5a99ff7fed66b8e_GH0.tar.gz) = 509368
SHA256 (zserge-jsmn-v1.0.0_GH0.tar.gz) = 5b1f46312cf205e6a0923a0656893bde9e022c76d06d980958fa8dbf79f0ea06
SIZE (zserge-jsmn-v1.0.0_GH0.tar.gz) = 11035
+SHA256 (67fdc507.patch) = f46d701ee9b3de11af3ed031834e553eb49baaeffee25f677270dbf99321821e
+SIZE (67fdc507.patch) = 2265
diff --git a/net-p2p/c-lightning/files/lightningd.in b/net-p2p/c-lightning/files/lightningd.in
index 97ae38757e29..ffe735e76b27 100644
--- a/net-p2p/c-lightning/files/lightningd.in
+++ b/net-p2p/c-lightning/files/lightningd.in
@@ -2,7 +2,7 @@
# $FreeBSD$
# PROVIDE: lightningd
-# REQUIRE: LOGIN cleanvar
+# REQUIRE: LOGIN bitcoind cleanvar
# KEYWORD: shutdown
# Add the following to %%LOCALBASE%%/etc/rc.conf.d/lightningd to influence
@@ -30,6 +30,7 @@ load_rc_config ${name}
: ${lightningd_network:="bitcoin"}
: ${lightningd_conf:="%%PREFIX%%/etc/${name}-${lightningd_network}.conf"}
+start_precmd="lightningd_start_precmd"
pidfile="${lightningd_base_dir}/lightningd-${lightningd_network}.pid"
command="%%PREFIX%%/bin/lightningd"
command_args=""
@@ -50,4 +51,43 @@ fi
command_args="${command_args} ${lightningd_extra_args}"
+check_bitcoind_ready()
+{
+ bitcoin-cli \
+ -rpcconnect=${bitcoin_addr}${bitcoin_port:+":"}${bitcoin_port} \
+ -rpcuser=${bitcoin_user} \
+ -stdinrpcpass \
+ echo itworks <<PASS
+${bitcoin_pass}
+PASS
+}
+
+lightningd_start_precmd()
+{
+ # Wait for bitcoind to be fully operational. lightningd would quit (refuse
+ # to start) if it can't talk to bitcoind via its RPC.
+ bitcoin_addr="`grep ^bitcoin-rpcconnect= "${lightningd_conf}" |cut -f 2- -d =`"
+ bitcoin_port="`grep ^bitcoin-rpcport= "${lightningd_conf}" |cut -f 2- -d =`"
+ bitcoin_user="`grep ^bitcoin-rpcuser= "${lightningd_conf}" |cut -f 2- -d =`"
+ bitcoin_pass="`grep ^bitcoin-rpcpassword= "${lightningd_conf}" |cut -f 2- -d =`"
+
+ i=20
+ while : ; do
+ if [ $i -eq 0 ] ; then
+ # Show errors from last attempt.
+ if ! check_bitcoind_ready ; then
+ echo "Failed: bitcoind did not start serving RPC, starting lightningd anyway"
+ fi
+ break
+ else
+ if check_bitcoind_ready > /dev/null 2>&1; then
+ break
+ fi
+ fi
+ echo "Waiting for bitcoind to start serving RPC, lightningd cannot start without it $i"
+ sleep 1
+ i=$((i - 1))
+ done
+}
+
run_rc_command "$1"