<p>Solved by encoding the checklocktimeverify integer correctly, following the command line steps provided by <a href="https://github.com/ChristopherA/Learning-Bitcoin-from-the-Command-Line/blob/master/08_2_Building_the_Structure_of_P2SH.md" rel="nofollow noreferrer">https://github.com/ChristopherA/Learning-Bitcoin-from-the-Command-Line/blob/master/08_2_Building_the_Structure_of_P2SH.md</a> </p>

<pre><code>bx script-to-address -v 196 "[9f7b2a5c] checklocktimeverify drop 2 [02bceab65ad6b5e3c1d6683b1d0ffd7bce572ce3ece0f1976fb04ba34bb0359c1b] [02c4916c1c044bda56670f28efdb6637fa24448f5184839f917a473abfd81e6d3d] 2 checkmultisig"
</code></pre>

<p>And for the spend transaction, setting locktime as the current unix time: </p>

<pre><code>bitcoin-cli -named createrawtransaction inputs='''[ { "txid": "'dc4f97b0bb843820eff1bf677472cfe4f56ade41baf1dce4cdef75f8f5a44836'", "vout": '0' } ]''' outputs='''{ "'2N6bFRmGF1JtHgHUYZKdVNZ2ZHtyHc8MBru'": 0.009 }''' locktime=1552996392
</code></pre>

<p>Successfully sent the transaction using bitcoin core: 
<a href="https://live.blockcypher.com/btc-testnet/tx/dac8db0182559bbf3e6f54efac6fb283bcd78356347173fb7f969a53c7d5ec36/" rel="nofollow noreferrer">https://live.blockcypher.com/btc-testnet/tx/dac8db0182559bbf3e6f54efac6fb283bcd78356347173fb7f969a53c7d5ec36/</a></p>

CC BY-SA 4.0
2019-03-19T12:47:18.253Z
2019-03-19T12:47:18.253Z
rusticbison
<p>I am using this locking script with libbitcoin explorer to create a bitcoin testnet transaction: </p>

<pre><code>bx script-to-address -v 196 "[efa716] checklocktimeverify drop 2 [02bceab65ad6b5e3c1d6683b1d0ffd7bce572ce3ece0f1976fb04ba34bb0359c1b] [02c4916c1c044bda56670f28efdb6637fa24448f5184839f917a473abfd81e6d3d] 2 checkmultisig"
</code></pre>

<p>This gives me the receiving address: </p>

<pre><code>2NA3vs7QUdoXhUELUAGkGUv1Cuy1DpM4uPs
</code></pre>

<p>The funding transaction can be seen here: 
<a href="https://api.blockcypher.com/v1/btc/test3/txs/56fd7329a72cb48a517b6a396a8fa537190ad1f72333781b21dbfd8ae1616dd6?limit=50&amp;includeHex=true" rel="nofollow noreferrer">https://api.blockcypher.com/v1/btc/test3/txs/56fd7329a72cb48a517b6a396a8fa537190ad1f72333781b21dbfd8ae1616dd6?limit=50&amp;includeHex=true</a></p>

<p>I create a raw transaction using bitcoin-cli, because bx unexpectedly changes the send-to-address. I have tried setting locktime to 00000000, 4294967295, and not specifying nlocktime at all.</p>

<pre><code>bitcoin-cli -named createrawtransaction inputs='''[ { "txid": "'56fd7329a72cb48a517b6a396a8fa537190ad1f72333781b21dbfd8ae1616dd6'", "vout": '1' } ]''' outputs='''{ "'2N2zbPDQWhcs5niMKqQ4dz8m8jxU5izkabh'": 0.00800000}''' locktime=00000000
</code></pre>

<p>Next, both signatures are applied to the transaction, using the appropriate private keys and <em>bx input-sign</em>.</p>

<pre><code>bx input-sign 46d170451e8565c9b5233ca160ba1aee9680f24059fa565af17ef11f80cc7d43 "[efa716] checklocktimeverify drop 2 [02bceab65ad6b5e3c1d6683b1d0ffd7bce572ce3ece0f1976fb04ba34bb0359c1b] [02c4916c1c044bda56670f28efdb6637fa24448f5184839f917a473abfd81e6d3d] 2 checkmultisig" 0200000001d66d61e18afddb211b783323f7d10a1937a58f6a396a7b518ab42ca72973fd560100000000ffffffff0100350c000000000017a9146aece0dbf34db9b86c8aab5e9ecb2b37c669b44f8700000000

