[Lightning-dev] Pizza for (lightning) bitcoins?

ZmnSCPxj ZmnSCPxj at protonmail.com
Sun Feb 25 15:30:53 UTC 2018


Good morning Robert,

Assuming you have a direct channel with the pizza provider, build a route from you to pizza provider to you.  You route the pizza price + 546 satoshi (the minimum for a nondust output) to the pizza provider, and the hop from the pizza provider to you is the 546 satoshi (so that the pizza provider gets paid the pizza price in total as the "routing fee").

You inform the pizza provider the hash of the preimage, which the pizza provider can check with their node exists as an incoming HTLC and an outgoing HTLC, with the difference being the pizza price.

Further, you set things up so that the HTLC to you expires in 3 blocks, which means that the pizza provider has to provide the pizza in three blocks or it is free.  This is the Bitcoin universe and all time is measured in terms of blocks; "minutes" is just a shared human delusion that is less real than blockchains.

When the pizza is delivered, your provide the preimage to the pizza provider via standard LN protocol, and when the pizza provider confirms to the delivery person that the pizza is paid for, the pizza is released to you.

Regards,
ZmnSCPxj

Sent with [ProtonMail](https://protonmail.com) Secure Email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On February 25, 2018 4:19 PM, Robert Olsson <robban at robtex.com> wrote:

> First of all, Laszlo, that was awesome!
>
> Instead of the part where you proved you had opened a channel, it would be awesome to add some escrow-functionality. Such as you get the invoice, and then you have a function to *almost* pay it, to verify it works thru the network with AMP and all. At that stage they start to make the pizza. And when you actually receive your pizza, you just somehow confirm the transaction, releasing the funds.
> Not sure you would have to prove anything with the preimage to the delivery guy. He should get some notification in his phone from his lightningnode that it is paid.
> If he never shows up you revert it somehow. Not sure how to do that technically, but we probably have most things in place for it already.
> Start your brains, guys! Things are getting serious, there is pizza at stake!
>
> Best regards
> Robert Olsson
>
> On Sun, Feb 25, 2018 at 3:29 AM, Laszlo Hanyecz <laszlo at heliacal.net> wrote:
>
>> I wanted to try out a real trade using lightning network.  I don't know of any pizza places near me that accept lightning bitcoin yet but a friend from London agreed to do it and he sub contracted out the pizza delivery to a local shop.
>> In short, I paid bitcoin using the lightning network and he arranged for pizza to be delivered to me.  In this trade my friend is just a middle man that is taking the risk on accepting lightning payments, but it demonstrates the basic premise of how this works for everyday transactions.  It could just as well be the pizza shop accepting the payment directly with their own lightning node.
>> I wanted two pizzas and to try to do it as close to atomically as possible.  I didn't want to prepay and end up with no pizza.  As far as I know we don't yet have pizza/bitcoin atomic swap software but we improvised and decided that I would need to provide the payment hash preimage to the delivery driver in order to claim my pizza.  If I can't produce the preimage, proving that I paid, then the pizza would not be handed over and it would be destroyed.  This works because I can't get the preimage without paying the invoice.  I agreed to open a channel and fund it with a sufficient amount for what we estimated the cost would end up being.  After we agreed to these terms my friend was able to verify that I funded a channel on the blockchain, which shows that I at least have the money (bitcoin).  He is taking on some entrepreneurial risk and prepaying his sub contractor to prepare and deliver the pizza to me, but at this point I have not risked my bitcoins, they're just committed to a channel.  I was given a bolt11 invoice which I decoded with the c-lightning cli to verify everything was as agreed:
>>
>> $ ./lightning-cli decodepay lnbc6490u1pdfrjhcpp5jyxuuskqw5
>>
>> 3apgqvtxa7emcrz5vs0qr2sxjayxv7
>>
>> jj70jznnl94sdp5x9vycgzrdpjk2um
>>
>> eypgxj7n6vykzqvfqg3jkcatcv5s9q
>>
>> 6t60fssxqyzx2qcqpgaue37x27yp3p
>>
>> n4cr6wuprvwedncz4kavqh83cp3l0v
>>
>> wfrprj0xj8cedkfmjdzea0xpp0jazf
>>
>> cyy77cq37ej6d3xvmujmgu56pe56kt
>>
>> cqa3vcys
>> { "currency" : "bc", "timestamp" : 1519504120, "created_at" : 1519504120, "expiry" : 72000, "payee" : "
>>
>> 0397b318c5e0d09b16e6229ec50744
>>
>> c8a7a8452b2d7c6d9855c826ff14b8
>>
>> fa8b27", "msatoshi" : 649000000, "description" : "1XL Cheesy Pizza, 1 Deluxe Pizza", "min_final_cltv_expiry" : 8, "payment_hash" : "
>>
>> 910dce42c07523d0a00c59bbecef03
>>
>> 151907806a81a5d2199e94bcf90a73
>>
>> f96b", "signature" : "
>>
>> 3045022100ef331f195e206219d703
>>
>> d3b811b1d96cf02adbac05cf1c063f
>>
>> 7b1c91847279a402207c65b64ee4d1
>>
>> 67af3042f97449c109ef6011f665a6
>>
>> c4ccdf25b4729a0e69ab2f" }
>>
>> When the pizza delivery arrived, I was asked "What is the preimage?" by the driver.  At this point I paid the invoice and instantly received the preimage in return.
>>
>> $ ./lightning-cli pay lnbc6490u1pdfrjhcpp5jyxuuskqw5
>>
>> 3apgqvtxa7emcrz5vs0qr2sxjayxv7
>>
>> jj70jznnl94sdp5x9vycgzrdpjk2um
>>
>> eypgxj7n6vykzqvfqg3jkcatcv5s9q
>>
>> 6t60fssxqyzx2qcqpgaue37x27yp3p
>>
>> n4cr6wuprvwedncz4kavqh83cp3l0v
>>
>> wfrprj0xj8cedkfmjdzea0xpp0jazf
>>
>> cyy77cq37ej6d3xvmujmgu56pe56kt
>>
>> cqa3vcys
>> { "preimage" : "
>>
>> 7241e3f185148625894b8887ad459b
>>
>> abd26540fc12124c3a7a96c937d89d
>>
>> a8c1", "tries" : 1 }
>>
>> In the interest of keeping it simple we agreed that the preimage would just be the first and last 4 characters of the hex string.  So my answer was 7241-a8c1.  I wrote this on a notepad and presented it to the driver who compared it to his own notepad, at which point I was given the pizza.  It's probably not a good practice to share the preimage.  The delivery driver didn't have the full string, only enough to verify that I had it.
>> How do you get the preimage for your invoice?  In c-lightning you can do it like this:
>> $ ./lightning-cli invoice 12345 label description
>> { "payment_hash" : "
>>
>> e04dfbd4adc634779b560c8e7072f8
>>
>> 83d5f17a3e32a33603bfc90a868287
>>
>> 3d44", "expiry_time" : 1519523498, "expires_at" : 1519523498, "bolt11" : "
>>
>> lnbc123450p1pdfyzy6pp5upxlh49d
>>
>> cc680x6kpj88quhcs02lz737x23nvq
>>
>> aley9gdq5884zqdqjv3jhxcmjd9c8g
>>
>> 6t0dccqpg802ys4s4z3rpm6d8zvdgq
>>
>> 397wewh5kaz527hnglz9xsmjxfjrhe
>>
>> 3mxq9pp7pqm0pwcwm748tav4am97gq
>>
>> rvnzxnlw5uxxawgw4vcywgphj26nf" }
>> $ sqlite3 ~/.lightning/lightningd.
>>
>> sqlite3 "SELECT quote(payment_key) FROM invoices ORDER BY id DESC LIMIT 1"
>> X'
>>
>> D3BE7E68D8B38B15A5194AEA131A21
>>
>> 429A1987085C95A0631273273546FF
>>
>> 5ED8'
>> Then you can verify that it's indeed the correct preimage by hashing it again and comparing it to the payment_hash in the invoice above:
>> $ echo "
>>
>> D3BE7E68D8B38B15A5194AEA131A21
>>
>> 429A1987085C95A0631273273546FF
>>
>> 5ED8" | xxd -r -p | sha256sum
>> e04dfbd4adc634779b560c8e7072f8
>>
>> 83d5f17a3e32a33603bfc90a868287
>>
>> 3d44  -
>> Note that you should not share the preimage with anyone.
>>
>> So is there any point to doing this instead of an on chain transaction?  For what I described here, probably not.  The goal was just to play around with c-lightning and do something more than shuffling a few satoshi back and forth.  Maybe eventually pizza shops will have their own lightning nodes and I can open channels to them directly.
>>
>> Some pics of my family enjoying the pizza here:
>> [http://eclipse.heliacal.net/~
>>
>> solar/bitcoin/lightning-pizza/](http://eclipse.heliacal.net/~solar/bitcoin/lightning-pizza/)
>> -Laszlo
>>
>> _______________________________________________
>> Lightning-dev mailing list
>> Lightning-dev at lists.linuxfoundation.org
>> https://lists.linuxfoundation.org/mailman/listinfo/lightning-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxfoundation.org/pipermail/lightning-dev/attachments/20180225/28e662b4/attachment-0001.html>


More information about the Lightning-dev mailing list