get10101 / 10101

10101 (Ten-Ten-One): Self-custodial derivative trading at your fingertips.
https://10101.finance
MIT License
128 stars 23 forks source link

Only charge fees on opening channel #393

Closed holzeis closed 1 year ago

holzeis commented 1 year ago

Currently we charge 2% on every routing transaction. Instead we want to charge the user for the on-chain transaction costs when opening an just-in-time channel. Routing fees are set 1 sat + 1% (this is the default config on the lnd) for the beta phase.

// edit: changed routing fees from 0 to 1 sat + 1%.

holzeis commented 1 year ago

Charging the receiver of the payment for the channel creation is not as straight forward as initially assumed. LDK (and I think any lightning implementation in general) checks if the received amount is at least the same amount as issued in the invoice. So we can't simply cut the amount from the forwarded htlc transaction.

Researching on how Breez does it, reveals that they are creating two invoices using the same pre-image. see below for a more detailed description. However, this seems to be a significant change

Breez Just-In-Time-Channel Fees (payed by the payee)

  1. When the recipient wants to receive a payment but lacks inbound capacity, their Breez app recognizes the lack and issues two invoices using the same preimage: one invoice is issued to the sender (requesting a payment) and a second is issued to the Breez LSP. The amount of the second invoice equals the amount requested from the payer minus a miniscule service fee to Breez for opening the channel the recipient requires. The invoice sent to the sender includes routing instructions, indicating a pseudo-channel between the recipient and the Breez node.
  2. When the sender pays the invoice they received from the recipient, the Breez node intercepts the payment and holds it.
  3. The Breez LSP then opens a channel with the recipient and skips funding confirmation. Then it pays the recipient the second invoice and receives the preimage.
  4. Once the preimage is received from the recipient, Breez settles the payment with the sender.

https://doc.breez.technology/#no-channel-management-zero-conf-channels-are-created-on-the-fly

bonomat commented 1 year ago

Deemed to be a post mvp ticket

luckysori commented 1 year ago

Related to #577.

bonomat commented 1 year ago

Duplicate of #577