Using the command line, I need some help with a simple time-lock script

I’m trying to experiment with simple time-locking scripts.

############################
# MAKE THE TIMELOCK SCRIPT #
############################
cardano-cli  query protocol-parameters --mainnet --out-file protocol.json
cardano-cli address key-gen --verification-key-file pay.vkey --signing-key-file pay.skey
currentTip=$(cardano-cli query tip --mainnet | jq -r .slot);
validBefore=$(( ${currentTip} + ${policyLen} ))
touch pay.script && echo "{\"type\":\"all\",\"scripts\":[{\"slot\":${validBefore},\"type\":\"before\"},{"\"keyHash\":\"$(cardano-cli address key-hash --payment-verification-key-file pay.vkey)\",\"type\":\"sig\""}]}" >> pay.script

In this script I made a before slot of 105952511. Still in the future - so I image this is a script where if I don’t unlock before the specified slot my funds are locked forever.

pay.script contents:

{"type":"all","scripts":[{"slot":105952511,"type":"before"},{"keyHash":"045b59b5607772377f6fb57dd6c0c48f3031e36147188337f39286f6","type":"sig"}]}

I created an address using this script like so:

#create an address using the script file
cardano-cli address build --payment-script-file pay.script --mainnet --out-file pay.addr

I setup my transaction like so:

payoutAddr=$(cat pay.addr)
utxo=051e828274056362ced65f0e0becb4268c0ffb19506d220c23674873110a4a37#0
startADA=1500000
addrto=$(cat ~/Fred/pay.addr)


cardano-cli transaction build-raw --fee 100000 \
--invalid-hereafter 105952510 \
--invalid-before 10952511 \
--tx-in ${utxo} \
--tx-in-script-file  pay.script \
--tx-out ${addrto}+1500000 \
--out-file tx.raw

Now to calculate the fee and change amount:

getMinFee=$(cardano-cli transaction calculate-min-fee --tx-body-file tx.raw --tx-in-count 1 --tx-out-count 1 --witness-count 1 --mainnet --protocol-params-file protocol.json)
minFeeParts=(${getMinFee})
minFee=${minFeeParts[0]}
lovelaceChange=$((${startADA}-${minFee}))

build the tx with the correct fee:

cardano-cli transaction build-raw --fee ${minFee}  \
--invalid-hereafter 105952510 \
--invalid-before 10952511 \
--tx-in ${utxo} \
--tx-in-script-file  pay.script \
--tx-out ${addrto}+${lovelaceChange} \
--out-file tx.raw

sign and submit:

cardano-cli transaction sign --signing-key-file pay.skey  --mainnet --tx-body-file tx.raw   --out-file tx.signed
cardano-cli transaction submit --tx-file  tx.signed --mainnet

I’ve tried adding

--required-signer-hash 0ea5de81a6c8e2fae4c6a13e6c3a8976525557b7a034ce89d0251706 \

in case it was required.

I’m getting the error message of:

Command failed: transaction submit  Error: Error while submitting tx: ShelleyTxValidationError ShelleyBasedEraBabbage (ApplyTxError [UtxowFailure (FromAlonzoUtxowFail (WrappedShelleyEraFailure (ScriptWitnessNotValidatingUTXOW (fromList [ScriptHash "0ea5de81a6c8e2fae4c6a13e6c3a8976525557b7a034ce89d0251706"]))))])

I can see the missing script hash is the policy ID from the pay.script file I created. Can anyone point at what I might have missed.