python package to showcase, test and build your own version of Pickhardt Payments

Overview

Pickhardt Payments Package

The pickhardtpayments package is a collection of classes and interfaces that help you to test and implement your dialect of Pickhardt Payments into your on Lightning Application.

What are Pickhardt Payments?

Pickhardt Payments are the method of deliverying satoshis from on Lightning network Node to another by using probabilistic payment delivery in a round based payment loop that updeates our belief of the remote liquidity in the Uncertainty Network and generates optimally reliable and cheap payment flows in every round by solving a piece wise linearized min integer cost flow problem with a seperable cost function.

As of now the two main features of the cost function are the linearized_uncertainty_unit_cost (effectively proportional to 1/channel_capacity) and the linearized_routing_unit_cost (effectivly just the ppm).

Depenencies

For simplicity the library currently uses a min cost flow solver from google's ortools and internally it stores all graphs and networks in networkx. I do not recommend writing critical in production or enterprise software on top of networkx as the library is rather slow and has a huge overhead of handling memory.

The dependencies can be found at:

build and install

Onestep install is via pip by typing pip install pickhardtpayments to your command line

If you want to build and install the library yourself you can do:

git clone https://github.com/renepickhardt/pickhardtpayments.git
cd pickhardtpayments
python -m build
pip install -e .

Example Code

This is a very stripped down example that shows how to run the library. Have a look at the example folder to find a longer version and more examples for the future

from pickhardtpayments.ChannelGraph import ChannelGraph
from pickhardtpayments.UncertaintyNetwork import UncertaintyNetwork
from pickhardtpayments.OracleLightningNetwork import OracleLightningNetwork
from pickhardtpayments.SyncSimulatedPaymentSession import SyncSimulatedPaymentSession


#we first need to import the chanenl graph from c-lightning jsondump
#you can get your own data set via:
# $: lightning-cli listchannels > listchannels20220412.json
# alternatively you can go to https://ln.rene-pickhardt.de to find a data dump
channel_graph = ChannelGraph("listchannels20220412.json")

uncertainty_network = UncertaintyNetwork(channel_graph)
oracle_lightning_network = OracleLightningNetwork(channel_graph)
#we create ourselves a payment session which in this case operates by sending out the onions
#sequentially 
payment_session = SyncSimulatedPaymentSession(oracle_lightning_network, 
                                 uncertainty_network,
                                 prune_network=False)

#we need to make sure we forget all learnt information on the Uncertainty Nework
payment_session.forget_information()

#we run the simulation of pickhardt payments and track all the results

#Rene Pickhardt's public node key
RENE = "03efccf2c383d7bf340da9a3f02e2c23104a0e4fe8ac1a880c8e2dc92fbdacd9df"
#Carsten Otto's public node key
C_OTTO = "027ce055380348d7812d2ae7745701c9f93e70c1adeb2657f053f91df4f2843c71"
tested_amount = 10_000_000 #10 million sats

payment_session.pickhardt_pay(RENE,C_OTTO, tested_amount,mu=0,base=0)

Acknowledgements & Funding

This work is funded via various sources including NTNU & BitMEX as well as many generous donors via https://donate.ln.rene-pickhardt.de or https://www.patreon.com/renepickhardt Feel free to go to my website at https://ln.rene-pickhardt.de to learn how I have been contributing to the open source community and why it is important to have independent open source contributors. In case you also wish to support me I will be very grateful

