<p>Regarding 1st question,</p>
<p>I guess your locktime <code>1694275749</code> is unix timestamp not little-endian byte(hex). Your script must encode number in little-endian byte(which is <code>a598fc64</code>), not timestamp decimal itself. If you already sent with <code>1694275749</code> locktime, it would be interpreted as little-endian byte(hex number), not as decimal, so unspendable as far as I know.</p>
<p>Regarding 2nd question,</p>
<p><a href="https://github.com/bitcoin/bips/blob/master/bip-0065.mediawiki" rel="nofollow noreferrer">BIP65</a> describes how to handle 2038 problem, which simply allows to accept 5 bytes number exceptionally for utc locktime when it's used with OP_CHECKLOCKTIMEVERIFY.</p>
<p>In BIP65,</p>
<blockquote>
<p>If we kept to that limit we'd have a year 2038 problem,
even though the nLockTime field in transactions themselves is uint32 which only becomes meaningless after the year 2106.
Thus as a special case we tell CScriptNum to accept up to 5-byte bignums, which are good until 2**32-1, the same limit as the nLockTime field itself.</p>
</blockquote>
<p>Therefore, OP_CHECKLOCKTIMEVERIFY locktime upper bound for timestamp is same with uint32 nLockTime.</p>

CC BY-SA 4.0
2024-06-03T05:42:55.997Z
2024-06-03T07:46:54.590Z
2024-06-03T07:46:54.590Z
Hyunhum Cho
<p>What im doing wrong?
Sinse I found out  that Bitcoin is programmable money Im trying to use it potential.
Using this site <a href="https://improvein.github.io/bitcoin-forge/?#/script/create" rel="nofollow noreferrer">https://improvein.github.io/bitcoin-forge/?#/script/create</a> I’ve created a conditional  script that holds 2 time locks for two pub keys.</p>
<p>OP_IF 1694275749 OP_CHECKLOCKTIMEVERIFY OP_DROP 03cd18ace3a339fcd0039fd87d7a7a8377537cd9a9f2afa2a3e76f40e53112a535 OP_CHECKSIG OP_ELSE 1694277749 OP_CHECKLOCKTIMEVERIFY OP_DROP 036bb176ed8fe2e38949a63ff964eed3c5e79fd88ac011cad1eecf22702ea65d23 OP_CHECKSIG OP_ENDIF</p>
<p>Script 63051694275749b1752103cd18ace3a339fcd0039fd87d7a7a8377537cd9a9f2afa2a3e76f40e53112a535ac67051694277749b17521036bb176ed8fe2e38949a63ff964eed3c5e79fd88ac011cad1eecf22702ea65d23ac68</p>
<p>Used this script to create with this tool
<a href="https://improvein.github.io/bitcoin-forge/?#/address/create" rel="nofollow noreferrer">https://improvein.github.io/bitcoin-forge/?#/address/create</a> Payment to Witness Script Hash
address  bc1qes2v6ts5ckxuz5mkwdeukcn62hkac05kf97gugc4jnu3kj3wg5as3nes34</p>
<p>Now I’m using bitcoin core cli to sign the input and create raw transaction. And I’m completely stack at this point. How and what to sign and how to put this puzzle for unlocking transaction.</p>
<p>The scope of this script is to give to family member some funds locked in future with ability to be spend it with one of 2 privet keys. If he loose his key, I can spend it with op_else condition.  I will provide some data</p>
<pre><code>gettxout 14290ef656c05f8e0c06b6d99a6ae72c77a8809b3a69dd5fb00f07ce9cee1637  vout 133


