Skip to main content

Self-hosted, non-custodial Bitcoin Lightning payments for autonomous AI agents — your node, your keys, your rules.

Project description

conduit-btc

Python SDK for Conduit — self-hosted, non-custodial Bitcoin Lightning payment infrastructure for autonomous AI agents.

Your node, your keys, your rules. Conduit is software tooling that you run on your own infrastructure, against your own LND node, with your own keys. It never touches your funds — it's a thin client for your Conduit instance.

pip install conduit-btc

The importable package is conduit:

from conduit import Agent

Quickstart

Point the SDK at the Conduit instance you deployed (a 5-minute Docker deploy against your own LND node), create an agent, and send a payment:

import conduit
from conduit import Agent

# Connect to YOUR self-hosted Conduit instance
conduit.api_key = "ck_live_..."              # an API key from your instance
conduit.base_url = "https://conduit.example.com"  # your Conduit URL

# Create an autonomous wallet with an optional spending policy
agent = Agent.create(name="compute-router-7", daily_limit=50_000)

agent.policy.attach(
    max_per_hour=10_000,
    allowlist=["02beef..."],
)

# Send a Lightning payment
receipt = agent.pay(
    to="compute-node-7@lnd.example.com",
    sats=150,
    memo="dataset query",
)

print(receipt.hash, receipt.settled_in_ms)
print(receipt.fee_sats, receipt.platform_fee_sats)

Client-centric API (ConduitClient)

Prefer a single client object with explicit methods over the Agent active-record style? ConduitClient wraps the same retrying, idempotent HTTP client and adds operator funding (credit_agent) — from pip install to a settled payment in a few lines:

from conduit import ConduitClient

client = ConduitClient(base_url="https://conduit.example.com", api_key="ck_live_...")

agent = client.create_agent("compute-router-7")
client.credit_agent(agent.id, sats=10_000)            # operator funds the agent

receipt = client.send_payment(agent.id, dest_pubkey="02beef...", sats=500)
print(receipt.status, receipt.platform_fee_sats)      # 'settled', 2

print(client.get_balance(agent.id).available)         # spendable sats
for tx in client.list_transactions(agent.id):
    print(tx.direction, tx.amount_sats, tx.status)

Both styles talk to the same instance — use whichever you prefer.

Platform fee on receipts

Every payment receipt includes a platform_fee_sats field — the per-transaction platform fee in satoshis configured by the operator who deployed the instance. It is separate from fee_sats (the LND routing fee):

  • fee_sats — the Lightning Network routing fee paid to route the payment.
  • platform_fee_sats — the operator's usage-based revenue, charged on top, kept on settle, and refunded in full if the payment fails.

The fee is configured on your instance via PLATFORM_FEE_PERCENT (default 0.5%), PLATFORM_FEE_MIN_SATS (default 1), and PLATFORM_FEE_MAX_SATS (default 1000).

receipt = agent.pay(to="...", sats=10_000)
print(receipt.amount_sats)        # 10000
print(receipt.fee_sats)           # LND routing fee
print(receipt.platform_fee_sats)  # your platform's per-tx revenue

Configuration

The SDK reads CONDUIT_API_KEY and CONDUIT_API_URL (default https://api.conduit.energy, the hosted demo console) from the environment. Set CONDUIT_API_URL to the URL of your own Conduit deployment.

export CONDUIT_API_KEY=ck_live_xxxxxxxxxxxxx
export CONDUIT_API_URL=https://conduit.example.com

or explicitly in code:

import conduit
conduit.api_key = "ck_live_..."
conduit.base_url = "https://conduit.example.com"

Errors

from conduit import PolicyViolation, InsufficientBalance, PaymentFailed

try:
    agent.pay(to=..., sats=...)
except PolicyViolation as e:
    print(e.code, e.message)  # e.g. "DAILY_LIMIT_EXCEEDED"

See the full error code list in the API docs.

Links

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

conduit_btc-0.8.5.tar.gz (19.6 kB view details)

Uploaded Source

Built Distribution

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

conduit_btc-0.8.5-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

Details for the file conduit_btc-0.8.5.tar.gz.

File metadata

  • Download URL: conduit_btc-0.8.5.tar.gz
  • Upload date:
  • Size: 19.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for conduit_btc-0.8.5.tar.gz
Algorithm Hash digest
SHA256 5f5871fe8cc1d954e352294f2011baaaff275d330070b297c363f71c5dd131cc
MD5 df6aae75299de73615e2e33fce1eda40
BLAKE2b-256 891a201368975e506c66961862a4ee00669cdf891b7dc69dd8db1b793c9702d5

See more details on using hashes here.

File details

Details for the file conduit_btc-0.8.5-py3-none-any.whl.

File metadata

  • Download URL: conduit_btc-0.8.5-py3-none-any.whl
  • Upload date:
  • Size: 17.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for conduit_btc-0.8.5-py3-none-any.whl
Algorithm Hash digest
SHA256 8ad20a8cc882642b9db7d6164ebc7a5695d637cf0a971e42f2f23dbc72fa5de5
MD5 022231fef088e96bf24fa408b3f728e3
BLAKE2b-256 7c27907e4342d1ad2b338f4213f9aba1a273d494cee06c5efcaec487b2a7ef0c

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