Hacking HODL invoices at #Bothathon 2019

The world’s first virtual lightning conference and hackathon, Boltathon, was inaugurated last weekend, with 10 seminars lead by speakers across the world, and over 20 hackathon projects completed. I participated in the hackathon, leveraging LND’s newly merged HODL invoices to create Lightning Poll, a refundable sats-for-votes polling site.

Boltathon was a uniquely-crypto conference in many ways; tickets were purchased with Bitcoin, on-chain or via the lightning network, hackathon and session tickets could be redeemed entirely anonymously, and audience members and speakers alike dialled in from almost every imaginable time zone for a truly decentralised experience.

The theme of the hackathon was to “hack social” with the subcategories of hack social interaction, covering anything from twitter to online gaming, and hack social good, covering projects designed to make the world a better place. The projects submitted at the end of the event ranged from pay-per-byte peer to peer streaming to non-custodial lighting network tips for Github contributors.

When brainstorming my project, there were two main considerations that drove my decision to work on lightning poll.

  1. The lightning network is unparalleled in its ability to process micropayments, which opens up interesting “satoshis as proof of existence” solutions to the proliferation of bots and fake news that we are currently experiencing. Adding a monetary element to identity verification has the potential to price out (or at least incumber) bot farms, by requiring high capital commitments for the creation of millions of accounts, while leaving the cost to individual, authentic accounts low.
  2. LND had recently merged in HODL invoices PR, which provides the ability to refund lightning invoices, and I was eager to try to work on a project which addressed a pain point around refunds which traditional payments systems cannot address.

My project aimed to address a small, but felt problem in social interaction between online content producers and fans. Content producers want genuine feedback from their followers about what they could like to see, for example: “Would you like me to post a cute cat video, or a cute dog video next?” Fans are eager to see content tailored to their interest, and are likely to be willing to pay a small amount to have that content made, but would be unhappy if they paid to see a cat video, but were not in the majority and ended up paying for the creation of a dog video. Because, the internet.

Lightning poll allows content creators to create lightning based pay-per-vote polls with refund rules which will repay a certain section of voters based on the outcome of the poll. What I specifically like about a refundable pay per vote scheme is that it places value on your vote, without necessarily costing you.

To create a poll, users need to create a lightning invoice with a zero amount that they can be paid out to once the poll closes. Invoices without a specified amount are as important to the structure of lightning poll as HODL invoices, because they allow payout of any non-zero amount. Without them, poll creators would have to submit an invoice with the exact settle amount after the poll closed, which would require logins, notification of poll payout amounts and a whole lot of other admin which you don’t want when trying to create a quick and easy poll.

Image for post
Image for post

Once created, voting is straightforward for users: select the option you want to vote for, pay the invoice via any lightning enabled wallet (HODL invoices are indistinguishable from regular invoices) and then wait to see the outcome of the vote. If your vote meets the refund strategy for the poll once it closes, you’ll get your sats back.

On the technical side of things there were, as always in a hackathon, many lessons learned.

  • If you’re not an informed web developer, don’t choose your framework based on it’s name. I picked the Gin and GOnic framework based on name alone, and ended up copy-pasting css into every HTML template because I couldn’t figure out the custom file server that the framework provided.
  • HODL invoices are incredible, but they are very new. I have become fairly acquainted with the V0.5 LND gprc client, so was not expecting some of the changes that HODL invoices bring in. As always after a good hour of debugging, I learned things I never knew I never knew - that HODL invoices hang when you pay them via lncli sendpayment , they introduce an invoice state which is open on creation, accepted when they have been paid, and finally released or settled when the receiving party chooses to cancel or accept the payment.

This project was incredibly fun to work on, and I am hoping to get it out on mainnet once I have my own node set up - a leap I’ve been wanting to take for a while, but have never quite committed to. If you’re interested in seeing a quick demo, I tweeted demo a video here, and the code is available on GitHub.

Claps and snaps and sats to ecurrencyhodler and Patrick Walters of Blockfuse for organising Boltathon, I can’t wait for the next one!

Written by

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store