I have two addresses in my regtest.
A
address is the P2SH-P2PKH. (sender)
B
address is the P2SH-P2PKH, but with OP_CHECKLOCKTIMEVERIFY
block height 201. (receiver)
My regtest doesen't have any block before it, Then I create some blocks (101) for A
and transfer some bitcoins to B
. A
Wants that the UTXO is available after block with height 201 for that reason B
creates this kind of script
$ bitcoin-cli decodescript 04C9000000B17576a914697c78eb51aadd3d977c1407e99baf9fe772240588AC
{
"asm": "201 OP_CHECKLOCKTIMEVERIFY OP_DROP OP_DUP OP_HASH160 697c78eb51aadd3d977c1407e99baf9fe7722405 OP_EQUALVERIFY OP_CHECKSIG",
"type": "nonstandard",
"p2sh": "2N9X4FL8mg9Tc88FuHgPzBqFXa6U1etuUck",
"segwit": {
"asm": "0 30ff9dbf6bab02945016f39e95aa5d67e0f2e6adc7392d1066a1e171513bcb33",
"hex": "002030ff9dbf6bab02945016f39e95aa5d67e0f2e6adc7392d1066a1e171513bcb33",
"reqSigs": 1,
"type": "witness_v0_scripthash",
"addresses": [
"bcrt1qxrlem0mt4vpfg5qk7w0ft2javls09e4dcuuj6yrx58shz5fmeves2tkaxf"
],
"p2sh-segwit": "2MtXn1EgzySHEw8BQXLG8n58dxss6NGRsGU"
}
}
B wants spend his bitcoins, it's the UTXO
[
{
"txid": "8cfc83e28fa520fed13a4199b72f588bf95fa84679d44b94efdff5d1f9f7812f",
"vout": 0,
"address": "2N9X4FL8mg9Tc88FuHgPzBqFXa6U1etuUck",
"label": "",
"scriptPubKey": "a914b2808972cf93673354475ece46820a2b3060978487",
"amount": 49.99100000,
"confirmations": 600,
"spendable": false,
"solvable": false,
"safe": true
}
]
And the current tip
$ bitcoin-cli getchaintips
[
{
"height": 701,
"hash": "1967a98ea0cca367a3699d09a30d046d31ed711989bc6f1a2ae61d7ade910866",
"branchlen": 0,
"status": "active"
}
]
Then B
create the transaction like this
02000000012f81f7f9d1f5dfef944bd47946a85ff98b582fb799413ad1fe20a58fe283fc8c000000008B47304402204cdc56d5be942d05edc218e40de872c9f50e78e018bbbbc9c11a05590aa54e8d02204163ce5796789fe4a7c9d1b1f0b3145ccca1eabb9489b92a4c6bc05508d5cbe6012102839f6ea8422639336f208a2cd2c199872f3e628bff39545eda72d8f71d4b45e42004C9000000B17576a914697c78eb51aadd3d977c1407e99baf9fe772240588ACfeffffff01c07aea290100000017a914d872ea0250c832eca1d7a75434db807397670ccd87C9000000
and use C9000000
in Locktime field
{
"txid": "d45d54d3cdae6c22f44cacfd705b2c1234658759f390d387186794240a77b16c",
"hash": "d45d54d3cdae6c22f44cacfd705b2c1234658759f390d387186794240a77b16c",
"version": 2,
"size": 222,
"vsize": 222,
"weight": 888,
"locktime": 201,
"vin": [
{
"txid": "8cfc83e28fa520fed13a4199b72f588bf95fa84679d44b94efdff5d1f9f7812f",
"vout": 0,
"scriptSig": {
"asm": "304402204cdc56d5be942d05edc218e40de872c9f50e78e018bbbbc9c11a05590aa54e8d02204163ce5796789fe4a7c9d1b1f0b3145ccca1eabb9489b92a4c6bc05508d5cbe6[ALL] 02839f6ea8422639336f208a2cd2c199872f3e628bff39545eda72d8f71d4b45e4 04c9000000b17576a914697c78eb51aadd3d977c1407e99baf9fe772240588ac",
"hex": "47304402204cdc56d5be942d05edc218e40de872c9f50e78e018bbbbc9c11a05590aa54e8d02204163ce5796789fe4a7c9d1b1f0b3145ccca1eabb9489b92a4c6bc05508d5cbe6012102839f6ea8422639336f208a2cd2c199872f3e628bff39545eda72d8f71d4b45e42004c9000000b17576a914697c78eb51aadd3d977c1407e99baf9fe772240588ac"
},
"sequence": 4294967294
}
],
"vout": [
{
"value": 49.982,
"n": 0,
"scriptPubKey": {
"asm": "OP_HASH160 d872ea0250c832eca1d7a75434db807397670ccd OP_EQUAL",
"hex": "a914d872ea0250c832eca1d7a75434db807397670ccd87",
"reqSigs": 1,
"type": "scripthash",
"addresses": [
"2NCyhc6DkujYJE6ui1sVFCJAiSa79BDWqKv"
]
}
}
]
}
But When I try to send Transaction I get that error:
non-mandatory-script-verify-flag (unknown error) (code 64)
With help of btcdeb I can see that error "error: exception thrown: non-minimally encoded script.
number". The same logic BUT with date works.
One more question: Is it correct flow? B
(receiver) creates P2SH with 201 OP_CHECKLOCKTIMEVERIFY OP_DROP
in order to satisfy A
(sender) requirements?