Skip to content

Commit

Permalink
Update Oracle Server docs, fix oracle server bugs (#2581)
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman committed Jan 29, 2021
1 parent 7e61f45 commit aee8fd2
Show file tree
Hide file tree
Showing 5 changed files with 206 additions and 191 deletions.
32 changes: 18 additions & 14 deletions app/cli/src/main/scala/org/bitcoins/cli/ConsoleCli.scala
Expand Up @@ -1061,7 +1061,7 @@ object ConsoleCli {
.text(s"Get oracle's staking address"),
cmd("listevents")
.action((_, conf) => conf.copy(command = ListEvents))
.text(s"Lists all event nonces"),
.text(s"Lists all event announcements"),
cmd("createevent")
.action((_, conf) =>
conf.copy(command = CreateEvent("", Instant.MIN, Seq.empty)))
Expand Down Expand Up @@ -1169,21 +1169,23 @@ object ConsoleCli {
}))
),
cmd("getevent")
.action((_, conf) => conf.copy(command = GetEvent(null)))
.action((_, conf) =>
conf.copy(command = GetEvent(OracleAnnouncementV0TLV.dummy)))
.text("Get an event's details")
.children(
arg[OracleAnnouncementTLV]("event")
.text("The event's oracle event tlv")
.text("The event's oracle announcement tlv")
.required()
.action((oracleEvent, conf) =>
.action((announcementTLV, conf) =>
conf.copy(command = conf.command match {
case getEvent: GetEvent =>
getEvent.copy(announcementTLV = oracleEvent)
getEvent.copy(announcementTLV = announcementTLV)
case other => other
}))
),
cmd("signevent")
.action((_, conf) => conf.copy(command = SignEvent(null, "")))
.action((_, conf) =>
conf.copy(command = SignEvent(OracleAnnouncementV0TLV.dummy, "")))
.text("Signs an event")
.children(
arg[OracleAnnouncementTLV]("event")
Expand All @@ -1206,11 +1208,12 @@ object ConsoleCli {
}))
),
cmd("signdigits")
.action((_, conf) => conf.copy(command = SignDigits(null, 0)))
.action((_, conf) =>
conf.copy(command = SignDigits(OracleAnnouncementV0TLV.dummy, 0)))
.text("Signs a large range event")
.children(
arg[OracleAnnouncementTLV]("event")
.text("The event's oracle event tlv")
.text("The event's oracle announcement tlv")
.required()
.action((event, conf) =>
conf.copy(command = conf.command match {
Expand All @@ -1219,7 +1222,7 @@ object ConsoleCli {
case other => other
})),
arg[Long]("outcome")
.text("The event's oracle event tlv")
.text("The number to sign")
.required()
.action((num, conf) =>
conf.copy(command = conf.command match {
Expand All @@ -1229,11 +1232,12 @@ object ConsoleCli {
}))
),
cmd("getsignatures")
.action((_, conf) => conf.copy(command = GetSignatures(null)))
.action((_, conf) =>
conf.copy(command = GetSignatures(OracleAnnouncementV0TLV.dummy)))
.text("Get the signatures from a signed event")
.children(
arg[OracleAnnouncementTLV]("event")
.text("The event descriptor associated with the event to sign")
.text("The oracle announcement associated with the event to sign")
.required()
.action((event, conf) =>
conf.copy(command = conf.command match {
Expand Down Expand Up @@ -1508,8 +1512,8 @@ object ConsoleCli {
RequestParam("getstakingaddress")
case ListEvents =>
RequestParam("listevents")
case GetEvent(nonce) =>
RequestParam("getevent", Seq(up.writeJs(nonce)))
case GetEvent(announcementTLV) =>
RequestParam("getevent", Seq(up.writeJs(announcementTLV)))
case CreateEvent(label, time, outcomes) =>
RequestParam(
"createevent",
Expand All @@ -1534,7 +1538,7 @@ object ConsoleCli {
case SignEvent(tlv, outcome) =>
RequestParam("signevent", Seq(up.writeJs(tlv), up.writeJs(outcome)))
case SignDigits(tlv, num) =>
RequestParam("signlargenumber", Seq(up.writeJs(tlv), up.writeJs(num)))
RequestParam("signdigits", Seq(up.writeJs(tlv), up.writeJs(num)))
case GetSignatures(tlv) =>
RequestParam("getsignatures", Seq(up.writeJs(tlv)))

Expand Down
Expand Up @@ -198,7 +198,7 @@ case class OracleRoutes(oracle: DLCOracle)(implicit
complete {
oracle.findEvent(announcementTLV.eventTLV).map {
case Some(completed: CompletedOracleEvent) =>
Server.httpSuccess(completed.signatures.map(_.hex))
Server.httpSuccess(completed.oracleAttestmentV0TLV.hex)
case None | Some(_: PendingOracleEvent) =>
Server.httpSuccess(ujson.Null)
}
Expand Down
87 changes: 87 additions & 0 deletions docs/oracle/build-oracle-server.md
@@ -0,0 +1,87 @@
---
id: build-oracle-server
title: Building the Oracle Server
---

The Oracle Server is a DLC Oracle with functionality for creating events and attesting to them.
The Oracle Server is interactable through the RPC interface.

The following a guide is for how to build the oracle server.
If you are looking for the documentation on how to use the oracle server,
checkout [this page](oracle-server.md).

## Step 1: Java and Scala

To get started you will need Java, Scala, and some other nice tools installed, luckily the Scala team has an easy setup process!

Simply follow the instructions in [this short blog](https://www.scala-lang.org/2020/06/29/one-click-install.html) to get started.

## Step 2: Bitcoin-S Repository

Now, it is time to clone the [Bitcoin-S repository](https://github.com/bitcoin-s/bitcoin-s/) by running

```bashrc
git clone --recursive git@github.com:bitcoin-s/bitcoin-s.git
```

or alternatively, if you do not have ssh setup with github, you can run

```bashrc
git clone --recursive https://github.com/bitcoin-s/bitcoin-s.git
```

Next, you will want to execute the commands

```bashrc
cd bitcoin-s
git submodule update
```

to download the secp256k1 submodule, this is so cryptographic functions like signing will be faster.

## Step 3: Building the Oracle Server

You can build the oracle server with the [sbt native packager](https://github.com/sbt/sbt-native-packager).
The native packager offers [numerous ways to package the project](https://github.com/sbt/sbt-native-packager#examples).

In this example we are going to use `stage` which will produce bash scripts we can easily execute. You can stage the server with the following command.

```bash
sbt oracleServer/universal:stage
```

This will produce a script to execute bitcoin-s which you can start with

```bash
./app/oracle-server/target/universal/stage/bin/bitcoin-s-oracle-server
```

Alternatively you can run the server by just using:

```bash
sbt oracleServer/run
```

## Step 4: Configuration

If you would like to pass in a custom datadir for your server, you can do

```bash
./app/oracle-server/target/universal/stage/bin/bitcoin-s-oracle-server --datadir /path/to/datadir/
```

To use a config file that is not the `bitcoin-s.conf` file in your datadir, you can do

```bash
./app/oracle-server/target/universal/stage/bin/bitcoin-s-oracle-server --conf /path/to/file.conf
```

You can also pass in a custom `rpcport` to bind to

```bash
./app/oracle-server/target/universal/stage/bin/bitcoin-s-oracle-server --rpcport 12345
```

For more information on configuring the server please see our [configuration](../config/configuration.md) document.

For more information on how to use our built in `cli` to interact with the server please see the [cli docs](../applications/cli.md).

0 comments on commit aee8fd2

Please sign in to comment.