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

Cezary Dziemian cezary.dziemian at gmail.com
Sun Feb 25 13:01:34 UTC 2018


 That is great! I even wrote an article about this (in polish)
http://lightningnetwork.pl/2018/02/25/oplacenie-pizzy-przez-ln/

Assume that delivery driver is honest and reliable we could call it atomic
swap I think. You exchanged bitcoins for preimage and preimage for pizza.
Great!

The only thing that makes me sad is that, pizza was scheduled to be
destroyed if not paid by you. In my opinion instead of destroying pizza, it
should be delivered to your friend!

2018-02-25 2:29 GMT+01:00 Laszlo Hanyecz <laszlo at heliacal.net>:

> 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 lnbc6490u1pdfrjhcpp5jyxuuskqw53apgqvtxa7emcrz5vs0qr2sxjayxv7jj70jznnl94sdp5x9vycgzrdpjk2umeypgxj7n6vykzqvfqg3jkcatcv5s9q6t60fssxqyzx2qcqpgaue37x27yp3pn4cr6wuprvwedncz4kavqh83cp3l0vwfrprj0xj8cedkfmjdzea0xpp0jazfcyy77cq37ej6d3xvmujmgu56pe56ktcqa3vcys
> { "currency" : "bc", "timestamp" : 1519504120, "created_at" : 1519504120, "expiry" : 72000, "payee" : "0397b318c5e0d09b16e6229ec50744c8a7a8452b2d7c6d9855c826ff14b8fa8b27", "msatoshi" : 649000000, "description" : "1XL Cheesy Pizza, 1 Deluxe Pizza", "min_final_cltv_expiry" : 8, "payment_hash" : "910dce42c07523d0a00c59bbecef03151907806a81a5d2199e94bcf90a73f96b", "signature" : "3045022100ef331f195e206219d703d3b811b1d96cf02adbac05cf1c063f7b1c91847279a402207c65b64ee4d167af3042f97449c109ef6011f665a6c4ccdf25b4729a0e69ab2f" }
>
> 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 lnbc6490u1pdfrjhcpp5jyxuuskqw53apgqvtxa7emcrz5vs0qr2sxjayxv7jj70jznnl94sdp5x9vycgzrdpjk2umeypgxj7n6vykzqvfqg3jkcatcv5s9q6t60fssxqyzx2qcqpgaue37x27yp3pn4cr6wuprvwedncz4kavqh83cp3l0vwfrprj0xj8cedkfmjdzea0xpp0jazfcyy77cq37ej6d3xvmujmgu56pe56ktcqa3vcys
> { "preimage" : "7241e3f185148625894b8887ad459babd26540fc12124c3a7a96c937d89da8c1", "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" : "e04dfbd4adc634779b560c8e7072f883d5f17a3e32a33603bfc90a8682873d44", "expiry_time" : 1519523498, "expires_at" : 1519523498, "bolt11" : "lnbc123450p1pdfyzy6pp5upxlh49dcc680x6kpj88quhcs02lz737x23nvqaley9gdq5884zqdqjv3jhxcmjd9c8g6t0dccqpg802ys4s4z3rpm6d8zvdgq397wewh5kaz527hnglz9xsmjxfjrhe3mxq9pp7pqm0pwcwm748tav4am97gqrvnzxnlw5uxxawgw4vcywgphj26nf" }
> $ sqlite3 ~/.lightning/lightningd.sqlite3 "SELECT quote(payment_key) FROM invoices ORDER BY id DESC LIMIT 1"
> X'D3BE7E68D8B38B15A5194AEA131A21429A1987085C95A0631273273546FF5ED8'
> 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 "D3BE7E68D8B38B15A5194AEA131A21429A1987085C95A0631273273546FF5ED8" | xxd -r -p | sha256sum
> e04dfbd4adc634779b560c8e7072f883d5f17a3e32a33603bfc90a8682873d44  -
> 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/
>
> -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/ee3a966b/attachment.html>


More information about the Lightning-dev mailing list