Develop Bitcoin Wallet with bitcore


This time, Let's create a Bitcoin wallet using the bitcore library. This article will confirm for the basic operation(receive and send of bitcoin) that will be needed. By the way, You will use the main net to implement the network. If you don't want to implementation on main net, please use test net.

Setting of module

You will use the bitcoin-lib module to create private key, and the bitcore-explorers module to check the information of UTXO.

npm install bitcore-lib
npm install bitcore-explorers

Generate private key and address

It reads the module and generates the private key and Bitcoin address.

let bitcore = require('bitcore-lib');
let privateKey = new bitcore.PrivateKey();
let address = privateKey.toAddress();


Check TXID and Balance

By checking the UTXO associated with the address you can check the balance.
A vout is an index number for an output in a transaction.

let explorers  = require('bitcore-explorers');
let insight = new explorers.Insight();

insight.getUnspentUtxos(address, (err,utxos)=>{
        console.log('UTXO processing error')
        let balance =>{
                vout: v.outputIndex,
                btc: v.satoshis * 1e-8,

Send your coin

You need to create a transaction when perform coin transfer processing. The transaction include that fee, Unspent Transaction Output, destination address, sent amount, receive address of change and private key.After creating the transaction, it broadcasting to the network.

let Transaction = bitcore.Transaction;
let sendAddress = "destination address";
let changeAddress = "receive address of change";
let sendAmout = Math.floor(parseFloat("send amout")*100000000);
let fee = parseFloat(1000);

insight.getUnspentUtxos(changeAddress, (err, utxos)=>{
        console.log('Bitcoin network connection error');
        let transaction = new Transaction()
        .to(sendAddress, sendAmout)

        insight.broadcast(transaction, (err, returnedTxId)=>{

The below's screen is actually state of send on the main network.
Since remittance process was successful, TXID(534a6f290...) is displayed.
※Please don't use ”privateKey(d1c88f9a...)” and "changeAddress(1G18w9uHE1m...)" displayed on the screen in consideration of security. The fund based on this private key is 0.

By checking the TXID at the time of remittance, you can check whether the process was really successful.

The complete code is released to Github.