Package 'rbtc'

Title: Bitcoin API
Description: Implementation of the RPC-JSON API for Bitcoin and utility functions for address creation and content analysis of the blockchain.
Authors: Bernhard Pfaff [aut, cre]
Maintainer: Bernhard Pfaff <[email protected]>
License: GPL-3
Version: 0.1-7
Built: 2024-11-20 03:34:06 UTC
Source: https://github.com/cran/rbtc

Help Index


RPC-JSON API: addnode

Description

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

Usage

addnode(con, node, command = c("add", "remove", "onetry"))

Arguments

con

object of class CONRPC.

node

character the node (see getpeerinfo() for nodes).

command

character '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.

Value

A S4-object of class ANSRPC.

Author(s)

Bernhard Pfaff

References

https://bitcoin.org/en/developer-reference#addnode, https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs

See Also

Other Network RPCs: clearbanned, disconnectnode, getaddednodeinfo, getconnectioncount, getnettotals, getnetworkinfo, getpeerinfo, listbanned, ping, setnetworkactive


The ANSRPC class

Description

This class definition is employed to cast the JSON-objects returned by API-calls to bitcoind.

Slots

rpcname

character the name of the API.

result

ANY the output/result of the API.

ecode

NullOrInteger the error code, in case of no error NULL.

emessage

NullOrIntegerCharacter the error message, in case of no error NULL.

id

character identifier to API-call.

See Also

Other bitcoind functions: CONRPC-class, NullOrCharacter-class, NullOrInteger-class, conrpc, rpcpost, startbtc, stopbtc


Base 58 binary-to-text-decoding

Description

This is a modified binary-to-text decoding used for decoding Bitcoin addresses, aka Base58Check. If this is applied to a WIF address and the first and last four bytes are dropped, the result is the corresponding private key.

Usage

base58CheckDecode(x)

Arguments

x

character, string in hex format.

Value

list, the decoded elements of the string.

Author(s)

Bernhard Pfaff

References

https://en.bitcoin.it/wiki/Wallet_import_format,
https://en.bitcoin.it/wiki/Address,
https://en.bitcoin.it/wiki/Base58Check_encoding

See Also

Other BtcAdresses: BTCADR-class, PrivKey2PubKey, PrivKey2Wif, PubHash2BtcAdr, PubKey2PubHash, Wif2PrivKey, base58CheckEncode, concatHex, createBtcAdr, createPrivateKey, decodeHex, hash160, hash256, validBtcAdr


Base 58 binary-to-text-encoding

Description

This is a modified binary-to-text encoding used for encoding Bitcoin addresses, aka Base58Check. If this is applied to an extended private key with its trailing check sum, then the result is the Wallet Import Format, (WIF).

Usage

base58CheckEncode(x)

Arguments

x

character, string in hex format.

Value

character, the encoded string.

Author(s)

Bernhard Pfaff

References

https://en.bitcoin.it/wiki/Wallet_import_format,
https://en.bitcoin.it/wiki/Address,
https://en.bitcoin.it/wiki/Base58Check_encoding

See Also

Other BtcAdresses: BTCADR-class, PrivKey2PubKey, PrivKey2Wif, PubHash2BtcAdr, PubKey2PubHash, Wif2PrivKey, base58CheckDecode, concatHex, createBtcAdr, createPrivateKey, decodeHex, hash160, hash256, validBtcAdr


Compute fee in a block

Description

This function returns the fee of the coinbase transaction. Hereby, the mining reward has been deducted. Initially, the mining reward was 50 BTC and is halved every 210,000 blocks.

Usage

bkfee(con, height)

Arguments

con

CONRPC, configuration object.

height

integer, the height of the block.

Value

numeric

Author(s)

Bernhard Pfaff

See Also

Other UtilityFuncs: blockattime, blockstats, date2int, int2date, intMaxDay, intMinDay, intRangeDay, intRangePeriod, timeofblock, txfee, txids, txinids, txstats, utxoage, utxotype, utxovalue


Block height at time

Description

This function returns the block heights closest to a provided date/time (time zone is GMT).

Usage

blockattime(con, targetdate)

Arguments

con

CONRPC, configuration object.

targetdate

POSIXct, the date/time of closest block heights.

Value

data.frame: the heights, the times and the time differences (in minutes) to the provided date/time.

Author(s)

Bernhard Pfaff

See Also

Other UtilityFuncs: bkfee, blockstats, date2int, int2date, intMaxDay, intMinDay, intRangeDay, intRangePeriod, timeofblock, txfee, txids, txinids, txstats, utxoage, utxotype, utxovalue


Obtaining statistics of a block

Description

This function returns key statistics of a block's content, such as the time, the count of transactions, and summary statistics of the UTXOs.

Usage

blockstats(con, height, excoinbase = TRUE)

Arguments

con

CONRPC, configuration object.

height

integer, the block's height.

excoinbase

logical, whether coinbase transaction should be excluded (default is TRUE).

Value

An object of class data.frame

Author(s)

Bernhard Pfaff

See Also

Other UtilityFuncs: bkfee, blockattime, date2int, int2date, intMaxDay, intMinDay, intRangeDay, intRangePeriod, timeofblock, txfee, txids, txinids, txstats, utxoage, utxotype, utxovalue


S4 class BTCADR

Description

S4-class for BTC addresses, ordinarily created by a call to createBtcAdr().

Slots

privkey

character, the private key.

wif

character, the WIF.

pubkey

character, the 512-bit public key.

pubhash

character, the hashed public key.

btcadr

character, the BTC address.

mainnet

logical, whether mainnet or testnet.

Author(s)

Bernhard Pfaff

References

https://en.bitcoin.it/wiki/Address

See Also

Other BtcAdresses: PrivKey2PubKey, PrivKey2Wif, PubHash2BtcAdr, PubKey2PubHash, Wif2PrivKey, base58CheckDecode, base58CheckEncode, concatHex, createBtcAdr, createPrivateKey, decodeHex, hash160, hash256, validBtcAdr


RPC-JSON API: clearbanned

Description

Clear all banned IPs.

Usage

clearbanned(con)

Arguments

con

object of class CONRPC.

Value

A S4-object of class ANSRPC.

Author(s)

Bernhard Pfaff

References

https://bitcoin.org/en/developer-reference#clearbanned, https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs

See Also

Other Network RPCs: addnode, disconnectnode, getaddednodeinfo, getconnectioncount, getnettotals, getnetworkinfo, getpeerinfo, listbanned, ping, setnetworkactive


Concatenate two hex strings

Description

This function concatenates two hex strings, provided without the 0x prefix, and returns a list object of the associated integers.

Usage

concatHex(hex1, hex2)

Arguments

hex1

character, a hex string.

hex2

character, a hex string.

Value

list

Author(s)

Bernhard Pfaff

References

https://en.bitcoin.it/wiki/Wallet_import_format,
https://en.bitcoin.it/wiki/Address

See Also

Other BtcAdresses: BTCADR-class, PrivKey2PubKey, PrivKey2Wif, PubHash2BtcAdr, PubKey2PubHash, Wif2PrivKey, base58CheckDecode, base58CheckEncode, createBtcAdr, createPrivateKey, decodeHex, hash160, hash256, validBtcAdr

Examples

suppressWarnings(RNGversion("3.5.0"))
h1 <- "80"
h2 <- createPrivateKey()
concatHex(h1, h2)

Extracting Configuration Settings

Description

This function extracts information from the configuration file bitcoin.conf with respect to the options rpcuser and rpcpassword.

