ExBitcoin v0.4.0 ExBitcoin.Network View Source

Network related RPC

Link to this section Summary

Functions

addnode “node” “add|remove|onetry”

clearbanned

disconnectnode “[address]” [nodeid]

getaddednodeinfo ( “node” )

getconnectioncount

getnettotals

getnetworkinfo Returns an object containing various state info regarding P2P networking

getpeerinfo

listbanned

ping

setban “subnet” “add|remove” (bantime) (absolute)

setnetworkactive true|false

Link to this section Functions

Link to this function addnode(node, command) View Source
addnode(:"String.t", :"String.t") :: any()

addnode “node” “add|remove|onetry”

Attempts to add or remove a node from the addnode list. Or try a connection to a node once.

Arguments:

  1. “node” (string, required) The node (see getpeerinfo for nodes)
  2. “command” (string, required) ‘add’ to add a node to the list, ‘remove’ to remove a node from the list, ‘onetry’ to try a connection to the node once

Examples:

bitcoin-cli addnode “192.168.0.6:8333” “onetry” curl —user myusername —data-binary ‘{“jsonrpc”: “1.0”, “id”:”curltest”, “method”: “addnode”, “params”: [“192.168.0.6:8333”, “onetry”] }’ -H ‘content-type: text/plain;’ http://127.0.0.1:8332/

Link to this function clearbanned() View Source
clearbanned() :: any()

clearbanned

Clear all banned IPs.

Examples:

bitcoin-cli clearbanned curl —user myusername —data-binary ‘{“jsonrpc”: “1.0”, “id”:”curltest”, “method”: “clearbanned”, “params”: [] }’ -H ‘content-type: text/plain;’ http://127.0.0.1:8332/

Link to this function disconnectnode(address, nodeid) View Source
disconnectnode(:"String.t", :"String.t") :: any()

disconnectnode “[address]” [nodeid]

Immediately disconnects from the specified peer node.

Strictly one out of ‘address’ and ‘nodeid’ can be provided to identify the node.

To disconnect by nodeid, either set ‘address’ to the empty string, or call using the named ‘nodeid’ argument only.

Arguments:

  1. “address” (string, optional) The IP address/port of the node
  2. “nodeid” (number, optional) The node ID (see getpeerinfo for node IDs)

Examples:

bitcoin-cli disconnectnode “192.168.0.6:8333” bitcoin-cli disconnectnode “” 1 curl —user myusername —data-binary ‘{“jsonrpc”: “1.0”, “id”:”curltest”, “method”: “disconnectnode”, “params”: [“192.168.0.6:8333”] }’ -H ‘content-type: text/plain;’ http://127.0.0.1:8332/ curl —user myusername —data-binary ‘{“jsonrpc”: “1.0”, “id”:”curltest”, “method”: “disconnectnode”, “params”: [“”, 1] }’ -H ‘content-type: text/plain;’ http://127.0.0.1:8332/

Link to this function getaddednodeinfo(node) View Source
getaddednodeinfo(:"String.t") :: any()

getaddednodeinfo ( “node” )

Returns information about the given added node, or all added nodes (note that onetry addnodes are not listed here)

Arguments:

  1. “node” (string, optional) If provided, return information about this specific node, otherwise all nodes are returned.

Result: [ {

"addednode" : "192.168.0.201",   (string) The node IP address or name (as provided to addnode)
"connected" : true|false,          (boolean) If connected
"addresses" : [                    (list of objects) Only when connected = true
   {
     "address" : "192.168.0.201:8333",  (string) The bitcoin server IP and port we're connected to
     "connected" : "outbound"           (string) connection, inbound or outbound
   }
 ]

} ,… ]

Examples:

bitcoin-cli getaddednodeinfo “192.168.0.201” curl —user myusername —data-binary ‘{“jsonrpc”: “1.0”, “id”:”curltest”, “method”: “getaddednodeinfo”, “params”: [“192.168.0.201”] }’ -H ‘content-type: text/plain;’ http://127.0.0.1:8332/

Link to this function getconnectioncount() View Source
getconnectioncount() :: any()

getconnectioncount

Returns the number of connections to other nodes.

