OP_IF condition in P2SH transaction fails on publishing

przez | 17 lipca, 2021

I am trying to build a simple payment transaction with the condition such that after 105 blocks are mined I can take back the locked funds. I am doing this in regtest.
Following is the redeem script:
OP_IF
OP_2 037fadaea6edf196bf70af16cefb2bd3c830e54c0a6e9a00bf7806b241933547f7
02fcb1c7507db15576ab35cd7c9b1ea570141a8b81c9938dae0320392b0f7034d0 OP_2
OP_CHECKMULTISIG
OP_ELSE 105 OP_CHECKSEQUENCEVERIFY OP_DROP
037fadaea6edf196bf70af16cefb2bd3c830e54c0a6e9a00bf7806b241933547f7 OP_CHECKSIG
OP_ENDIF

The corresponding address is:
2MvtqHu88v1u6ovi8teTNeoz3frk3fH5zMH

I get the following funding transaction:
$ bitcoin-core.cli -regtest -rpcuser=test -rpcpassword=test generatetoaddress 1 2MvtqHu88v1u6ovi8teTNeoz3frk3fH5zMH
[
„43dbc0a0fd995f70fea89fb6eb6098a4f881cd64a30f417b884b549b52e54cce”
]
$ bitcoin-core.cli -regtest -rpcuser=test -rpcpassword=test getblock 43dbc0a0fd995f70fea89fb6eb6098a4f881cd64a30f417b884b549b52e54cce|jq .tx
[
„624d92839eb89104d0909df89f95785cb8bb77f0fec66c6c40cf3ad2804a3966”
]

I create the following signature preimage:
01 00 00 00 (version)
01 (input count)
66394a80d23acf406c6cc6fef077bbb85c78959ff89d90d00491b89e83924d62 (previous tx)
00000000 (previous txout index)
71635221037fadaea6edf196bf70af16cefb2bd3c830e54c0a6e9a00bf7806b241933547f72102fcb1c7507db15576ab35cd7c9b1ea570141a8b81c9938dae0320392b0f7034d052ae670169b27521037fadaea6edf196bf70af16cefb2bd3c830e54c0a6e9a00bf7806b241933547f7ac68 (redeem script)
ffffffff (sequence)
02 (output count)
00ca9a3b00000000 (amount)
1976a914bfbca807e507802e27a64c2b9c2915819033990c88ac (P2PKH)
f0006bee00000000
1976a9142004e0ff6a6f08115d048fd9af177fae702f681a88ac (p2PKH)
00000000 (locktime)
01000000 (sighash_all)

which is signed by private keys:
L26JcHRhqEQv8V9DaAmE4bdszwqXS7tHznGYJPp7fxEoEQxxBPcQ for 037fadaea6edf196bf70af16cefb2bd3c830e54c0a6e9a00bf7806b241933547f7

and
KxR8HHyfAwFPidCw2vXThXqT4vSMNeufirHFapnfCfkzLaohtujG for 02fcb1c7507db15576ab35cd7c9b1ea570141a8b81c9938dae0320392b0f7034d0

