<p>Yes this is possible and (at least with clightning) very easy to do. I always use <a href="https://github.com/shesek/spark-wallet/blob/master/doc/dev-regtest-env.md" rel="nofollow noreferrer">this script by Nadav Ivgi</a> from his spark wallet. The key part is this : (MIT license by Nadav Ivgi) </p>

<pre><code>$ mkdir -p /tmp/spark-env/{btc,ln1,ln2}

$ bitcoind --regtest --datadir=/tmp/spark-env/btc --printtoconsole
$ lightningd --network regtest --lightning-dir /tmp/spark-env/ln1 --bitcoin-datadir /tmp/spark-env/btc --addr 127.0.0.1:9600
$ lightningd --network regtest --lightning-dir /tmp/spark-env/ln2 --bitcoin-datadir /tmp/spark-env/btc --addr 127.0.0.1:9601

$ alias btc='bitcoin-cli --regtest --datadir=/tmp/spark-env/btc' \
        ln1='lightning-cli --lightning-dir /tmp/spark-env/ln1' \
        ln2='lightning-cli --lightning-dir /tmp/spark-env/ln2'

$ btc generate 101 &amp;&amp; btc sendtoaddress $(ln1 newaddr | jq -r .address) 5 &amp;&amp; btc generate 1

# wait for onchain funds to show up on `ln1 listfunds` (updated every 30s)

$ ln1 connect $(ln2 getinfo | jq -r .id) 127.0.0.1 9601 &amp;&amp; \
  ln1 fundchannel $(ln2 getinfo | jq -r .id) 16777215 1100perkb &amp;&amp; btc generate 1

</code></pre>

<p>If you use docker you can even spin up Nadavs docker image with:</p>

<pre><code>$ docker run -e NETWORK=regtest -e API_TOKEN=1234 -p 9112:9112 shesek/lightning-charge
</code></pre>

<p>but if you want more lightning nodes fired up that already form a network you can use <a href="https://github.com/cdecker/lnet" rel="nofollow noreferrer">lnet by Christian Decker</a>. With that script you can provide a weighed graph and get the lightning nodes as the graph defines. </p>

CC BY-SA 4.0
2019-05-10T13:23:56.330Z
Is lnet supposed to be used only with c-lightning?
Sergei Tikhomirov
CC BY-SA 4.0
2019-05-10T13:55:32.790Z
I think so. But I think it would be possible to extend to other lightning implementations (: maybe you find something in the test cases of each implementation. I think I remember that a fair fraction of lnet code comes from clightning test cases.
Rene Pickhardt
CC BY-SA 4.0
2019-05-10T20:45:40.903Z
I did some experiments with lnd in regtest mode. Just normally start bitcoind with zmq in regtest. Put the zmq connection and lnd chain mode to regtest. I will post an in-depth answer with exact configuration and commands later
sanket1729
CC BY-SA 4.0
2019-05-10T13:06:50.403Z
2019-05-12T11:57:41.913Z
2019-05-12T11:57:41.913Z
Rene Pickhardt
<p>I want to do some Lightning experiments, but want to avoid the burden of synchronizing the blockchain (even testnet). Can I experiment with Lightning using regtest? Is there a manual for setting it up?</p>

<lightning-network><regtest><core-lightning>
Can I test Lightning on Bitcoin regtest?
Sergei Tikhomirov
# Can I test Lightning on Bitcoin regtest?

(Asked by: username_0 on 2019-05-10)

I want to do some Lightning experiments, but want to avoid the burden of synchronizing the blockchain (even testnet). Can I experiment with Lightning using regtest? Is there a manual for setting it up?

**Tags:** lightning-network, regtest, core-lightning


---

## 1 answers

### Answer by username_1 on 2019-05-10. Score: 2 | Accepted answer

Yes this is possible and (at least with clightning) very easy to do. I always use [this script by Nadav Ivgi](https://github.com/shesek/spark-wallet/blob/master/doc/dev-regtest-env.md) from his spark wallet. The key part is this : (MIT license by Nadav Ivgi)

```
$ mkdir -p /tmp/spark-env/{btc,ln1,ln2}

$ bitcoind --regtest --datadir=/tmp/spark-env/btc --printtoconsole
$ lightningd --network regtest --lightning-dir /tmp/spark-env/ln1 --bitcoin-datadir /tmp/spark-env/btc --addr 127.0.0.1:9600
$ lightningd --network regtest --lightning-dir /tmp/spark-env/ln2 --bitcoin-datadir /tmp/spark-env/btc --addr 127.0.0.1:9601

$ alias btc='bitcoin-cli --regtest --datadir=/tmp/spark-env/btc' \
        ln1='lightning-cli --lightning-dir /tmp/spark-env/ln1' \
        ln2='lightning-cli --lightning-dir /tmp/spark-env/ln2'

$ btc generate 101 && btc sendtoaddress $(ln1 newaddr | jq -r .address) 5 && btc generate 1

# wait for onchain funds to show up on `ln1 listfunds` (updated every 30s)

$ ln1 connect $(ln2 getinfo | jq -r .id) 127.0.0.1 9601 && \
  ln1 fundchannel $(ln2 getinfo | jq -r .id) 16777215 1100perkb && btc generate 1

```

If you use docker you can even spin up Nadavs docker image with:

```
$ docker run -e NETWORK=regtest -e API_TOKEN=1234 -p 9112:9112 shesek/lightning-charge

```

but if you want more lightning nodes fired up that already form a network you can use [lnet by Christian Decker](https://github.com/cdecker/lnet). With that script you can provide a weighed graph and get the lightning nodes as the graph defines.

> **Comments:**
> **username_0**: Is lnet supposed to be used only with c-lightning?  
> **username_1**: I think so. But I think it would be possible to extend to other lightning implementations (: maybe you find something in the test cases of each implementation. I think I remember that a fair fraction of lnet code comes from clightning test cases.  
> **username_2**: I did some experiments with lnd in regtest mode. Just normally start bitcoind with zmq in regtest. Put the zmq connection and lnd chain mode to regtest. I will post an in-depth answer with exact configuration and commands later  

---