Result: n (numeric) The connection count

Examples:

bitcoin-cli getconnectioncount curl —user myusername —data-binary ‘{“jsonrpc”: “1.0”, “id”:”curltest”, “method”: “getconnectioncount”, “params”: [] }’ -H ‘content-type: text/plain;’ http://127.0.0.1:8332/

Link to this function getnettotals() View Source
getnettotals() :: any()

getnettotals

Returns information about network traffic, including bytes in, bytes out, and current time.

Result: { “totalbytesrecv”: n, (numeric) Total bytes received “totalbytessent”: n, (numeric) Total bytes sent “timemillis”: t, (numeric) Current UNIX time in milliseconds “uploadtarget”: {

"timeframe": n,                         (numeric) Length of the measuring timeframe in seconds
"target": n,                            (numeric) Target in bytes
"target_reached": true|false,           (boolean) True if target is reached
"serve_historical_blocks": true|false,  (boolean) True if serving historical blocks
"bytes_left_in_cycle": t,               (numeric) Bytes left in current time cycle
"time_left_in_cycle": t                 (numeric) Seconds left in current time cycle

} }

Examples:

bitcoin-cli getnettotals curl —user myusername —data-binary ‘{“jsonrpc”: “1.0”, “id”:”curltest”, “method”: “getnettotals”, “params”: [] }’ -H ‘content-type: text/plain;’ http://127.0.0.1:8332/

Link to this function getnetworkinfo() View Source
getnetworkinfo() :: any()

getnetworkinfo Returns an object containing various state info regarding P2P networking.

Result: { “version”: xxxxx, (numeric) the server version “subversion”: “/Satoshi:x.x.x/“, (string) the server subversion string “protocolversion”: xxxxx, (numeric) the protocol version “localservices”: “xxxxxxxxxxxxxxxx”, (string) the services we offer to the network “localrelay”: true|false, (bool) true if transaction relay is requested from peers “timeoffset”: xxxxx, (numeric) the time offset “connections”: xxxxx, (numeric) the number of connections “networkactive”: true|false, (bool) whether p2p networking is enabled “networks”: [ (array) information per network {

"name": "xxx",                     (string) network (ipv4, ipv6 or onion)
"limited": true|false,               (boolean) is the network limited using -onlynet?
"reachable": true|false,             (boolean) is the network reachable?
"proxy": "host:port"               (string) the proxy that is used for this network, or empty if none
"proxy_randomize_credentials": true|false,  (string) Whether randomized credentials are used

} ,… ], “relayfee”: x.xxxxxxxx, (numeric) minimum relay fee for transactions in BTC/kB “incrementalfee”: x.xxxxxxxx, (numeric) minimum fee increment for mempool limiting or BIP 125 replacement in BTC/kB “localaddresses”: [ (array) list of local addresses {

"address": "xxxx",                 (string) network address
"port": xxx,                         (numeric) network port
"score": xxx                         (numeric) relative score

} ,… ] “warnings”: “…” (string) any network warnings }

Examples:

bitcoin-cli getnetworkinfo curl —user myusername —data-binary ‘{“jsonrpc”: “1.0”, “id”:”curltest”, “method”: “getnetworkinfo”, “params”: [] }’ -H ‘content-type: text/plain;’ http://127.0.0.1:8332/

Link to this function getpeerinfo() View Source
getpeerinfo() :: any()

getpeerinfo

Returns data about each connected network node as a json array of objects.

