Metadata-Version: 2.1
Name: cuatrorpc
Version: 0.7.2
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: MacOS
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python
Classifier: Programming Language :: Rust
Classifier: Typing :: Typed
License-File: LICENSE
Summary: Fast RPC client library for Python in rust.
Keywords: fast,rpc,bitcoin
Home-Page: https://github.com/bleach86/CuatroRPC
Author: bleach86 <tux@ghostbyjohnmcafee.com>
Author-email: bleach86 <tux@ghostbyjohnmcafee.com>
License: MIT
Requires-Python: >=3.8
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Source Code, https://github.com/bleach86/CuatroRPC

# CuatroRPC

Fast Bitcoin RPC Client Library for Python leveraging Rust.

CuatroRPC aims to be a simple and fast RPC Client for Bitcoin compatible RPC servers.

## Installation

Installation can be done with pip.

```
pip install cuatrorpc
```

## Usage

```
from cuatrorpc import RpcClient

rpc = RpcClient(username="username", password="password", port=8033)

# Get the block count
print(rpc.callrpc("getblockcount"))
```

Arguments are passed as a python objects in a list.

```
from cuatrorpc import RpcClient

rpc = RpcClient(username="username", password="password", port=8033)

block_height = 1337

# Get get block hash from index
block_hash = rpc.callrpc("getblockhash", [block_height])

# Get the block details along with all of the trasnaction data for the block
block_details = rpc.callrpc("getblock", [block_hash, 2])

# Since the return for 'getblock' is a json object,
# block_details is automatically converted to a python object

# Get the timestamp of the block

timestamp = block_details['time']

print(timestamp)
```

For Async operations, use the RpcClientAsync class

```
from cuatrorpc import RpcClientAsync
import asyncio


rpc = RpcClientAsync(username="username", password="password", port=8033)

async def main():
  # Get the block count
  block_count = await rpc.callrpc("getblockcount")
  print(block_count)

if __name__ == "__main__":
  asyncio.run(main())
```

## Usage CLI Binary

You can optionally use the cli binary to make rpc calls.

```
from cuatrorpc import RpcClientCLI


rpc_cli = RpcClientCLI(cli_bin_path="/path/to/bitcoin-cli",
                                data_dir_path="/path/to/.bitcoin",
                                daemon_conf_path="/path/to/.bitcoin/bitcoin.conf"
                                )

# Everything from here is the same as the http version except the method is called callrpc_cli

# Get the block count
print(rpc_cli.callrpc("getblockcount"))
```

For Async operations, use the RpcClientCLIAsync class

```
from cuatrorpc import RpcClientCLIAsync
import asyncio


rpc_cli = RpcClientCLIAsync(cli_bin_path="/path/to/bitcoin-cli",
                                data_dir_path="/path/to/.bitcoin",
                                daemon_conf_path="/path/to/.bitcoin/bitcoin.conf"
                                )

# From here everything is the same as with the async http version.

async def main():
  # Get the block count
  block_count = await rpc_cli.callrpc("getblockcount")
  print(block_count)

if __name__ == "__main__":
  asyncio.run(main())
```

