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
Release history Release notifications | RSS feed
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.4.tar.gz
(16.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file apibtc-1.0.4.tar.gz.
File metadata
- Download URL: apibtc-1.0.4.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3394c1d1f60afdd4bae48a13efb877463924f9d74a2e1da3a6ffa21b41eebe9a
|
|
| MD5 |
36db46cbfc826cd1c525128dcbfd4c8e
|
|
| BLAKE2b-256 |
636da338774e73183afa63675913e2db30d3ab73154d8548ee68d7b5153c0b53
|
File details
Details for the file apibtc-1.0.4-py3-none-any.whl.
File metadata
- Download URL: apibtc-1.0.4-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78c43ba281409bc11cdf95fd325f6b5b15e5e67696390f14655c8a17a54a6447
|
|
| MD5 |
d117891e458915825cfedf928b0240e1
|
|
| BLAKE2b-256 |
05be10dc221fffbeba3ab134719c67dd213c737bf31f3c04d4383211ab55d270
|