bx input-sign 53064d99236c9e5fe30d2fe2dc3a5f6cd2374cac3f5c997a327218381d41c7d7 "[efa716] checklocktimeverify drop 2 [02bceab65ad6b5e3c1d6683b1d0ffd7bce572ce3ece0f1976fb04ba34bb0359c1b] [02c4916c1c044bda56670f28efdb6637fa24448f5184839f917a473abfd81e6d3d] 2 checkmultisig" 0200000001d66d61e18afddb211b783323f7d10a1937a58f6a396a7b518ab42ca72973fd560100000000ffffffff0100350c000000000017a9146aece0dbf34db9b86c8aab5e9ecb2b37c669b44f8700000000
</code></pre>

<p>This gives the endorsements: </p>

<pre><code>endorsement1 = 30450221008694e53196e222ed86935d9c2d16c14baec194d70e3eed474bc2423ec8adcf4f02204d6a72b87f190684a5f52228620d77357be5dd3265bfcdfd16d9a260a09fa33401
endorsement2 = 304402207006d5e588298cd8ae2cd2430c1cba38b3a0a31bbee8ea0ab0349e509e50e9b802200207fc65e28acb070f9fa9cfc11ae06b4b10c112daa23fb05f9e297c430580e301
</code></pre>

<p>The script is encoded: </p>

<pre><code>bx script-encode "[efa716] checklocktimeverify drop 2 [02bceab65ad6b5e3c1d6683b1d0ffd7bce572ce3ece0f1976fb04ba34bb0359c1b] [02c4916c1c044bda56670f28efdb6637fa24448f5184839f917a473abfd81e6d3d] 2 checkmultisig"
</code></pre>

<p>And finally:</p>

<pre><code>bx input-set "zero [30450221008694e53196e222ed86935d9c2d16c14baec194d70e3eed474bc2423ec8adcf4f02204d6a72b87f190684a5f52228620d77357be5dd3265bfcdfd16d9a260a09fa33401] [304402207006d5e588298cd8ae2cd2430c1cba38b3a0a31bbee8ea0ab0349e509e50e9b802200207fc65e28acb070f9fa9cfc11ae06b4b10c112daa23fb05f9e297c430580e301] [03efa716b175522102bceab65ad6b5e3c1d6683b1d0ffd7bce572ce3ece0f1976fb04ba34bb0359c1b2102c4916c1c044bda56670f28efdb6637fa24448f5184839f917a473abfd81e6d3d52ae]" 0200000001d66d61e18afddb211b783323f7d10a1937a58f6a396a7b518ab42ca72973fd560100000000ffffffff0100350c000000000017a9146aece0dbf34db9b86c8aab5e9ecb2b37c669b44f8700000000
</code></pre>

<p>I can validate using bx: </p>

<pre><code>bx input-validate 02bceab65ad6b5e3c1d6683b1d0ffd7bce572ce3ece0f1976fb04ba34bb0359c1b "[efa716] checklocktimeverify drop 2 [02bceab65ad6b5e3c1d6683b1d0ffd7bce572ce3ece0f1976fb04ba34bb0359c1b] [02c4916c1c044bda56670f28efdb6637fa24448f5184839f917a473abfd81e6d3d] 2 checkmultisig" 30450221008694e53196e222ed86935d9c2d16c14baec194d70e3eed474bc2423ec8adcf4f02204d6a72b87f190684a5f52228620d77357be5dd3265bfcdfd16d9a260a09fa33401 0200000001d66d61e18afddb211b783323f7d10a1937a58f6a396a7b518ab42ca72973fd5601000000e1004830450221008694e53196e222ed86935d9c2d16c14baec194d70e3eed474bc2423ec8adcf4f02204d6a72b87f190684a5f52228620d77357be5dd3265bfcdfd16d9a260a09fa3340147304402207006d5e588298cd8ae2cd2430c1cba38b3a0a31bbee8ea0ab0349e509e50e9b802200207fc65e28acb070f9fa9cfc11ae06b4b10c112daa23fb05f9e297c430580e3014c4d03efa716b175522102bceab65ad6b5e3c1d6683b1d0ffd7bce572ce3ece0f1976fb04ba34bb0359c1b2102c4916c1c044bda56670f28efdb6637fa24448f5184839f917a473abfd81e6d3d52aeffffffff0100350c000000000017a9146aece0dbf34db9b86c8aab5e9ecb2b37c669b44f8700000000

Endorsement is valid
</code></pre>

<p>However, when using bitcoin-cli sendrawtransaction, I always see one of these error messages: </p>

<pre><code># No nlocktime set, or set at 0
error code -26
error message:
non-mandatory-script-verify-flag (Locktime requirement not satisfied) (code 64)

