Skip to content

Suggestion: lower-level "paycode" below "invoice" level #2666

@ZmnSCPxj

Description

@ZmnSCPxj

Currently, all incoming payments are done via invoice interface.

This includes incoming payments that will be used for e.g. rebalancing.

However, we might want to consider:

  1. A user c-lightning node might want to have some rebalancing plugin that ensures it has sufficient incoming liquidity to accept at least the median size of its payments.
  2. The same node has a separate merchant software that monitors customer payments via waitanyinvoice.

Currently, the only way for a rebalance to work would be to generate a synthetic invoice and making a self-payment to that.

However, this synthetic invoice might confuse or otherwise interact badly with merchant software running on top of c-lightning using waitanyinvoice.

So I suggest the following low-level interface; then invoice would actually build on top of this low-level interface.

  • paycode {12345|any} {timeout} - generate a paycode. The paycode is identified by payment_hash that is returned by this command.
  • waitpaycode {hash} - wait for the paycode to be paid, or timeout.
  • listpaycodes {hash} - list paycodes and their status and timeouts.
  • delpaycode {hash} {status} - delete a paycode if it has the given status. Any attached invoice is also deleted.

Of note, there is no waitanypaycode - the intent is that the low-level interface is to be used for such things as circular donation and rebalancing, which should generate one paycode for an instance of its command execution and pay attention only to that single paycode.


Internally, this is implemented using the same struct invoices, but at invoice creation we add a new boolean flag paycode_only (adding this to the invoices table with value false for existing entries).

Then we modify waitanyinvoice and listinvoices to skip invoices with paycode_only equal to true.

(the above can be an alternate interface, but I like the conceptual separation at the JSON-RPC level of the low-level "paycode" versus the high-level "invoice")

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureAimed at improving the existing functionality or a new feature that provides additional value

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions