Bitcore not signing nlocktimetx correctly

I’m having issues creating an nlocktimetx - partictularly broadcasting this serialized tx after the transaction has been signed. This code very naively tries to sign the first utxo found by insight. I am unable to broadcast the signed transaction - every thing is giving me an error saying that the tx was either a double spend (not the case) or formatted incorrectly. The transaction is fully signed. I know this because the if(tx.isFullySigned()) predicate evalutes to true during the execution of this code. However if I try and broadcast this tx after the lock has expired the transaction is still invalid

function createNLockTimeTx(fromAddress, toAddress, lockExpirationDate, privateKey){
//var date = new Date(lockExpirationDate);
//30 min lock time for testing
var date = new Date(new Date().getTime() + 30*60000);
insight.getUnspentUtxos(fromAddress, function(err, utxos) {
if (err) {
throw err
} else {
console.log("From Address: " + fromAddress.toString())
console.log(“To Address: " + toAddress.toString())
for (i =0 ; i < utxos.length; i++ ) {
var amount = utxos[0].satoshis - txFee
var tx = new bitcore.Transaction().from(utxos).to(toAddress,amount).lockUntilDate(date).change(toAddress)
//legacy issues with bitcoin, have to have the sequence number set to less than 0xfffffff
tx.inputs[0].sequenceNumber = 0
console.log(“Tx fully signed: " + tx.isFullySigned())
console.log(“Tx verify: " + tx.verify())
//console.log(“Tx verifySignature: " + tx.verifySignature())

        if (tx.isFullySigned()) {
            $("#signedNLockTimeTxHeading").text("Signed nLockTimeTx: ")
        } else {
            $("#signedNLockTimeTx").val("You provided a private key that was incorrect. If you are sure this was the correct" +
            " key try giving the key in WIF format")




Does anyone see what I am doing incorrectly?

All seems right. Can you try to decode the raw transaction with bitcoin-cli? By decoding the serialized tx you could get some hits of what is the problem.

(bitcoin decoderawtransaction <hex>) or an online tool like ( or

Here is the example of a signed transaction I am creating - this is using the test network:


I am using to deserialize and verify the tx - which evalutes just fine on blockr. However when the lock time expires and it becomes a valid tx to push the network rejects it.

Note that the originating address is: mv8vxFPszZrWFLNErRL6DfUdEsehdvowKS

The lock time on that transaction expires in roughly 30 minutes.