{
  &quot;bestblock&quot;: &quot;0000000000000000000528fb0e92c1e79378a1b241eb144ca0f97054fdf42dfb&quot;,
  &quot;confirmations&quot;: 155,
  &quot;value&quot;: 0.00007726,
  &quot;scriptPubKey&quot;: {
    &quot;asm&quot;: &quot;0 cc14cd2e14c58dc153767373cb627a55eddc3e96497c8e231594f91b4a2e453b&quot;,
    &quot;desc&quot;: &quot;addr(bc1qes2v6ts5ckxuz5mkwdeukcn62hkac05kf97gugc4jnu3kj3wg5as3nes34)#k8s5es0p&quot;,
    &quot;hex&quot;: &quot;0020cc14cd2e14c58dc153767373cb627a55eddc3e96497c8e231594f91b4a2e453b&quot;,
    &quot;address&quot;: &quot;bc1qes2v6ts5ckxuz5mkwdeukcn62hkac05kf97gugc4jnu3kj3wg5as3nes34&quot;,
    &quot;type&quot;: &quot;witness_v0_scripthash&quot;
  },
  &quot;coinbase&quot;: false
}
</code></pre>
<p>the locking script</p>
<pre><code>{
  &quot;asm&quot;: &quot;1692429480 OP_CHECKLOCKTIMEVERIFY OP_DROP OP_IF 03cd18ace3a339fcd0039fd87d7a7a8377537cd9a9f2afa2a3e76f40e53112a535 OP_CHECKSIG OP_ELSE 1692602280 OP_CHECKLOCKTIMEVERIFY OP_DROP 036bb176ed8fe2e38949a63ff964eed3c5e79fd88ac011cad1eecf22702ea65d23 OP_CHECKSIG OP_ENDIF&quot;,
  &quot;desc&quot;: &quot;raw(04a86ce064b175632103cd18ace3a339fcd0039fd87d7a7a8377537cd9a9f2afa2a3e76f40e53112a535ac6704a80fe364b17521036bb176ed8fe2e38949a63ff964eed3c5e79fd88ac011cad1eecf22702ea65d23ac68)#r3dcxvh2&quot;,
  &quot;type&quot;: &quot;nonstandard&quot;,
  &quot;p2sh&quot;: &quot;38cTqVJf1jPBDCjg8wKdFx476uHX3qgEaB&quot;,
  &quot;segwit&quot;: {
    &quot;asm&quot;: &quot;0 69672524bb7737429280e9c862b3fdcea0dc22037cbaaa755d6132b4841811e4&quot;,
    &quot;desc&quot;: &quot;wsh(raw(04a86ce064b175632103cd18ace3a339fcd0039fd87d7a7a8377537cd9a9f2afa2a3e76f40e53112a535ac6704a80fe364b17521036bb176ed8fe2e38949a63ff964eed3c5e79fd88ac011cad1eecf22702ea65d23ac68))#7uzehfsr&quot;,
    &quot;hex&quot;: &quot;002069672524bb7737429280e9c862b3fdcea0dc22037cbaaa755d6132b4841811e4&quot;,
    &quot;address&quot;: &quot;bc1qd9nj2f9mwum59y5qa8yx9vlae6sdcgsr0ja25a2avyetfpqcz8jqg69shh&quot;,
    &quot;type&quot;: &quot;witness_v0_scripthash&quot;,
    &quot;p2sh-segwit&quot;: &quot;3NqDPiKTsbYA18GRWzrsE5wYYxGhH9XS96&quot;
  }
}
</code></pre>
<p>and 2nd question</p>
<p>how segwit time locked script will work considering The &quot;Year 2038 problem&quot; when issue arises because a 32-bit signed integer can represent a maximum value of 2,147,483,647 seconds, which is approximately 68 years. The Unix epoch started on January 1, 1970, so adding 68 years to this date brings us to January 19, 2038. so question is : funds time locked after January 19, 2038 will be spendable same way like today?</p>

<script><segregated-witness><input-script><signrawtransaction><input>
conditional spending from P2WSH address
bitc
# conditional spending from P2WSH address

(Asked by: username_0 on 2023-09-10)

What im doing wrong?
Sinse I found out that Bitcoin is programmable money Im trying to use it potential.
Using this site <https://improvein.github.io/bitcoin-forge/?#/script/create> I’ve created a conditional script that holds 2 time locks for two pub keys.

OP\_IF 1694275749 OP\_CHECKLOCKTIMEVERIFY OP\_DROP 03cd18ace3a339fcd0039fd87d7a7a8377537cd9a9f2afa2a3e76f40e53112a535 OP\_CHECKSIG OP\_ELSE 1694277749 OP\_CHECKLOCKTIMEVERIFY OP\_DROP 036bb176ed8fe2e38949a63ff964eed3c5e79fd88ac011cad1eecf22702ea65d23 OP\_CHECKSIG OP\_ENDIF

Script 63051694275749b1752103cd18ace3a339fcd0039fd87d7a7a8377537cd9a9f2afa2a3e76f40e53112a535ac67051694277749b17521036bb176ed8fe2e38949a63ff964eed3c5e79fd88ac011cad1eecf22702ea65d23ac68

Used this script to create with this tool
<https://improvein.github.io/bitcoin-forge/?#/address/create> Payment to Witness Script Hash
address bc1qes2v6ts5ckxuz5mkwdeukcn62hkac05kf97gugc4jnu3kj3wg5as3nes34

Now I’m using bitcoin core cli to sign the input and create raw transaction. And I’m completely stack at this point. How and what to sign and how to put this puzzle for unlocking transaction.

The scope of this script is to give to family member some funds locked in future with ability to be spend it with one of 2 privet keys. If he loose his key, I can spend it with op\_else condition. I will provide some data

