Giter Club home page Giter Club logo

lncontract's Introduction

LNContract

Django App to manage contract integrating Lightning Network.

LNContract integrates the Business to Business context into LN Applications. Unlike retail transactions, Business to Business transactions require a lasting relationship between the parties. A manufacturer of subsystems supplier to a larger manufacturer buyer, for example, might have contracts to build those subsystems over several months or years and require milestone type payments along the way.

LNContract manages this type of relationship, integrating into the LN Network. At a high level, the app would manage the basic terms of a contract, parties obligations and payments, with payments through a LN channel via RPC.

Because the parties need an existing relationship, a channel would be better than a payment route. The channel itself could embody an aspect of the contract, as we'll see in a minute.

I am mindful that relying on a direct channel will require at least one utxo and so this won't scale, but this aspect could potentially be revised to use a federation or Taro as things develop.

Consider a manufacturer of electronic subsystems (seller) having a supply contract to a systems integrator (buyer). The supply contract requires:

The seller to manufacture and deliver 12 subsystems.

Delivery of first two units is 9 months from the date of contract and 2 units/month thereafter.

Total Contract is for 150,000,000 sats.

Milestone payments:

    materials on order: 25,000,000 sats

    stage 1 assembly: 15,000,000 sats

    stage 2 assembly: 30,000,000 sats

    subsystem testing: 60,000,000 sats

    delivery and acceptance: 20,000,000 sats

But would the seller even start work on this without anything? Maybe if he knew money was ear-marked for the contract. The channel itself could serve this purpose, acting as a quasi Letter of Credit. Buyer could give the seller some comfort by funding a channel for 30,000,000 sats at contract signing and then fund further channels (or splice in more funding) at regular intervals.

The app manages the contract. It would create funding and payment terms. It would create invoices and receive payments. It would effect all of this through an RPC connection to its LN Node and ultimately to the counterparty's node via the channel. Ideally, the counterparty would also be using the app, which the contract could require.

lncontract's People

Contributors

tkchattoraj avatar

Stargazers

22388o⚡️  avatar Rukundo avatar 志宇 avatar

Watchers

James Cloos avatar  avatar

lncontract's Issues

Account for Channel Open status response when too many channels

Below is the error response:

_MultiThreadedRendezvous at /contracts/open_channel/2
<_MultiThreadedRendezvous of RPC that terminated with:
status = StatusCode.UNKNOWN
details = "received funding error from 031c43195c2aa38d186cc8194f30756e88fc2b65fd9adaeed25f0dfe1b6663d383: chan_id=6a4c7f20541a18acb44ff64f395166f33bd9af6649a922208d27be62ef27fcff, err=Number of pending channels exceed maximum"
debug_error_string = "{"created":"@1668000701.004908513","description":"Error received from peer ipv4:127.0.0.1:10001","file":"src/core/lib/surface/call.cc","file_line":966,"grpc_message":"received funding error from 031c43195c2aa38d186cc8194f30756e88fc2b65fd9adaeed25f0dfe1b6663d383: chan_id=6a4c7f20541a18acb44ff64f395166f33bd9af6649a922208d27be62ef27fcff, err=Number of pending channels exceed maximum","grpc_status":2}"


change the limit on channels?
or account for the error?

Multiple Channels

Provide multiple channels with counterparty --earmarked to an aspect of the contract, e.g. funding for various stages

Integration

  1. Bolt 12--aspects of offer that are meaningful within context of contract

  2. Taproot/Schnorr sigs--aggregate sig made up of internal approvals

Account for MultThreadedRendezvous from OpenChannelRequest

Output from the OpenChannelRequest:

<_MultiThreadedRendezvous object>
chan_pending {
txid: "\276^e\377\2153\000\337\316\021\326g\316\332\235J\322\256\245%\213GZ\272\341\277~\230\371\212\335" output_index: 1 } pending_chan_id: "m\025\3269\024\321\n\037\022\005\335\211f\353n-a\265\025Q\345\375\277\231?\006\262\304V\214\035"

chan_open {
channel_point {
funding_txid_bytes: "\276^e\377\2153\000\337\316\021\326g\316\332\235J\322\256\245%\213GZ\272\341\277~\230\371\212\335" output_index: 1 } } pending_chan_id: "m\025\3269\024\321\n\037\022\005\335\211f\353n-a\265\025Q\345\375\277\231?\006\262\304V\214\035"

Nd provide for templates that show each stage: chan_pending, chan_open.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.