# nLocktime set for max or 4294967295
error code -26
error message:
non-final (code 64)
</code></pre>

<p>I have seen this thread: 
<a href="https://bitcoin.stackexchange.com/questions/80902/transaction-still-unspendable-with-cltv">Transaction still unspendable with CLTV</a></p>

<p>But even though I have broadcasted the transaction via a block explorer, the transaction seems to be ignored. What could the cause of this? </p>

<script><multi-signature><locktime>
How to spend a multisignature, CLTV time-locked UTXO?
rusticbison
# How to spend a multisignature, CLTV time-locked UTXO?

(Asked by: username_0 on 2019-03-19)

I am using this locking script with libbitcoin explorer to create a bitcoin testnet transaction:

```
bx script-to-address -v 196 "[efa716] checklocktimeverify drop 2 [02bceab65ad6b5e3c1d6683b1d0ffd7bce572ce3ece0f1976fb04ba34bb0359c1b] [02c4916c1c044bda56670f28efdb6637fa24448f5184839f917a473abfd81e6d3d] 2 checkmultisig"

```

This gives me the receiving address:

```
2NA3vs7QUdoXhUELUAGkGUv1Cuy1DpM4uPs

```

The funding transaction can be seen here:
<https://api.blockcypher.com/v1/btc/test3/txs/56fd7329a72cb48a517b6a396a8fa537190ad1f72333781b21dbfd8ae1616dd6?limit=50&includeHex=true>

I create a raw transaction using bitcoin-cli, because bx unexpectedly changes the send-to-address. I have tried setting locktime to 00000000, 4294967295, and not specifying nlocktime at all.

```
bitcoin-cli -named createrawtransaction inputs='''[ { "txid": "'56fd7329a72cb48a517b6a396a8fa537190ad1f72333781b21dbfd8ae1616dd6'", "vout": '1' } ]''' outputs='''{ "'2N2zbPDQWhcs5niMKqQ4dz8m8jxU5izkabh'": 0.00800000}''' locktime=00000000

```

Next, both signatures are applied to the transaction, using the appropriate private keys and *bx input-sign*.

```
bx input-sign 46d170451e8565c9b5233ca160ba1aee9680f24059fa565af17ef11f80cc7d43 "[efa716] checklocktimeverify drop 2 [02bceab65ad6b5e3c1d6683b1d0ffd7bce572ce3ece0f1976fb04ba34bb0359c1b] [02c4916c1c044bda56670f28efdb6637fa24448f5184839f917a473abfd81e6d3d] 2 checkmultisig" 0200000001d66d61e18afddb211b783323f7d10a1937a58f6a396a7b518ab42ca72973fd560100000000ffffffff0100350c000000000017a9146aece0dbf34db9b86c8aab5e9ecb2b37c669b44f8700000000

bx input-sign 53064d99236c9e5fe30d2fe2dc3a5f6cd2374cac3f5c997a327218381d41c7d7 "[efa716] checklocktimeverify drop 2 [02bceab65ad6b5e3c1d6683b1d0ffd7bce572ce3ece0f1976fb04ba34bb0359c1b] [02c4916c1c044bda56670f28efdb6637fa24448f5184839f917a473abfd81e6d3d] 2 checkmultisig" 0200000001d66d61e18afddb211b783323f7d10a1937a58f6a396a7b518ab42ca72973fd560100000000ffffffff0100350c000000000017a9146aece0dbf34db9b86c8aab5e9ecb2b37c669b44f8700000000

```

This gives the endorsements:

```
endorsement1 = 30450221008694e53196e222ed86935d9c2d16c14baec194d70e3eed474bc2423ec8adcf4f02204d6a72b87f190684a5f52228620d77357be5dd3265bfcdfd16d9a260a09fa33401
endorsement2 = 304402207006d5e588298cd8ae2cd2430c1cba38b3a0a31bbee8ea0ab0349e509e50e9b802200207fc65e28acb070f9fa9cfc11ae06b4b10c112daa23fb05f9e297c430580e301

```

The script is encoded:

```
bx script-encode "[efa716] checklocktimeverify drop 2 [02bceab65ad6b5e3c1d6683b1d0ffd7bce572ce3ece0f1976fb04ba34bb0359c1b] [02c4916c1c044bda56670f28efdb6637fa24448f5184839f917a473abfd81e6d3d] 2 checkmultisig"

```

And finally:

