const slot = lucid.currentSlot();
const POSIXTime = lucid.utils.slotToUnixTime(slot);
await lucid.newTx()
.collectFrom([utxo], redeemer)
.payToAddress(buyerAddr, utxo.assets)
.payToAddress(sellerAddr, { lovelace: PRICE + utxoLovelace })
.attachSpendingValidator(escrowScript)
.validTo(Number(BigInt(POSIXTime)))
If I add [ .validTo(Number(BigInt(POSIXTime))) ]
This Transaction passes the validation of TIME-CHECK of my Escrow Smart Contract and txHash is generated.
BUT THE Transaction do not reflect onchain as it fails when submitting. But Lucid doesn't give any error, instead it gives TxHash and positive response.
BUT IF I ADD [ .validTo(Number(BigInt(POSIXTime) + 60000n)) ]
This transaction also succeeds as well as the Transaction is actually reflected on chain which denotes that the transaction has been executed successfully.
The Problem is when I am giving the current Posixtime, Lucid takes time to convert everything and actually execute the code onchain. So when the transcation is actually executed onchain, the validity time already passed and its in history, and cardano doesnt allow transaction to be executed which has --invalid-hereafter < actual current Posixtime.
Lucid needs to FIX this as this is a potential BUG for Validity check with Deadline PosixTime.
Lucid should accomodate the current PosixTime in their code when actually submitting the transaction onchain
OR
Lucid should expose MINIMUM DELAY REQUIRED time that we need to add when doing transaction through LUCID.