mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-03-24 16:44:48 +01:00
Add fixed dlc doc instructions (#1376)
This commit is contained in:
parent
20c6e43df2
commit
e49bb86e47
1 changed files with 5 additions and 5 deletions
|
@ -48,7 +48,7 @@ f8758d7f03a65b67b90f62301a3554849bde6d00d50e965eb123398de9fd6ea7af05f01f1ca852cf
|
|||
|
||||
Note: if you wish to setup your own oracle for testing, you can do so by pasting the following into the `sbt core/console`:
|
||||
|
||||
```scala
|
||||
```scala mdoc:to-string
|
||||
import org.bitcoins.core.crypto._
|
||||
import org.bitcoins.core.util.CryptoUtil
|
||||
import scodec.bits.ByteVector
|
||||
|
@ -56,15 +56,15 @@ import org.bitcoins.core.currency._
|
|||
|
||||
val privKey = ECPrivateKey.freshPrivateKey
|
||||
val pubKey = privKey.publicKey
|
||||
val nonce = SchnorrNonce.freshNonce
|
||||
val rValue = nonce.publicKey
|
||||
val kValue = ECPrivateKey.freshPrivateKey
|
||||
val rValue = kValue.schnorrNonce
|
||||
val winHash = CryptoUtil.sha256(ByteVector("WIN".getBytes)).flip
|
||||
val loseHash = CryptoUtil.sha256(ByteVector("LOSE".getBytes)).flip
|
||||
|
||||
(pubKey.bytes ++ rValue.bytes).toHex
|
||||
(winHash.bytes ++ Satoshis(100000).bytes ++ loseHash.bytes ++ Satoshis.zero.bytes).toHex
|
||||
Schnorr.signWithNonce(winHash.bytes, privKey, nonce).hex
|
||||
Schnorr.signWithNonce(loseHash.bytes, privKey, nonce).hex
|
||||
privKey.schnorrSignWithNonce(winHash.bytes, kValue)
|
||||
privKey.schnorrSignWithNonce(loseHash.bytes, kValue)
|
||||
```
|
||||
|
||||
Where you can replace the messages `WIN` and `LOSE` to have the oracle sign any two messages, and replace `Satoshis(100000)` and `Satoshis.zero` to change the outcomes.
|
||||
|
|
Loading…
Add table
Reference in a new issue