btc_* Methods (Bitcoin Core)
The btc_* namespace provides passthrough access to Bitcoin Core RPC methods. These are the standard bitcoind JSON-RPC methods with a btc_ prefix.
Block Methods
| Method | Description |
|---|---|
| btc_getblockcount | Get the current block height |
| btc_getblockhash | Get the block hash at a specific height |
| btc_getbestblockhash | Get the hash of the current best block |
| btc_getblock | Get block data by hash |
| btc_getblockheader | Get block header data |
Blockchain Info
| Method | Description |
|---|---|
| btc_getblockchaininfo | Get blockchain state information |
| btc_getdifficulty | Get the current difficulty |
Transaction Methods
| Method | Description |
|---|---|
| btc_getrawtransaction | Get raw transaction data |
| btc_sendrawtransaction | Broadcast a signed transaction |
Mempool Methods
| Method | Description |
|---|---|
| btc_getmempoolinfo | Get mempool statistics |
| btc_getrawmempool | Get all mempool transaction IDs |
Fee Estimation
| Method | Description |
|---|---|
| btc_estimatesmartfee | Estimate fee for confirmation within N blocks |
btc_getblockcount
Get the current block height.
// Request
{
"jsonrpc": "2.0",
"method": "btc_getblockcount",
"params": [],
"id": 1
}
// Response
{
"jsonrpc": "2.0",
"result": 925736,
"id": 1
}
// Lua Example
local height = _RPC.btc_getblockcount()
return { current_height = height }btc_getblockhash
Get the block hash at a specific height.
// Request
{
"jsonrpc": "2.0",
"method": "btc_getblockhash",
"params": [840000],
"id": 1
}
// Response
{
"jsonrpc": "2.0",
"result": "0000000000000000000320283a032748cef8227873ff4872689bf23f1cda83a5",
"id": 1
}
// Lua Example
local hash = _RPC.btc_getblockhash(840000)
return { block_hash = hash }btc_getblock
Get block data by hash. Verbosity: 0=hex, 1=JSON, 2=JSON with full tx.
// Request
{
"jsonrpc": "2.0",
"method": "btc_getblock",
"params": ["0000000000000000000320283a032748cef8227873ff4872689bf23f1cda83a5", 1],
"id": 1
}
// Lua Example
local height = _RPC.btc_getblockcount()
local hash = _RPC.btc_getblockhash(height)
local block = _RPC.btc_getblock(hash, 1)
return {
height = block.height,
time = block.time,
tx_count = #block.tx
}btc_getblockchaininfo
Get blockchain state information.
// Request
{
"jsonrpc": "2.0",
"method": "btc_getblockchaininfo",
"params": [],
"id": 1
}
// Response
{
"jsonrpc": "2.0",
"result": {
"chain": "main",
"blocks": 925737,
"headers": 925737,
"bestblockhash": "000000000000000000001d43...",
"difficulty": 149301205959699.9,
"verificationprogress": 1,
"pruned": false
},
"id": 1
}
// Lua Example
local info = _RPC.btc_getblockchaininfo()
return {
chain = info.chain,
height = info.blocks,
difficulty = info.difficulty
}btc_getmempoolinfo
Get mempool statistics.
// Request
{
"jsonrpc": "2.0",
"method": "btc_getmempoolinfo",
"params": [],
"id": 1
}
// Response
{
"jsonrpc": "2.0",
"result": {
"loaded": true,
"size": 15381,
"bytes": 14475763,
"usage": 76718160,
"total_fee": 0.02045846
},
"id": 1
}
// Lua Example
local mempool = _RPC.btc_getmempoolinfo()
return {
tx_count = mempool.size,
size_mb = mempool.bytes / 1000000
}btc_estimatesmartfee
Estimate fee for confirmation within N blocks.
// Request
{
"jsonrpc": "2.0",
"method": "btc_estimatesmartfee",
"params": [6],
"id": 1
}
// Response
{
"jsonrpc": "2.0",
"result": {
"feerate": 0.00001013,
"blocks": 6
},
"id": 1
}
// Note: Use esplora_feeestimates in Lua scripts instead