And the following transaction is created:
$ bitcoin-core.cli -regtest -rpcuser=test -rpcpassword=test decoderawtransaction 010000000166394a80d23acf406c6cc6fef077bbb85c78959ff89d90d00491b89e83924d6200000000fd06010047304402204c287224a6d18870e35d282069a10c3d18712616b8c7abe90cf8a12b2dc1927c02203f4f7c4a1ee3af7835473512b7e094131974fb54d91c574fc109e343f91c931a0147304402205b71bb4e032e830a645c7466c720a892a69770767eb0efeabcf2cfbc73229f3102204732229df52bfea9e44fba9a945db8c4d04880bae74d5a819328a04182ca8daf0101014c71635221037fadaea6edf196bf70af16cefb2bd3c830e54c0a6e9a00bf7806b241933547f72102fcb1c7507db15576ab35cd7c9b1ea570141a8b81c9938dae0320392b0f7034d052ae670169b27521037fadaea6edf196bf70af16cefb2bd3c830e54c0a6e9a00bf7806b241933547f7ac68ffffffff0200ca9a3b000000001976a914bfbca807e507802e27a64c2b9c2915819033990c88acf0006bee000000001976a9142004e0ff6a6f08115d048fd9af177fae702f681a88ac00000000
{
„txid”: „1dbffb942c0abe5b238a09846d29eeae5f3859e74657e122d556f3f832715021”,
„hash”: „1dbffb942c0abe5b238a09846d29eeae5f3859e74657e122d556f3f832715021”,
„version”: 1,
„size”: 383,
„vsize”: 383,
„weight”: 1532,
„locktime”: 0,
„vin”: [
{
„txid”: „624d92839eb89104d0909df89f95785cb8bb77f0fec66c6c40cf3ad2804a3966”,
„vout”: 0,
„scriptSig”: {
„asm”: „0 304402204c287224a6d18870e35d282069a10c3d18712616b8c7abe90cf8a12b2dc1927c02203f4f7c4a1ee3af7835473512b7e094131974fb54d91c574fc109e343f91c931a[ALL] 304402205b71bb4e032e830a645c7466c720a892a69770767eb0efeabcf2cfbc73229f3102204732229df52bfea9e44fba9a945db8c4d04880bae74d5a819328a04182ca8daf[ALL] 1 635221037fadaea6edf196bf70af16cefb2bd3c830e54c0a6e9a00bf7806b241933547f72102fcb1c7507db15576ab35cd7c9b1ea570141a8b81c9938dae0320392b0f7034d052ae670169b27521037fadaea6edf196bf70af16cefb2bd3c830e54c0a6e9a00bf7806b241933547f7ac68”,
„hex”: „0047304402204c287224a6d18870e35d282069a10c3d18712616b8c7abe90cf8a12b2dc1927c02203f4f7c4a1ee3af7835473512b7e094131974fb54d91c574fc109e343f91c931a0147304402205b71bb4e032e830a645c7466c720a892a69770767eb0efeabcf2cfbc73229f3102204732229df52bfea9e44fba9a945db8c4d04880bae74d5a819328a04182ca8daf0101014c71635221037fadaea6edf196bf70af16cefb2bd3c830e54c0a6e9a00bf7806b241933547f72102fcb1c7507db15576ab35cd7c9b1ea570141a8b81c9938dae0320392b0f7034d052ae670169b27521037fadaea6edf196bf70af16cefb2bd3c830e54c0a6e9a00bf7806b241933547f7ac68”
},
„sequence”: 4294967295
}
],
„vout”: [
{
„value”: 10.00000000,
„n”: 0,
„scriptPubKey”: {
„asm”: „OP_DUP OP_HASH160 bfbca807e507802e27a64c2b9c2915819033990c OP_EQUALVERIFY OP_CHECKSIG”,
„hex”: „76a914bfbca807e507802e27a64c2b9c2915819033990c88ac”,
„reqSigs”: 1,
„type”: „pubkeyhash”,
„addresses”: [
„mxzmMmVycLDgAA48VtHDeh389eDAwiJqwQ”
]
}
},
{
„value”: 39.99990000,
„n”: 1,
„scriptPubKey”: {
„asm”: „OP_DUP OP_HASH160 2004e0ff6a6f08115d048fd9af177fae702f681a OP_EQUALVERIFY OP_CHECKSIG”,
„hex”: „76a9142004e0ff6a6f08115d048fd9af177fae702f681a88ac”,
„reqSigs”: 1,
„type”: „pubkeyhash”,
„addresses”: [
„miSFmBeKXf5Wp7Luj46XTu3Yh57nAwhZAo”
]
}
}
]
}

On publishing I get the following error:
$ bitcoin-core.cli -regtest -rpcuser=test -rpcpassword=test sendrawtransaction 010000000166394a80d23acf406c6cc6fef077bbb85c78959ff89d90d00491b89e83924d6200000000fd06010047304402204c287224a6d18870e35d282069a10c3d18712616b8c7abe90cf8a12b2dc1927c02203f4f7c4a1ee3af7835473512b7e094131974fb54d91c574fc109e343f91c931a0147304402205b71bb4e032e830a645c7466c720a892a69770767eb0efeabcf2cfbc73229f3102204732229df52bfea9e44fba9a945db8c4d04880bae74d5a819328a04182ca8daf0101014c71635221037fadaea6edf196bf70af16cefb2bd3c830e54c0a6e9a00bf7806b241933547f72102fcb1c7507db15576ab35cd7c9b1ea570141a8b81c9938dae0320392b0f7034d052ae670169b27521037fadaea6edf196bf70af16cefb2bd3c830e54c0a6e9a00bf7806b241933547f7ac68ffffffff0200ca9a3b000000001976a914bfbca807e507802e27a64c2b9c2915819033990c88acf0006bee000000001976a9142004e0ff6a6f08115d048fd9af177fae702f681a88ac00000000
error code: -26
error message:
non-mandatory-script-verify-flag (Data push larger than necessary)

Not sure where I made mistake. Please help resolve this issue.