Lightning Lottery

From
Jump to: navigation, search

Since I am not a super experienced developper my idea was to keep it simple and implement a web app on top of LND. Gambling/lotteries are an area where Lightning can really shine. However, there can still be a liquidity problem with regards to large payouts. That's why my brilliant idea is to pay the winner out with an Amazon giftcard from Bitrefill.

The basic idea would be to have a UI where you can submit your email and pay an invoice. After enough people joined in the winner is decided randomly, an order is filled via the BitRefill API and the voucher is mailed to the winner.

This is ofcourse not 'provably fair', nor can it ever be. We can however improve on this with secrets/hashes? I am not an expert on this, if someone has any ideas please share them :).

I already got a BitRefill API key from Sergej, and a very simple, very much WIP server communicating with LND written in Go can be found on my GitHub.


Overview

On the highest level there is obviously the front-end, the back-end and the wallet. The backend talks to the wallet for receiving invoices, receiving updates on paid invoices and paying invoices from Bitrefill. I would identify 4 services that need to run in the back-end:


Entry-listener

This component needs to listen for entries submitted via the UI, store them, ask the wallet for an invoice and respond with the invoice.

Invoice-listener

This component needs to listen to the wallet for paid invoices, if a certain invoice is paid corresponding a participant ID in the database, update the entry to "paid". Maybe send an email to the participant or send an event over websocket to the UI. If total # paid is high enough, notify next component.

Lottery-draw

Check for # of participants, if enough (30 for voucher of 25 euros?) pick winner at random. Post winner to next component.

Winner-handler

Store the winner, buy the voucher, send email to winner.