```
bx input-set "zero [30450221008694e53196e222ed86935d9c2d16c14baec194d70e3eed474bc2423ec8adcf4f02204d6a72b87f190684a5f52228620d77357be5dd3265bfcdfd16d9a260a09fa33401] [304402207006d5e588298cd8ae2cd2430c1cba38b3a0a31bbee8ea0ab0349e509e50e9b802200207fc65e28acb070f9fa9cfc11ae06b4b10c112daa23fb05f9e297c430580e301] [03efa716b175522102bceab65ad6b5e3c1d6683b1d0ffd7bce572ce3ece0f1976fb04ba34bb0359c1b2102c4916c1c044bda56670f28efdb6637fa24448f5184839f917a473abfd81e6d3d52ae]" 0200000001d66d61e18afddb211b783323f7d10a1937a58f6a396a7b518ab42ca72973fd560100000000ffffffff0100350c000000000017a9146aece0dbf34db9b86c8aab5e9ecb2b37c669b44f8700000000

```

I can validate using bx:

```
bx input-validate 02bceab65ad6b5e3c1d6683b1d0ffd7bce572ce3ece0f1976fb04ba34bb0359c1b "[efa716] checklocktimeverify drop 2 [02bceab65ad6b5e3c1d6683b1d0ffd7bce572ce3ece0f1976fb04ba34bb0359c1b] [02c4916c1c044bda56670f28efdb6637fa24448f5184839f917a473abfd81e6d3d] 2 checkmultisig" 30450221008694e53196e222ed86935d9c2d16c14baec194d70e3eed474bc2423ec8adcf4f02204d6a72b87f190684a5f52228620d77357be5dd3265bfcdfd16d9a260a09fa33401 0200000001d66d61e18afddb211b783323f7d10a1937a58f6a396a7b518ab42ca72973fd5601000000e1004830450221008694e53196e222ed86935d9c2d16c14baec194d70e3eed474bc2423ec8adcf4f02204d6a72b87f190684a5f52228620d77357be5dd3265bfcdfd16d9a260a09fa3340147304402207006d5e588298cd8ae2cd2430c1cba38b3a0a31bbee8ea0ab0349e509e50e9b802200207fc65e28acb070f9fa9cfc11ae06b4b10c112daa23fb05f9e297c430580e3014c4d03efa716b175522102bceab65ad6b5e3c1d6683b1d0ffd7bce572ce3ece0f1976fb04ba34bb0359c1b2102c4916c1c044bda56670f28efdb6637fa24448f5184839f917a473abfd81e6d3d52aeffffffff0100350c000000000017a9146aece0dbf34db9b86c8aab5e9ecb2b37c669b44f8700000000

Endorsement is valid

```

However, when using bitcoin-cli sendrawtransaction, I always see one of these error messages:

```
# No nlocktime set, or set at 0
error code -26
error message:
non-mandatory-script-verify-flag (Locktime requirement not satisfied) (code 64)

# nLocktime set for max or 4294967295
error code -26
error message:
non-final (code 64)

```

I have seen this thread:
[Transaction still unspendable with CLTV](https://bitcoin.stackexchange.com/questions/80902/transaction-still-unspendable-with-cltv)

But even though I have broadcasted the transaction via a block explorer, the transaction seems to be ignored. What could the cause of this?

**Tags:** script, multi-signature, locktime


---

## 1 answers

### Answer by username_0 on 2019-03-19. Score: 2

Solved by encoding the checklocktimeverify integer correctly, following the command line steps provided by <https://github.com/ChristopherA/Learning-Bitcoin-from-the-Command-Line/blob/master/08_2_Building_the_Structure_of_P2SH.md>

```
bx script-to-address -v 196 "[9f7b2a5c] checklocktimeverify drop 2 [02bceab65ad6b5e3c1d6683b1d0ffd7bce572ce3ece0f1976fb04ba34bb0359c1b] [02c4916c1c044bda56670f28efdb6637fa24448f5184839f917a473abfd81e6d3d] 2 checkmultisig"

```

And for the spend transaction, setting locktime as the current unix time:

```
bitcoin-cli -named createrawtransaction inputs='''[ { "txid": "'dc4f97b0bb843820eff1bf677472cfe4f56ade41baf1dce4cdef75f8f5a44836'", "vout": '0' } ]''' outputs='''{ "'2N6bFRmGF1JtHgHUYZKdVNZ2ZHtyHc8MBru'": 0.009 }''' locktime=1552996392

```

Successfully sent the transaction using bitcoin core:
<https://live.blockcypher.com/btc-testnet/tx/dac8db0182559bbf3e6f54efac6fb283bcd78356347173fb7f969a53c7d5ec36/>


---

