<p>Yes...</p>

<p>... But it is going to be a lot of work. </p>

<p>First you should look at <a href="https://github.com/bitcoin/bips/blob/master/bip-0199.mediawiki" rel="nofollow noreferrer">BIP 199 which defines htlc scripts</a>. However that alone will only tell you how to create a htlc output. </p>

<p>But with the transaction itself it is not done. You need to use the right channel state and keys so you could read BOLT 02, 03 and 05 to learn about the peer protocol and messages you need to exchange with your channel partner (for such you will actually also need  BOLT 08 and 01 covering setting up a transport session and the message format), the key derivation and the exact onchain specs for htlc output and witeness  scripts. You will find all the BOLTs at <a href="https://github.com/lightningnetwork/lightning-rfc?files=1" rel="nofollow noreferrer">https://github.com/lightningnetwork/lightning-rfc?files=1</a></p>

<p>All of this can be done in regtest. If you want to use a regular lightning implementation you can also run them in regtest mode by changing the corresponding entry in the config file. </p>

CC BY-SA 4.0
2019-05-21T13:31:01.580Z
2019-05-21T13:31:01.580Z
Rene Pickhardt
<p>Is there any way to implement HTLC manually for locking funds in the channels in lightning network for a period of time (by setting intervals) and releasing the funds after the time lock expired using bitcoin regtest mode?</p>

<lightning-network><regtest><node.js><hash-time-locked-contract>
Implement HTLC manually by writing scripts
user95615
# Implement HTLC manually by writing scripts

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

Is there any way to implement HTLC manually for locking funds in the channels in lightning network for a period of time (by setting intervals) and releasing the funds after the time lock expired using bitcoin regtest mode?

**Tags:** lightning-network, regtest, node.js, hash-time-locked-contract


---

## 1 answers

### Answer by username_1 on 2019-05-21. Score: 1

Yes...

... But it is going to be a lot of work.

First you should look at [BIP 199 which defines htlc scripts](https://github.com/bitcoin/bips/blob/master/bip-0199.mediawiki). However that alone will only tell you how to create a htlc output.

But with the transaction itself it is not done. You need to use the right channel state and keys so you could read BOLT 02, 03 and 05 to learn about the peer protocol and messages you need to exchange with your channel partner (for such you will actually also need BOLT 08 and 01 covering setting up a transport session and the message format), the key derivation and the exact onchain specs for htlc output and witeness scripts. You will find all the BOLTs at <https://github.com/lightningnetwork/lightning-rfc?files=1>

All of this can be done in regtest. If you want to use a regular lightning implementation you can also run them in regtest mode by changing the corresponding entry in the config file.


---