```
gettxout 14290ef656c05f8e0c06b6d99a6ae72c77a8809b3a69dd5fb00f07ce9cee1637  vout 133

{
  "bestblock": "0000000000000000000528fb0e92c1e79378a1b241eb144ca0f97054fdf42dfb",
  "confirmations": 155,
  "value": 0.00007726,
  "scriptPubKey": {
    "asm": "0 cc14cd2e14c58dc153767373cb627a55eddc3e96497c8e231594f91b4a2e453b",
    "desc": "addr(bc1qes2v6ts5ckxuz5mkwdeukcn62hkac05kf97gugc4jnu3kj3wg5as3nes34)#k8s5es0p",
    "hex": "0020cc14cd2e14c58dc153767373cb627a55eddc3e96497c8e231594f91b4a2e453b",
    "address": "bc1qes2v6ts5ckxuz5mkwdeukcn62hkac05kf97gugc4jnu3kj3wg5as3nes34",
    "type": "witness_v0_scripthash"
  },
  "coinbase": false
}

```

the locking script

```
{
  "asm": "1692429480 OP_CHECKLOCKTIMEVERIFY OP_DROP OP_IF 03cd18ace3a339fcd0039fd87d7a7a8377537cd9a9f2afa2a3e76f40e53112a535 OP_CHECKSIG OP_ELSE 1692602280 OP_CHECKLOCKTIMEVERIFY OP_DROP 036bb176ed8fe2e38949a63ff964eed3c5e79fd88ac011cad1eecf22702ea65d23 OP_CHECKSIG OP_ENDIF",
  "desc": "raw(04a86ce064b175632103cd18ace3a339fcd0039fd87d7a7a8377537cd9a9f2afa2a3e76f40e53112a535ac6704a80fe364b17521036bb176ed8fe2e38949a63ff964eed3c5e79fd88ac011cad1eecf22702ea65d23ac68)#r3dcxvh2",
  "type": "nonstandard",
  "p2sh": "38cTqVJf1jPBDCjg8wKdFx476uHX3qgEaB",
  "segwit": {
    "asm": "0 69672524bb7737429280e9c862b3fdcea0dc22037cbaaa755d6132b4841811e4",
    "desc": "wsh(raw(04a86ce064b175632103cd18ace3a339fcd0039fd87d7a7a8377537cd9a9f2afa2a3e76f40e53112a535ac6704a80fe364b17521036bb176ed8fe2e38949a63ff964eed3c5e79fd88ac011cad1eecf22702ea65d23ac68))#7uzehfsr",
    "hex": "002069672524bb7737429280e9c862b3fdcea0dc22037cbaaa755d6132b4841811e4",
    "address": "bc1qd9nj2f9mwum59y5qa8yx9vlae6sdcgsr0ja25a2avyetfpqcz8jqg69shh",
    "type": "witness_v0_scripthash",
    "p2sh-segwit": "3NqDPiKTsbYA18GRWzrsE5wYYxGhH9XS96"
  }
}

```

and 2nd question

how segwit time locked script will work considering The "Year 2038 problem" when issue arises because a 32-bit signed integer can represent a maximum value of 2,147,483,647 seconds, which is approximately 68 years. The Unix epoch started on January 1, 1970, so adding 68 years to this date brings us to January 19, 2038. so question is : funds time locked after January 19, 2038 will be spendable same way like today?

**Tags:** script, segregated-witness, input-script, signrawtransaction, input


---

## 1 answers

### Answer by username_1 on 2024-06-03. Score: 1

Regarding 1st question,

I guess your locktime `1694275749` is unix timestamp not little-endian byte(hex). Your script must encode number in little-endian byte(which is `a598fc64`), not timestamp decimal itself. If you already sent with `1694275749` locktime, it would be interpreted as little-endian byte(hex number), not as decimal, so unspendable as far as I know.

Regarding 2nd question,

[BIP65](https://github.com/bitcoin/bips/blob/master/bip-0065.mediawiki) describes how to handle 2038 problem, which simply allows to accept 5 bytes number exceptionally for utc locktime when it's used with OP\_CHECKLOCKTIMEVERIFY.

In BIP65,

> If we kept to that limit we'd have a year 2038 problem,
> even though the nLockTime field in transactions themselves is uint32 which only becomes meaningless after the year 2106.
> Thus as a special case we tell CScriptNum to accept up to 5-byte bignums, which are good until 2\*\*32-1, the same limit as the nLockTime field itself.

Therefore, OP\_CHECKLOCKTIMEVERIFY locktime upper bound for timestamp is same with uint32 nLockTime.


---

