Add dynamic channel creation documentation

This commit is contained in:
Yaacov Akiba Slama
2020-11-16 12:14:37 +02:00
parent f407ec9e9c
commit aa0db5402c
2 changed files with 63 additions and 12 deletions

View File

@@ -5,18 +5,11 @@ This is a simple example of an lspd that works with an [lnd](https://github.com/
## Installation
1. git clone https://github.com/breez/lspd (or fork)
2. Modify the code in server.go if you use different values than the recommeded values when opening channels:
* **ChannelCapacity**: channel capacity is sats, defined in the channelAmount const (recommended: 1000000).
* **TargetConf**: the number of blocks that the funding transaction *should* confirm in, will be used for fee estimation (recommended: 0).
* **MinHtlcMsat**: the channel_reserve value in sats (recommended: 1000000).
* **BaseFeeMsat**: base tx fee in msats (recommended: 1000).
* **FeeRate**: fee rate (recommended: 0.000001). The total fee charged is BaseFeeMsat + (amount * FeeRate / 1000000)
* **TimeLockDelta**: the minimum number of blocks this node requires to be added to the expiry of HTLCs (recommended: 144).
3. Compile lspd using `go build .`
4. Create a random token (for instance using the command `openssl rand -base64 48`)
5. Define the environment variables as described in sample.env. If `CERTMAGIC_DOMAIN` is defined, certificate for this domain is automatically obtained and renewed from Let's Encrypt. In this case, the port needs to be 443. If `CERTMAGIC_DOMAIN` is not defined, lspd needs to run behind a reverse proxy like treafik or nginx.
6. Run lspd
7. Share with Breez the TOKEN and the LISTEN_ADDRESS you've defined (send to contact@breez.technology)
1. Compile lspd using `go build .`
1. Create a random token (for instance using the command `openssl rand -base64 48`)
1. Define the environment variables as described in sample.env. If `CERTMAGIC_DOMAIN` is defined, certificate for this domain is automatically obtained and renewed from Let's Encrypt. In this case, the port needs to be 443. If `CERTMAGIC_DOMAIN` is not defined, lspd needs to run behind a reverse proxy like treafik or nginx.
1. Run lspd
1. Share with Breez the TOKEN and the LISTEN_ADDRESS you've defined (send to contact@breez.technology)
## Implement your own lspd
You can create your own lsdp by implementing the grpc methods described [here](https://github.com/breez/lspd/blob/master/rpc/lspd.md).
@@ -24,3 +17,11 @@ You can create your own lsdp by implementing the grpc methods described [here](h
## Use a smaller channel reserve
You can apply the PR from https://github.com/lightningnetwork/lnd/pull/2708 to be able to create channels with a channel reserve smaller than 1% of the channel capacity.
Then add the field `RemoteChanReserveSat` in the `lnrpc.OpenChannelRequest` struct when opening a channel.
## Flow for creating channels
When Alice wants Bob to pay her an amount and Alice doesn't have a channel with sufficient capacity, she calls the lspd function RegisterPayment() and sending the paymentHash, paymentSecret (for mpp payments), destination (Alice pubkey), and two amounts.
The first amount (incoming from the lsp point of view) is the amount BOB will pay. The second amount (outgoing from the lsp point of view) is the amount Alice will receive. The difference between these two amounts is the fees for the lsp.
In order to open the channel on the fly, the lsp is connecting to lnd using the interceptor api.
## Probing support
The lsp supports probing non-mpp payments if the payment hash for probing is sha256('probing-01:' || payment_hash) when payment_hash is the hash of the real payment.

View File

@@ -8,6 +8,9 @@
- [ChannelInformationRequest](#lspd.ChannelInformationRequest)
- [OpenChannelReply](#lspd.OpenChannelReply)
- [OpenChannelRequest](#lspd.OpenChannelRequest)
- [PaymentInformation](#lspd.PaymentInformation)
- [RegisterPaymentReply](#lspd.RegisterPaymentReply)
- [RegisterPaymentRequest](#lspd.RegisterPaymentRequest)
@@ -42,6 +45,8 @@
| fee_rate | [double](#double) | | The effective fee rate in milli-satoshis. The precision of this value goes / up to 6 decimal places, so 1e-6. |
| time_lock_delta | [uint32](#uint32) | | The required timelock delta for HTLCs forwarded over the channel. |
| min_htlc_msat | [int64](#int64) | | The minimum value in millisatoshi we will require for incoming HTLCs on / the channel. |
| channel_fee_permyriad | [int64](#int64) | | |
| lsp_pubkey | [bytes](#bytes) | | |
@@ -93,6 +98,50 @@
<a name="lspd.PaymentInformation"></a>
### PaymentInformation
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| payment_hash | [bytes](#bytes) | | |
| payment_secret | [bytes](#bytes) | | |
| destination | [bytes](#bytes) | | |
| incoming_amount_msat | [int64](#int64) | | |
| outgoing_amount_msat | [int64](#int64) | | |
<a name="lspd.RegisterPaymentReply"></a>
### RegisterPaymentReply
<a name="lspd.RegisterPaymentRequest"></a>
### RegisterPaymentRequest
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| blob | [bytes](#bytes) | | |
@@ -109,6 +158,7 @@
| ----------- | ------------ | ------------- | ------------|
| ChannelInformation | [ChannelInformationRequest](#lspd.ChannelInformationRequest) | [ChannelInformationReply](#lspd.ChannelInformationReply) | |
| OpenChannel | [OpenChannelRequest](#lspd.OpenChannelRequest) | [OpenChannelReply](#lspd.OpenChannelReply) | |
| RegisterPayment | [RegisterPaymentRequest](#lspd.RegisterPaymentRequest) | [RegisterPaymentReply](#lspd.RegisterPaymentReply) | |