You are using insight which is the simple but less secure way because it uses a third party service, and it has nothing to do with your local bitcoin full node. You should start over by introducing bitcoind as a service to bitcore,
For this to happen you need to
1- Install a bitcore node,
2- Add bitcoind as service to this node,
3- Install bitcore-lib,
3- use extended methods and events that are now available to do what you want. e.g. getting balance for every address and generating / relaying a transaction for spending that balance.
Below I try to present a very simplified and basic approach to your inquiry. I hope it would help:
var bitcoreNode= require('bitcore-node');
var Bitcoin = bitcoreNode.services.Bitcoin;
var Node = bitcoreNode.Node;
var configuration = {
datadir: '/home/user/.bitcoin',
network: 'testnet',
services: [
{
name: 'bitcoind',
module: Bitcoin,
config: {
spawn: {
datadir: '/home//.bitcoin',
exec: '/home//bitcore-node/bin/bitcoind'
}
}
}
]
};
var node = new Node(configuration);
node.start(function() {
console.log('Bitcoin Node is starting ...');
});
node.on('ready', function() {
console.log('Bitcoin Node Ready');
});
node.on('error', function(Err) {
console.error(Err);
});
For example you can get total satoshi balance of an address by
var total= node.services.bitcoind.getAddressBalance(, false ) ;
var address =;
var UTXOs = node.services.bitcoind.getAddressUnspentOutputs(address, options);
var utx0= {"txId" : UTXOs[0].txId,
"outputIndex" : UTXOs[0].outputIndex,
"address" : UTXOs[0].address,
"script" : UTXOs[0].script,
"satoshis" : UTXOs[0].satoshi
};
// I deliberately wrote it foolishly to disclose the object content ;)
// checking last few blocks to use a proper fee:
var numberOfBlocks = 5;
var suggestedFee = node.services.bitcoind.estimateFee(numberOfBlocks);
var bitcore = require('bitcore-lib');
var privateKey = new bitcore.PrivateKey();
var transaction = new bitcore.Transaction()
.from(utxo)
.to(, suggestedFee )
.sign(privateKey);
var hashSent = node.services.bitcoind.sendTransaction(transaction.serialize());
console.log( "transaction sent:"+hash);
Jessica,
I have been in your situation many times and I know what a headache it is, but as of my experience, eventually you have to elaborate a
![Smiley](https://bitcointalk.org/Smileys/default/smiley.gif)