Usage

conrpc(conf.file)

Arguments

conf.file

character, the fully qualified path.

Value

An S4-object of class CONRPC.

Author(s)

Bernhard Pfaff

See Also

Other bitcoind functions: ANSRPC-class, CONRPC-class, NullOrCharacter-class, NullOrInteger-class, rpcpost, startbtc, stopbtc


The CONRPC class

Description

S4-class for curl connections to RPC-JSON.

Details

The slots rpcuse and rpcpwd are required in the call to curl. Furthermore, the fully qualified path to bitcoin.conf (slot config) is required for starting and stopping bitcoind as daemon.

See Also

Other bitcoind functions: ANSRPC-class, NullOrCharacter-class, NullOrInteger-class, conrpc, rpcpost, startbtc, stopbtc


containsPoint-methods

Description

Checks whether a point is on a defined ellipctic curve.

Usage

containsPoint(curve, x, y)

## S4 method for signature 'ECPARAM,bigz,bigz'
containsPoint(curve, x, y)

## S4 method for signature 'ECPARAM,integer,integer'
containsPoint(curve, x, y)

## S4 method for signature 'ECPARAM,character,character'
containsPoint(curve, x, y)

Arguments

curve

an S4-object of class ECPARAM.

x

an S4-object of class bigz, the x-coordinate.

y

an S4-object of class bigz, the y-coordinate.

Value

logical

Author(s)

Bernhard Pfaff

References

https://en.bitcoin.it/wiki/Secp256k1

See Also

Other EllipticCurve: ECPARAM-class, ECPOINT-class, EcparamOrNull-class, ecoperators, ecparam, ecpoint, isNull

Examples

p <- "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F"
b <- "0x0000000000000000000000000000000000000000000000000000000000000007"
a <- "0x0000000000000000000000000000000000000000000000000000000000000000"
curve256 <- ecparam(p, a, b)
Gx <- "0x79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798"
Gy <- "0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"
containsPoint(curve256, Gx, Gy)

Create BTC addresses

Description

This function creates an object of S4-class BTCADR.

Usage

createBtcAdr(privkey, mainnet = TRUE)

Arguments

privkey

character, a private key.

mainnet

logical, for which net the keys should belong to.

Value

Object of S4-class BTCADR

Author(s)

Bernhard Pfaff

References

https://en.bitcoin.it/wiki/Address

See Also

Other BtcAdresses: BTCADR-class, PrivKey2PubKey, PrivKey2Wif, PubHash2BtcAdr, PubKey2PubHash, Wif2PrivKey, base58CheckDecode, base58CheckEncode, concatHex, createPrivateKey, decodeHex, hash160, hash256, validBtcAdr


Creation of a private key

Description

Returns a random 256-bit private key in hex notation.

Usage

createPrivateKey()

Value

character.

Author(s)

Bernhard Pfaff

References

https://en.bitcoin.it/wiki/Wallet_import_format,
https://en.bitcoin.it/wiki/Address

See Also

Other BtcAdresses: BTCADR-class, PrivKey2PubKey, PrivKey2Wif, PubHash2BtcAdr, PubKey2PubHash, Wif2PrivKey, base58CheckDecode, base58CheckEncode, concatHex, createBtcAdr, decodeHex, hash160, hash256, validBtcAdr

Examples

suppressWarnings(RNGversion("3.5.0"))
createPrivateKey()

Convert date/time to integer

Description

