<p>I am trying to create a htlc smart contract manually by writing a script and  finding the hex using the btcc compiler. Now node A has to create a transaction using that hex and lock money in that p2sh address for upto 150 blocks. If node B can provide the secret value before 150 blocks then he can claim the coins and if not the it will go back to node A. I am new to this concept and where ever i read about creating transactions they are explaining in a theoretical way and I could not understand what to do the redeem script hex and how to lock money and how will node B claim it before 150 blocks and how will the raw transaction created by node A will be accessible to node B. Can you please give a reference or steps to follow to understand and implement it? </p>

<p>Which documentation should i refer for doing it and what commands should be used and how it should be used?</p>

<p>How to create the p2sh address. And another problem i am facing is that i am getting different hash160 everytime in different website. Not sure which one is accurate. Please guide me.</p>

<p>P.S:  I am running bitcoin in regtest mode.</p>

CC BY-SA 4.0
2019-06-28T09:12:15.323Z
Are you looking for a script that you can use or Bitcoin-core commands to create such a transaction?
Ugam Kamat
CC BY-SA 4.0
2019-06-28T09:22:01.640Z
commands to create such transaction
prajna
CC BY-SA 4.0
2019-06-28T09:27:25.590Z
I have created the redeem script hex , now i don't know what to do with that.
prajna
CC BY-SA 4.0
2019-06-28T09:38:55.620Z
Check @pieterwuille answer over here: https://bitcoin.stackexchange.com/questions/80902/transaction-still-unspendable-with-cltv. Bitcoin Core by default does not support signing transactions with CLTV scripts
Ugam Kamat
CC BY-SA 4.0
2019-06-28T10:53:24.277Z
I want to know how to create a transaction and how to sign, send and claim it step by step and what are the required fields for doing that. And which privkey should be used and which address should be used. later when the recipient has to claim, then where should he produce the preimage to claim the money.
prajna
CC BY-SA 4.0
2019-06-29T17:34:51.830Z
sending a transaction to that htlc script is simple. Just use the standard Bitcoin core commands to send it to a P2SH address. However, it is while spending such script that issue arises in Bitcoin Core as it does not support dog ing transactions with CLTV scripts.
Ugam Kamat
CC BY-SA 4.0
2019-07-08T10:33:31.383Z
Which commands do I use. How to put the condition. I mean where? Where should i put the locking and unlocking script , how to spend it. Suppose we don't focus on the cltv scripts and if it is a basic script,  What do I do with it. How to get a p2sh from   the redeem script and how to proceed.
prajna
<bitcoind><script><raw-transaction>
HTLC in blockchain regtest mode by creating transactions manually
prajna
# HTLC in blockchain regtest mode by creating transactions manually

(Asked by: username_0 on 2019-06-28)

I am trying to create a htlc smart contract manually by writing a script and finding the hex using the btcc compiler. Now node A has to create a transaction using that hex and lock money in that p2sh address for upto 150 blocks. If node B can provide the secret value before 150 blocks then he can claim the coins and if not the it will go back to node A. I am new to this concept and where ever i read about creating transactions they are explaining in a theoretical way and I could not understand what to do the redeem script hex and how to lock money and how will node B claim it before 150 blocks and how will the raw transaction created by node A will be accessible to node B. Can you please give a reference or steps to follow to understand and implement it?

Which documentation should i refer for doing it and what commands should be used and how it should be used?

How to create the p2sh address. And another problem i am facing is that i am getting different hash160 everytime in different website. Not sure which one is accurate. Please guide me.

P.S: I am running bitcoin in regtest mode.

**Tags:** bitcoind, script, raw-transaction

> **Comments:**
> **username_1**: Are you looking for a script that you can use or Bitcoin-core commands to create such a transaction?  
> **username_0**: commands to create such transaction  
> **username_0**: I have created the redeem script hex , now i don't know what to do with that.  
> **username_1**: Check @pieterwuille answer over here: https://bitcoin.stackexchange.com/questions/80902/transaction-still-unspendable-with-cltv. Bitcoin Core by default does not support signing transactions with CLTV scripts  
> **username_0**: I want to know how to create a transaction and how to sign, send and claim it step by step and what are the required fields for doing that. And which privkey should be used and which address should be used. later when the recipient has to claim, then where should he produce the preimage to claim the money.  
> **username_1**: sending a transaction to that htlc script is simple. Just use the standard Bitcoin core commands to send it to a P2SH address. However, it is while spending such script that issue arises in Bitcoin Core as it does not support dog ing transactions with CLTV scripts.  
> **username_0**: Which commands do I use. How to put the condition. I mean where? Where should i put the locking and unlocking script , how to spend it. Suppose we don't focus on the cltv scripts and if it is a basic script,  What do I do with it. How to get a p2sh from   the redeem script and how to proceed.  

---

## 0 answers

