Transaction script based on github code


(Makka) #1

Based on the code on github I tried to make a tx with a custom script.
The code is the following

var toAddress = 'mrU9pEmAx26HcbKVrABvgL7AwA5fjNFoDc';
var fromAddress = 'mszYqVnqKoQx4jcTdJXxwKAissE3Jbrrc1';
var simpleUtxoWith100000Satoshis = {
  address: fromAddress,
  txId: 'a477af6b2667c29670467e4e0728b685ee07b240235771862318e29ddbe58458',
  outputIndex: 0,
  script: bitcore.Script.buildPublicKeyHashOut(fromAddress).toString(),
  satoshis: 100000
};

var anyoneCanSpendUTXO = JSON.parse(JSON.stringify(simpleUtxoWith100000Satoshis));
anyoneCanSpendUTXO.script = new bitcore.Script().add('OP_TRUE');
var transaction = new  bitcore.Transaction().from(anyoneCanSpendUTXO).to(toAddress, 50000);
console.log(transaction)

debugging the output, I see that OP_TRUE is not included as a script. I used this tool to verify that.
Any ideas why?