Unable to broadcast transaction through insight api


(Vikash Yadav) #1

i am preforming a transaction using bitcore and insight api. here is my code

var bitcore=require(‘bitcore-lib’);
var explorers = require(‘bitcore-explorers’);
var transaction =new bitcore.Transaction();
var insight = new explorers.Insight();
var client = new explorers.Insight(‘https://test-insight.bitpay.com’,‘testnet’);
var serialized;
var testnetPrivateKey = new bitcore.PrivateKey(bitcore.Networks.testnet);
// test net address from private key
var address = testnetPrivateKey.toAddress();
client.getUnspentUtxos(‘muubTtynzh3K2oiR5h9CLznyCmKuMA3Vxd’, function(err, utxos) {

transaction.from(utxos)
    .to('mqs3dt36xR5t3pxW4n7CZF6uZAcDv3j4sY',1000) // sending 1000 statoshi to address 'mqs3dt36xR5t3pxW4n7CZF6uZAcDv3j4sY'
      .change(address)                             
        .sign('366c3af17e59041c45e28fd9ac37fc1ef02a3361bb9ca4905d919b0096c59a4f') // private key of muubTtynzh3K2oiR5h9CLznyCmKuMA3Vxd
        var txSerialized = transaction.serialize();
       insight.broadcast(txSerialized, function(err, returnedTxId) { // broadcasting tx
          if (err) {
            console.log(err);
          } else {
            console.log(returnedTxId);
          }
        });

});

i am getting error: Missing inputs. Code:-25

need help ! thanks in advance …