Skip to content
LearnBitcoin

ResearchBitcoin Dev Archive lightning-dev list

Payee pay fee

9 messages, Feb 14 to 26, 2019. Started by Cezary Dziemian.

ZmnSCPxj (4), Rusty Russell (3), Cezary Dziemian (2)

Permalink First message in the Wayback Machine

Cezary Dziemian permalink original

Hi,

Not sure if this topic was mentioned, but is there any plan to provide payment solution in witch Payee pay fee instead of payer?

The issue I found is on our exchange, when user can withdraw funds using LN. If we don't know fee in advance, he can't just withdraw everything what he has. We can assume, that he can withdraw up to 99,5% of his funds, but it would be nice, if he can just withdraw everything and what he receives is just his funds minus fee.

Did you discussed this before?

Best Regards, Cezary Dziemian

ZmnSCPxj in reply to Cezary Dziemian permalink original

Good morning Cezary,

I have alluded to this issue before: https://www.learnbitcoin.com/archive/lists/lightning-dev/t/2019/lnurl-to-enable-payer-payee-interactions#m-3e6321a9 See "Withdrawing funds from a service".

Quoted text (1 line)
>From my point-of-view, the proper solution would involve the payee providing one or more complete paths from the payer to the payee node.

These will be provided as fully encrypted onions to the payer, providing the following benefits:

1.  The payee knows exactly how much it will lose in fees, since it is the one providing the path.
2.  The payer cannot correlate a particular user with its LN node, improving privacy.
3.  The payer cannot bias the route towards other nodes it controls that happen, completely for no good reason, to charge high LN fees; the payee generates the route and controls its fees.

The use-case is where the payer is a publicly-useable service (an exchange as you gave example to). In this case, the payer provides its node address to the user, but the user never provides its node address to the service.

There is no spec yet, and I am too busy with other considerations to actually work on anything Lightning-related, but perhaps you can pick up this, and continue its development.

We need:

1.  Some standard of transporting multiple *encrypted* onions from the user (payee) to the service (payer).
2.  Some implementation must provide some method of generating multiple routes from the user (payee) to the service (payer).
    Importantly, this must compute "forwards", i.e. a constant amount will be released by the payer, and the payee will take whatever value remains after fees.
    This is more difficult than it seems due to how LN fees are computed, unfortunately (it is based on the outgoing amount; while mathematically it is possible to just manipulate the equations, in practice roundoffs will be different in some edge cases between the "backwards" and "forwards" methods).
    In addition, the implementation needs to have some heuristic, i.e. if it finds a route that loses more than 1% of the value being paid (overrideable by the user), then it probably should reject that route and not provide it to the service (payer).

In essence, this issue shows the "other side" of merchants, which is exchanges. Current LN is biased towards merchants: the merchant exposes its node ID (on the invoice it provides to the user). For exchanges, we need to perform a dual transformation, where the exchange exposes its node ID somehow (via a mechanism that does not yet exist).

Regards, ZmnSCPxj

Sent with ProtonMail Secure Email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ On Thursday, February 14, 2019 10:06 PM, Cezary Dziemian <cezary.dziemian at gmail.com> wrote:

Quoted text (7 lines)
> Hi,
> Not sure if this topic was mentioned, but is there any plan to provide payment solution in witch Payee pay fee instead of payer?
>
> The issue I found is on our exchange, when user can withdraw funds using LN. If we don't know fee in advance, he can't just withdraw everything what he has. We can assume, that he can withdraw up to 99,5% of his funds, but it would be nice, if he can just withdraw everything and what he receives is just his funds minus fee.
> Did you discussed this before?
> Best Regards,
> Cezary Dziemian
Cezary Dziemian in reply to ZmnSCPxj permalink original

Thanks for answer ZMNSCPxj,

Sad to hear that you have anything non LN-related to do that has higher priority.

What, can't this this be done in easier way? For example:

1. Payee provides fee limit along with with Invoice. This can be amount percentage or absolute value in msats. 2. Payer in order to pay just finds route, that do not exceed limit from invoice 3. Payer just pays invoice

Solution above do not solve all issues, but at least it is easy to implement and can be provided quite fast. I think, this is quite important, because right now I see a lot of services that just cover fee costs, what makes it easy to steal. I'm afraid that sooner or later someone will use this method to steal some funds, what undermines LN confidence.

Best regards, Cezary Dziemian

pt., 15 lut 2019 o 06:40 ZmnSCPxj <ZmnSCPxj at protonmail.com> napisał(a):

