-
Notifications
You must be signed in to change notification settings - Fork 31
Closed
Description
The script in the payment object should be roughly like this:
OP_2 ${publicKeyW} ${publicKeyB} ${operatorPublicKey} OP_3 OP_CHECKMULTISIG
- Initially, the two players should jointly sign and broadcast a transaction that spends the wagers to the winner
- If a certain number of blocks has passed where the looser refuses to sign, the winner can contact the operator with a partially signed transaction. The operator would check who the winner is and that the partially signed transaction pays to the winner. In that case the operator would sign and bradcast the transaction.
Possible implementation
In the test
- Copy the last test in
apps.async-testand tests spending from a 2-of-3 multisig script (as above)
In the game
- Update the
_ownersproperty of thePaymentclass to be the above multi-sig script - Update the
getASMfunction to return the same script - Copy the
spendWithSecretfunction and call itspendWithSecret2 - Winner creates an unsinged transaction
redeemTx - Winner creates their signature using
bscript.signature.encode(hdPrivateKey.sign(sigHash), Transaction.SIGHASH_ALL) - Winner then send the redeemTx and their signature to the operator
- The operator syncs against the game and determines if the output script pays to the winner (this check can be implemented when the rest works). If not the operator returns an error.
- The operator also created a signature using
bscript.signature.encode(hdPrivateKey.sign(sigHash), Transaction.SIGHASH_ALL) - The operator adds both signatures as the input script as in the end of the
spendWithSecretfunction - The operator broadcasts the transaction
Notes
- The white player calls
makeTxto build the partially signed transaction that the white player send to the black player in the URL - The black player then calls the
completeTxfunction to complete the transaction - The winner calls the
spendfunction once the game is over. This function accessed the/secretroute on the server - The winner build the spending transaction in the
spendWithSecretfunction
Metadata
Metadata
Assignees
Labels
No labels