This function returns the associated integer time for a given date/time object (coercible as POSIXct object.

Usage

date2int(x)

Arguments

x

POSIXct, date/time object.

Value

integer

Author(s)

Bernhard Pfaff

See Also

Other UtilityFuncs: bkfee, blockattime, blockstats, int2date, intMaxDay, intMinDay, intRangeDay, intRangePeriod, timeofblock, txfee, txids, txinids, txstats, utxoage, utxotype, utxovalue

Examples

d <- "2017-03-15"
date2int(d)

Decoding of a hex string

Description

This function converts a hex string,, whereby the string must not contain the 0x prefix, to a list object with the associated integers as its elements.

Usage

decodeHex(s)

Arguments

s

character, the hex string.

Value

list

Author(s)

Bernhard Pfaff

References

https://en.bitcoin.it/wiki/Wallet_import_format,
https://en.bitcoin.it/wiki/Address

See Also

Other BtcAdresses: BTCADR-class, PrivKey2PubKey, PrivKey2Wif, PubHash2BtcAdr, PubKey2PubHash, Wif2PrivKey, base58CheckDecode, base58CheckEncode, concatHex, createBtcAdr, createPrivateKey, hash160, hash256, validBtcAdr

Examples

suppressWarnings(RNGversion("3.5.0"))
pk <- createPrivateKey()
decodeHex(pk)

RPC-JSON API: decoderawtransaction

Description

Return a JSON object representing the serialized, hex-encoded transaction.

Usage

decoderawtransaction(con, hexstring)

Arguments

con

object of class CONRPC.

hexstring

character, the transaction hex string.

Value

A S4-object of class ANSRPC.

Author(s)

Bernhard Pfaff

References

https://bitcoin.org/en/developer-reference#getblock, https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs

See Also

Other RawTransactions RPCs: getrawtransaction


RPC-JSON API: decodescript

Description

The decodescript RPC decodes a hex-encoded P2SH redeem script.

Usage

decodescript(con, redeem)

Arguments

con

object of class CONRPC.

redeem

character, the P2SH.

Value

A S4-object of class ANSRPC.

Author(s)

Bernhard Pfaff

References

https://bitcoin.org/en/developer-reference#decodescript, https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs

See Also

Other Blockchain RPCs: getbestblockhash, getblockchaininfo, getblockcount, getblockhash, getblockheader, getblock, getchaintips, getchaintxstats, getdifficulty, getmempoolancestors, getmempooldescendants, getmempoolentry, getmempoolinfo, getrawmempool, gettxoutproof, gettxoutsetinfo, gettxout, preciousblock, pruneblockchain, verifychain, verifytxoutproof


RPC-JSON API: disconnectnode

Description

Immediately disconnects from the specified peer node. Strictly one out of address and nodeid can be provided to identify the node.

Usage

disconnectnode(con, address = NULL, nodeid = NULL)

Arguments

con

object of class CONRPC.

address

character the IP address/port of the node.

nodeid

character The node ID (see getpeerinfo() for node IDs).

Value

A S4-object of class ANSRPC.

Author(s)

Bernhard Pfaff

References

https://bitcoin.org/en/developer-reference#disconnectnode, https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs

See Also

Other Network RPCs: addnode, clearbanned, getaddednodeinfo, getconnectioncount, getnettotals, getnetworkinfo, getpeerinfo, listbanned, ping, setnetworkactive


Elliptic curve operators

Description

The following operarations for EC points are available:

doubleUp

multiplying a point by itself

+

point addition

leftmostBit

highest bit value of an integer

AND

logical and-operator for two integers

*

multiplication of an integer scalar with an EC point

Usage

doubleUp(ecp)

## S4 method for signature 'ECPOINT'
doubleUp(ecp)

## S4 method for signature 'ECPOINT,ECPOINT'
e1 + e2

leftmostBit(x)

## S4 method for signature 'bigz'
leftmostBit(x)

AND(x, y)

## S4 method for signature 'bigz,bigz'
AND(x, y)

## S4 method for signature 'ECPOINT,bigz'
e1 * e2

## S4 method for signature 'bigz,ECPOINT'
e1 * e2

Arguments

ecp

point on elliptic curve

e1

point on elliptic curve, or integer

e2

point on elliptic curve, or integer

x

integer

y

integer

Author(s)

Bernhard Pfaff

References

https://en.bitcoin.it/wiki/Secp256k1

See Also

Other EllipticCurve: ECPARAM-class, ECPOINT-class, EcparamOrNull-class, containsPoint, ecparam, ecpoint, isNull


Creating objects of class ECPARAM

Description

This function returns an object of S4-class ECPARAM, that does contain the parametrization of an elliptic curve.

Usage

ecparam(p, a, b)

Arguments

p

integer

a

integer

b

integer

Value

An object of S4-class ECPARAM

Author(s)

Bernhard Pfaff

References

https://en.bitcoin.it/wiki/Secp256k1

See Also

Other EllipticCurve: ECPARAM-class, ECPOINT-class, EcparamOrNull-class, containsPoint, ecoperators, ecpoint, isNull

Examples

p <- "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F"
b <- "0x0000000000000000000000000000000000000000000000000000000000000007"
a <- "0x0000000000000000000000000000000000000000000000000000000000000000"
curve256 <- ecparam(p, a, b)
curve256

The ECPARAM class

Description

S4-class for elliptic curve parameters. Objects of this class do contain the big integer parameters of elliptic curves. Instances of this class are ordinarily created by a call to exparam

Slots

p

bigz, curve dimension.

a

bigz, parameter.

b

bigz, parameter.

Author(s)

Bernhard Pfaff

References

https://en.bitcoin.it/wiki/Secp256k1

See Also

Other EllipticCurve: ECPOINT-class, EcparamOrNull-class, containsPoint, ecoperators, ecparam, ecpoint, isNull


S4 Class Union ECPARAM or NULL

Description

S4-class union of NULL or ECPARAM.

Author(s)

Bernhard Pfaff

References

https://en.bitcoin.it/wiki/Secp256k1

See Also

Other EllipticCurve: ECPARAM-class, ECPOINT-class, containsPoint, ecoperators, ecparam, ecpoint, isNull


Creating objects of class ECPOINT

Description

This function returns an object of S4-class ECPOINT, that does represent a point on an elliptic curve.

Usage

ecpoint(ecparam = NULL, x, y, r = NULL)

Arguments

ecparam

integerECPARAM

x

x-coordinate, to be coercible to bigz.

y

y-coordinate, to be coercible to bigz.

r

the order of the base point.

Value

An object of S4-class ECPOINT

Author(s)

Bernhard Pfaff

References

https://en.bitcoin.it/wiki/Secp256k1

See Also

Other EllipticCurve: ECPARAM-class, ECPOINT-class, EcparamOrNull-class, containsPoint, ecoperators, ecparam, isNull

Examples

p <- "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F"
b <- "0x0000000000000000000000000000000000000000000000000000000000000007"
a <- "0x0000000000000000000000000000000000000000000000000000000000000000"
r <- "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141"
x <- "0x79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798"
y <- "0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"
curve256 <- ecparam(p, a, b)
ecp <- ecpoint(curve256, x, y, r)
ecp

S4 Class ECPOINT

Description

S4-class for a point on an elliptic curve. Ordinarily, objects are created by calling ecpoint.

Slots

ecparam

ECPARAM

x

bigz

y

bigz

r

bigz

Author(s)

Bernhard Pfaff

References

https://en.bitcoin.it/wiki/Secp256k1

See Also

Other EllipticCurve: ECPARAM-class, EcparamOrNull-class, containsPoint, ecoperators, ecparam, ecpoint, isNull


RPC-JSON API: getaddednodeinfo

Description

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

Usage

getaddednodeinfo(con, node = NULL)

Arguments

con

object of class CONRPC.

node

character the node (see getpeerinfo() for nodes).

Value

A S4-object of class ANSRPC.

Author(s)

Bernhard Pfaff

References

https://bitcoin.org/en/developer-reference#getaddednodeinfo, https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs

See Also

Other Network RPCs: addnode, clearbanned, disconnectnode, getconnectioncount, getnettotals, getnetworkinfo, getpeerinfo, listbanned, ping, setnetworkactive


RPC-JSON API: getbestblockhash

Description

Returns the hash of the best (tip) block in the longest blockchain.

Usage

getbestblockhash(con)

Arguments

con

object of class CONRPC.

Value

A S4-object of class ANSRPC.

Author(s)

Bernhard Pfaff

References

https://bitcoin.org/en/developer-reference#getbestblockhash, https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs

See Also

Other Blockchain RPCs: decodescript, getblockchaininfo, getblockcount, getblockhash, getblockheader, getblock, getchaintips, getchaintxstats, getdifficulty, getmempoolancestors, getmempooldescendants, getmempoolentry, getmempoolinfo, getrawmempool, gettxoutproof, gettxoutsetinfo, gettxout, preciousblock, pruneblockchain, verifychain, verifytxoutproof


RPC-JSON API: getblock

Description

Returns information of a block hash. The returned level of details depends on the argument verbosity.

Usage

getblock(con, blockhash, verbosity = c("l1", "l0", "l2"))

Arguments

con

object of class CONRPC.

blockhash

character, the block hash.

verbosity

character, level of returned details.

Details

If verbosity is 'l0', returns a string that is serialized, hex-encoded data for block 'hash'. If verbosity is 'l1' (the default), returns an object with information about block <hash>. If verbosity is 'l2', returns an object with information about block <hash> and information about each transaction.

Value

A S4-object of class ANSRPC.

Author(s)

Bernhard Pfaff

References

https://bitcoin.org/en/developer-reference#getblock, https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs

See Also

Other Blockchain RPCs: decodescript, getbestblockhash, getblockchaininfo, getblockcount, getblockhash, getblockheader, getchaintips, getchaintxstats, getdifficulty, getmempoolancestors, getmempooldescendants, getmempoolentry, getmempoolinfo, getrawmempool, gettxoutproof, gettxoutsetinfo, gettxout, preciousblock, pruneblockchain, verifychain, verifytxoutproof


RPC-JSON API: getblockchaininfo

Description

Returns an object containing various state info regarding blockchain processing.

Usage

getblockchaininfo(con)

Arguments

con

object of class CONRPC.

Value

A S4-object of class ANSRPC.

Author(s)

Bernhard Pfaff

References

https://bitcoin.org/en/developer-reference#getblockchaininfo, https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs

See Also

Other Blockchain RPCs: decodescript, getbestblockhash, getblockcount, getblockhash, getblockheader, getblock, getchaintips, getchaintxstats, getdifficulty, getmempoolancestors, getmempooldescendants, getmempoolentry, getmempoolinfo, getrawmempool, gettxoutproof, gettxoutsetinfo, gettxout, preciousblock, pruneblockchain, verifychain, verifytxoutproof


RPC-JSON API: getblockcount

Description

Returns the number of blocks in the longest blockchain.

Usage

getblockcount(con)

Arguments

con

object of class CONRPC.

Value

A S4-object of class ANSRPC.

Author(s)

Bernhard Pfaff

References

https://bitcoin.org/en/developer-reference#getblockcount, https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs

See Also

Other Blockchain RPCs: decodescript, getbestblockhash, getblockchaininfo, getblockhash, getblockheader, getblock, getchaintips, getchaintxstats, getdifficulty, getmempoolancestors, getmempooldescendants, getmempoolentry, getmempoolinfo, getrawmempool, gettxoutproof, gettxoutsetinfo, gettxout, preciousblock, pruneblockchain, verifychain, verifytxoutproof


RPC-JSON API: getblockhash

Description

Returns hash of block in best-block-chain at height provided.

Usage

getblockhash(con, height)

Arguments

con

object of class CONRPC.

height

integer the height index.

Value

A S4-object of class ANSRPC.

Author(s)

Bernhard Pfaff

References

https://bitcoin.org/en/developer-reference#getblockhash, https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs

See Also

Other Blockchain RPCs: decodescript, getbestblockhash, getblockchaininfo, getblockcount, getblockheader, getblock, getchaintips, getchaintxstats, getdifficulty, getmempoolancestors, getmempooldescendants, getmempoolentry, getmempoolinfo, getrawmempool, gettxoutproof, gettxoutsetinfo, gettxout, preciousblock, pruneblockchain, verifychain, verifytxoutproof


RPC-JSON API: getblockheader

Description

Returns the block header for a given hash string.

Usage

getblockheader(con, hash, verbose = TRUE)

Arguments

con

object of class CONRPC.

hash

character the block hash.

verbose

logical TRUE for a json object, FALSE for the hex encoded data.

Value

A S4-object of class ANSRPC.

Details

If verbose is false, returns a string that is serialized, hex-encoded data for blockheader 'hash'. If verbose is true, returns an Object with information about blockheader <hash>.

Author(s)

Bernhard Pfaff

References

https://bitcoin.org/en/developer-reference#getblockheader, https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs

See Also

Other Blockchain RPCs: decodescript, getbestblockhash, getblockchaininfo, getblockcount, getblockhash, getblock, getchaintips, getchaintxstats, getdifficulty, getmempoolancestors, getmempooldescendants, getmempoolentry, getmempoolinfo, getrawmempool, gettxoutproof, gettxoutsetinfo, gettxout, preciousblock, pruneblockchain, verifychain, verifytxoutproof


RPC-JSON API: getchaintips

Description

Return information about all known tips in the block tree, including the main chain as well as orphaned branches.

Usage

getchaintips(con)

Arguments

con

object of class CONRPC.

Value

A S4-object of class ANSRPC.

Author(s)

Bernhard Pfaff

References

https://bitcoin.org/en/developer-reference#getchaintips, https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs

See Also

Other Blockchain RPCs: decodescript, getbestblockhash, getblockchaininfo, getblockcount, getblockhash, getblockheader, getblock, getchaintxstats, getdifficulty, getmempoolancestors, getmempooldescendants, getmempoolentry, getmempoolinfo, getrawmempool, gettxoutproof, gettxoutsetinfo, gettxout, preciousblock, pruneblockchain, verifychain, verifytxoutproof


RPC-JSON API: getchaintxstats

Description

Compute statistics about the total number and rate of transactions in the chain.

Usage

getchaintxstats(con, nblocks = NULL, blockhash = NULL)

Arguments

con

object of class CONRPC.

nblocks

integer optional, size of the window in number of blocks (default: one month).

blockhash

character optional, the hash of the block that ends the window.

Value

A S4-object of class ANSRPC.

Author(s)

Bernhard Pfaff

References

https://bitcoin.org/en/developer-reference#getchaintxstats, https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs

See Also

Other Blockchain RPCs: decodescript, getbestblockhash, getblockchaininfo, getblockcount, getblockhash, getblockheader, getblock, getchaintips, getdifficulty, getmempoolancestors, getmempooldescendants, getmempoolentry, getmempoolinfo, getrawmempool, gettxoutproof, gettxoutsetinfo, gettxout, preciousblock, pruneblockchain, verifychain, verifytxoutproof


RPC-JSON API: getconnectioncount

Description

Returns the number of connections to other nodes.

Usage

getconnectioncount(con)

Arguments

con

object of class CONRPC.

Value

A S4-object of class ANSRPC.

Author(s)

Bernhard Pfaff

References

https://bitcoin.org/en/developer-reference#getconnectioncount, https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs

See Also

Other Network RPCs: addnode, clearbanned, disconnectnode, getaddednodeinfo, getnettotals, getnetworkinfo, getpeerinfo, listbanned, ping, setnetworkactive


RPC-JSON API: getdifficulty

Description

Returns the proof-of-work difficulty as a multiple of the minimum difficulty.

Usage

getdifficulty(con)

Arguments

con

object of class CONRPC.

Value

A S4-object of class ANSRPC.

Author(s)

Bernhard Pfaff

References

https://bitcoin.org/en/developer-reference#getdifficulty, https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs

See Also

Other Blockchain RPCs: decodescript, getbestblockhash, getblockchaininfo, getblockcount, getblockhash, getblockheader, getblock, getchaintips, getchaintxstats, getmempoolancestors, getmempooldescendants, getmempoolentry, getmempoolinfo, getrawmempool, gettxoutproof, gettxoutsetinfo, gettxout, preciousblock, pruneblockchain, verifychain, verifytxoutproof


RPC-JSON API: Help

Description

Returning information about RPC functions.

Usage

gethelp(con, rpc = "")

Arguments

con

object of class CONRPC.

rpc

character, name of RPC function.

Value

A S4-object of class ANSRPC.

Author(s)

Bernhard Pfaff

References

https://bitcoin.org/en/developer-reference#help, https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs

See Also

Other Control RPCs: getinfo, getwalletinfo


RPC-JSON API: getinfo

Description

Returning information about bitcoin configuration and settings.

Usage

getinfo(con)

Arguments

con

object of class CONRPC.

Details

WARNING: getinfo is deprecated and will be fully removed in 0.16. Projects should transition to using getblockchaininfo, getnetworkinfo, and getwalletinfo before upgrading to 0.16.

Value

A S4-object of class ANSRPC.

Author(s)

Bernhard Pfaff

References

https://bitcoin.org/en/developer-reference#getinfo, https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs

See Also

Other Control RPCs: gethelp, getwalletinfo


RPC-JSON API: getmempoolancestors

Description

If txid is in the mempool, returns all in-mempool ancestors.

Usage

getmempoolancestors(con, txid, verbose = FALSE)

Arguments

con

object of class CONRPC.

txid

character, the transaction id (must be in mempool).

verbose

logical, TrueTRUE for a json object, FALSE for array of transaction ids (default).

Value

A S4-object of class ANSRPC.

Author(s)

Bernhard Pfaff

References

https://bitcoin.org/en/developer-reference#getmempoolancestors, https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs

See Also

Other Blockchain RPCs: decodescript, getbestblockhash, getblockchaininfo, getblockcount, getblockhash, getblockheader, getblock, getchaintips, getchaintxstats, getdifficulty, getmempooldescendants, getmempoolentry, getmempoolinfo, getrawmempool, gettxoutproof, gettxoutsetinfo, gettxout, preciousblock, pruneblockchain, verifychain, verifytxoutproof


RPC-JSON API: getmempooldescendants

Description

If txid is in the mempool, returns all in-mempool descendants.

Usage

getmempooldescendants(con, txid, verbose = FALSE)

Arguments

con

object of class CONRPC.

txid

character, the transaction id (must be in mempool).

verbose

logical, TrueTRUE for a json object, FALSE for array of transaction ids (default).

Value

A S4-object of class ANSRPC.

Author(s)

Bernhard Pfaff

References

https://bitcoin.org/en/developer-reference#getmempooldescendants, https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs

See Also

Other Blockchain RPCs: decodescript, getbestblockhash, getblockchaininfo, getblockcount, getblockhash, getblockheader, getblock, getchaintips, getchaintxstats, getdifficulty, getmempoolancestors, getmempoolentry, getmempoolinfo, getrawmempool, gettxoutproof, gettxoutsetinfo, gettxout, preciousblock, pruneblockchain, verifychain, verifytxoutproof


RPC-JSON API: getmempoolentry

Description

Returns mempool data for given transaction.

Usage

getmempoolentry(con, txid)

Arguments

con

object of class CONRPC.

txid

character, the transaction id (must be in mempool).

Value

A S4-object of class ANSRPC.

Author(s)

Bernhard Pfaff

References

https://bitcoin.org/en/developer-reference#getmempoolentry, https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs

See Also

Other Blockchain RPCs: decodescript, getbestblockhash, getblockchaininfo, getblockcount, getblockhash, getblockheader, getblock, getchaintips, getchaintxstats, getdifficulty, getmempoolancestors, getmempooldescendants, getmempoolinfo, getrawmempool, gettxoutproof, gettxoutsetinfo, gettxout, preciousblock, pruneblockchain, verifychain, verifytxoutproof


RPC-JSON API: getmempoolinfo

Description

Returns details on the active state of the TX memory pool.

Usage

getmempoolinfo(con)

Arguments

con

object of class CONRPC.

Value

A S4-object of class ANSRPC.

Author(s)

Bernhard Pfaff

References

https://bitcoin.org/en/developer-reference#getmempoolinfo, https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs

See Also

Other Blockchain RPCs: decodescript, getbestblockhash, getblockchaininfo, getblockcount, getblockhash, getblockheader, getblock, getchaintips, getchaintxstats, getdifficulty, getmempoolancestors, getmempooldescendants, getmempoolentry, getrawmempool, gettxoutproof, gettxoutsetinfo, gettxout, preciousblock, pruneblockchain, verifychain, verifytxoutproof


RPC-JSON API: getnettotals

Description

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

Usage

getnettotals(con)

Arguments

con

object of class CONRPC.

Value

A S4-object of class ANSRPC.

Author(s)

Bernhard Pfaff

References

https://bitcoin.org/en/developer-reference#getnettotals, https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs

See Also

Other Network RPCs: addnode, clearbanned, disconnectnode, getaddednodeinfo, getconnectioncount, getnetworkinfo, getpeerinfo, listbanned, ping, setnetworkactive


RPC-JSON API: getnetworkinfo

Description

Returns an object containing various state info regarding P2P networking.

Usage

getnetworkinfo(con)

Arguments

con

object of class CONRPC.

Value

A S4-object of class ANSRPC.

Author(s)

Bernhard Pfaff

References

https://bitcoin.org/en/developer-reference#getnetworkinfo, https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs

See Also

Other Network RPCs: addnode, clearbanned, disconnectnode, getaddednodeinfo, getconnectioncount, getnettotals, getpeerinfo, listbanned, ping, setnetworkactive


RPC-JSON API: getpeerinfo

Description

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

Usage

getpeerinfo(con)

Arguments

con

object of class CONRPC.

Value

A S4-object of class ANSRPC.

Author(s)

Bernhard Pfaff

References

https://bitcoin.org/en/developer-reference#getpeerinfo, https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs

See Also

Other Network RPCs: addnode, clearbanned, disconnectnode, getaddednodeinfo, getconnectioncount, getnettotals, getnetworkinfo, listbanned, ping, setnetworkactive


RPC-JSON API: getrawmempool

Description

Returns all transaction ids in memory pool as a json array of string transaction ids. Hint: use getmempoolentry to fetch a specific transaction from the mempool.

Usage

getrawmempool(con, verbose = TRUE)

Arguments

con

object of class CONRPC.

verbose

logical, TRUE for a json object, FALSE for array of transaction ids

Value

A S4-object of class ANSRPC.

Author(s)

Bernhard Pfaff

References

https://bitcoin.org/en/developer-reference#getrawmempool, https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs

See Also

Other Blockchain RPCs: decodescript, getbestblockhash, getblockchaininfo, getblockcount, getblockhash, getblockheader, getblock, getchaintips, getchaintxstats, getdifficulty, getmempoolancestors, getmempooldescendants, getmempoolentry, getmempoolinfo, gettxoutproof, gettxoutsetinfo, gettxout, preciousblock, pruneblockchain, verifychain, verifytxoutproof


RPC-JSON API: getrawtransaction

Description

Returns the raw transaction data.

Usage

getrawtransaction(con, txid, verbose = FALSE)

Arguments

con

object of class CONRPC.

txid

character, the transaction id.

verbose

logical, type of output.

Details

By default this function only works for mempool transactions. If the -txindex option is enabled, it also works for blockchain transactions. DEPRECATED: for now, it also works for transactions with unspent outputs. If verbose is 'true', returns an object with information about 'txid'. If verbose is 'false' or omitted, returns a string that is serialized, hex-encoded data for 'txid'.

Value

A S4-object of class ANSRPC.

Author(s)

Bernhard Pfaff

References

https://bitcoin.org/en/developer-reference#getblock, https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs

See Also

Other RawTransactions RPCs: decoderawtransaction


RPC-JSON API: gettxout

Description

Returns details about an unspent transaction output.

Usage

gettxout(con, txid, n, incmempool = TRUE)

Arguments

con

object of class CONRPC.

txid

charcater the transaction id.

n

integer vout number.

incmempool

logical whether to include the mempool (default TRUE).

Details

Note that an unspent output that is spent in the mempool won't appear.

Value

A S4-object of class ANSRPC.

Author(s)

Bernhard Pfaff

References

https://bitcoin.org/en/developer-reference#gettxout, https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs

See Also

Other Blockchain RPCs: decodescript, getbestblockhash, getblockchaininfo, getblockcount, getblockhash, getblockheader, getblock, getchaintips, getchaintxstats, getdifficulty, getmempoolancestors, getmempooldescendants, getmempoolentry, getmempoolinfo, getrawmempool, gettxoutproof, gettxoutsetinfo, preciousblock, pruneblockchain, verifychain, verifytxoutproof


RPC-JSON API: gettxoutproof

Description

Returns a hex-encoded proof that "txid" was included in a block.

Usage

gettxoutproof(con, txids, blockhash = NULL)

Arguments

con

object of class CONRPC.

txids

charcater a json array of txids to filter.

blockhash

integer looks for txid in the block with this hash, (optional, default NULL).

Details

NOTE: By default this function only works sometimes. This is when there is an unspent output in the utxo for this transaction. To make it always work, you need to maintain a transaction index, using the -txindex command line option or specify the block in which the transaction is included manually (by blockhash).

Value

A S4-object of class ANSRPC.

Author(s)

Bernhard Pfaff

References

https://bitcoin.org/en/developer-reference#gettxoutproof, https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs

See Also

Other Blockchain RPCs: decodescript, getbestblockhash, getblockchaininfo, getblockcount, getblockhash, getblockheader, getblock, getchaintips, getchaintxstats, getdifficulty, getmempoolancestors, getmempooldescendants, getmempoolentry, getmempoolinfo, getrawmempool, gettxoutsetinfo, gettxout, preciousblock, pruneblockchain, verifychain, verifytxoutproof


RPC-JSON API: gettxoutsetinfo

Description

Returns statistics about the unspent transaction output set. Note this call may take some time.

Usage

gettxoutsetinfo(con)

Arguments

con

object of class CONRPC.

Value

A S4-object of class ANSRPC.

Author(s)

Bernhard Pfaff

References

https://bitcoin.org/en/developer-reference#gettxoutsetinfo, https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs

See Also

Other Blockchain RPCs: decodescript, getbestblockhash, getblockchaininfo, getblockcount, getblockhash, getblockheader, getblock, getchaintips, getchaintxstats, getdifficulty, getmempoolancestors, getmempooldescendants, getmempoolentry, getmempoolinfo, getrawmempool, gettxoutproof, gettxout, preciousblock, pruneblockchain, verifychain, verifytxoutproof


RPC-JSON API: getwalletinfo

Description

Returning information about bitcoin wallet.

Usage

getwalletinfo(con)

Arguments

con

object of class CONRPC.

Value

A S4-object of class ANSRPC.

Author(s)

Bernhard Pfaff

References

https://bitcoin.org/en/developer-reference#getwalletinfo, https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs

See Also

Other Control RPCs: gethelp, getinfo


BTC hash160

Description

This function returns the hash by applying the sha256 hashing first and then to the resulting hash the ripemd160 algorithm.

Usage

hash160(d)

Arguments

d

raw, vector.

Value

character, the value of d hashed with sha256 and ripemd160.

Author(s)

Bernhard Pfaff

References

https://en.bitcoin.it/wiki/Address

See Also

Other BtcAdresses: BTCADR-class, PrivKey2PubKey, PrivKey2Wif, PubHash2BtcAdr, PubKey2PubHash, Wif2PrivKey, base58CheckDecode, base58CheckEncode, concatHex, createBtcAdr, createPrivateKey, decodeHex, hash256, validBtcAdr


BTC hash256

Description

This function returns the hash by applying the sha256 hashing algorithm twice to a raw object.

Usage

hash256(d)

Arguments

d

raw, vector.

Value

character, the value of d hashed twice.

Author(s)

Bernhard Pfaff

References

https://en.bitcoin.it/wiki/Address

See Also

Other BtcAdresses: BTCADR-class, PrivKey2PubKey, PrivKey2Wif, PubHash2BtcAdr, PubKey2PubHash, Wif2PrivKey, base58CheckDecode, base58CheckEncode, concatHex, createBtcAdr, createPrivateKey, decodeHex, hash160, validBtcAdr


Convert time stamp to POSIX

Description

This function returns the associated POSIXct time to the time stamp integer in a block header.

Usage

int2date(x)

Arguments

x

integer, the block header time stamp

Value

An object of class POSIXct, POSIXt

Author(s)

Bernhard Pfaff

References

https://en.bitcoin.it/wiki/Block_timestamp

See Also

Other UtilityFuncs: bkfee, blockattime, blockstats, date2int, intMaxDay, intMinDay, intRangeDay, intRangePeriod, timeofblock, txfee, txids, txinids, txstats, utxoage, utxotype, utxovalue

Examples

ts <- 1532954868
int2date(ts)

Integer representation of a day-end

Description

This function returns the associated integer time for the end of a specific day (i.e., 23:59:59 time).

Usage

intMaxDay(x)

Arguments

x

POSIXct, date/time object.

Value

integer

Author(s)

Bernhard Pfaff

See Also

Other UtilityFuncs: bkfee, blockattime, blockstats, date2int, int2date, intMinDay, intRangeDay, intRangePeriod, timeofblock, txfee, txids, txinids, txstats, utxoage, utxotype, utxovalue

Examples

d1 <- "2017-03-15"
d1 <- intMaxDay(d1)
d2 <- "2017-03-15 23:59:59"
d2 <- intMaxDay(d2)
identical(d1,d2)

Integer representation of a day-begin

Description

This function returns the associated integer time for the start of a specific day (i.e., 00:00:00 time).

Usage

intMinDay(x)

Arguments

x

POSIXct, date/time object.

Value

integer

Author(s)

Bernhard Pfaff

See Also

Other UtilityFuncs: bkfee, blockattime, blockstats, date2int, int2date, intMaxDay, intRangeDay, intRangePeriod, timeofblock, txfee, txids, txinids, txstats, utxoage, utxotype, utxovalue

Examples

d1 <- "2017-03-15"
d1 <- intMinDay(d1)
d2 <- "2017-03-15 00:00:00"
d2 <- intMinDay(d2)
identical(d1,d2)

Integer range within a day

Description

This function returns the associated integer times for the start and end of a specific day.

Usage

intRangeDay(x)

Arguments

x

POSIXct, date/time object.

Value

integer

Author(s)

Bernhard Pfaff

See Also

Other UtilityFuncs: bkfee, blockattime, blockstats, date2int, int2date, intMaxDay, intMinDay, intRangePeriod, timeofblock, txfee, txids, txinids, txstats, utxoage, utxotype, utxovalue

Examples

d1 <- "2017-03-15"
intRangeDay(d1)
intMinDay(d1)
intMaxDay(d1)

Integer range between two dates

Description

This function returns the associated integer times for the start of date d1 and the end of date d2.

Usage

intRangePeriod(d1, d2)

Arguments

d1

POSIXct, date/time object.

d2

POSIXct, date/time object.

Value

integer

Author(s)

Bernhard Pfaff

See Also

Other UtilityFuncs: bkfee, blockattime, blockstats, date2int, int2date, intMaxDay, intMinDay, intRangeDay, timeofblock, txfee, txids, txinids, txstats, utxoage, utxotype, utxovalue

Examples

d1 <- "2017-03-15"
d2 <- "2017-04-15"
intRangePeriod(d1, d2)
intMinDay(d1)
intMaxDay(d2)

Test for empty EC point

Description

Checks whether an EC point does exist.

Usage

isNull(x)

## S4 method for signature 'ECPOINT'
isNull(x)

Arguments

x

object

Value

logical

Author(s)

Bernhard Pfaff

References

https://en.bitcoin.it/wiki/Secp256k1

See Also

Other EllipticCurve: ECPARAM-class, ECPOINT-class, EcparamOrNull-class, containsPoint, ecoperators, ecparam, ecpoint


RPC-JSON API: listbanned

Description

List all banned IPs/Subnets.

Usage

listbanned(con)

Arguments

con

object of class CONRPC.

Value

A S4-object of class ANSRPC.

Author(s)

Bernhard Pfaff

References

https://bitcoin.org/en/developer-reference#listbanned, https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs

See Also

Other Network RPCs: addnode, clearbanned, disconnectnode, getaddednodeinfo, getconnectioncount, getnettotals, getnetworkinfo, getpeerinfo, ping, setnetworkactive


S4 Class Union NULL or character

Description

S4-class union of NULL or character.

See Also

Other bitcoind functions: ANSRPC-class, CONRPC-class, NullOrInteger-class, conrpc, rpcpost, startbtc, stopbtc


S4 Class Union NULL or integer

Description

S4-class union of NULL or integer.

See Also

Other bitcoind functions: ANSRPC-class, CONRPC-class, NullOrCharacter-class, conrpc, rpcpost, startbtc, stopbtc


RPC-JSON API: ping

Description

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.

Usage

ping(con)

Arguments

con

object of class CONRPC.

Value

A S4-object of class ANSRPC.

Author(s)

Bernhard Pfaff

References

https://bitcoin.org/en/developer-reference#ping, https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs

See Also

Other Network RPCs: addnode, clearbanned, disconnectnode, getaddednodeinfo, getconnectioncount, getnettotals, getnetworkinfo, getpeerinfo, listbanned, setnetworkactive


RPC-JSON API: preciousblock

Description

Treats a block as if it were received before others with the same work. A can override the effect of an earlier one. The effects of preciousblock are not retained across restarts.

Usage

preciousblock(con, blockhash)

Arguments

con

object of class CONRPC.

blockhash

character, the hash of the block to mark as precious.

Value

A S4-object of class ANSRPC.

Author(s)

Bernhard Pfaff

References

https://bitcoin.org/en/developer-reference#preciousblock, https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs

See Also

Other Blockchain RPCs: decodescript, getbestblockhash, getblockchaininfo, getblockcount, getblockhash, getblockheader, getblock, getchaintips, getchaintxstats, getdifficulty, getmempoolancestors, getmempooldescendants, getmempoolentry, getmempoolinfo, getrawmempool, gettxoutproof, gettxoutsetinfo, gettxout, pruneblockchain, verifychain, verifytxoutproof


Create public key from private key

Description

This function creates the 512-bit public key corresponding to a private key.

Usage

PrivKey2PubKey(privkey, mainnet = TRUE)

Arguments

privkey

character, the private key.

mainnet

logical, whether the WIF should correspond to the mainnet or testnet.

Value

character, the public key.

Author(s)

Bernhard Pfaff

References

https://en.bitcoin.it/wiki/Address

See Also

Other BtcAdresses: BTCADR-class, PrivKey2Wif, PubHash2BtcAdr, PubKey2PubHash, Wif2PrivKey, base58CheckDecode, base58CheckEncode, concatHex, createBtcAdr, createPrivateKey, decodeHex, hash160, hash256, validBtcAdr


Create WIF from a private key

Description

Returns the corresponding WIF key from a private key

Usage

PrivKey2Wif(privkey, mainnet = TRUE)

Arguments

privkey

character, a private key.

mainnet

logical, whether the WIF should correspond to the mainnet or testnet.

Value

character, the WIF key

Author(s)

Bernhard Pfaff

References

https://en.bitcoin.it/wiki/Wallet_import_format,
https://en.bitcoin.it/wiki/Address

See Also

Other BtcAdresses: BTCADR-class, PrivKey2PubKey, PubHash2BtcAdr, PubKey2PubHash, Wif2PrivKey, base58CheckDecode, base58CheckEncode, concatHex, createBtcAdr, createPrivateKey, decodeHex, hash160, hash256, validBtcAdr

Examples

suppressWarnings(RNGversion("3.5.0"))
pk <- createPrivateKey()
PrivKey2Wif(pk)

RPC-JSON API: pruneblockchain

Description

Pruning of blockchain.

Usage

pruneblockchain(con, height)

Arguments

con

object of class CONRPC.

height

integer The block height to prune up to.

Value

A S4-object of class ANSRPC.

Details

May be set to a discrete height, or a unix timestamp to prune blocks whose block time is at least 2 hours older than the provided timestamp.

Author(s)

Bernhard Pfaff

References

https://bitcoin.org/en/developer-reference#pruneblockchain, https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs

See Also

Other Blockchain RPCs: decodescript, getbestblockhash, getblockchaininfo, getblockcount, getblockhash, getblockheader, getblock, getchaintips, getchaintxstats, getdifficulty, getmempoolancestors, getmempooldescendants, getmempoolentry, getmempoolinfo, getrawmempool, gettxoutproof, gettxoutsetinfo, gettxout, preciousblock, verifychain, verifytxoutproof


Create BTC address from public key hash

Description

This function returns the corresponding BTC address from a hashed public key.

Usage

PubHash2BtcAdr(pubhash)

Arguments

pubhash

character, the public key hash.

Value

character, the BTC address

Author(s)

Bernhard Pfaff

References

https://en.bitcoin.it/wiki/Address

See Also

Other BtcAdresses: BTCADR-class, PrivKey2PubKey, PrivKey2Wif, PubKey2PubHash, Wif2PrivKey, base58CheckDecode, base58CheckEncode, concatHex, createBtcAdr, createPrivateKey, decodeHex, hash160, hash256, validBtcAdr


Create public key hash from 512-bit public key

Description

This function returns the associated public key hash from a 512-bit public key by using the hash160() function.

Usage

PubKey2PubHash(pubkey, mainnet = TRUE)

Arguments

pubkey

character, the public key.

mainnet

logical, whether the WIF should correspond to the mainnet or testnet.

Value

character, the hash of a public key

Author(s)

Bernhard Pfaff

References

https://en.bitcoin.it/wiki/Address

See Also

Other BtcAdresses: BTCADR-class, PrivKey2PubKey, PrivKey2Wif, PubHash2BtcAdr, Wif2PrivKey, base58CheckDecode, base58CheckEncode, concatHex, createBtcAdr, createPrivateKey, decodeHex, hash160, hash256, validBtcAdr


HTTP post of RPC-JSON

Description

This function executes an RPC-JSON post.

Usage

rpcpost(con, api, plist = list())

Arguments

con

CONRPC object, returned from conrpc().

api

character the name of the RPC function.

plist

list a named list object of the parameters for api

Value

A list object, coerced JSON answer from RPC.

Author(s)

Bernhard Pfaff

See Also

Other bitcoind functions: ANSRPC-class, CONRPC-class, NullOrCharacter-class, NullOrInteger-class, conrpc, startbtc, stopbtc


RPC-JSON API: setnetworkactive

Description

Disable/enable all p2p network activity.

Usage

setnetworkactive(con, state = TRUE)

Arguments

con

object of class CONRPC.

state

logical the network state.

Value

A S4-object of class ANSRPC.

Author(s)

Bernhard Pfaff

References

https://bitcoin.org/en/developer-reference#setnetworkactive, https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs

See Also

Other Network RPCs: addnode, clearbanned, disconnectnode, getaddednodeinfo, getconnectioncount, getnettotals, getnetworkinfo, getpeerinfo, listbanned, ping


show-methods

Description

Defined show-methods for S4-classes.

Usage

## S4 method for signature 'ANSRPC'
show(object)

## S4 method for signature 'BTCADR'
show(object)

## S4 method for signature 'ECPARAM'
show(object)

Arguments

object

a S4-class object.


Start bitcoind server process

Description

This function does start the bitcoind-server process. It should only be called when no suitable RPC-JSON process is running

Usage

startbtc(confbtc)

Arguments

confbtc

CONRPC object, returned from conrpc().

Details

The process is started by calling system(). Hereby, the options: rpcuser, rpcpassword and conf are used in the call to bitcoind.

Value

NULL

Author(s)

Bernhard Pfaff

See Also

Other bitcoind functions: ANSRPC-class, CONRPC-class, NullOrCharacter-class, NullOrInteger-class, conrpc, rpcpost, stopbtc


Stop bitcoind server process

Description

This function stops a running bitcoind process. It calls bitcoin-cli stop via the R function system().

Usage

stopbtc(confbtc)

Arguments

confbtc

CONRPC object, returned from conrpc().

Author(s)

Bernhard Pfaff

See Also

Other bitcoind functions: ANSRPC-class, CONRPC-class, NullOrCharacter-class, NullOrInteger-class, conrpc, rpcpost, startbtc


Time of a block

Description

This function returns the time of a block in GMT.

Usage

timeofblock(con, height)

Arguments

con

CONRPC, configuration object.

height

integer, the height of the block.

Value

POSIXct

Author(s)

Bernhard Pfaff

See Also

Other UtilityFuncs: bkfee, blockattime, blockstats, date2int, int2date, intMaxDay, intMinDay, intRangeDay, intRangePeriod, txfee, txids, txinids, txstats, utxoage, utxotype, utxovalue


Compute fee of a transaction

Description

This function returns the implicit fee of a transaction, by computing the difference between the sum of its inputs and the sum of its outputs.

Usage

txfee(con, txid)

Arguments

con

CONRPC, configuration object.

txid

character, the id of the transaction.

Value

numeric

Author(s)

Bernhard Pfaff

See Also

Other UtilityFuncs: bkfee, blockattime, blockstats, date2int, int2date, intMaxDay, intMinDay, intRangeDay, intRangePeriod, timeofblock, txids, txinids, txstats, utxoage, utxotype, utxovalue


Retrieve TX Ids in block

Description

This function retrieves the transaction IDs in a block.

Usage

txids(con, height, excoinbase = TRUE)

Arguments

con

CONRPC, configuration object.

height

integer, the block's height.

excoinbase

logical, whether coinbase transaction should be excluded (default is TRUE).

Value

character

Author(s)

Bernhard Pfaff

See Also

Other UtilityFuncs: bkfee, blockattime, blockstats, date2int, int2date, intMaxDay, intMinDay, intRangeDay, intRangePeriod, timeofblock, txfee, txinids, txstats, utxoage, utxotype, utxovalue


Retrieving the input transaction IDs

Description

This function returns the transaction IDs of the inputs for a given transaction.

Usage

txinids(con, txid)

Arguments

con

CONRPC, configuration object.

txid

character, the id of the transaction.

Value

data.frame, the transaction ID(s) and the position(s) of the previous UTXO(s).

Author(s)

Bernhard Pfaff

See Also

Other UtilityFuncs: bkfee, blockattime, blockstats, date2int, int2date, intMaxDay, intMinDay, intRangeDay, intRangePeriod, timeofblock, txfee, txids, txstats, utxoage, utxotype, utxovalue


Statistics of a transaction

Description

This function returns key statistics/characteristics of a transaction.

Usage

txstats(con, txid)

Arguments

con

CONRPC, configuration object.

txid

character, the id of the transaction.

Value

data.frame

Author(s)

Bernhard Pfaff

See Also

Other UtilityFuncs: bkfee, blockattime, blockstats, date2int, int2date, intMaxDay, intMinDay, intRangeDay, intRangePeriod, timeofblock, txfee, txids, txinids, utxoage, utxotype, utxovalue


Age of UTXOs

Description

This function returns a difftime object measuring the elapsed time(s) between the UTXO(s) in a transaction and its input(s) (previous UTXO(s)).

Usage

utxoage(con, txid, units = c("auto", "secs", "mins", "hours", "days",
  "weeks"))

Arguments

con

CONRPC, configuration object.

txid

character, the id of the transaction.

units

character, the time difference units; passed to difftime().

Value

difftime

Author(s)

Bernhard Pfaff

See Also

Other UtilityFuncs: bkfee, blockattime, blockstats, date2int, int2date, intMaxDay, intMinDay, intRangeDay, intRangePeriod, timeofblock, txfee, txids, txinids, txstats, utxotype, utxovalue


Retrieving types of UTXOs

Description

This function returns the types of the UTXO(s) in a transaction.

Usage

utxotype(con, txid)

Arguments

con

CONRPC, configuration object.

txid

character, the id of the transaction.

Value

character

Author(s)

Bernhard Pfaff

See Also

Other UtilityFuncs: bkfee, blockattime, blockstats, date2int, int2date, intMaxDay, intMinDay, intRangeDay, intRangePeriod, timeofblock, txfee, txids, txinids, txstats, utxoage, utxovalue


Retrieving values of UTXOs

Description

This function returns the values of UTXO(s) in a transaction.

Usage

utxovalue(con, txid)

Arguments

con

CONRPC, configuration object.

txid

character, the id of the transaction.

Value

numeric

Author(s)

Bernhard Pfaff

See Also

Other UtilityFuncs: bkfee, blockattime, blockstats, date2int, int2date, intMaxDay, intMinDay, intRangeDay, intRangePeriod, timeofblock, txfee, txids, txinids, txstats, utxoage, utxotype


Validate S4-class BTCADR

Description

This function validates objects of S4-class BTCADR. Hereby, checks are conducted with respect to the first character of the addresses; their consistency with the net version and the correspondence of the checksums.

Usage

validBtcAdr(object)

Arguments

object

BTCADR object

Author(s)

Bernhard Pfaff

References

https://en.bitcoin.it/wiki/Address

See Also

Other BtcAdresses: BTCADR-class, PrivKey2PubKey, PrivKey2Wif, PubHash2BtcAdr, PubKey2PubHash, Wif2PrivKey, base58CheckDecode, base58CheckEncode, concatHex, createBtcAdr, createPrivateKey, decodeHex, hash160, hash256


RPC-JSON API: verifychain

Description

Verifies blockchain database.

Usage

verifychain(con, checklevel = NULL, nblocks = NULL)

Arguments

con

object of class CONRPC.

checklevel

integer (optional, 0-4, default=3), how thorough the block verification is.a json array of txids to filter.

nblocks

integer (optional, default=6, 0=all), the number of blocks to check.

Value

A S4-object of class ANSRPC.

Author(s)

Bernhard Pfaff

References

https://bitcoin.org/en/developer-reference#verifychain, https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs

See Also

Other Blockchain RPCs: decodescript, getbestblockhash, getblockchaininfo, getblockcount, getblockhash, getblockheader, getblock, getchaintips, getchaintxstats, getdifficulty, getmempoolancestors, getmempooldescendants, getmempoolentry, getmempoolinfo, getrawmempool, gettxoutproof, gettxoutsetinfo, gettxout, preciousblock, pruneblockchain, verifytxoutproof


RPC-JSON API: verifytxoutproof

Description

Verifies that a proof points to a transaction in a block, returning the transaction it commits to and throwing an RPC error if the block is not in our best chain.

Usage

verifytxoutproof(con, proof)

Arguments

con

object of class CONRPC.

proof

character the hex-encoded proof generated by gettxoutproof.

Value

A S4-object of class ANSRPC.

Author(s)

Bernhard Pfaff

References

https://bitcoin.org/en/developer-reference#verifytxoutproof, https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs

See Also

Other Blockchain RPCs: decodescript, getbestblockhash, getblockchaininfo, getblockcount, getblockhash, getblockheader, getblock, getchaintips, getchaintxstats, getdifficulty, getmempoolancestors, getmempooldescendants, getmempoolentry, getmempoolinfo, getrawmempool, gettxoutproof, gettxoutsetinfo, gettxout, preciousblock, pruneblockchain, verifychain


Create private key from WIF

Description

Returns the corresponding private key from a WIF key.

Usage

Wif2PrivKey(wif)

Arguments

wif

character, a WIF key.

Value

character, the corresponding private key.

Author(s)

Bernhard Pfaff

References

https://en.bitcoin.it/wiki/Wallet_import_format,
https://en.bitcoin.it/wiki/Address

See Also

Other BtcAdresses: BTCADR-class, PrivKey2PubKey, PrivKey2Wif, PubHash2BtcAdr, PubKey2PubHash, base58CheckDecode, base58CheckEncode, concatHex, createBtcAdr, createPrivateKey, decodeHex, hash160, hash256, validBtcAdr

Examples

suppressWarnings(RNGversion("3.5.0"))
pk1 <- createPrivateKey()
wif <- PrivKey2Wif(pk1)
pk2 <- Wif2PrivKey(wif)
identical(pk1, pk2)