supertestnet / bitcoin-chess

Play a game of chess and signal every move in a bitcoin transaction. An educational experiment with key tweaking
Creative Commons Zero v1.0 Universal
11 stars 0 forks source link

Implementation in lightning network #2

Open SamirSaidani opened 2 years ago

SamirSaidani commented 2 years ago

I really like this piece of code, the idea is awesome! To avoid spamming the bitcoin blockchain, how would you implement that in LN?

👍 for CC0

supertestnet commented 2 years ago

Thanks Samir! I have a few ideas for implementing it in LN, the one that seems most promising to me right now is to embed your moves in lightning preimages. Whenever you make a lightning payment, the recipient of the money has to give you a piece of text called a preimage which serves as a kind of receipt. It's signed by him so there's proof it came from him.

So what you can do is, at the start of the game, have Black pay a sat over lightning to get a preimage from White containing White's chess move, then do the reverse where White sends a sat to Black to get his move, and so on til the game ends. They'd just be sending the same sat back and forth -- unless there are routing fees, then they'd probably lose some sats to those. The players end up with a bunch of preimages containing the full history of the game and each one is signed by either you or your opponent, so you can use them to prove who won to other people.

You couldn't, however, follow along with the progress of the game as an outsider -- not unless one of the two players showed you these preimages. So it's not public automatically like it is when you do it on the blockchain.