Quoted text (80 lines)
> Good morning Cezary,
>
> I have alluded to this issue before:
> https://www.learnbitcoin.com/archive/lists/lightning-dev/t/2019/lnurl-to-enable-payer-payee-interactions#m-3e6321a9
> See "Withdrawing funds from a service".
>
> From my point-of-view, the proper solution would involve the payee
> providing one or more complete paths from the payer to the payee node.
> These will be provided as fully encrypted onions to the payer, providing
> the following benefits:
>
> 1.  The payee knows exactly how much it will lose in fees, since it is the
> one providing the path.
> 2.  The payer cannot correlate a particular user with its LN node,
> improving privacy.
> 3.  The payer cannot bias the route towards other nodes it controls that
> happen, completely for no good reason, to charge high LN fees; the payee
> generates the route and controls its fees.
>
> The use-case is where the payer is a publicly-useable service (an exchange
> as you gave example to).
> In this case, the payer provides its node address to the user, but the
> user never provides its node address to the service.
>
> There is no spec yet, and I am too busy with other considerations to
> actually work on anything Lightning-related, but perhaps you can pick up
> this, and continue its development.
>
> We need:
>
> 1.  Some standard of transporting multiple *encrypted* onions from the
> user (payee) to the service (payer).
> 2.  Some implementation must provide some method of generating multiple
> routes from the user (payee) to the service (payer).
>     Importantly, this must compute "forwards", i.e. a constant amount will
> be released by the payer, and the payee will take whatever value remains
> after fees.
>     This is more difficult than it seems due to how LN fees are computed,
> unfortunately (it is based on the outgoing amount; while mathematically it
> is possible to just manipulate the equations, in practice roundoffs will be
> different in some edge cases between the "backwards" and "forwards"
> methods).
>     In addition, the implementation needs to have some heuristic, i.e. if
> it finds a route that loses more than 1% of the value being paid
> (overrideable by the user), then it probably should reject that route and
> not provide it to the service (payer).
>
> In essence, this issue shows the "other side" of merchants, which is
> exchanges.
> Current LN is biased towards merchants: the merchant exposes its node ID
> (on the invoice it provides to the user).
> For exchanges, we need to perform a dual transformation, where the
> exchange exposes its node ID somehow (via a mechanism that does not yet
> exist).
>
> Regards,
> ZmnSCPxj
>
>
> Sent with ProtonMail Secure Email.
>
> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> On Thursday, February 14, 2019 10:06 PM, Cezary Dziemian <
> cezary.dziemian at gmail.com> wrote:
>
> > Hi,
> > Not sure if this topic was mentioned, but is there any plan to provide
> payment solution in witch Payee pay fee instead of payer?
> >
> > The issue I found is on our exchange, when user can withdraw funds using
> LN. If we don't know fee in advance, he can't just withdraw everything what
> he has. We can assume, that he can withdraw up to 99,5% of his funds, but
> it would be nice, if he can just withdraw everything and what he receives
> is just his funds minus fee.
> > Did you discussed this before?
> > Best Regards,
> > Cezary Dziemian
>
>
>
ZmnSCPxj in reply to Cezary Dziemian permalink original

Good morning Cezary,

Quoted text (7 lines)
> What, can't this this be done in easier way? For example:
>
> 1. Payee provides fee limit along with with Invoice. This can be amount percentage or absolute value in msats.
> 2. Payer in order to pay just finds route, that do not exceed limit from invoice
> 3. Payer just pays invoice
>
> Solution above do not solve all issues, but at least it is easy to implement and can be provided quite fast. I think, this is quite important, because right now I see a lot of services that just cover fee costs, what makes it easy to steal. I'm afraid that sooner or later someone will use this method to steal some funds, what undermines LN confidence.

This is possible. You could propose additional field in BOLT11 spec for this.

I would tweak this slightly.

It is currently allowed to pay more than an invoice value. So a plausible proposal is:

1.  User of an exchange service decides withdrawn amount.
2.  User decides largest acceptable loss in LN fees.
3.  User computes: invoice_value = withdrawn_amount - max_ln_fees.
4.  In BOLT11, specify a new `withdrawn_amount` tag that signals that the service performing the payment should not spend more than the specified `withdrawn_amount`, and should deduct only the amount released by the service (the amount released, includes fees) from the user account.
    This is trust-based; but any custodial service is inherently trust-based anyway.
5.  A "good" service would overpay to the user, such that `withdrawn_amount` is exactly what it releases.
    Again, this computation is more complex than the current computation, as the LN BOLT spec currently specifies that fees are computed "backwards" from the value that the destination receives.
    A "not bad" service will just pay the `invoice_value` to the user and deduct `withdrawn_amount` always, and fail the withdrawal if it would release more than `withdrawn_amount`.
    A "bad" service will becomes the next MtGox.

Regards, ZmnSCPxj

Rusty Russell in reply to Cezary Dziemian permalink original

Cezary Dziemian <cezary.dziemian at gmail.com> writes:

Quoted text (6 lines)
> Thanks for answer ZMNSCPxj,
>
> Sad to hear that you have anything non LN-related to do that has higher
> priority.
>
> What, can't this this be done in easier way? For example:

I've been thinking about this as 'the yalls problem'. But it is has similarities to recurring payments and bolt11 "offers", where you also have to do an interaction to get the real invoice.

