Skip to content
LearnBitcoin

ResearchBitcoin Dev Archive lightning-dev list

BOLT 11, real time micro payments, and route redundancy

9 messages, Aug 30, 2017, to Mar 6, 2018. Started by Andy Schroder.

Andy Schroder (4), Rusty Russell (4), Christian Decker

Permalink First message in the Wayback Machine

Andy Schroder permalink original

Hello,

I'm looking through BOLT 11. I don't really see an option for a refund address like is present in BIP 70. Is this intentional? If so, why do you not see that people would possibly want to receive a refund?

I'm trying to adapt my fuel pump (http://andyschroder.com/BitcoinVendingDevices/) to use lightening and it requires a refund address because their is a pre-payment required. Change is then immediately returned at the end of the sale for any unused credit. An alternative is for one's automobile to do real time micro pre-payments, but I'm not sure that the latency of a lightening payment will be low enough and the bandwidth requirement might be too expensive. It would likely also require people's automobiles to measure the product delivered and have an on board wallet. This would be ideal long term, but I'm not sure if it is realistic at this time.

Also, assuming that a real time micropayment is doable at the automobile level, what happens if one of your hops goes down in the middle of the product delivery? Can there be automatic alternate/redundant fail over routes like happens with IP traffic? It seems like this could be difficult with onion routing.

With all that being said, even if real time micro payments can be a reality, I still see many of other unrelated use cases where there may be a refund desired. I think that's why they put a refund address option in BIP 70.

Any information would be greatly appreciated.

Thanks,

Rusty Russell in reply to Andy Schroder permalink original

Andy Schroder <info at AndySchroder.com> writes:

Quoted text (5 lines)
> Hello,
>
> I'm looking through BOLT 11. I don't really see an option for a refund
> address like is present in BIP 70. Is this intentional? If so, why do
> you not see that people would possibly want to receive a refund?

Hi!

        I never even thought of that requirement!
        The payment latency is likely to be in the hundreds of
