Problem in broadcasting transaction using insight API


(Vikash Yadav) #1

below 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
        serialized=transaction.toObject()
       insight.broadcast(transaction, function(err, returnedTxId) { // broadcasting tx
          if (err) {
            console.log(err);
          } else {
            console.log(returnedTxId);
          }
        });

});

iam getting this error:

Missing inputs. Code:-25