Skip to main content

LNPay Python SDK - at the moment a basic wrapper for the LNPay API

Project description


LNPay Python SDK - at the moment a basic wrapper for the LNPay API


Get it on pip

pip install lnpay-py 


First import into your python module

import lnpay_py

Now, you need to instantiate it with a Public API Key from

# Set your public key
lnpay_api_key = 'pak_XXX'

# init lnpay

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()

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)

Generate Invoice

my_wallet = LNPayWallet(lnpay_wallet_key)
invoice_params = {
    'num_satoshis': 2,
    'memo': 'Tester'
invoice = my_wallet.create_invoice(invoice_params)

Pay Invoice

my_wallet = LNPayWallet(lnpay_wallet_key)
invoice_params = {
    'payment_request': 'lnbc....'
pay_result = my_wallet.pay_invoice(invoice_params)

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)

Get Wallet Transactions

my_wallet = LNPayWallet(lnpay_wallet_key)
transactions = my_wallet.get_transactions()


my_wallet = LNPayWallet(lnpay_wallet_key)
lnurl_params = {
    'num_satoshis': 1,
    'memo': 'SatsBack!'
lnurl_link = my_wallet.get_lnurl(lnurl_params)

Get Invoice / Check if Settled

lntx_id = 'lntx_XXX'
ln_tx = LNPayLnTx(lntx_id)
invoice_result = ln_tx.get_info()

See this example file


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.txt
  • python install

3. Run Tests


4. Publishing To Pypi

  • Create an account for pypi & pypi test
  • Install twine - pip install twine
  • Increment version in
  • Remove current items in dist - rm -rf dist/*
  • Build package - python install
  • Build sdist - python sdist
  • Run pypi test upload - twine upload --repository-url dist/*
  • Upload to pypi - twine upload --repository-url dist/*

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

lnpay-py-0.1.0.tar.gz (8.0 kB view hashes)

Uploaded source

Built Distribution

lnpay_py-0.1.0-py3.6.egg (14.9 kB view hashes)

Uploaded 3 6

Supported by

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