From 821aa636fc8d0b804e31976886a158f66b45ce1a Mon Sep 17 00:00:00 2001 From: keblek <68111648+keblek@users.noreply.github.com> Date: Tue, 9 Feb 2021 00:41:22 +0100 Subject: [PATCH 1/7] Bump clightning to 9.3 --- code/docker/c-lightning/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/docker/c-lightning/Dockerfile b/code/docker/c-lightning/Dockerfile index b9a505c..bac711d 100644 --- a/code/docker/c-lightning/Dockerfile +++ b/code/docker/c-lightning/Dockerfile @@ -5,7 +5,7 @@ RUN apt update && apt install -yqq \ software-properties-common # c-lightning -ENV C_LIGHTNING_VER 0.9.2~0~ubuntu18.04.1 +ENV C_LIGHTNING_VER 0.9.3~20210120202101201901~ubuntu20.04.1 RUN add-apt-repository -u ppa:lightningnetwork/ppa RUN apt-get install -yqq \ lightningd=${C_LIGHTNING_VER} From d482f18ef6f9302ac83688d38a26dff59be22bf9 Mon Sep 17 00:00:00 2001 From: keblek <68111648+keblek@users.noreply.github.com> Date: Tue, 9 Feb 2021 00:42:13 +0100 Subject: [PATCH 2/7] Removed unnecessary command line argument --- code/docker/c-lightning/bashrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/docker/c-lightning/bashrc b/code/docker/c-lightning/bashrc index 7d0e4cc..e0cd922 100644 --- a/code/docker/c-lightning/bashrc +++ b/code/docker/c-lightning/bashrc @@ -1,4 +1,4 @@ -alias lightning-cli="lightning-cli --network regtest --lightning-dir=/lightningd" +alias lightning-cli="lightning-cli --lightning-dir=/lightningd" [[ $PS1 && -f /usr/share/bash-completion/bash_completion ]] && \ . /usr/share/bash-completion/bash_completion From 68504ea5110305902c0c48c88143bf05c33ee668 Mon Sep 17 00:00:00 2001 From: keblek <68111648+keblek@users.noreply.github.com> Date: Tue, 9 Feb 2021 00:42:41 +0100 Subject: [PATCH 3/7] Removed another unnecessary command line argument --- code/docker/c-lightning/c-lightning-entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/docker/c-lightning/c-lightning-entrypoint.sh b/code/docker/c-lightning/c-lightning-entrypoint.sh index 0bcd4a6..b901332 100644 --- a/code/docker/c-lightning/c-lightning-entrypoint.sh +++ b/code/docker/c-lightning/c-lightning-entrypoint.sh @@ -6,7 +6,7 @@ source /usr/local/bin/wait-for-bitcoind.sh echo Starting c-lightning... lightningd --lightning-dir=/lightningd --daemon -until lightning-cli --lightning-dir=/lightningd --network regtest getinfo > /dev/null 2>&1 +until lightning-cli --lightning-dir=/lightningd getinfo > /dev/null 2>&1 do sleep 1 done From 1b8f94e6b4162f4427d4834100c19719caaca485 Mon Sep 17 00:00:00 2001 From: Matthias Debernardini Date: Tue, 9 Feb 2021 11:47:11 +0100 Subject: [PATCH 4/7] Adding docker example for payment round robin --- code/perpetualpayments/Makefile | 16 ++++ code/perpetualpayments/bitcoind/Dockerfile | 46 +++++++++ code/perpetualpayments/bitcoind/bashrc | 5 + .../bitcoind/bitcoind-entrypoint.sh | 23 +++++ .../bitcoind/bitcoind/bitcoin.conf | 22 +++++ .../bitcoind/bitcoind/keys/demo_address.txt | 1 + .../bitcoind/bitcoind/keys/demo_mnemonic.txt | 1 + .../bitcoind/bitcoind/keys/demo_privkey.txt | 1 + code/perpetualpayments/bitcoind/mine.sh | 20 ++++ code/perpetualpayments/c-lightning/Dockerfile | 33 +++++++ code/perpetualpayments/c-lightning/bashrc | 4 + .../c-lightning/c-lightning-entrypoint.sh | 17 ++++ .../c-lightning/fund-c-lightning.sh | 22 +++++ .../c-lightning/lightningd/config | 9 ++ code/perpetualpayments/c-lightning/logtail.sh | 5 + .../c-lightning/wait-for-bitcoind.sh | 16 ++++ code/perpetualpayments/docker-compose.yml | 95 +++++++++++++++++++ code/perpetualpayments/fund-all-nodes.sh | 36 +++++++ .../perpetualpayments/make-network-payloop.sh | 23 +++++ code/perpetualpayments/make-topology.sh | 38 ++++++++ code/perpetualpayments/payment-loop.sh | 37 ++++++++ 21 files changed, 470 insertions(+) create mode 100644 code/perpetualpayments/Makefile create mode 100644 code/perpetualpayments/bitcoind/Dockerfile create mode 100644 code/perpetualpayments/bitcoind/bashrc create mode 100644 code/perpetualpayments/bitcoind/bitcoind-entrypoint.sh create mode 100644 code/perpetualpayments/bitcoind/bitcoind/bitcoin.conf create mode 100644 code/perpetualpayments/bitcoind/bitcoind/keys/demo_address.txt create mode 100644 code/perpetualpayments/bitcoind/bitcoind/keys/demo_mnemonic.txt create mode 100644 code/perpetualpayments/bitcoind/bitcoind/keys/demo_privkey.txt create mode 100755 code/perpetualpayments/bitcoind/mine.sh create mode 100644 code/perpetualpayments/c-lightning/Dockerfile create mode 100644 code/perpetualpayments/c-lightning/bashrc create mode 100644 code/perpetualpayments/c-lightning/c-lightning-entrypoint.sh create mode 100644 code/perpetualpayments/c-lightning/fund-c-lightning.sh create mode 100644 code/perpetualpayments/c-lightning/lightningd/config create mode 100644 code/perpetualpayments/c-lightning/logtail.sh create mode 100644 code/perpetualpayments/c-lightning/wait-for-bitcoind.sh create mode 100644 code/perpetualpayments/docker-compose.yml create mode 100644 code/perpetualpayments/fund-all-nodes.sh create mode 100644 code/perpetualpayments/make-network-payloop.sh create mode 100644 code/perpetualpayments/make-topology.sh create mode 100644 code/perpetualpayments/payment-loop.sh diff --git a/code/perpetualpayments/Makefile b/code/perpetualpayments/Makefile new file mode 100644 index 0000000..ead00f7 --- /dev/null +++ b/code/perpetualpayments/Makefile @@ -0,0 +1,16 @@ + +REGISTRY=docker.com +NAME=lnbook +CONTAINERS=bitcoind c-lightning + +all: build-all push-all + +build-all: + for container in ${CONTAINERS}; do \ + docker build -t ${NAME}/$$container $$container -f $$container/Dockerfile; \ + done + +push-all: + for container in ${CONTAINERS}; do \ + docker push ${NAME}/$$container; \ + done diff --git a/code/perpetualpayments/bitcoind/Dockerfile b/code/perpetualpayments/bitcoind/Dockerfile new file mode 100644 index 0000000..b2555b6 --- /dev/null +++ b/code/perpetualpayments/bitcoind/Dockerfile @@ -0,0 +1,46 @@ +FROM ubuntu:20.04 AS bitcoind-base + +RUN apt update && apt install -yqq \ + curl gosu jq bash-completion + +ENV BITCOIND_VERSION 0.21.0 +# Install binaries for Bitcoin Core +ADD https://bitcoincore.org/bin/bitcoin-core-${BITCOIND_VERSION}/bitcoin-${BITCOIND_VERSION}-x86_64-linux-gnu.tar.gz /usr/local +RUN cd /usr/local/ \ + && tar -zxf bitcoin-${BITCOIND_VERSION}-x86_64-linux-gnu.tar.gz \ + && cd bitcoin-${BITCOIND_VERSION} \ + && install bin/* /usr/local/bin \ + && install include/* /usr/local/include \ + && install -v lib/* /usr/local/lib + +ENV GH_URL https://raw.githubusercontent.com/bitcoin/bitcoin/master/ +ENV BC /usr/share/bash-completion/completions/ +ADD $GH_URL/contrib/bitcoin-cli.bash-completion $BC/bitcoin-cli +ADD $GH_URL/contrib/bitcoind.bash-completion $BC/bitcoind +ADD $GH_URL/contrib/bitcoin-tx.bash-completion $BC/bitcoin-tx + +FROM bitcoind-base AS bitcoind + +ADD bitcoind /bitcoind +RUN ln -s /bitcoind /root/. + +ADD bashrc /root/.bashrc +ADD bitcoind-entrypoint.sh /usr/local/bin +RUN chmod +x /usr/local/bin/bitcoind-entrypoint.sh +ADD mine.sh /usr/local/bin +RUN chmod +x /usr/local/bin/mine.sh + +# bitcoind P2P +EXPOSE 18444/tcp +# bitcoind regtest RPC +EXPOSE 18443/tcp +# zmqpubrawblock +EXPOSE 12005/tcp +# zmqpubrawtx +EXPOSE 12006/tcp + +WORKDIR /bitcoind +ENTRYPOINT ["/usr/local/bin/bitcoind-entrypoint.sh"] + +# Mine new block every 10 seconds +CMD ["/usr/local/bin/mine.sh"] diff --git a/code/perpetualpayments/bitcoind/bashrc b/code/perpetualpayments/bitcoind/bashrc new file mode 100644 index 0000000..5f4b902 --- /dev/null +++ b/code/perpetualpayments/bitcoind/bashrc @@ -0,0 +1,5 @@ +# Use bash-completion, if available +alias bitcoin-cli="bitcoin-cli -datadir=/bitcoind" + +[[ $PS1 && -f /usr/share/bash-completion/bash_completion ]] && \ + . /usr/share/bash-completion/bash_completion diff --git a/code/perpetualpayments/bitcoind/bitcoind-entrypoint.sh b/code/perpetualpayments/bitcoind/bitcoind-entrypoint.sh new file mode 100644 index 0000000..167ef66 --- /dev/null +++ b/code/perpetualpayments/bitcoind/bitcoind-entrypoint.sh @@ -0,0 +1,23 @@ +#!/bin/bash +set -Eeuo pipefail + +echo Starting bitcoind... +bitcoind -datadir=/bitcoind -daemon +until bitcoin-cli -datadir=/bitcoind getblockchaininfo > /dev/null 2>&1 +do + sleep 1 +done +echo bitcoind started +export address=`cat /bitcoind/keys/demo_address.txt` +export privkey=`cat /bitcoind/keys/demo_privkey.txt` +echo "================================================" +echo "Importing demo private key" +echo "Bitcoin address: " ${address} +echo "Private key: " ${privkey} +echo "================================================" +bitcoin-cli -datadir=/bitcoind createwallet regtest +bitcoin-cli -datadir=/bitcoind importprivkey $privkey + +# Executing CMD +echo "$@" +exec "$@" diff --git a/code/perpetualpayments/bitcoind/bitcoind/bitcoin.conf b/code/perpetualpayments/bitcoind/bitcoind/bitcoin.conf new file mode 100644 index 0000000..36d6903 --- /dev/null +++ b/code/perpetualpayments/bitcoind/bitcoind/bitcoin.conf @@ -0,0 +1,22 @@ +regtest=1 +server=1 +debuglogfile=debug.log +debug=1 +txindex=1 +printtoconsole=0 + +[regtest] +fallbackfee=0.000001 +port=18444 +noconnect=1 +dnsseed=0 +dns=0 +upnp=0 +onlynet=ipv4 +rpcport=18443 +rpcbind=0.0.0.0 +rpcallowip=0.0.0.0/0 +rpcuser=regtest +rpcpassword=regtest +zmqpubrawblock=tcp://0.0.0.0:12005 +zmqpubrawtx=tcp://0.0.0.0:12006 diff --git a/code/perpetualpayments/bitcoind/bitcoind/keys/demo_address.txt b/code/perpetualpayments/bitcoind/bitcoind/keys/demo_address.txt new file mode 100644 index 0000000..ae62ea3 --- /dev/null +++ b/code/perpetualpayments/bitcoind/bitcoind/keys/demo_address.txt @@ -0,0 +1 @@ +2NBKgwSWY5qEmfN2Br4WtMDGuamjpuUc5q1 diff --git a/code/perpetualpayments/bitcoind/bitcoind/keys/demo_mnemonic.txt b/code/perpetualpayments/bitcoind/bitcoind/keys/demo_mnemonic.txt new file mode 100644 index 0000000..37f503c --- /dev/null +++ b/code/perpetualpayments/bitcoind/bitcoind/keys/demo_mnemonic.txt @@ -0,0 +1 @@ +electric flash rain cloud umbrella energy charge ozone air thunder crack wet diff --git a/code/perpetualpayments/bitcoind/bitcoind/keys/demo_privkey.txt b/code/perpetualpayments/bitcoind/bitcoind/keys/demo_privkey.txt new file mode 100644 index 0000000..6acc8df --- /dev/null +++ b/code/perpetualpayments/bitcoind/bitcoind/keys/demo_privkey.txt @@ -0,0 +1 @@ +cSaejkcWwU25jMweWEewRSsrVQq2FGTij1xjXv4x1XvxVRF1ZCr3 diff --git a/code/perpetualpayments/bitcoind/mine.sh b/code/perpetualpayments/bitcoind/mine.sh new file mode 100755 index 0000000..5e08f57 --- /dev/null +++ b/code/perpetualpayments/bitcoind/mine.sh @@ -0,0 +1,20 @@ +#!/bin/bash +set -Eeuo pipefail + +export address=`cat /bitcoind/keys/demo_address.txt` +export privkey=`cat /bitcoind/keys/demo_privkey.txt` +echo "================================================" +echo "Bitcoin address: " ${address} +echo "Private key: " ${privkey} +echo "Balance:" `bitcoin-cli -datadir=/bitcoind getbalance` +echo "================================================" +echo "Mining 101 blocks to unlock some bitcoin" +bitcoin-cli -datadir=/bitcoind generatetoaddress 101 $address +echo "Mining 1 block every 10 seconds" +while sleep 10; do \ + bitcoin-cli -datadir=/bitcoind generatetoaddress 1 $address; \ + echo "Balance:" `bitcoin-cli -datadir=/bitcoind getbalance`; \ +done + +# If loop is interrupted, stop bitcoind +bitcoin-cli -datadir=/bitcoind stop diff --git a/code/perpetualpayments/c-lightning/Dockerfile b/code/perpetualpayments/c-lightning/Dockerfile new file mode 100644 index 0000000..f3df06e --- /dev/null +++ b/code/perpetualpayments/c-lightning/Dockerfile @@ -0,0 +1,33 @@ +FROM lnbook/bitcoind AS c-lightning-base + +# Install software-properties-common to add apt repositories +RUN apt update && apt install -yqq \ + software-properties-common + +# c-lightning +ENV C_LIGHTNING_VER 0.9.3~20210120202101201901~ubuntu20.04.1 +RUN add-apt-repository -u ppa:lightningnetwork/ppa +RUN apt-get install -yqq \ + lightningd=${C_LIGHTNING_VER} + +ADD https://raw.githubusercontent.com/ElementsProject/lightning/master/contrib/lightning-cli.bash-completion /usr/share/bash-completion/completions/lightning-cli + +FROM c-lightning-base AS c-lightning-run + +ADD lightningd /lightningd +WORKDIR /lightningd +RUN ln -s /lightningd /root/.lightning + +ADD bashrc /root/.bashrc +ADD c-lightning-entrypoint.sh /usr/local/bin +RUN chmod +x /usr/local/bin/c-lightning-entrypoint.sh +ADD logtail.sh /usr/local/bin +RUN chmod +x /usr/local/bin/logtail.sh +ADD wait-for-bitcoind.sh /usr/local/bin +RUN chmod +x /usr/local/bin/wait-for-bitcoind.sh + +EXPOSE 9735 9835 +ENTRYPOINT ["/usr/local/bin/c-lightning-entrypoint.sh"] + +# Show logs from beginning and keep following +CMD ["/usr/local/bin/logtail.sh"] diff --git a/code/perpetualpayments/c-lightning/bashrc b/code/perpetualpayments/c-lightning/bashrc new file mode 100644 index 0000000..e0cd922 --- /dev/null +++ b/code/perpetualpayments/c-lightning/bashrc @@ -0,0 +1,4 @@ +alias lightning-cli="lightning-cli --lightning-dir=/lightningd" + +[[ $PS1 && -f /usr/share/bash-completion/bash_completion ]] && \ + . /usr/share/bash-completion/bash_completion diff --git a/code/perpetualpayments/c-lightning/c-lightning-entrypoint.sh b/code/perpetualpayments/c-lightning/c-lightning-entrypoint.sh new file mode 100644 index 0000000..4724a89 --- /dev/null +++ b/code/perpetualpayments/c-lightning/c-lightning-entrypoint.sh @@ -0,0 +1,17 @@ +#!/bin/bash +set -Eeuo pipefail + +source /usr/local/bin/wait-for-bitcoind.sh + +echo Starting c-lightning... +lightningd --lightning-dir=/lightningd --daemon + +until lightning-cli --lightning-dir=/lightningd getinfo > /dev/null 2>&1 +do + sleep 1 +done + +echo "Startup complete" + +echo "$@" +exec "$@" diff --git a/code/perpetualpayments/c-lightning/fund-c-lightning.sh b/code/perpetualpayments/c-lightning/fund-c-lightning.sh new file mode 100644 index 0000000..11f536f --- /dev/null +++ b/code/perpetualpayments/c-lightning/fund-c-lightning.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# Generate a new receiving address for LND wallet +address=$(lightning-cli --lightning-dir=/lightningd newaddr | jq .address) + +# Ask Bitcoin Core to send 10 BTC to the address, using JSON-RPC call +curl --user regtest:regtest \ + -H 'content-type: text/plain;' \ + http://bitcoind:18443/ \ + --data-binary @- < /dev/null 2>&1 +do + echo -n "." + sleep 1 +done + +echo Waiting for bitcoind to mine blocks... +until bitcoin-cli -rpcconnect=bitcoind -rpcport=18443 -rpcuser=regtest -rpcpassword=regtest getbalance | jq -e ". > 0" > /dev/null 2>&1 +do + echo -n "." + sleep 1 +done diff --git a/code/perpetualpayments/docker-compose.yml b/code/perpetualpayments/docker-compose.yml new file mode 100644 index 0000000..27de45d --- /dev/null +++ b/code/perpetualpayments/docker-compose.yml @@ -0,0 +1,95 @@ +version: "3.3" +networks: + lnnet: + +services: + bitcoind: + container_name: bitcoind + build: + context: bitcoind + image: lnbook/bitcoind:latest + networks: + - lnnet + expose: + - "18443" + - "12005" + - "12006" + restart: always + + Aa: + container_name: Aa + build: + context: c-lightning + image: lnbook/c-lightning:latest + networks: + - lnnet + expose: + - "9735" + restart: always + depends_on: + - bitcoind + + Bb: + container_name: Bb + build: + context: c-lightning + image: lnbook/c-lightning:latest + networks: + - lnnet + expose: + - "9735" + restart: always + depends_on: + - bitcoind + + Cc: + container_name: Cc + build: + context: c-lightning + image: lnbook/c-lightning:latest + networks: + - lnnet + expose: + - "9735" + restart: always + depends_on: + - bitcoind + + Dd: + container_name: Dd + build: + context: c-lightning + image: lnbook/c-lightning:latest + networks: + - lnnet + expose: + - "9735" + restart: always + depends_on: + - bitcoind + + Ee: + container_name: Ee + build: + context: c-lightning + image: lnbook/c-lightning:latest + networks: + - lnnet + expose: + - "9735" + restart: always + depends_on: + - bitcoind + + Ff: + container_name: Ff + build: + context: c-lightning + image: lnbook/c-lightning:latest + networks: + - lnnet + expose: + - "9735" + restart: always + depends_on: + - bitcoind diff --git a/code/perpetualpayments/fund-all-nodes.sh b/code/perpetualpayments/fund-all-nodes.sh new file mode 100644 index 0000000..c82111a --- /dev/null +++ b/code/perpetualpayments/fund-all-nodes.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +#docker-compose exec -T Aa lightning-cli getinfo +#docker-compose exec -T Bb lightning-cli getinfo +#docker-compose exec -T Cc lightning-cli getinfo +#docker-compose exec -T Ee lightning-cli getinfo +#docker-compose exec -T Dd lightning-cli getinfo +#docker-compose exec -T Ff lightning-cli getinfo + +echo getting addresses +a=$(docker-compose exec -T Aa bash -c "lightning-cli newaddr | jq -r .bech32") +echo $a +b=$(docker-compose exec -T Bb bash -c "lightning-cli newaddr | jq -r .bech32") +echo $b +c=$(docker-compose exec -T Cc bash -c "lightning-cli newaddr | jq -r .bech32") +echo $c +d=$(docker-compose exec -T Dd bash -c "lightning-cli newaddr | jq -r .bech32") +echo $d +e=$(docker-compose exec -T Ee bash -c "lightning-cli newaddr | jq -r .bech32") +echo $e +f=$(docker-compose exec -T Ff bash -c "lightning-cli newaddr | jq -r .bech32") +echo $f + +echo funding wallets +ba=$(docker-compose exec -T bitcoind bash -c "bitcoin-cli -regtest -rpcport=18443 -rpcuser=regtest -rpcpassword=regtest sendtoaddress $a 10") +echo $ba +bb=$(docker-compose exec -T bitcoind bash -c "bitcoin-cli -regtest -rpcport=18443 -rpcuser=regtest -rpcpassword=regtest sendtoaddress $b 10") +echo $bb +bc=$(docker-compose exec -T bitcoind bash -c "bitcoin-cli -regtest -rpcport=18443 -rpcuser=regtest -rpcpassword=regtest sendtoaddress $c 10") +echo $bc +bd=$(docker-compose exec -T bitcoind bash -c "bitcoin-cli -regtest -rpcport=18443 -rpcuser=regtest -rpcpassword=regtest sendtoaddress $d 10") +echo $bd +be=$(docker-compose exec -T bitcoind bash -c "bitcoin-cli -regtest -rpcport=18443 -rpcuser=regtest -rpcpassword=regtest sendtoaddress $e 10") +echo $be +bf=$(docker-compose exec -T bitcoind bash -c "bitcoin-cli -regtest -rpcport=18443 -rpcuser=regtest -rpcpassword=regtest sendtoaddress $f 10") +echo $bf diff --git a/code/perpetualpayments/make-network-payloop.sh b/code/perpetualpayments/make-network-payloop.sh new file mode 100644 index 0000000..350e8ec --- /dev/null +++ b/code/perpetualpayments/make-network-payloop.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +#docker-compose up -d && bash make-network-payloop.sh +echo Wait for network to load for 180 sec +sleep 180 + +echo Funding all nodes +source fund-all-nodes.sh +sleep 60 +echo Making topology +source make-topology.sh +sleep 60 +echo Entering the payment loop +source payment-loop.sh + +#docker-compose exec -T Aa lightning-cli +#docker-compose exec -T Bb lightning-cli +#docker-compose exec -T Cc lightning-cli +#docker-compose exec -T Ee lightning-cli +#docker-compose exec -T Dd lightning-cli +#docker-compose exec -T Ff lightning-cli + +exit 0 diff --git a/code/perpetualpayments/make-topology.sh b/code/perpetualpayments/make-topology.sh new file mode 100644 index 0000000..91bda78 --- /dev/null +++ b/code/perpetualpayments/make-topology.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +echo Getting node IDs +a_ID=$(docker-compose exec -T Aa bash -c "lightning-cli getinfo | jq -r .id") +b_ID=$(docker-compose exec -T Bb bash -c "lightning-cli getinfo | jq -r .id") +c_ID=$(docker-compose exec -T Cc bash -c "lightning-cli getinfo | jq -r .id") +d_ID=$(docker-compose exec -T Dd bash -c "lightning-cli getinfo | jq -r .id") +e_ID=$(docker-compose exec -T Ee bash -c "lightning-cli getinfo | jq -r .id") +f_ID=$(docker-compose exec -T Ff bash -c "lightning-cli getinfo | jq -r .id") + +# Let's tell everyone what we found! +#echo A ${a_ID} +#echo B ${b_ID} +#echo C ${c_ID} +#echo D ${d_ID} +#echo E ${e_ID} +#echo F ${f_ID} + +echo Setting up channels... +echo A to B +docker-compose exec -T Aa lightning-cli connect ${b_ID}@Bb +docker-compose exec -T Aa lightning-cli -k fundchannel id=${b_ID} amount=1000000sat minconf=0 +echo B to C +docker-compose exec -T Bb lightning-cli connect ${c_ID}@Cc +docker-compose exec -T Bb lightning-cli -k fundchannel id=${c_ID} amount=1000000sat minconf=0 +echo C to D +docker-compose exec -T Cc lightning-cli connect ${d_ID}@Dd +docker-compose exec -T Cc lightning-cli -k fundchannel id=${d_ID} amount=1000000sat minconf=0 +echo D to E +docker-compose exec -T Dd lightning-cli connect ${e_ID}@Ee +docker-compose exec -T Dd lightning-cli -k fundchannel id=${e_ID} amount=1000000sat minconf=0 +echo E to F +docker-compose exec -T Ee lightning-cli connect ${f_ID}@Ff +docker-compose exec -T Ee lightning-cli -k fundchannel id=${f_ID} amount=1000000sat minconf=0 +echo F to A +docker-compose exec -T Ff lightning-cli connect ${a_ID}@Aa +docker-compose exec -T Ff lightning-cli -k fundchannel id=${a_ID} amount=1000000sat minconf=0 + diff --git a/code/perpetualpayments/payment-loop.sh b/code/perpetualpayments/payment-loop.sh new file mode 100644 index 0000000..78fd158 --- /dev/null +++ b/code/perpetualpayments/payment-loop.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +echo pay in a loop + +start=$(date +"%T") + +for i in {1..2} +do + echo A pays B + INV=$(docker-compose exec -T Bb bash -c "lightning-cli invoice 10000sat inva{$i} desc | jq -r .bolt11") + docker-compose exec -T Aa bash -c "lightning-cli pay $INV" + + echo B pays C + INV=$(docker-compose exec -T Cc bash -c "lightning-cli invoice 10000sat invb{$i} desc | jq -r .bolt11") + docker-compose exec -T Bb bash -c "lightning-cli pay $INV" + + echo C pays D + INV=$(docker-compose exec -T Dd bash -c "lightning-cli invoice 10000sat invc{$i} desc | jq -r .bolt11") + docker-compose exec -T Cc bash -c "lightning-cli pay $INV" + + echo D pays E + INV=$(docker-compose exec -T Ee bash -c "lightning-cli invoice 10000sat invd{$i} desc | jq -r .bolt11") + docker-compose exec -T Dd bash -c "lightning-cli pay $INV" + + echo E pays F + INV=$(docker-compose exec -T Ff bash -c "lightning-cli invoice 10000sat inve{$i} desc | jq -r .bolt11") + docker-compose exec -T Ee bash -c "lightning-cli pay $INV" + + echo F pays A + INV=$(docker-compose exec -T Aa bash -c "lightning-cli invoice 10000sat invf{$i} desc | jq -r .bolt11") + docker-compose exec -T Ff bash -c "lightning-cli pay $INV" +done +stop=$(date +"%T") + +echo time to finish +echo start $start +echo stop $stop From 5815a8c86590d88b3e834e0a942544febf3fd54a Mon Sep 17 00:00:00 2001 From: Matthias Debernardini Date: Tue, 9 Feb 2021 12:03:22 +0100 Subject: [PATCH 5/7] Renaming files, deleting comments --- code/{perpetualpayments => doughnuteconomy}/Makefile | 0 .../bitcoind/Dockerfile | 0 .../bitcoind/bashrc | 0 .../bitcoind/bitcoind-entrypoint.sh | 0 .../bitcoind/bitcoind/bitcoin.conf | 0 .../bitcoind/bitcoind/keys/demo_address.txt | 0 .../bitcoind/bitcoind/keys/demo_mnemonic.txt | 0 .../bitcoind/bitcoind/keys/demo_privkey.txt | 0 .../bitcoind/mine.sh | 0 .../c-lightning/Dockerfile | 0 .../c-lightning/bashrc | 0 .../c-lightning/c-lightning-entrypoint.sh | 0 .../c-lightning/fund-c-lightning.sh | 0 .../c-lightning/lightningd/config | 0 .../c-lightning/logtail.sh | 0 .../c-lightning/wait-for-bitcoind.sh | 0 .../docker-compose.yml | 0 .../doughnut.sh} | 7 ++++--- .../fund-all-nodes.sh => doughnuteconomy/fund-nodes.sh} | 7 ------- .../make-topology.sh | 8 -------- .../payment-loop.sh | 2 +- 21 files changed, 5 insertions(+), 19 deletions(-) rename code/{perpetualpayments => doughnuteconomy}/Makefile (100%) rename code/{perpetualpayments => doughnuteconomy}/bitcoind/Dockerfile (100%) rename code/{perpetualpayments => doughnuteconomy}/bitcoind/bashrc (100%) rename code/{perpetualpayments => doughnuteconomy}/bitcoind/bitcoind-entrypoint.sh (100%) rename code/{perpetualpayments => doughnuteconomy}/bitcoind/bitcoind/bitcoin.conf (100%) rename code/{perpetualpayments => doughnuteconomy}/bitcoind/bitcoind/keys/demo_address.txt (100%) rename code/{perpetualpayments => doughnuteconomy}/bitcoind/bitcoind/keys/demo_mnemonic.txt (100%) rename code/{perpetualpayments => doughnuteconomy}/bitcoind/bitcoind/keys/demo_privkey.txt (100%) rename code/{perpetualpayments => doughnuteconomy}/bitcoind/mine.sh (100%) rename code/{perpetualpayments => doughnuteconomy}/c-lightning/Dockerfile (100%) rename code/{perpetualpayments => doughnuteconomy}/c-lightning/bashrc (100%) rename code/{perpetualpayments => doughnuteconomy}/c-lightning/c-lightning-entrypoint.sh (100%) rename code/{perpetualpayments => doughnuteconomy}/c-lightning/fund-c-lightning.sh (100%) rename code/{perpetualpayments => doughnuteconomy}/c-lightning/lightningd/config (100%) rename code/{perpetualpayments => doughnuteconomy}/c-lightning/logtail.sh (100%) rename code/{perpetualpayments => doughnuteconomy}/c-lightning/wait-for-bitcoind.sh (100%) rename code/{perpetualpayments => doughnuteconomy}/docker-compose.yml (100%) rename code/{perpetualpayments/make-network-payloop.sh => doughnuteconomy/doughnut.sh} (73%) rename code/{perpetualpayments/fund-all-nodes.sh => doughnuteconomy/fund-nodes.sh} (83%) rename code/{perpetualpayments => doughnuteconomy}/make-topology.sh (91%) rename code/{perpetualpayments => doughnuteconomy}/payment-loop.sh (99%) diff --git a/code/perpetualpayments/Makefile b/code/doughnuteconomy/Makefile similarity index 100% rename from code/perpetualpayments/Makefile rename to code/doughnuteconomy/Makefile diff --git a/code/perpetualpayments/bitcoind/Dockerfile b/code/doughnuteconomy/bitcoind/Dockerfile similarity index 100% rename from code/perpetualpayments/bitcoind/Dockerfile rename to code/doughnuteconomy/bitcoind/Dockerfile diff --git a/code/perpetualpayments/bitcoind/bashrc b/code/doughnuteconomy/bitcoind/bashrc similarity index 100% rename from code/perpetualpayments/bitcoind/bashrc rename to code/doughnuteconomy/bitcoind/bashrc diff --git a/code/perpetualpayments/bitcoind/bitcoind-entrypoint.sh b/code/doughnuteconomy/bitcoind/bitcoind-entrypoint.sh similarity index 100% rename from code/perpetualpayments/bitcoind/bitcoind-entrypoint.sh rename to code/doughnuteconomy/bitcoind/bitcoind-entrypoint.sh diff --git a/code/perpetualpayments/bitcoind/bitcoind/bitcoin.conf b/code/doughnuteconomy/bitcoind/bitcoind/bitcoin.conf similarity index 100% rename from code/perpetualpayments/bitcoind/bitcoind/bitcoin.conf rename to code/doughnuteconomy/bitcoind/bitcoind/bitcoin.conf diff --git a/code/perpetualpayments/bitcoind/bitcoind/keys/demo_address.txt b/code/doughnuteconomy/bitcoind/bitcoind/keys/demo_address.txt similarity index 100% rename from code/perpetualpayments/bitcoind/bitcoind/keys/demo_address.txt rename to code/doughnuteconomy/bitcoind/bitcoind/keys/demo_address.txt diff --git a/code/perpetualpayments/bitcoind/bitcoind/keys/demo_mnemonic.txt b/code/doughnuteconomy/bitcoind/bitcoind/keys/demo_mnemonic.txt similarity index 100% rename from code/perpetualpayments/bitcoind/bitcoind/keys/demo_mnemonic.txt rename to code/doughnuteconomy/bitcoind/bitcoind/keys/demo_mnemonic.txt diff --git a/code/perpetualpayments/bitcoind/bitcoind/keys/demo_privkey.txt b/code/doughnuteconomy/bitcoind/bitcoind/keys/demo_privkey.txt similarity index 100% rename from code/perpetualpayments/bitcoind/bitcoind/keys/demo_privkey.txt rename to code/doughnuteconomy/bitcoind/bitcoind/keys/demo_privkey.txt diff --git a/code/perpetualpayments/bitcoind/mine.sh b/code/doughnuteconomy/bitcoind/mine.sh similarity index 100% rename from code/perpetualpayments/bitcoind/mine.sh rename to code/doughnuteconomy/bitcoind/mine.sh diff --git a/code/perpetualpayments/c-lightning/Dockerfile b/code/doughnuteconomy/c-lightning/Dockerfile similarity index 100% rename from code/perpetualpayments/c-lightning/Dockerfile rename to code/doughnuteconomy/c-lightning/Dockerfile diff --git a/code/perpetualpayments/c-lightning/bashrc b/code/doughnuteconomy/c-lightning/bashrc similarity index 100% rename from code/perpetualpayments/c-lightning/bashrc rename to code/doughnuteconomy/c-lightning/bashrc diff --git a/code/perpetualpayments/c-lightning/c-lightning-entrypoint.sh b/code/doughnuteconomy/c-lightning/c-lightning-entrypoint.sh similarity index 100% rename from code/perpetualpayments/c-lightning/c-lightning-entrypoint.sh rename to code/doughnuteconomy/c-lightning/c-lightning-entrypoint.sh diff --git a/code/perpetualpayments/c-lightning/fund-c-lightning.sh b/code/doughnuteconomy/c-lightning/fund-c-lightning.sh similarity index 100% rename from code/perpetualpayments/c-lightning/fund-c-lightning.sh rename to code/doughnuteconomy/c-lightning/fund-c-lightning.sh diff --git a/code/perpetualpayments/c-lightning/lightningd/config b/code/doughnuteconomy/c-lightning/lightningd/config similarity index 100% rename from code/perpetualpayments/c-lightning/lightningd/config rename to code/doughnuteconomy/c-lightning/lightningd/config diff --git a/code/perpetualpayments/c-lightning/logtail.sh b/code/doughnuteconomy/c-lightning/logtail.sh similarity index 100% rename from code/perpetualpayments/c-lightning/logtail.sh rename to code/doughnuteconomy/c-lightning/logtail.sh diff --git a/code/perpetualpayments/c-lightning/wait-for-bitcoind.sh b/code/doughnuteconomy/c-lightning/wait-for-bitcoind.sh similarity index 100% rename from code/perpetualpayments/c-lightning/wait-for-bitcoind.sh rename to code/doughnuteconomy/c-lightning/wait-for-bitcoind.sh diff --git a/code/perpetualpayments/docker-compose.yml b/code/doughnuteconomy/docker-compose.yml similarity index 100% rename from code/perpetualpayments/docker-compose.yml rename to code/doughnuteconomy/docker-compose.yml diff --git a/code/perpetualpayments/make-network-payloop.sh b/code/doughnuteconomy/doughnut.sh similarity index 73% rename from code/perpetualpayments/make-network-payloop.sh rename to code/doughnuteconomy/doughnut.sh index 350e8ec..394a542 100644 --- a/code/perpetualpayments/make-network-payloop.sh +++ b/code/doughnuteconomy/doughnut.sh @@ -1,11 +1,11 @@ #!/bin/bash -#docker-compose up -d && bash make-network-payloop.sh +# docker-compose up -d && bash doughnut.sh echo Wait for network to load for 180 sec sleep 180 echo Funding all nodes -source fund-all-nodes.sh +source fund-nodes.sh sleep 60 echo Making topology source make-topology.sh @@ -13,7 +13,8 @@ sleep 60 echo Entering the payment loop source payment-loop.sh -#docker-compose exec -T Aa lightning-cli +# here for convinience to query the nodes +#docker-compose exec -T Aa lightning-cli #docker-compose exec -T Bb lightning-cli #docker-compose exec -T Cc lightning-cli #docker-compose exec -T Ee lightning-cli diff --git a/code/perpetualpayments/fund-all-nodes.sh b/code/doughnuteconomy/fund-nodes.sh similarity index 83% rename from code/perpetualpayments/fund-all-nodes.sh rename to code/doughnuteconomy/fund-nodes.sh index c82111a..7b7313f 100644 --- a/code/perpetualpayments/fund-all-nodes.sh +++ b/code/doughnuteconomy/fund-nodes.sh @@ -1,12 +1,5 @@ #!/bin/bash -#docker-compose exec -T Aa lightning-cli getinfo -#docker-compose exec -T Bb lightning-cli getinfo -#docker-compose exec -T Cc lightning-cli getinfo -#docker-compose exec -T Ee lightning-cli getinfo -#docker-compose exec -T Dd lightning-cli getinfo -#docker-compose exec -T Ff lightning-cli getinfo - echo getting addresses a=$(docker-compose exec -T Aa bash -c "lightning-cli newaddr | jq -r .bech32") echo $a diff --git a/code/perpetualpayments/make-topology.sh b/code/doughnuteconomy/make-topology.sh similarity index 91% rename from code/perpetualpayments/make-topology.sh rename to code/doughnuteconomy/make-topology.sh index 91bda78..62ed9ae 100644 --- a/code/perpetualpayments/make-topology.sh +++ b/code/doughnuteconomy/make-topology.sh @@ -8,14 +8,6 @@ d_ID=$(docker-compose exec -T Dd bash -c "lightning-cli getinfo | jq -r .id") e_ID=$(docker-compose exec -T Ee bash -c "lightning-cli getinfo | jq -r .id") f_ID=$(docker-compose exec -T Ff bash -c "lightning-cli getinfo | jq -r .id") -# Let's tell everyone what we found! -#echo A ${a_ID} -#echo B ${b_ID} -#echo C ${c_ID} -#echo D ${d_ID} -#echo E ${e_ID} -#echo F ${f_ID} - echo Setting up channels... echo A to B docker-compose exec -T Aa lightning-cli connect ${b_ID}@Bb diff --git a/code/perpetualpayments/payment-loop.sh b/code/doughnuteconomy/payment-loop.sh similarity index 99% rename from code/perpetualpayments/payment-loop.sh rename to code/doughnuteconomy/payment-loop.sh index 78fd158..c21785c 100644 --- a/code/perpetualpayments/payment-loop.sh +++ b/code/doughnuteconomy/payment-loop.sh @@ -4,7 +4,7 @@ echo pay in a loop start=$(date +"%T") -for i in {1..2} +for i in {1..20} do echo A pays B INV=$(docker-compose exec -T Bb bash -c "lightning-cli invoice 10000sat inva{$i} desc | jq -r .bolt11") From 32b3480e4204f2a81cd35f778f7c2b8c4d71ff8f Mon Sep 17 00:00:00 2001 From: keblek <68111648+keblek@users.noreply.github.com> Date: Thu, 18 Feb 2021 12:19:12 +0100 Subject: [PATCH 6/7] Deleting doughnut economy --- code/doughnuteconomy/Makefile | 16 ---- code/doughnuteconomy/bitcoind/Dockerfile | 46 --------- code/doughnuteconomy/bitcoind/bashrc | 5 - .../bitcoind/bitcoind-entrypoint.sh | 23 ----- .../bitcoind/bitcoind/bitcoin.conf | 22 ----- .../bitcoind/bitcoind/keys/demo_address.txt | 1 - .../bitcoind/bitcoind/keys/demo_mnemonic.txt | 1 - .../bitcoind/bitcoind/keys/demo_privkey.txt | 1 - code/doughnuteconomy/bitcoind/mine.sh | 20 ---- code/doughnuteconomy/c-lightning/Dockerfile | 33 ------- code/doughnuteconomy/c-lightning/bashrc | 4 - .../c-lightning/c-lightning-entrypoint.sh | 17 ---- .../c-lightning/fund-c-lightning.sh | 22 ----- .../c-lightning/lightningd/config | 9 -- code/doughnuteconomy/c-lightning/logtail.sh | 5 - .../c-lightning/wait-for-bitcoind.sh | 16 ---- code/doughnuteconomy/docker-compose.yml | 95 ------------------- code/doughnuteconomy/doughnut.sh | 24 ----- code/doughnuteconomy/fund-nodes.sh | 29 ------ code/doughnuteconomy/make-topology.sh | 30 ------ code/doughnuteconomy/payment-loop.sh | 37 -------- 21 files changed, 456 deletions(-) delete mode 100644 code/doughnuteconomy/Makefile delete mode 100644 code/doughnuteconomy/bitcoind/Dockerfile delete mode 100644 code/doughnuteconomy/bitcoind/bashrc delete mode 100644 code/doughnuteconomy/bitcoind/bitcoind-entrypoint.sh delete mode 100644 code/doughnuteconomy/bitcoind/bitcoind/bitcoin.conf delete mode 100644 code/doughnuteconomy/bitcoind/bitcoind/keys/demo_address.txt delete mode 100644 code/doughnuteconomy/bitcoind/bitcoind/keys/demo_mnemonic.txt delete mode 100644 code/doughnuteconomy/bitcoind/bitcoind/keys/demo_privkey.txt delete mode 100755 code/doughnuteconomy/bitcoind/mine.sh delete mode 100644 code/doughnuteconomy/c-lightning/Dockerfile delete mode 100644 code/doughnuteconomy/c-lightning/bashrc delete mode 100644 code/doughnuteconomy/c-lightning/c-lightning-entrypoint.sh delete mode 100644 code/doughnuteconomy/c-lightning/fund-c-lightning.sh delete mode 100644 code/doughnuteconomy/c-lightning/lightningd/config delete mode 100644 code/doughnuteconomy/c-lightning/logtail.sh delete mode 100644 code/doughnuteconomy/c-lightning/wait-for-bitcoind.sh delete mode 100644 code/doughnuteconomy/docker-compose.yml delete mode 100644 code/doughnuteconomy/doughnut.sh delete mode 100644 code/doughnuteconomy/fund-nodes.sh delete mode 100644 code/doughnuteconomy/make-topology.sh delete mode 100644 code/doughnuteconomy/payment-loop.sh diff --git a/code/doughnuteconomy/Makefile b/code/doughnuteconomy/Makefile deleted file mode 100644 index ead00f7..0000000 --- a/code/doughnuteconomy/Makefile +++ /dev/null @@ -1,16 +0,0 @@ - -REGISTRY=docker.com -NAME=lnbook -CONTAINERS=bitcoind c-lightning - -all: build-all push-all - -build-all: - for container in ${CONTAINERS}; do \ - docker build -t ${NAME}/$$container $$container -f $$container/Dockerfile; \ - done - -push-all: - for container in ${CONTAINERS}; do \ - docker push ${NAME}/$$container; \ - done diff --git a/code/doughnuteconomy/bitcoind/Dockerfile b/code/doughnuteconomy/bitcoind/Dockerfile deleted file mode 100644 index b2555b6..0000000 --- a/code/doughnuteconomy/bitcoind/Dockerfile +++ /dev/null @@ -1,46 +0,0 @@ -FROM ubuntu:20.04 AS bitcoind-base - -RUN apt update && apt install -yqq \ - curl gosu jq bash-completion - -ENV BITCOIND_VERSION 0.21.0 -# Install binaries for Bitcoin Core -ADD https://bitcoincore.org/bin/bitcoin-core-${BITCOIND_VERSION}/bitcoin-${BITCOIND_VERSION}-x86_64-linux-gnu.tar.gz /usr/local -RUN cd /usr/local/ \ - && tar -zxf bitcoin-${BITCOIND_VERSION}-x86_64-linux-gnu.tar.gz \ - && cd bitcoin-${BITCOIND_VERSION} \ - && install bin/* /usr/local/bin \ - && install include/* /usr/local/include \ - && install -v lib/* /usr/local/lib - -ENV GH_URL https://raw.githubusercontent.com/bitcoin/bitcoin/master/ -ENV BC /usr/share/bash-completion/completions/ -ADD $GH_URL/contrib/bitcoin-cli.bash-completion $BC/bitcoin-cli -ADD $GH_URL/contrib/bitcoind.bash-completion $BC/bitcoind -ADD $GH_URL/contrib/bitcoin-tx.bash-completion $BC/bitcoin-tx - -FROM bitcoind-base AS bitcoind - -ADD bitcoind /bitcoind -RUN ln -s /bitcoind /root/. - -ADD bashrc /root/.bashrc -ADD bitcoind-entrypoint.sh /usr/local/bin -RUN chmod +x /usr/local/bin/bitcoind-entrypoint.sh -ADD mine.sh /usr/local/bin -RUN chmod +x /usr/local/bin/mine.sh - -# bitcoind P2P -EXPOSE 18444/tcp -# bitcoind regtest RPC -EXPOSE 18443/tcp -# zmqpubrawblock -EXPOSE 12005/tcp -# zmqpubrawtx -EXPOSE 12006/tcp - -WORKDIR /bitcoind -ENTRYPOINT ["/usr/local/bin/bitcoind-entrypoint.sh"] - -# Mine new block every 10 seconds -CMD ["/usr/local/bin/mine.sh"] diff --git a/code/doughnuteconomy/bitcoind/bashrc b/code/doughnuteconomy/bitcoind/bashrc deleted file mode 100644 index 5f4b902..0000000 --- a/code/doughnuteconomy/bitcoind/bashrc +++ /dev/null @@ -1,5 +0,0 @@ -# Use bash-completion, if available -alias bitcoin-cli="bitcoin-cli -datadir=/bitcoind" - -[[ $PS1 && -f /usr/share/bash-completion/bash_completion ]] && \ - . /usr/share/bash-completion/bash_completion diff --git a/code/doughnuteconomy/bitcoind/bitcoind-entrypoint.sh b/code/doughnuteconomy/bitcoind/bitcoind-entrypoint.sh deleted file mode 100644 index 167ef66..0000000 --- a/code/doughnuteconomy/bitcoind/bitcoind-entrypoint.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -set -Eeuo pipefail - -echo Starting bitcoind... -bitcoind -datadir=/bitcoind -daemon -until bitcoin-cli -datadir=/bitcoind getblockchaininfo > /dev/null 2>&1 -do - sleep 1 -done -echo bitcoind started -export address=`cat /bitcoind/keys/demo_address.txt` -export privkey=`cat /bitcoind/keys/demo_privkey.txt` -echo "================================================" -echo "Importing demo private key" -echo "Bitcoin address: " ${address} -echo "Private key: " ${privkey} -echo "================================================" -bitcoin-cli -datadir=/bitcoind createwallet regtest -bitcoin-cli -datadir=/bitcoind importprivkey $privkey - -# Executing CMD -echo "$@" -exec "$@" diff --git a/code/doughnuteconomy/bitcoind/bitcoind/bitcoin.conf b/code/doughnuteconomy/bitcoind/bitcoind/bitcoin.conf deleted file mode 100644 index 36d6903..0000000 --- a/code/doughnuteconomy/bitcoind/bitcoind/bitcoin.conf +++ /dev/null @@ -1,22 +0,0 @@ -regtest=1 -server=1 -debuglogfile=debug.log -debug=1 -txindex=1 -printtoconsole=0 - -[regtest] -fallbackfee=0.000001 -port=18444 -noconnect=1 -dnsseed=0 -dns=0 -upnp=0 -onlynet=ipv4 -rpcport=18443 -rpcbind=0.0.0.0 -rpcallowip=0.0.0.0/0 -rpcuser=regtest -rpcpassword=regtest -zmqpubrawblock=tcp://0.0.0.0:12005 -zmqpubrawtx=tcp://0.0.0.0:12006 diff --git a/code/doughnuteconomy/bitcoind/bitcoind/keys/demo_address.txt b/code/doughnuteconomy/bitcoind/bitcoind/keys/demo_address.txt deleted file mode 100644 index ae62ea3..0000000 --- a/code/doughnuteconomy/bitcoind/bitcoind/keys/demo_address.txt +++ /dev/null @@ -1 +0,0 @@ -2NBKgwSWY5qEmfN2Br4WtMDGuamjpuUc5q1 diff --git a/code/doughnuteconomy/bitcoind/bitcoind/keys/demo_mnemonic.txt b/code/doughnuteconomy/bitcoind/bitcoind/keys/demo_mnemonic.txt deleted file mode 100644 index 37f503c..0000000 --- a/code/doughnuteconomy/bitcoind/bitcoind/keys/demo_mnemonic.txt +++ /dev/null @@ -1 +0,0 @@ -electric flash rain cloud umbrella energy charge ozone air thunder crack wet diff --git a/code/doughnuteconomy/bitcoind/bitcoind/keys/demo_privkey.txt b/code/doughnuteconomy/bitcoind/bitcoind/keys/demo_privkey.txt deleted file mode 100644 index 6acc8df..0000000 --- a/code/doughnuteconomy/bitcoind/bitcoind/keys/demo_privkey.txt +++ /dev/null @@ -1 +0,0 @@ -cSaejkcWwU25jMweWEewRSsrVQq2FGTij1xjXv4x1XvxVRF1ZCr3 diff --git a/code/doughnuteconomy/bitcoind/mine.sh b/code/doughnuteconomy/bitcoind/mine.sh deleted file mode 100755 index 5e08f57..0000000 --- a/code/doughnuteconomy/bitcoind/mine.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -set -Eeuo pipefail - -export address=`cat /bitcoind/keys/demo_address.txt` -export privkey=`cat /bitcoind/keys/demo_privkey.txt` -echo "================================================" -echo "Bitcoin address: " ${address} -echo "Private key: " ${privkey} -echo "Balance:" `bitcoin-cli -datadir=/bitcoind getbalance` -echo "================================================" -echo "Mining 101 blocks to unlock some bitcoin" -bitcoin-cli -datadir=/bitcoind generatetoaddress 101 $address -echo "Mining 1 block every 10 seconds" -while sleep 10; do \ - bitcoin-cli -datadir=/bitcoind generatetoaddress 1 $address; \ - echo "Balance:" `bitcoin-cli -datadir=/bitcoind getbalance`; \ -done - -# If loop is interrupted, stop bitcoind -bitcoin-cli -datadir=/bitcoind stop diff --git a/code/doughnuteconomy/c-lightning/Dockerfile b/code/doughnuteconomy/c-lightning/Dockerfile deleted file mode 100644 index f3df06e..0000000 --- a/code/doughnuteconomy/c-lightning/Dockerfile +++ /dev/null @@ -1,33 +0,0 @@ -FROM lnbook/bitcoind AS c-lightning-base - -# Install software-properties-common to add apt repositories -RUN apt update && apt install -yqq \ - software-properties-common - -# c-lightning -ENV C_LIGHTNING_VER 0.9.3~20210120202101201901~ubuntu20.04.1 -RUN add-apt-repository -u ppa:lightningnetwork/ppa -RUN apt-get install -yqq \ - lightningd=${C_LIGHTNING_VER} - -ADD https://raw.githubusercontent.com/ElementsProject/lightning/master/contrib/lightning-cli.bash-completion /usr/share/bash-completion/completions/lightning-cli - -FROM c-lightning-base AS c-lightning-run - -ADD lightningd /lightningd -WORKDIR /lightningd -RUN ln -s /lightningd /root/.lightning - -ADD bashrc /root/.bashrc -ADD c-lightning-entrypoint.sh /usr/local/bin -RUN chmod +x /usr/local/bin/c-lightning-entrypoint.sh -ADD logtail.sh /usr/local/bin -RUN chmod +x /usr/local/bin/logtail.sh -ADD wait-for-bitcoind.sh /usr/local/bin -RUN chmod +x /usr/local/bin/wait-for-bitcoind.sh - -EXPOSE 9735 9835 -ENTRYPOINT ["/usr/local/bin/c-lightning-entrypoint.sh"] - -# Show logs from beginning and keep following -CMD ["/usr/local/bin/logtail.sh"] diff --git a/code/doughnuteconomy/c-lightning/bashrc b/code/doughnuteconomy/c-lightning/bashrc deleted file mode 100644 index e0cd922..0000000 --- a/code/doughnuteconomy/c-lightning/bashrc +++ /dev/null @@ -1,4 +0,0 @@ -alias lightning-cli="lightning-cli --lightning-dir=/lightningd" - -[[ $PS1 && -f /usr/share/bash-completion/bash_completion ]] && \ - . /usr/share/bash-completion/bash_completion diff --git a/code/doughnuteconomy/c-lightning/c-lightning-entrypoint.sh b/code/doughnuteconomy/c-lightning/c-lightning-entrypoint.sh deleted file mode 100644 index 4724a89..0000000 --- a/code/doughnuteconomy/c-lightning/c-lightning-entrypoint.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -set -Eeuo pipefail - -source /usr/local/bin/wait-for-bitcoind.sh - -echo Starting c-lightning... -lightningd --lightning-dir=/lightningd --daemon - -until lightning-cli --lightning-dir=/lightningd getinfo > /dev/null 2>&1 -do - sleep 1 -done - -echo "Startup complete" - -echo "$@" -exec "$@" diff --git a/code/doughnuteconomy/c-lightning/fund-c-lightning.sh b/code/doughnuteconomy/c-lightning/fund-c-lightning.sh deleted file mode 100644 index 11f536f..0000000 --- a/code/doughnuteconomy/c-lightning/fund-c-lightning.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -# Generate a new receiving address for LND wallet -address=$(lightning-cli --lightning-dir=/lightningd newaddr | jq .address) - -# Ask Bitcoin Core to send 10 BTC to the address, using JSON-RPC call -curl --user regtest:regtest \ - -H 'content-type: text/plain;' \ - http://bitcoind:18443/ \ - --data-binary @- < /dev/null 2>&1 -do - echo -n "." - sleep 1 -done - -echo Waiting for bitcoind to mine blocks... -until bitcoin-cli -rpcconnect=bitcoind -rpcport=18443 -rpcuser=regtest -rpcpassword=regtest getbalance | jq -e ". > 0" > /dev/null 2>&1 -do - echo -n "." - sleep 1 -done diff --git a/code/doughnuteconomy/docker-compose.yml b/code/doughnuteconomy/docker-compose.yml deleted file mode 100644 index 27de45d..0000000 --- a/code/doughnuteconomy/docker-compose.yml +++ /dev/null @@ -1,95 +0,0 @@ -version: "3.3" -networks: - lnnet: - -services: - bitcoind: - container_name: bitcoind - build: - context: bitcoind - image: lnbook/bitcoind:latest - networks: - - lnnet - expose: - - "18443" - - "12005" - - "12006" - restart: always - - Aa: - container_name: Aa - build: - context: c-lightning - image: lnbook/c-lightning:latest - networks: - - lnnet - expose: - - "9735" - restart: always - depends_on: - - bitcoind - - Bb: - container_name: Bb - build: - context: c-lightning - image: lnbook/c-lightning:latest - networks: - - lnnet - expose: - - "9735" - restart: always - depends_on: - - bitcoind - - Cc: - container_name: Cc - build: - context: c-lightning - image: lnbook/c-lightning:latest - networks: - - lnnet - expose: - - "9735" - restart: always - depends_on: - - bitcoind - - Dd: - container_name: Dd - build: - context: c-lightning - image: lnbook/c-lightning:latest - networks: - - lnnet - expose: - - "9735" - restart: always - depends_on: - - bitcoind - - Ee: - container_name: Ee - build: - context: c-lightning - image: lnbook/c-lightning:latest - networks: - - lnnet - expose: - - "9735" - restart: always - depends_on: - - bitcoind - - Ff: - container_name: Ff - build: - context: c-lightning - image: lnbook/c-lightning:latest - networks: - - lnnet - expose: - - "9735" - restart: always - depends_on: - - bitcoind diff --git a/code/doughnuteconomy/doughnut.sh b/code/doughnuteconomy/doughnut.sh deleted file mode 100644 index 394a542..0000000 --- a/code/doughnuteconomy/doughnut.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -# docker-compose up -d && bash doughnut.sh -echo Wait for network to load for 180 sec -sleep 180 - -echo Funding all nodes -source fund-nodes.sh -sleep 60 -echo Making topology -source make-topology.sh -sleep 60 -echo Entering the payment loop -source payment-loop.sh - -# here for convinience to query the nodes -#docker-compose exec -T Aa lightning-cli -#docker-compose exec -T Bb lightning-cli -#docker-compose exec -T Cc lightning-cli -#docker-compose exec -T Ee lightning-cli -#docker-compose exec -T Dd lightning-cli -#docker-compose exec -T Ff lightning-cli - -exit 0 diff --git a/code/doughnuteconomy/fund-nodes.sh b/code/doughnuteconomy/fund-nodes.sh deleted file mode 100644 index 7b7313f..0000000 --- a/code/doughnuteconomy/fund-nodes.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash - -echo getting addresses -a=$(docker-compose exec -T Aa bash -c "lightning-cli newaddr | jq -r .bech32") -echo $a -b=$(docker-compose exec -T Bb bash -c "lightning-cli newaddr | jq -r .bech32") -echo $b -c=$(docker-compose exec -T Cc bash -c "lightning-cli newaddr | jq -r .bech32") -echo $c -d=$(docker-compose exec -T Dd bash -c "lightning-cli newaddr | jq -r .bech32") -echo $d -e=$(docker-compose exec -T Ee bash -c "lightning-cli newaddr | jq -r .bech32") -echo $e -f=$(docker-compose exec -T Ff bash -c "lightning-cli newaddr | jq -r .bech32") -echo $f - -echo funding wallets -ba=$(docker-compose exec -T bitcoind bash -c "bitcoin-cli -regtest -rpcport=18443 -rpcuser=regtest -rpcpassword=regtest sendtoaddress $a 10") -echo $ba -bb=$(docker-compose exec -T bitcoind bash -c "bitcoin-cli -regtest -rpcport=18443 -rpcuser=regtest -rpcpassword=regtest sendtoaddress $b 10") -echo $bb -bc=$(docker-compose exec -T bitcoind bash -c "bitcoin-cli -regtest -rpcport=18443 -rpcuser=regtest -rpcpassword=regtest sendtoaddress $c 10") -echo $bc -bd=$(docker-compose exec -T bitcoind bash -c "bitcoin-cli -regtest -rpcport=18443 -rpcuser=regtest -rpcpassword=regtest sendtoaddress $d 10") -echo $bd -be=$(docker-compose exec -T bitcoind bash -c "bitcoin-cli -regtest -rpcport=18443 -rpcuser=regtest -rpcpassword=regtest sendtoaddress $e 10") -echo $be -bf=$(docker-compose exec -T bitcoind bash -c "bitcoin-cli -regtest -rpcport=18443 -rpcuser=regtest -rpcpassword=regtest sendtoaddress $f 10") -echo $bf diff --git a/code/doughnuteconomy/make-topology.sh b/code/doughnuteconomy/make-topology.sh deleted file mode 100644 index 62ed9ae..0000000 --- a/code/doughnuteconomy/make-topology.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -echo Getting node IDs -a_ID=$(docker-compose exec -T Aa bash -c "lightning-cli getinfo | jq -r .id") -b_ID=$(docker-compose exec -T Bb bash -c "lightning-cli getinfo | jq -r .id") -c_ID=$(docker-compose exec -T Cc bash -c "lightning-cli getinfo | jq -r .id") -d_ID=$(docker-compose exec -T Dd bash -c "lightning-cli getinfo | jq -r .id") -e_ID=$(docker-compose exec -T Ee bash -c "lightning-cli getinfo | jq -r .id") -f_ID=$(docker-compose exec -T Ff bash -c "lightning-cli getinfo | jq -r .id") - -echo Setting up channels... -echo A to B -docker-compose exec -T Aa lightning-cli connect ${b_ID}@Bb -docker-compose exec -T Aa lightning-cli -k fundchannel id=${b_ID} amount=1000000sat minconf=0 -echo B to C -docker-compose exec -T Bb lightning-cli connect ${c_ID}@Cc -docker-compose exec -T Bb lightning-cli -k fundchannel id=${c_ID} amount=1000000sat minconf=0 -echo C to D -docker-compose exec -T Cc lightning-cli connect ${d_ID}@Dd -docker-compose exec -T Cc lightning-cli -k fundchannel id=${d_ID} amount=1000000sat minconf=0 -echo D to E -docker-compose exec -T Dd lightning-cli connect ${e_ID}@Ee -docker-compose exec -T Dd lightning-cli -k fundchannel id=${e_ID} amount=1000000sat minconf=0 -echo E to F -docker-compose exec -T Ee lightning-cli connect ${f_ID}@Ff -docker-compose exec -T Ee lightning-cli -k fundchannel id=${f_ID} amount=1000000sat minconf=0 -echo F to A -docker-compose exec -T Ff lightning-cli connect ${a_ID}@Aa -docker-compose exec -T Ff lightning-cli -k fundchannel id=${a_ID} amount=1000000sat minconf=0 - diff --git a/code/doughnuteconomy/payment-loop.sh b/code/doughnuteconomy/payment-loop.sh deleted file mode 100644 index c21785c..0000000 --- a/code/doughnuteconomy/payment-loop.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash - -echo pay in a loop - -start=$(date +"%T") - -for i in {1..20} -do - echo A pays B - INV=$(docker-compose exec -T Bb bash -c "lightning-cli invoice 10000sat inva{$i} desc | jq -r .bolt11") - docker-compose exec -T Aa bash -c "lightning-cli pay $INV" - - echo B pays C - INV=$(docker-compose exec -T Cc bash -c "lightning-cli invoice 10000sat invb{$i} desc | jq -r .bolt11") - docker-compose exec -T Bb bash -c "lightning-cli pay $INV" - - echo C pays D - INV=$(docker-compose exec -T Dd bash -c "lightning-cli invoice 10000sat invc{$i} desc | jq -r .bolt11") - docker-compose exec -T Cc bash -c "lightning-cli pay $INV" - - echo D pays E - INV=$(docker-compose exec -T Ee bash -c "lightning-cli invoice 10000sat invd{$i} desc | jq -r .bolt11") - docker-compose exec -T Dd bash -c "lightning-cli pay $INV" - - echo E pays F - INV=$(docker-compose exec -T Ff bash -c "lightning-cli invoice 10000sat inve{$i} desc | jq -r .bolt11") - docker-compose exec -T Ee bash -c "lightning-cli pay $INV" - - echo F pays A - INV=$(docker-compose exec -T Aa bash -c "lightning-cli invoice 10000sat invf{$i} desc | jq -r .bolt11") - docker-compose exec -T Ff bash -c "lightning-cli pay $INV" -done -stop=$(date +"%T") - -echo time to finish -echo start $start -echo stop $stop From 8c4923a01cfbf209ac853477ae5d60a07a3172dc Mon Sep 17 00:00:00 2001 From: keblek <68111648+keblek@users.noreply.github.com> Date: Sun, 21 Feb 2021 21:30:02 +0100 Subject: [PATCH 7/7] Changed comment, wrong implementation Refers to LND, should be c-lightning --- code/docker/c-lightning/fund-c-lightning.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/docker/c-lightning/fund-c-lightning.sh b/code/docker/c-lightning/fund-c-lightning.sh index a14fe61..3ba5082 100644 --- a/code/docker/c-lightning/fund-c-lightning.sh +++ b/code/docker/c-lightning/fund-c-lightning.sh @@ -1,7 +1,7 @@ #!/bin/bash set -Eeuo pipefail -# Generate a new receiving address for LND wallet +# Generate a new receiving address for c-lightning wallet address=$(lightning-cli --lightning-dir=/lightningd --network regtest newaddr | jq .address) # Ask Bitcoin Core to send 10 BTC to the address, using JSON-RPC call