bitcoin-cli Network Commands

This section describes how to use 'bitcoin-cli getclock' command.

Once I have my Bitcoin Core Daemon running on the Bitcoin test network, the most important commands to learn are "bitcoin-cli" network commands which allows you see the Bitcoin network and control your connection to the network.

1. Run Bitcoin Core Daemon on the test network in a command window.

C:\>\local\bitcoin-0.15.1\bin\bitcoind -testnet

2. Run Bitcoin Core CLI in another command window and check the uptime:

C:\>\local\bitcoin-0.15.1\bin\bitcoin-cli -testnet uptime

3. Get the height of the blockchain maintained by the network.

C:\>\local\bitcoin-0.15.1\bin\bitcoin-cli -testnet getchaintips
  "height": 1029998,
  "hash": "00000000000121674d133d45b91941c6168b4c19d32f529432a4c184174d0b86",
  "branchlen": 1029998,
  "status": "headers-only"
  "height": 0,
  "hash": "000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943",
  "branchlen": 0,
  "status": "active"

4. Get the number of blocks that have been synchronized on my local Bitcoin Core Daemon so far.

C:\>\local\bitcoin-0.15.1\bin\bitcoin-cli -testnet getblockcount

C:\>\local\bitcoin-0.15.1\bin\bitcoin-cli -testnet getblockcount

5. Get the number of peers that I am currently connected to:

C:\>\local\bitcoin-0.15.1\bin\bitcoin-cli -testnet getconnectioncount

6. Get connection details with my peers.

C:\>\local\bitcoin-0.15.1\bin\bitcoin-cli -testnet getpeerinfo
    "id": 15,
    "addr": "",
    "addrlocal": "yy.yy.yy.yy:59934",
    "addrbind": "zz.zz.zz.zz:59934",
    "services": "000000000000000d",
    "relaytxes": true,
    "lastsend": 1518359089,
    "lastrecv": 1518359090,
    "bytessent": 2351,
    "bytesrecv": 479395,
    "conntime": 1518359084,
    "id": 17,
    "addr": "nn.nn.nn.nn:18333",
    "addrlocal": "yy.yy.yy.yy:59936",
    "addrbind": "zz.zz.zz.zz:59936",
    "services": "000000000000000d",
    "relaytxes": true,
    "lastsend": 1518359088,
    "lastrecv": 1518359088,
    "bytessent": 2046,
    "bytesrecv": 1582,
    "conntime": 1518359086,

7. Stop connections to the network. I can resume it later with "setnetworkactive true".

C:\>\local\bitcoin-0.15.1\bin\bitcoin-cli -testnet setnetworkactive false

Last update: 2017.

Table of Contents

 About This Book

 Introduction of Bitcoin

 Bitcoin Blockchain

 Bitcoin Wallet

Bitcoin Core

 Bitcoin Core Programs

 Bitcoin Core Daemon

 Bitcoin Core CLI

 Bitcoin Core CLI Commands

 Access Bitcoin Test Network "-testnet"

bitcoin-cli Network Commands

 "bitcoin-cli getclock" Command

 bitcoin-cli Transaction Commands

 bitcoin-cli Wallet Commands

 "bitcoin-cli encryptwallet" - Set Wallet Password

 "bitcoin-cli walletpassphrase" - Unlock Wallet

 "bitcoin-cli backupwallet" - Backup Wallet

 Bitcoin Transaction

 Bitcoin-Qt - Bitcoin Core GUI

 Bitcoin Mining

 Bitcoin Consensus Rules

 Bitcoin Block Data Structure

 Bitcoin Transaction Data Structure API

 Copay - Bitcoin Wallet


 PDF Printing Version