Skip to content

Instantly share code, notes, and snippets.

@imylomylo
Created November 26, 2018 08:52
Show Gist options
  • Save imylomylo/32da17f537e2b74b36cadac6245c87b0 to your computer and use it in GitHub Desktop.
Save imylomylo/32da17f537e2b74b36cadac6245c87b0 to your computer and use it in GitHub Desktop.
Dice flow
Setting up a table
#############
https://github.com/smk762/kmd_pulp/blob/master/Staked/dice/dice_table.sh#L176
We can see here that to setup a table we use the `dicefund` command which gives us a `rawtransaction` to broadcast on the network at https://github.com/smk762/kmd_pulp/blob/master/Staked/dice/dice_table.sh#L180
We go into a loop to check that the `dicefund` (table setup) transaction has been confirmed https://github.com/smk762/kmd_pulp/blob/master/Staked/dice/dice_table.sh#L191
When confirmed, doing a `dicelist` gives us a list of tables https://github.com/smk762/kmd_pulp/blob/master/Staked/dice/dice_table.sh#L195
Then need to fund the table with UTXOs and wait for them to confirm using `diceaddfunds` https://github.com/smk762/kmd_pulp/blob/master/Staked/dice/dice_table.sh#L238
Betting
######
Find a list of tables that are available with `dicelist` https://github.com/smk762/kmd_pulp/blob/master/Staked/dice/dice.sh#L95
Using the tx id of the table we are interested in we issue a `diceinfo` https://github.com/smk762/kmd_pulp/blob/master/Staked/dice/dice.sh#L124 and it gives us min and max bets and other info about this table
Placing a bet with `dicebet` https://github.com/smk762/kmd_pulp/blob/master/Staked/dice/dice.sh#L183 matching the name txid that created the table, an amount and the odds we wait for a successful result of placing the bet (not error) followed by broadcasting the bet with `sendrawtransaction` https://github.com/smk762/kmd_pulp/blob/master/Staked/dice/dice.sh#L200 and then waiting for the bet to be confirmed
Bet is confirmed in mempool with txid in block https://github.com/smk762/kmd_pulp/blob/master/Staked/dice/dice.sh#L214
Wait some time for the `betstatus` to be determined https://github.com/smk762/kmd_pulp/blob/master/Staked/dice/dice.sh#L249
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment