Add helper functions for hashing annoucements for SbExplorerClient (#2861)

This commit is contained in:
benthecarman 2021-04-06 06:28:02 -05:00 committed by GitHub
parent c738f23e58
commit a4454e83a1
2 changed files with 19 additions and 1 deletions

View file

@ -10,6 +10,7 @@ import akka.http.scaladsl.model.{
}
import akka.http.scaladsl.{Http, HttpExt}
import akka.util.ByteString
import org.bitcoins.core.protocol.tlv.OracleAnnouncementTLV
import org.bitcoins.crypto.Sha256Digest
import org.bitcoins.explorer.env.ExplorerEnv
import org.bitcoins.explorer.model.{
@ -50,6 +51,14 @@ case class SbExplorerClient(env: ExplorerEnv)(implicit system: ActorSystem) {
}
}
/** Gets an announcement from the oracle explorer
* @see https://gist.github.com/Christewart/a9e55d9ba582ac9a5ceffa96db9d7e1f#get-event
*/
def getEvent(
announcement: OracleAnnouncementTLV): Future[SbAnnouncementEvent] = {
getEvent(announcement.sha256)
}
/** Gets an announcement from the oracle explorer
* @see https://gist.github.com/Christewart/a9e55d9ba582ac9a5ceffa96db9d7e1f#get-event
*/

View file

@ -1,6 +1,6 @@
package org.bitcoins.explorer.model
import org.bitcoins.core.protocol.tlv.OracleAttestmentV0TLV
import org.bitcoins.core.protocol.tlv._
import org.bitcoins.crypto.Sha256Digest
case class CreateAttestations(
@ -11,3 +11,12 @@ case class CreateAttestations(
s"attestations=${attestment.hex}"
}
}
object CreateAttestations {
def apply(
announcement: OracleAnnouncementTLV,
attestment: OracleAttestmentV0TLV): CreateAttestations = {
CreateAttestations(announcement.sha256, attestment)
}
}