I am using bitcore-lib to create transactions. I can add an output with CLTV to the transaction but am unable to add an output address to it. This is my code (typescript/node):
const lockScript = Script.empty()
.add(blockAsBuffer)
.add(177) // OP_CLTV
.add(117) // OP_DROP
.add(Script.buildPublicKeyHashOut(this.privateKeyAddress));
const transaction = new Transaction();
transaction.from(unspentOutputs);
// Following is where I'm adding the CLTV but can't add an output address
transaction.addOutput(new Transaction.Output({
script: lockScript,
satoshis: satoshisToLock
}));
transaction.change(this.privateKeyAddress);
transaction.fee(feeInSatoshis);
transaction.sign(this.privateKey);
With the above code, the transaction-output is something like the following. Note that there's no address attached to the CLTV output. Is there a way to add an address to that output using the bitcore-lib (or any other javascript lib)?
...
{
"value": 0.00001,
"n": 2,
"scriptPubKey": {
"asm": "1658883 OP_CHECKLOCKTIMEVERIFY OP_DROP OP_DUP OP_HASH160 89605b86b7ad185ebc10fe457b98776838972cf0 OP_EQUALVERIFY OP_CHECKSIG",
"hex": "0403501900b17576a91489605b86b7ad185ebc10fe457b98776838972cf088ac",
"type": "nonstandard"
}
},
...
In case you are curious as to why do I want to do this, see the previous question that I had asked: Using CLTV can I freeze some funds from a wallet, and make them available, in a single transaction?