Comments
  • Introduction of AttemptClass and PaymentClass (Issue #20)

    Introduction of AttemptClass and PaymentClass (Issue #20)

    Extraction of Attempt and Payment. A Payment is a central object in the library, and in particular in the simulation. This is why it "deserves" its own Class. Each onion is recorded as an Attempt and registered with the respective Payment. This not only allows for statistics for each Payment object but also collects all attempts where an amount could successfully flow from sender to receiver.

    refactoring of SyncSimulatedPaymentSession has been done as well as a first version of the documentation of the two classes.

    opened by sebulino 2
  • Fix typos in documentation

    Fix typos in documentation

    As people get familiar with Pickhardt Payments and how they work, it should be easier for them to follow along when they come across this repo. Hence,I thought it necessary to clear up some grammatical issues in the documentation.

    opened by nassersaazi 1
  • [wip] initial commit to implement payment simulation on LN

    [wip] initial commit to implement payment simulation on LN

    Template to include the simulation of payments on the ChannelGraph, extending the previous single period model to a multi period model.

    Not included is the Channel Graph "listchannels20220412.json", residing in repo root.

    opened by sebulino 1
  • Pull request #24 (Introduction of AttemptClass and PaymentClass) broke the payment algorithm or simulation

    Pull request #24 (Introduction of AttemptClass and PaymentClass) broke the payment algorithm or simulation

    It seems like this merged pull request broke the payment algorithm or simulation:

    https://github.com/renepickhardt/pickhardtpayments/pull/24

    PickhardtPaymentsExample.ipynb examples don't work anymore:

    Round number: 10 Try to deliver 18879883 satoshi:

    Statistics about 46 candidate onions:

    successful attempts:

    p = 100.00% amt: 216543 sats hops: 4 ppm: 1413 p = 94.37% amt: 84263 sats hops: 5 ppm: 1349 p = 90.69% amt: 59164 sats hops: 5 ppm: 1708 p = 75.00% amt: 337453 sats hops: 5 ppm: 1417 p = 73.91% amt: 112351 sats hops: 5 ppm: 1374 p = 99.52% amt: 42718 sats hops: 6 ppm: 1348 p = 100.00% amt: 35946 sats hops: 6 ppm: 1367 p = 94.97% amt: 242846 sats hops: 7 ppm: 1696 p = 77.42% amt: 2351 sats hops: 9 ppm: 1427

    failed attempts:

    p = 100.00% amt: 88000 sats hops: 2 ppm: 1339 p = 74.25% amt: 288187 sats hops: 2 ppm: 1341 p = 14.57% amt: 1574652 sats hops: 2 ppm: 1359 p = 100.00% amt: 102400 sats hops: 2 ppm: 1381 p = 100.00% amt: 102400 sats hops: 2 ppm: 1356 ....

    SUMMARY:

    Rounds of mcf-computations: 10 Number of attempts made: 448 Number of failed attempts: 356 Failure rate: 79.46% total Payment lifetime (including inefficient memory management): 8.661 sec Learnt entropy: 229.60 bits fee for settlement of delivery: 0.000 sat --> 0 ppm used mu: 100

    opened by adamritter 2
  • create Channel in opposite direction, if not exists

    create Channel in opposite direction, if not exists

    It's possible that in the Channel Graph there's only information about one channel and information about its return channel is missing. Consequently they are currently not created in the UncertaintyNetwork (and possibly the OracleNetwork).

    For the UncertaintyNetwork we still have enough information to create the return channel with a good enough estimate. Thus we should create them if needed. This could be done in the constructor or when the getter is called and would return none.

    opened by sebulino 0
  • Move Min Cost flow Computation to Payment Class?

    Move Min Cost flow Computation to Payment Class?

    The PaymentSession consists usually of a payment loop and sends out attempts either synchronously (mostely for simulations) or concurrently (in mainnet). It seems as if the min cost flow computation is part of a payment. Thus we might regactor some things into the Payment class and have it very concise and shielded.

    A counter argument would be that the min cost clow solver with the new Library by @lagrang3 will store the uncertainty network and maintain the arcs of the solver for the next round of computation during the payment session. In that sense it seems reasonable that the solver lives outside the payments but within the session.

    On the other hand the beauty of moving the solver would be that the payment would be responsible for planning the payment independently how the loop is handeling and updating everything.

    Looking forward to also have the discussion with @sebulino

    opened by renepickhardt 2
  • Introduction of a Path class

    Introduction of a Path class

    We merged PR #24 so that we can focus on #18 . But it became clear that some of the refactoring is not fully completed yet. In particular it seems important to introduce a Path classe which wraps a list of UncertaintyChannels.

    opened by renepickhardt 0
  • Adding a min-cost flow library

    Adding a min-cost flow library

    Hi @renepickhardt. I have prepared a draft for the C-API. I still owe you an example, I'll work on that.

    I'm also proposing an example that illustrates the use of the Python-API from my point of view. Very soon I will work on the specifics of the Python-API.

    Just for the record: we have already a MCF solver in C++ in my repository https://github.com/Lagrang3/mincostflow and we have a prototype of the uncertainty network and payment session already in this repository. We are defining the C and Python APIs before implementation.

    Comments are welcomed!

    opened by Lagrang3 20
Owner
Rene Pickhardt
Self-employed Data Science Consultant (ML & NLP & Analytics), hacker, open (source, education, access, data,...) activist, bitcoin & lightning network admirer
Rene Pickhardt
The earliest beta version of pytgcalls on Linux x86_64 and ARM64! Use in production at your own risk!

Public beta test. Use in production at your own risk! tgcalls - a python binding for tgcalls (c++ lib by Telegram); pytgcalls - library connecting pyt

Il'ya 21 Jan 13, 2022
This is a method to build your own qgis configuration packages using osgeo4W.

This is a method to build your own qgis configuration packages using osgeo4W. Then you can automate deployment in your organization with a controled and trusted environnement.

Régis Haubourg 26 Dec 5, 2022
Build your own Etherscan with web3.py

Build your own Etherscan with web3.py Video Tutorial: Run it pip3 install -r requirements.txt export FLASK_APP=app export FLASK_ENV=development flask

null 35 Jan 2, 2023
Installer, package manager, build wrapper and version manager for Piccolo

Piccl Installer, package manager, build wrapper and version manager for Piccolo

null 1 Dec 19, 2021
Its a simple and fun to use application. You can make your own quizes and send the lik of the quiz to your friends.

Quiz Application Its a simple and fun to use application. You can make your own quizes and send the lik of the quiz to your friends. When they would a

Atharva Parkhe 1 Feb 23, 2022
edgetest is a tox-inspired python library that will loop through your project's dependencies, and check if your project is compatible with the latest version of each dependency

Bleeding edge dependency testing Full Documentation edgetest is a tox-inspired python library that will loop through your project's dependencies, and

Capital One 16 Dec 7, 2022
Provides guideline on how to configure pre-commit hooks in your own python project

Pre-commit Configuration Guide The main aim of this repository is to act as a guide on how to configure the pre-commit hooks in your existing python p

Faraz Ahmed Khan 2 Mar 31, 2022
Simple AoC helper program you can use to develop your own solutions in python.

AoC-Compabion Simple AoC helper program you can use to develop your own solutions in python. Simply install it in your python environment using pip fr

Alexander Vollmer 1 Dec 20, 2021
Python Create Your Own Tool Series

Python Create Your Own Tool Series Hey there! This is an additional Github repository that contains the final product files for each video in my Youtu

Joe Helle 21 Dec 2, 2022
Run-Your-Own Firefox Sync Server

Run-Your-Own Firefox Sync Server This is an all-in-one package for running a self-hosted Firefox Sync server. It bundles the "tokenserver" project for

Mozilla Services 1.7k Dec 30, 2022
Run CodeServer on Google Colab using Inlets in less than 60 secs using your own domain.

Inlets Colab Run CodeServer on Colab using Inlets in less than 60 secs using your own domain. Features Optimized for Inlets/InletsPro Use your own Cus

null 2 Dec 30, 2021
Myrepo - A tool to create your own Arch Linux repository

myrepo A (experimental) tool to create your own Arch Linux repository Example We

Anton Hvornum 5 Feb 19, 2022
Procedurally generated Oblique Strategies for writing your own Oblique Strategies

Procedurally generated Oblique Strategies for writing your own Oblique Strategies.

Gordon Brander 13 Aug 17, 2022
The refactoring tutorial I wrote for PyConDE 2022. You can also work through the exercises on your own.

Refactoring 101 planet images by Justin Nichol on opengameart.org CC-BY 3.0 Goal of this Tutorial In this tutorial, you will refactor a space travel t

Kristian Rother 9 Jun 10, 2022
A tool to build reproducible wheels for you Python project or for all of your dependencies

asaman: Amra Saman (আমরা সমান) This is a tool to build reproducible wheels for your Python project or for all of your dependencies. What this means is

Kushal Das 14 Aug 5, 2022
my own python useful functions

PythonToolKit Motivation This Repo should help save time for data scientists' daily work regarding the Time Series regression task by providing functi

Kai 2 Oct 1, 2022
India's own RPA Platform Python Powered

Welcome to My-AutoPylot , Made in India with ❤️ What is My-AutoPylot? PyBots is an Indian firm based in Vadodara, Gujarat. My-AutoPylot is a product d

PyBots Pvt Ltd 28 Sep 12, 2022
Users can read others' travel journeys in addition to being able to upload and delete posts detailing their own experiences

Users can read others' travel journeys in addition to being able to upload and delete posts detailing their own experiences! Posts are organized by country and destination within that country.

Christopher Zeas 1 Feb 3, 2022