Skip to main content

Python client for interacting with the Hyperlabs Bitcoin API

Project description

from apibtc import Wallet
from mnemonic import Mnemonic
from bip32utils import BIP32Key

# Declare API url
BASE_URL = "API_BASE_URL"

# Create two wallets
# Wallet 1 - Invoice Creator
mnemon1 = Mnemonic('english')
words1 = mnemon1.generate(128)
private_key1 = BIP32Key.fromEntropy(mnemon1.to_seed(words1)).PrivateKey().hex()
wallet1 = Wallet(base_url=BASE_URL, privkey=private_key1)

# Wallet 2 - Invoice Payer
mnemon2 = Mnemonic('english')
words2 = mnemon2.generate(128)
private_key2 = BIP32Key.fromEntropy(mnemon2.to_seed(words2)).PrivateKey().hex()
wallet2 = Wallet(base_url=BASE_URL, privkey=private_key2)

# Payment flow
# Create invoice with wallet1
invoice = wallet1.addinvoice(satoshis=1000, memo="Payment from wallet2", expiry=3600)

# Pay invoice with wallet2
wallet2.sendpayment(paymentrequest=invoice['payment_request'], timeout=30, feelimit=100)

# Check balances after payment
print("Wallet1 balance:", wallet1.getbalance())
print("Wallet2 balance:", wallet2.getbalance())

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

apibtc-1.0.5.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

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

apibtc-1.0.5-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file apibtc-1.0.5.tar.gz.

File metadata

  • Download URL: apibtc-1.0.5.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for apibtc-1.0.5.tar.gz
Algorithm Hash digest
SHA256 9582f0c78933ae183ee6e0b4376043aca38acefd1e302877ef595f711e81b373
MD5 8051f6557f564dcb63fd7d44d4e15e80
BLAKE2b-256 c0356b988274bec402211637c064fc911f0fb6e3f91aef364db3beab436d810e

See more details on using hashes here.

File details

Details for the file apibtc-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: apibtc-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for apibtc-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 bffa29902931274a9e9e85e290c317231110024b8e172d0db3e5bc9b2bf86c31
MD5 7c39f1b325eb24977a3682746f05db64
BLAKE2b-256 bb62d36db1bc3443255c48c4b8c887a1965d5ef18b2b1db9c4d333012528288e

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