Result: [ {

"id": n,                   (numeric) Peer index
"addr":"host:port",      (string) The IP address and port of the peer
"addrbind":"ip:port",    (string) Bind address of the connection to the peer
"addrlocal":"ip:port",   (string) Local address as reported by the peer
"services":"xxxxxxxxxxxxxxxx",   (string) The services offered
"relaytxes":true|false,    (boolean) Whether peer has asked us to relay transactions to it
"lastsend": ttt,           (numeric) The time in seconds since epoch (Jan 1 1970 GMT) of the last send
"lastrecv": ttt,           (numeric) The time in seconds since epoch (Jan 1 1970 GMT) of the last receive
"bytessent": n,            (numeric) The total bytes sent
"bytesrecv": n,            (numeric) The total bytes received
"conntime": ttt,           (numeric) The connection time in seconds since epoch (Jan 1 1970 GMT)
"timeoffset": ttt,         (numeric) The time offset in seconds
"pingtime": n,             (numeric) ping time (if available)
"minping": n,              (numeric) minimum observed ping time (if any at all)
"pingwait": n,             (numeric) ping wait (if non-zero)
"version": v,              (numeric) The peer version, such as 7001
"subver": "/Satoshi:0.8.5/",  (string) The string version
"inbound": true|false,     (boolean) Inbound (true) or Outbound (false)
"addnode": true|false,     (boolean) Whether connection was due to addnode and is using an addnode slot
"startingheight": n,       (numeric) The starting height (block) of the peer
"banscore": n,             (numeric) The ban score
"synced_headers": n,       (numeric) The last header we have in common with this peer
"synced_blocks": n,        (numeric) The last block we have in common with this peer
"inflight": [
   n,                        (numeric) The heights of blocks we're currently asking from this peer
   ...
],
"whitelisted": true|false, (boolean) Whether the peer is whitelisted
"bytessent_per_msg": {
   "addr": n,              (numeric) The total bytes sent aggregated by message type
   ...
},
"bytesrecv_per_msg": {
   "addr": n,              (numeric) The total bytes received aggregated by message type
   ...
}

} ,… ]

Examples:

bitcoin-cli getpeerinfo curl —user myusername —data-binary ‘{“jsonrpc”: “1.0”, “id”:”curltest”, “method”: “getpeerinfo”, “params”: [] }’ -H ‘content-type: text/plain;’ http://127.0.0.1:8332/

Link to this function listbanned() View Source
listbanned() :: any()

listbanned

List all banned IPs/Subnets.

Examples:

bitcoin-cli listbanned curl —user myusername —data-binary ‘{“jsonrpc”: “1.0”, “id”:”curltest”, “method”: “listbanned”, “params”: [] }’ -H ‘content-type: text/plain;’ http://127.0.0.1:8332/

ping

Requests that a ping be sent to all other nodes, to measure ping time. Results provided in getpeerinfo, pingtime and pingwait fields are decimal seconds. Ping command is handled in queue with all other commands, so it measures processing backlog, not just network ping.

Examples:

bitcoin-cli ping curl —user myusername —data-binary ‘{“jsonrpc”: “1.0”, “id”:”curltest”, “method”: “ping”, “params”: [] }’ -H ‘content-type: text/plain;’ http://127.0.0.1:8332/

Link to this function setban(subnet, command, bantime, absolute) View Source
setban(:"String.t", :"String.t", :"String.t", :"String.t") :: any()

setban “subnet” “add|remove” (bantime) (absolute)

Attempts to add or remove an IP/Subnet from the banned list.

Arguments:

  1. “subnet” (string, required) The IP/Subnet (see getpeerinfo for nodes IP) with an optional netmask (default is /32 = single IP)
  2. “command” (string, required) ‘add’ to add an IP/Subnet to the list, ‘remove’ to remove an IP/Subnet from the list
  3. “bantime” (numeric, optional) time in seconds how long (or until when if [absolute] is set) the IP is banned (0 or empty means using the default time of 24h which can also be overwritten by the -bantime startup argument)
  4. “absolute” (boolean, optional) If set, the bantime must be an absolute timestamp in seconds since epoch (Jan 1 1970 GMT)

Examples:

bitcoin-cli setban “192.168.0.6” “add” 86400 bitcoin-cli setban “192.168.0.0/24” “add” curl —user myusername —data-binary ‘{“jsonrpc”: “1.0”, “id”:”curltest”, “method”: “setban”, “params”: [“192.168.0.6”, “add”, 86400] }’ -H ‘content-type: text/plain;’ http://127.0.0.1:8332/

Link to this function setnetworkactive(state) View Source
setnetworkactive(:"String.t") :: any()

setnetworkactive true|false

Disable/enable all p2p network activity.

Arguments:

  1. “state” (boolean, required) true to enable networking, false to disable