Skip to main content

A Python library for interacting with the Denaro cyptocurrency

Project description

Denaro Python Client Module Documentation

This module is a lightweight Python client for interacting with a Denaro blockchain node.
It provides helper functions to query node state, blockchain data, addresses, transactions, and to build, sign, and submit transactions.

Important:
All functions that communicate with the node return a requests.Response object, not parsed data.
You must explicitly call .json(), .text, .status_code, etc., on the returned value.


Requirements

Python

  • Python 3.8+

Dependencies

pip install requests ecdsa

Configuration

DECIMALS = 10**6
NODE = "http://denaro.mine.bz:3006/"
DEBUG = True

Description

  • DECIMALS Atomic units per Denaro coin (1 DNR = 1,000,000 units).

  • NODE Base URL of the Denaro node API.

  • DEBUG If enabled, prints the raw requests.Response object and its decoded JSON payload.


Return Value Convention (IMPORTANT)

All network-related functions return:

requests.Response

This allows you to manually inspect:

response.status_code
response.headers
response.text
response.json()

Example:

resp = get_status()
if resp.status_code == 200:
    data = resp.json()

Node & Blockchain API Functions

All functions below return requests.Response.


get_node_info() -> requests.Response

Fetches general node information.

resp = get_node_info()

get_status() -> requests.Response

Returns blockchain and node status.

resp = get_status()

get_peers() -> requests.Response

Returns the list of known peers.

resp = get_peers()

get_block() -> requests.Response

Returns the latest block.

resp = get_block()

get_blocks() -> requests.Response

Returns a list of recent blocks.

resp = get_blocks()

get_transaction(txhash) -> requests.Response

Fetches a transaction by its hash.

resp = get_transaction("TX_HASH")

get_pending_transactions() -> requests.Response

Returns all pending (mempool) transactions.

resp = get_pending_transactions()

get_address_info(addr) -> requests.Response

Returns balance and transaction history for an address.

resp = get_address_info("DNR_ADDRESS")

submit_tx(tx_hex) -> requests.Response

Submits a hex-encoded transaction to the network.

resp = submit_tx(tx_hex)

sync_blockchain() -> requests.Response

Triggers a blockchain synchronization.

resp = sync_blockchain()

get_mining_info() -> requests.Response

Returns mining-related information.

resp = get_mining_info()

submit_block(id, content, txs) -> requests.Response

Submits a mined block.

resp = submit_block(
    id="BLOCK_ID",
    content="BLOCK_CONTENT",
    txs=[tx_hex_1, tx_hex_2]
)

Cryptographic Utilities

These functions do not return requests.Response.


sha256(b: bytes) -> bytes

Computes a SHA-256 hash.


double_sha256(b: bytes) -> bytes

Computes SHA256(SHA256(data)).


amount_to_int(amount: float) -> int

Converts a human-readable Denaro amount to atomic units.

amount_to_int(1.0)  # 1000000

Transaction Construction


build_tx_object(from_addr, to_addr, amount_int) -> dict

Creates an unsigned transaction object.


serialize_tx(tx: dict) -> bytes

Serializes a transaction deterministically (sorted keys, compact JSON).


sign_tx(tx_bytes, privkey_hex) -> dict

Signs a serialized transaction using ECDSA secp256k1.

Returns a dictionary containing:

  • signature (hex)
  • public_key (hex)

make_tx_hex(from_addr, to_addr, amount, privkey_hex) -> str

Builds, signs, serializes, and hex-encodes a transaction.

tx_hex = make_tx_hex(...)

Sending Transactions


send(from_addr, to_addr, amount, privkey_hex) -> requests.Response

High-level convenience function.

  • Builds the transaction
  • Signs it
  • Submits it to the node
resp = send(
    from_addr="FROM_ADDRESS",
    to_addr="TO_ADDRESS",
    amount=0.5,
    privkey_hex="PRIVATE_KEY_HEX"
)

Returned value is a requests.Response.


Notes & Limitations

  • All node interactions return requests.Response
  • Private keys must be raw hex strings
  • No UTXO selection, fee calculation, or balance validation
  • Debug mode may expose sensitive data in logs

Example Usage

resp = get_address_info("FROM_ADDRESS")
print(resp.status_code)
print(resp.json())

resp = send(
    from_addr="FROM_ADDRESS",
    to_addr="TO_ADDRESS",
    amount=1.0,
    privkey_hex="PRIVATE_KEY"
)
print(resp.json())

Disclaimer

This module is provided as-is for development and experimentation. Use extreme caution when handling real funds.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

denarolib-1.0.2.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

denarolib-1.0.2-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file denarolib-1.0.2.tar.gz.

File metadata

  • Download URL: denarolib-1.0.2.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for denarolib-1.0.2.tar.gz
Algorithm Hash digest
SHA256 27cd54fadf1a7d9cfa00b837f1bef90fd86ee0da10bf541682cdbcefdf3e1657
MD5 82df8cf66f0d8dd50ab9cdddc472945a
BLAKE2b-256 dae56342cd071ba75859a845d36607db585b2a43efdfb1468ebee50203fe16a9

See more details on using hashes here.

File details

Details for the file denarolib-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: denarolib-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for denarolib-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 64346e6c74b685eaa6c09194a914f553b02ad9619fd8db33e38a571d876dc266
MD5 f064046c373edf4572a34810ea16a2e0
BLAKE2b-256 09367d7c7fd50de808852fe490e9902795276bfe39b4e6728ef1b3b1568fe789

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page