I have coded NodeJS script for bitcoin for send all balance from by address to some other one. Now I want to do this for the litecoin. For bitcoin I have used bitcore-lib and bitcore-explorers libs to do that.

For litecoin I have found forked and adopted lib litecore-lib, but I can't found solution to receive UTXO data for some LTC address like I do it in case of bitcoin:

var Insight = require("bitcore-explorers").Insight;
var insight = new Insight(network);
insight.getUnspentUtxos(sourceAddress, function (error, utxos) {
    // determine balance, fee and sign transaction

How can I do this for litecoin? Thanks!

3 Answers 3


I used the request library to manually retrieve information from the insight API. I also used the litecore-lib library to create the transaction.

var Litecoin = require("litecore-lib");
var request = require("request");

//manually hit an insight api to retrieve utxos of address
function getUTXOs(address) {
  return new Promise((resolve, reject) => {
      uri: 'https://insight.litecore.io/api/addr/' + address + '/utxo',
      json: true
      (error, response, body) => {
        if(error) reject(error);

//manually hit an insight api to broadcast your tx
function broadcastTX(rawtx) {
  return new Promise((resolve, reject) => {
      uri: 'https://insight.litecore.io/tx/send',
      method: 'POST',
      json: {
      (error, response, body) => {
        if(error) reject(error);

//your private key and address here
var privateKey = PrivateKey.fromWIF('YOUR_PRIVATE_KEY_HERE');
var address = privateKey.toPublicKey().toAddress();

  .then((utxos) => {

    let balance = 0;
    for (var i = 0; i < utxos.length; i++) {
      balance +=utxos[i]['satoshis'];
    } //add up the balance in satoshi format from all utxos

    var fee = 1500; //fee for the tx
    var tx = new Litecoin.Transaction() //use litecore-lib to create a transaction
      .to('TO_ADDRESS', balance - fee) //note: you are sending all your balance AKA sweeping

    return broadcastTX(tx) //broadcast the serialized tx
  .then((result) => {
    console.log(result) // txid
  .catch((error) => {
    throw error;



You can use https://github.com/litecoin-project/litecore-explorers like this:

var explorers = require('bitcore-explorers');
var insight = new explorers.Insight(https://insight.litecore.io', 'mainnet');

insight.getUtxos('mgBmKKZEkK...', function(err, utxos) {
  if (err) {
    // Handle errors...
  } else {
    // Do something with utxos

Here is the module what you may require https://www.npmjs.com/package/litecore-explorers

  • This package is the result of my attempts to adopt bitcore-explorers package for litecoin, so it doesn't work! Don't try to use it! May 24, 2018 at 7:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.