mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-01-19 05:43:51 +01:00
Add fixed dlc doc instructions (#1376)
This commit is contained in:
parent
37c62369eb
commit
e02664b01a
@ -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…
Reference in New Issue
Block a user