lightningdevkit / lightning-liquidity

Other
27 stars 17 forks source link

How to request `lsps0.listprotocols` and get the response? #17

Closed yanganto closed 9 months ago

yanganto commented 1 year ago

Hi there,

First, sorry to open PR(#15, #16) before this issue, and thanks for this crate, such that we can have a channel to talk to each other. I will list down the details here before the bi-week meeting starts just to make sure I will not miss out on some detail and do not mean on this (I live in the +8 timezone, and the time of the meeting is midnight), and you do not need to hurry to respond this if you are busy.


Real Use Case

An application uses LiquidityManager, which has LSPS0MessageHandler in it. Now lsps0.listprotocols is implemented inside, it is good to request the application(release build) and make sure it works to validate the application before delivery.

So anything under #[cfg(test)] or unit test will not solve, because every byte in #[cfg(test)] or unit test is not really in the release build binary. I do integrate and do not have the duty of developing this repo, contributing to test cases, or any kind of unit test that does not make sense from my end and does not solve my issue on validating the release binary.


The Way to Receive Response in Blockchain This is the part I really confuse in this project. In General, the response of blockchain sends out in two ways, it is hard to know how it will be in the current project. Different blockchains may use different names, and the basic mechanism are these.

 Blockchain Node   <----->    Queryer (possibly a Node, client, or cli, etc whatever)

For the direct response, the function actually handles the content of the request and will return the content of the response.

Blockchain Node   <----->  Blockchain Node (Queryer, also a blockchain node to receive Event)
   |
   \-----------> Blockchain Node
    \-----------> Blockchain Node
     \-----------> Blockchain Node
      ....

In this way, the response or event will send to every node. There are three ways a query can know the exact response to his request.

yanganto commented 9 months ago

To sum up, the solution is an event with the public key as the response.

ref: https://github.com/lightningdevkit/lightning-liquidity/commit/1f11274bb277cbf101dda99eb77ca71ed381002d

tnull commented 9 months ago

To sum up, the solution is an event with the public key as the response.

ref: 1f11274

Currently, yes. Note that the API is still considered unstable and might undergo further changes.