joule-labs / webln-docs

Documentation for the WebLN library & spec, at https://webln.dev
https://webln.dev
11 stars 14 forks source link

Question : what is flow of lightning game ? #9

Closed vinhyenvodoi98 closed 4 years ago

vinhyenvodoi98 commented 4 years ago

i'm a newbie of lightning and trying to build lightning game ( like https://thundersats.com/ ) what is flow of game ? like this, isn't it ?

          Connect `Thundersats` Lnd node
                       |
                      BET
                       |
                 send payment
                       |
                      Play
                   ____|____
              |                 |
              win            lose
                |
   makeInvoice -> send

BUT lightning don't have SmartContract . What makes sure players are not scammed ? i mean when player send payment game not start or when player win Thundersats not paying the invoice.

do you know any opensource lightning network game ?

Thanks !!!

wbobeirne commented 4 years ago

What makes sure players are not scammed ?

Nothing does with that (typical) flow. Most games of this type use provable randomness so that users can validate that their game was fair, but that verification can only happen after the bets happen. LN is more focused on privacy and decentralization than it is on programmability.

do you know any opensource lightning network game ?

I wrote a tutorial on how to make lightning apps that you may find useful: https://medium.com/@wbobeirne/making-a-lightning-web-app-part-1-4a13c82f3f78 I'm not sure off the top of my head of any games that are open source though.

vinhyenvodoi98 commented 4 years ago

@wbobeirne
https://thundersats.com/ as i know now channel is single-funded channel i have some question that

wbobeirne commented 4 years ago

who's create channel ( player or game ) after 6 block to verify so that the channel is considered valid , it take a lot of time and like i saw https://thundersats.com/ just place your bets on the table and hit Play. How could it be?

It can be either, and it doesn't need to be a direct channel. You can use one of your node's existing channels and the transaction will get routed to their node. That's where the network in Lightning Network comes from, you can hop across multiple channels if there's a path with liquidity.

If this is a user's first time using their node, and they land on your website, then yes they'll need to setup a channel and wait for the tx to be verified on chain. But after that, it's all good.

when player lose all their satoshi in channel, solution is create another channel, isn't it ?

If they have no outbound liquidity anymore, then yes, they'll have to create another channel. That's why opening large channels is encouraged, to avoid having to do this often.

vinhyenvodoi98 commented 4 years ago

@wbobeirne Thank for tutorial

https://medium.com/@wbobeirne/making-a-lightning-web-app-part-1-4a13c82f3f78

Can i rebuild with js and Reactjs Hooks and write a tutorial in my native language ?
do you know any LN testnet like Ropsten or Rinkeby in Ethereum ?

wbobeirne commented 4 years ago

Can i rebuild...

Go nuts, it's open source!

do you know any LN testnet

Yep, bitcoin has one testnet (just called testnet) and all of the node implementations have flags to run on it instead of mainnet. You'll have to refer to the documentation of the node you're running to see how to use testnet.

There's also a Ganache-like app for simulated local networks called Polar, which you can find over here: https://github.com/jamaljsr/polar

vinhyenvodoi98 commented 4 years ago

@wbobeirne

You can use one of your node's existing channels and the transaction will get routed to their node.

Await a minute the problem is when i create a channel it is single-funded channel , my balance in channel is ( for example ) 10000000 satoshi and the number of satoshi in the remote side is 0 . If i win in a gambling game for the first time how they pay my invoce ?

when i try to create a channel ,where is my satoshi ( in on-chain ) go ?