milliseconds, making it hard to match with a pump as it normally works
AFAICT.  People don't appreciate overpaying :)
Quoted text (10 lines)
> I'm trying to adapt my fuel pump
> (http://andyschroder.com/BitcoinVendingDevices/) to use lightening and
> it requires a refund address because their is a pre-payment required.
> Change is then immediately returned at the end of the sale for any
> unused credit. An alternative is for one's automobile to do real time
> micro pre-payments, but I'm not sure that the latency of a lightening
> payment will be low enough and the bandwidth requirement might be too
> expensive. It would likely also require people's automobiles to measure
> the product delivered and have an on board wallet. This would be ideal
> long term, but I'm not sure if it is realistic at this time.

It's only a problem if the a goes down actually *during* a payment, which is a fairly narrow window.

Then it's stuck, and you re-route a new payment.

Quoted text (10 lines)
> Also, assuming that a real time micropayment is doable at the automobile
> level, what happens if one of your hops goes down in the middle of the
> product delivery? Can there be automatic alternate/redundant fail over
> routes like happens with IP traffic? It seems like this could be
> difficult with onion routing.
>
> With all that being said, even if real time micro payments can be a
> reality, I still see many of other unrelated use cases where there may
> be a refund desired. I think that's why they put a refund address option
> in BIP 70.

I think the logical approach is a flag in BOLT 11 which says it wants a refund address, and we put the refund information in the payment onion itself.

The refund requires basically another complete BOLT 11 payment request, which would be only known to the final recipient. That won't fit in the onion for 1.0, but there's a brainstorming item to allow for more information to be crammed in there:

        https://github.com/lightningnetwork/lightning-rfc/wiki/Brainstorming

I've filed a feature request: https://github.com/lightningnetwork/lightning-rfc/issues/234

Thanks! Rusty.

Andy Schroder in reply to Rusty Russell permalink original

Hello,

Yes, it seems as though high frequency payments are not a reality. For high value products that are delivered quickly, "micro" payments are not even possible. With my fuel delivery system, the smallest volume of product that could be individually payed for would be on the order of a hundred mL. If I were to implement paying by the 100mL, is there any protocol for doing repeated payments? Do you have to request a new payment request, or can you just send more to the same payment request?

Regarding the payment route going down, if you can re-use the same payment request, when you say *during* a payment, do you mean when you are actually sending the payment (I think this is probably it), or everything related to that payment request (I don't think this is it)? It seems like this could definitely be a problem for lower value products that are delivered slowly over long periods of time, such as water, natural gas, electricity, internet, a parking meter, or some kind of digital content.

Regarding the refund address. Thanks for adding that to the issue requests. I guess I'm confused how this is going to work safely. If you put a refund request in with your payment, isn't that revealing the public key of your node and then defeating the whole purpose of the onion routing of the payment in the first place (I'm, assuming the payee node re-uses the same public key?)? It seems like rather than putting a flag in BOLT 11 to instruct a payer to include a refund payment request, shouldn't the payer just know to do that if they think they will need to? Or maybe they won't always?

In BOLT 11, how does a payee distinguish payments from different payers? In standard bitcoin transactions, this is usually by different bitcoin addresses that have been presented to different payers. Is this what the purpose of the d and h tagged fields are?

In BOLT 11, in the examples section, for the p tagged field, it lists it as a "preimage". Is this supposed to be a "preimage hash"?

In BOLT 11, what's the point of tagged field n if the public key is implied through the signature and the required recovery id?

Thanks,

Andy Schroder

On 09/01/2017 11:39 PM, Rusty Russell wrote:

Quoted text (56 lines)
> Andy Schroder <info at AndySchroder.com> writes:
>> Hello,
>>
>> I'm looking through BOLT 11. I don't really see an option for a refund
>> address like is present in BIP 70. Is this intentional? If so, why do
>> you not see that people would possibly want to receive a refund?
> Hi!
>
>          I never even thought of that requirement!
>
>          The payment latency is likely to be in the hundreds of
> milliseconds, making it hard to match with a pump as it normally works
> AFAICT.  People don't appreciate overpaying :)
>
>> I'm trying to adapt my fuel pump
>> (http://andyschroder.com/BitcoinVendingDevices/) to use lightening and
>> it requires a refund address because their is a pre-payment required.
>> Change is then immediately returned at the end of the sale for any
>> unused credit. An alternative is for one's automobile to do real time
>> micro pre-payments, but I'm not sure that the latency of a lightening
>> payment will be low enough and the bandwidth requirement might be too
>> expensive. It would likely also require people's automobiles to measure
>> the product delivered and have an on board wallet. This would be ideal
>> long term, but I'm not sure if it is realistic at this time.
> It's only a problem if the a goes down actually *during* a payment,
> which is a fairly narrow window.
>
> Then it's stuck, and you re-route a new payment.
>
>> Also, assuming that a real time micropayment is doable at the automobile
>> level, what happens if one of your hops goes down in the middle of the
>> product delivery? Can there be automatic alternate/redundant fail over
>> routes like happens with IP traffic? It seems like this could be
>> difficult with onion routing.
>>
>> With all that being said, even if real time micro payments can be a
>> reality, I still see many of other unrelated use cases where there may
>> be a refund desired. I think that's why they put a refund address option
>> in BIP 70.
> I think the logical approach is a flag in BOLT 11 which says it wants a
> refund address, and we put the refund information in the payment onion
> itself.
>
> The refund requires basically another complete BOLT 11 payment
> request, which would be only known to the final recipient.  That won't
> fit in the onion for 1.0, but there's a brainstorming item to allow for
> more information to be crammed in there:
>
>          https://github.com/lightningnetwork/lightning-rfc/wiki/Brainstorming
>
> I've filed a feature request:
> https://github.com/lightningnetwork/lightning-rfc/issues/234
>
> Thanks!
> Rusty.
>
Rusty Russell in reply to Andy Schroder permalink original

Andy Schroder <info at AndySchroder.com> writes:

Quoted text (9 lines)
> Hello,
>
> Yes, it seems as though high frequency payments are not a reality. For
> high value products that are delivered quickly, "micro" payments are not
> even possible. With my fuel delivery system, the smallest volume of
> product that could be individually payed for would be on the order of a
> hundred mL. If I were to implement paying by the 100mL, is there any
> protocol for doing repeated payments? Do you have to request a new
> payment request, or can you just send more to the same payment request?

Not currently, no: paying the same payment request twice is an invitation for anyone in the middle to just take your funds!

With 1.1 we're looking at changing the way payment hashes work so this will be possible (kind of like bip32, except for lightning).

Quoted text (8 lines)
> Regarding the payment route going down, if you can re-use the same
> payment request, when you say *during* a payment, do you mean when you
> are actually sending the payment (I think this is probably it), or
> everything related to that payment request (I don't think this is it)?
> It seems like this could definitely be a problem for lower value
> products that are delivered slowly over long periods of time, such as
> water, natural gas, electricity, internet, a parking meter, or some kind
> of digital content.

No, it's only during the actualy payment. Which looks like:

A: Hi B, I'll pay you $1 for preimage of hash X. B: Hi C, I'll pay you $0.99 for preimage of hash X. C: Hi D, I'll pay you $0.98 for preimage of hash X. D: Thanks C, here's the preimage. C: Thanks B, here's the preimage. B: Thanks A, here's the preimage.

Now, if B or C go down after receiving the offer but before either failing or returning the preimage, A has to wait, unsure if they'll try to redeem the offer or not. (If B or C are simply offline, A or B simply fail and A gets to try again on a different route).

In practice it's a few hundred ms of exposure, but it's still possible. Then we slow down to blockchain speed.

Quoted text (9 lines)
> Regarding the refund address. Thanks for adding that to the issue
> requests. I guess I'm confused how this is going to work safely. If you
> put a refund request in with your payment, isn't that revealing the
> public key of your node and then defeating the whole purpose of the
> onion routing of the payment in the first place (I'm, assuming the payee
> node re-uses the same public key?)? It seems like rather than putting a
> flag in BOLT 11 to instruct a payer to include a refund payment request,
> shouldn't the payer just know to do that if they think they will need
> to? Or maybe they won't always?

Nobody along the route (B and C in our example above) can see it. And D kind of has to, since it needs to send the refund.

But there needs to be some way for D to tell A it wants a refund address, hence a flag in BOLT 11.

Quoted text (4 lines)
> In BOLT 11, how does a payee distinguish payments from different payers?
> In standard bitcoin transactions, this is usually by different bitcoin
> addresses that have been presented to different payers. Is this what the
> purpose of the d and h tagged fields are?

In this case 'p' is the payment-specific variable.

Quoted text (2 lines)
> In BOLT 11, in the examples section, for the p tagged field, it lists it
> as a "preimage". Is this supposed to be a "preimage hash"?

Oops, thanks!

https://github.com/lightningnetwork/lightning-rfc/pull/235

Quoted text (2 lines)
> In BOLT 11, what's the point of tagged field n if the public key is
> implied through the signature and the required recovery id?

I like key recovery, but there were some question marks over it. So if we decide doing key recovery is a dumb idea, we can start using the n field. Since everyone should support it, it's a trivial change.

Cheers! Rusty.

Christian Decker in reply to Rusty Russell permalink original

On Mon, Sep 04, 2017 at 10:04:01AM +0930, Rusty Russell wrote:

Quoted text (5 lines)
> Not currently, no: paying the same payment request twice is an
> invitation for anyone in the middle to just take your funds!
>
> With 1.1 we're looking at changing the way payment hashes work so this
> will be possible (kind of like bip32, except for lightning).

We could allow for amount adjustments while the payment has not been resolved. So let's say the sender would like to perform incremental payments to a recipient. The recipient issues a payment request that indicates support for adjustments. The sender now sends an initial transfer to the recipient through a route of her chosing. The recipient does not immediately claim the transfer by revealing the preimage, instead it serves the sender and keeps the transfer open. The sender now increments the amount by sending an updated add_htlc message with matching payment hash and a higher value. Nodes along the route notice that this is an update to an existing HTLC, and forward it along the route (resetting any timeouts to unlock the HTLCs).

This could allow for payments similar to the simple Spillman style payment channels, but routed along a path or multiple hops, but it obviously has some pitfalls as well, e.g., it opens a new DoS vector where an attacker can lock up funds for a longer time, so we need to be careful about how we implement these.

Cheers, Christian

Andy Schroder in reply to Rusty Russell permalink original

On 09/03/2017 08:34 PM, Rusty Russell wrote:

Quoted text (12 lines)
> Andy Schroder <info at AndySchroder.com> writes:
>> Hello,
>>
>> Yes, it seems as though high frequency payments are not a reality. For
>> high value products that are delivered quickly, "micro" payments are not
>> even possible. With my fuel delivery system, the smallest volume of
>> product that could be individually payed for would be on the order of a
>> hundred mL. If I were to implement paying by the 100mL, is there any
>> protocol for doing repeated payments? Do you have to request a new
>> payment request, or can you just send more to the same payment request?
> Not currently, no: paying the same payment request twice is an
> invitation for anyone in the middle to just take your funds!

Thanks for the clarification on this. So, basically, donations with lightening work a lot different from with blockchain donation (static/reused) addresses because they can't be re-used? If so, that's fine. I always though static donation addresses were a cool idea, but at the same time are a huge privacy problem for both parties. Might be worth pointing this out in the BIP for newcomers.

Quoted text (3 lines)
>
> With 1.1 we're looking at changing the way payment hashes work so this
> will be possible (kind of like bip32, except for lightning).

That would definitely help.

Quoted text (22 lines)
>
>> Regarding the payment route going down, if you can re-use the same
>> payment request, when you say *during* a payment, do you mean when you
>> are actually sending the payment (I think this is probably it), or
>> everything related to that payment request (I don't think this is it)?
>> It seems like this could definitely be a problem for lower value
>> products that are delivered slowly over long periods of time, such as
>> water, natural gas, electricity, internet, a parking meter, or some kind
>> of digital content.
> No, it's only during the actualy payment.  Which looks like:
>
>   A: Hi B, I'll pay you $1 for preimage of hash X.
>   B: Hi C, I'll pay you $0.99 for preimage of hash X.
>   C: Hi D, I'll pay you $0.98 for preimage of hash X.
>   D: Thanks C, here's the preimage.
>   C: Thanks B, here's the preimage.
>   B: Thanks A, here's the preimage.
>
> Now, if B or C go down after receiving the offer but before either
> failing or returning the preimage, A has to wait, unsure if they'll try
> to redeem the offer or not.  (If B or C are simply offline, A or B
> simply fail and A gets to try again on a different route).

Are there any security holes where B or C can receive the offer, but pretend they don't and then the payment gets re-routed some other way?

Any way for a party to have multiple hosts for redundancy, like how you can have multiple MX and NS records in DNS?

Quoted text (15 lines)
>
> In practice it's a few hundred ms of exposure, but it's still possible.
> Then we slow down to blockchain speed.
>
>> Regarding the refund address. Thanks for adding that to the issue
>> requests. I guess I'm confused how this is going to work safely. If you
>> put a refund request in with your payment, isn't that revealing the
>> public key of your node and then defeating the whole purpose of the
>> onion routing of the payment in the first place (I'm, assuming the payee
>> node re-uses the same public key?)? It seems like rather than putting a
>> flag in BOLT 11 to instruct a payer to include a refund payment request,
>> shouldn't the payer just know to do that if they think they will need
>> to? Or maybe they won't always?
> Nobody along the route (B and C in our example above) can see it.  And D
> kind of has to, since it needs to send the refund.

It seems to me like this is sort of a limitation in privacy with lightening. With blockchain payments on my fuel pump, I could return a refund back to the customer without always knowing who they are. With lightning, it looks like the payer will reveal their identity to the payee by offering a refund payment request. It's great that those along the payment route don't know, but it's still bad to have the payer revealed to the payee. Why does someone have to reveal their identity just to get a refund?

Quoted text (3 lines)
>
> But there needs to be some way for D to tell A it wants a refund
> address, hence a flag in BOLT 11.

I guess it won't hurt to be explicit.

Quoted text (5 lines)
>> In BOLT 11, how does a payee distinguish payments from different payers?
>> In standard bitcoin transactions, this is usually by different bitcoin
>> addresses that have been presented to different payers. Is this what the
>> purpose of the d and h tagged fields are?
> In this case 'p' is the payment-specific variable.

Gotcha.

Quoted text (12 lines)
>
>> In BOLT 11, in the examples section, for the p tagged field, it lists it
>> as a "preimage". Is this supposed to be a "preimage hash"?
> Oops, thanks!
>
> https://github.com/lightningnetwork/lightning-rfc/pull/235
>
>> In BOLT 11, what's the point of tagged field n if the public key is
>> implied through the signature and the required recovery id?
> I like key recovery, but there were some question marks over it.  So if
> we decide doing key recovery is a dumb idea, we can start using the n
> field.  Since everyone should support it, it's a trivial change.

Makes sense.

Quoted text (4 lines)
>
> Cheers!
> Rusty.
>
Rusty Russell in reply to Andy Schroder permalink original

Andy Schroder <info at AndySchroder.com> writes:

Quoted text (21 lines)
> On 09/03/2017 08:34 PM, Rusty Russell wrote:
>> Andy Schroder <info at AndySchroder.com> writes:
>>> Hello,
>>>
>>> Yes, it seems as though high frequency payments are not a reality. For
>>> high value products that are delivered quickly, "micro" payments are not
>>> even possible. With my fuel delivery system, the smallest volume of
>>> product that could be individually payed for would be on the order of a
>>> hundred mL. If I were to implement paying by the 100mL, is there any
>>> protocol for doing repeated payments? Do you have to request a new
>>> payment request, or can you just send more to the same payment request?
>> Not currently, no: paying the same payment request twice is an
>> invitation for anyone in the middle to just take your funds!
>
>
> Thanks for the clarification on this. So, basically, donations with
> lightening work a lot different from with blockchain donation
> (static/reused) addresses because they can't be re-used? If so, that's
> fine. I always though static donation addresses were a cool idea, but at
> the same time are a huge privacy problem for both parties. Might be
> worth pointing this out in the BIP for newcomers.

Yes, lightning is an interactive protocol, whereas bitcoin on-chain isn't. As you point out, that leads to problems...

Quoted text (21 lines)
>>> It seems like this could definitely be a problem for lower value
>>> products that are delivered slowly over long periods of time, such as
>>> water, natural gas, electricity, internet, a parking meter, or some kind
>>> of digital content.
>> No, it's only during the actualy payment.  Which looks like:
>>
>>   A: Hi B, I'll pay you $1 for preimage of hash X.
>>   B: Hi C, I'll pay you $0.99 for preimage of hash X.
>>   C: Hi D, I'll pay you $0.98 for preimage of hash X.
>>   D: Thanks C, here's the preimage.
>>   C: Thanks B, here's the preimage.
>>   B: Thanks A, here's the preimage.
>>
>> Now, if B or C go down after receiving the offer but before either
>> failing or returning the preimage, A has to wait, unsure if they'll try
>> to redeem the offer or not.  (If B or C are simply offline, A or B
>> simply fail and A gets to try again on a different route).
>
>
> Are there any security holes where B or C can receive the offer, but
> pretend they don't and then the payment gets re-routed some other way?

No; if I've sent the committed offer, I have to assume you can redeem it. Technically we send in batches (offer, offer ... commit) and c-lightning uses a 10 msec timer so there's a chance to get a failure before we send the commit.

Quoted text (2 lines)
> Any way for a party to have multiple hosts for redundancy, like how you
> can have multiple MX and NS records in DNS?

More than possible, but it requires multinode realtime failover, which I don't think anyone has implemented yet...

Quoted text (15 lines)
>>> node re-uses the same public key?)? It seems like rather than putting a
>>> flag in BOLT 11 to instruct a payer to include a refund payment request,
>>> shouldn't the payer just know to do that if they think they will need
>>> to? Or maybe they won't always?
>> Nobody along the route (B and C in our example above) can see it.  And D
>> kind of has to, since it needs to send the refund.
>
> It seems to me like this is sort of a limitation in privacy with
> lightening. With blockchain payments on my fuel pump, I could return a
> refund back to the customer without always knowing who they are. With
> lightning, it looks like the payer will reveal their identity to the
> payee by offering a refund payment request. It's great that those along
> the payment route don't know, but it's still bad to have the payer
> revealed to the payee. Why does someone have to reveal their identity
> just to get a refund?

Indeed, it's deeply suboptimal for privacy.

There's a more complex scheme which is possible, using round-trip payments (I think this was originally from Christian Decker?); I make a payment via you and back to myself, it's just that I pay your node an abnormally high "fee". But unfortunately for security reasons each encrypted hop contains the amount it expects to be sent, which doesn't work if I don't know how much you're going to refund.

Technically, you can put a really small amount in there (each node only insists that the amount sent is >= this amount), but this just allows one of those return nodes to untracably steal the extra refund amount.

So, we really need to be able to include a (smaller) return onion to fix this properly. I've added that to:

        https://github.com/lightningnetwork/lightning-rfc/wiki/Brainstorming#refunds

Thanks! Rusty.

Andy Schroder in reply to Rusty Russell permalink original

On 09/14/2017 11:49 PM, Rusty Russell wrote:

Quoted text (39 lines)
>>>> I guess I'm confused how this is going to work safely. If you
>>>> put a refund request in with your payment, isn't that revealing the
>>>> public key of your node and then defeating the whole purpose of the
>>>> onion routing of the payment in the first place (I'm, assuming the payee
>>>>  node re-uses the same public key?)? It seems like rather than putting a
>>>> >>> flag in BOLT 11 to instruct a payer to include a refund payment request,
>>>> >>> shouldn't the payer just know to do that if they think they will need
>>>> >>> to? Or maybe they won't always?
>>> >> Nobody along the route (B and C in our example above) can see it.  And D
>>> >> kind of has to, since it needs to send the refund.
>> >
>> > It seems to me like this is sort of a limitation in privacy with
>> > lightening. With blockchain payments on my fuel pump, I could return a
>> > refund back to the customer without always knowing who they are. With
>> > lightning, it looks like the payer will reveal their identity to the
>> > payee by offering a refund payment request. It's great that those along
>> > the payment route don't know, but it's still bad to have the payer
>> > revealed to the payee. Why does someone have to reveal their identity
>> > just to get a refund?
> Indeed, it's deeply suboptimal for privacy.
>
> There's a more complex scheme which is possible, using round-trip
> payments (I think this was originally from Christian Decker?); I make a
> payment via you and back to myself, it's just that I pay your node an
> abnormally high "fee".  But unfortunately for security reasons each
> encrypted hop contains the amount it expects to be sent, which doesn't
> work if I don't know how much you're going to refund.
>
> Technically, you can put a really small amount in there (each node only
> insists that the amount sent is >= this amount), but this just allows
> one of those return nodes to untracably steal the extra refund amount.
>
> So, we really need to be able to include a (smaller) return onion to
> fix this properly.  I've added that to:
>
>         https://github.com/lightningnetwork/lightning-rfc/wiki/Brainstorming#refunds
>
> Thanks!
> Rusty.

If you are including a smaller return onion, you are including that with the payment? That return onion would be created by the payer since they know the routes from the payer to the payee? If so, how could this work if the route no longer has capacity (or goes down) by the time the payee decides it's going to send the refund back to the payer (which could be minutes, hours, or days later)? Also, even if all routes are still up, the payer may not necessarily know how much refund the payee will be giving them, so they may not necessarily be able to even know what the best route they should build an onion for?

Andy Schroder

Rusty Russell in reply to Andy Schroder permalink original

Andy Schroder <info at AndySchroder.com> writes:

Quoted text (18 lines)
> On 09/14/2017 11:49 PM, Rusty Russell wrote:
>> So, we really need to be able to include a (smaller) return onion to
>> fix this properly.  I've added that to:
>>
>>         https://github.com/lightningnetwork/lightning-rfc/wiki/Brainstorming#refunds
>>
>> Thanks!
>> Rusty.
>
> If you are including a smaller return onion, you are including that with
> the payment? That return onion would be created by the payer since they
> know the routes from the payer to the payee? If so, how could this work
> if the route no longer has capacity (or goes down) by the time the payee
> decides it's going to send the refund back to the payer (which could be
> minutes, hours, or days later)? Also, even if all routes are still up,
> the payer may not necessarily know how much refund the payee will be
> giving them, so they may not necessarily be able to even know what the
> best route they should build an onion for?

You're right. While optimal routes aren't necessary, failures are possible and made worse by the inability to retry via a different route. I've noted this on the brainstorming phase.

We don't currently return a reply message on success, but we could. It's best-effort of course (it won't appear if we drop to chain). I wonder if we could use that somehow.

The general solution seems to require an ability to send payments to an anonymous destinations, which we don't have.

Thanks! Rusty.