I'm working on a tool for timelocked contract generation. My redeem script looks like so:
OP_HASH160 <revocationHash> OP_EQUAL
<timeDelay> OP_CHECKSEQUENCEVERIFY OP_DROP
The goal is that Alice can spend the funds after a time delay, while Bob can spend them at any time by proving knowledge of the hash preimage.
Spending through the revocation hash is easy enough. However, I'm having trouble constructing a transaction that spends based on the timelock is proving more difficult. Essentially, my questions are:
- What does the
<timeDelay>value represent? How can I e.g. lock the funds for 2 blocks?
- From what I've read, the sequence number on the spend transaction needs to be set. But what should it be set to?
- How do I practically implement this using
bitcoinjs-libor another library?