To recap: yalls currently asks you to produce a valid invoice which it will then pay. It covers fees (presumably up to some limit). But it's a manual and messy process.

At the summit, Takaya Imai proposed a standard mechanism for such a "pull an invoice" request. I now see his wisdom; sorry for the delay!

So we need a web way of asking a client to send an invoice or offer over HTTPS. Is this a new URI scheme? How would this work?

Longer term, we need a format for bolt11 offers (lno1...?); kind of a template for the real invoice(s) which you would fetch, and a new message type so you can route these requests through the lightning network. This would give us an "automated payment" mechanism, too: you would provide this once and yalls could do automatic payouts by requesting a new invoice though LN itself.

Cheers, Rusty.

ZmnSCPxj in reply to Rusty Russell permalink original

Good morning Rusty,

Quoted text (2 lines)
> So we need a web way of asking a client to send an invoice or offer over
> HTTPS. Is this a new URI scheme? How would this work?

I thought that offers would work over LN alone?

When you first proposed the offers, I thought it was this way:

1.  Payee gives BOLT12 offer to Payer.
2.  Payer generates a completely new random preimage and computes its hash.
3.  Payer issues a payment along an LN route from Payer to Payee using its random hash.
4.  At the payee hop, the onion packet contains some identifying information from the BOLT12 offer.
5.  Payee generates a BOLT11 invoice.
6.  Payee sends back an error packet, which includes the BOLT11 invoice.
7.  Payer receives the error packet that includes the BOLT11 invoice.
8.  Payer pays using the BOLT11 invoice.

Intermediate nodes remain unaware of this new feature and do not require upgrades. A node issuing a BOLT12 offer would implicitly signal its support for this feature by the simple fact of being able to issue the BOLT12 offer. A node that can understand a BOLT12 offer implicitly means it supports this feature.

Regards, ZmnSCPxj

Rusty Russell in reply to ZmnSCPxj permalink original

ZmnSCPxj <ZmnSCPxj at protonmail.com> writes:

Quoted text (17 lines)
> Good morning Rusty,
>
>> So we need a web way of asking a client to send an invoice or offer over
>> HTTPS. Is this a new URI scheme? How would this work?
>
> I thought that offers would work over LN alone?
>
> When you first proposed the offers, I thought it was this way:
>
> 1.  Payee gives BOLT12 offer to Payer.
> 2.  Payer generates a completely new random preimage and computes its hash.
> 3.  Payer issues a payment along an LN route from Payer to Payee using its random hash.
> 4.  At the payee hop, the onion packet contains some identifying information from the BOLT12 offer.
> 5.  Payee generates a BOLT11 invoice.
> 6.  Payee sends back an error packet, which includes the BOLT11 invoice.
> 7.  Payer receives the error packet that includes the BOLT11 invoice.
> 8.  Payer pays using the BOLT11 invoice.

Yes. But how does the payee know to give the bolt12 offer to the payer?

That's the piece that's missing here, which is actually independent.

Quoted text (1 line)
> Intermediate nodes remain unaware of this new feature and do not require upgrades.

That works if we use a fake "payment" like this to get the real invoice. Be nicer to use a real message format though, as it's less overhead for everyone and faster.

Quoted text (2 lines)
> A node issuing a BOLT12 offer would implicitly signal its support for this feature by the simple fact of being able to issue the BOLT12 offer.
> A node that can understand a BOLT12 offer implicitly means it supports this feature.

Yes; I think it's early enough that we don't need to cram offers into bolt11 in some backwards compat way, they can be a new thing.

Cheers, Rusty.

ZmnSCPxj in reply to Rusty Russell permalink original

Good morning Rusty,

Quoted text (4 lines)
>
> Yes. But how does the payee know to give the bolt12 offer to the payer?
>
> That's the piece that's missing here, which is actually independent.

Ah, I understand now.

In the context of this thread, payer is a service, while payee is user. So I presume an HTTPS PUT or POST request, with the payer providing the HTTPS server?

Quoted text (6 lines)
>
> > Intermediate nodes remain unaware of this new feature and do not require upgrades.
>
> That works if we use a fake "payment" like this to get the real invoice.
> Be nicer to use a real message format though, as it's less overhead for
> everyone and faster.

While good for back-compatibility, it indeed has the above drawback of overhead. Perhaps it is early enough that rolling out a new feature that must needs be "sufficiently universal" is still plausible.

Might it be possible to use SURBs as in the other thread?

Regards, ZmnSCPxj

Rusty Russell in reply to ZmnSCPxj permalink original

ZmnSCPxj <ZmnSCPxj at protonmail.com> writes:

Quoted text (1 line)
> Might it be possible to use SURBs as in the other thread?

It's possible, but you still don't want it for all the same reasons: you have a nicely anonymized path you know works, so why use something else?

Cheers, Rusty.