lnpay-py
LNPay Python SDK - at the moment a basic wrapper for the LNPay API
Install
Get it on pip
pip install lnpay-py
Setup
First import into your python module
import lnpay_py
Now, you need to instantiate it with a Public API Key from LNPay.co
# Set your public key
lnpay_api_key = 'pak_XXX'
# init lnpay
lnpay_py.initialize(lnpay_api_key)
Usage - Documentation
The first alpha version of this SDK is mainly a wrapper for the LNPay API
Everyhing revolves around the wallet and Wallet Access Keys (WAK) which grant various levels of permission.
Instantiate a Wallet / Check Balance
When interacting with the wallet, import the wallet module and then initialize the wallet.
from lnpay_py.wallet import LNPayWallet
my_wallet = LNPayWallet(lnpay_wallet_key)
Then you can proceed to check balance, etc.
info = my_wallet.get_info()
print(info)
Create a wallet
You can create a wallet from the UI or via the API. When you create a wallet via the API, Wallet Access Keys (WAK) are returned. You need to save these.
wallet_params = {
'user_label': 'My wallet'
}
new_wallet = lnpay_py.create_wallet(wallet_params)
print(new_wallet)
Generate Invoice
my_wallet = LNPayWallet(lnpay_wallet_key)
invoice_params = {
'num_satoshis': 2,
'memo': 'Tester'
}
invoice = my_wallet.create_invoice(invoice_params)
print(invoice)
Pay Invoice
my_wallet = LNPayWallet(lnpay_wallet_key)
invoice_params = {
'payment_request': 'lnbc....'
}
pay_result = my_wallet.pay_invoice(invoice_params)
print(pay_result)
Transfers between wallets
my_wallet = LNPayWallet(lnpay_wallet_key)
transfer_params = {
'dest_wallet_id': 'w_XXX',
'num_satoshis': 1,
'memo': 'Transfer Memo'
}
transfer_result = my_wallet.internal_transfer(transfer_params)
print(transfer_result)
Get Wallet Transactions
my_wallet = LNPayWallet(lnpay_wallet_key)
transactions = my_wallet.get_transactions()
print(transactions)
Get LNURL
my_wallet = LNPayWallet(lnpay_wallet_key)
lnurl_params = {
'num_satoshis': 1,
'memo': 'SatsBack!'
}
lnurl_link = my_wallet.get_lnurl(lnurl_params)
print(lnurl_link)
Get Invoice / Check if Settled
lntx_id = 'lntx_XXX'
ln_tx = LNPayLnTx(lntx_id)
invoice_result = ln_tx.get_info()
print(invoice_result)
Development
1. Installation
You will need to have python installed as well as pip
Clone the repository
2. Getting started
- open the command line and switch into the project folder
pip install -rrequirements.txtpython setup.py install
3. Run Tests
./run_tests.sh
4. Publishing To Pypi
- Create an account for pypi & pypi test
- Install twine -
pip install twine - Increment version in
__init__.py - Remove current items in dist -
rm -rf dist/* - Build package -
python setup.py install - Build sdist -
python setup.py sdist - Run pypi test upload -
twine upload --repository-url https://test.pypi.org/legacy/ dist/* - Upload to pypi -
twine upload --repository-url https://upload.pypi.org/legacy/ dist/*
Metadata
Release files for lnpay-py 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lnpay-py-0.1.0.tar.gz | 8.0 kB | Without provenance | Details for lnpay-py-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lnpay_py-0.1.0-py3.6.egg | Legacy Egg format | - | - | Details for lnpay_py-0.1.0-py3.6.egg |
Total release size: 23.0 kB
Release files / lnpay-py-0.1.0.tar.gz
| Download URL | lnpay-py-0.1.0.tar.gz |
|---|---|
| Size | 8.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
844751741efe8192e13c647fe16e2e657a89b79e5f6733db0a1bff217c6314f0
|
|
BLAKE2b-256 checksum How to use checksums |
3ecc40146ac56ca00f8b49282bacd37ef27be105c08754693b64cc42f66fd4a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.6
|
Release files / lnpay_py-0.1.0-py3.6.egg
| Download URL | lnpay_py-0.1.0-py3.6.egg |
|---|---|
| Size | 14.9 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
f0aabe392f6cea90bb07630ca60a470625b7ec2815dc09bf20a16b48b485e237
|
|
BLAKE2b-256 checksum How to use checksums |
5da8234aad46080f11b2569e9c45c55f2b807eac30c2c88138f6f384b1ba9e9d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.6
|
Security for lnpay-py 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.