mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2024-11-19 01:40:55 +01:00
Pull over simple syntax changes for {cli,oracleServer,bench,dlcNode,dlcOracle,dlcOracleTest,eclairRpc,lndRpc,lndRpcTest} from #5713 (#5721)
This commit is contained in:
parent
602725174f
commit
7c07aa0355
@ -124,7 +124,7 @@ object CliReaders {
|
||||
override def arity: Int = 1
|
||||
override def reads: String => ContractDescriptorTLV = { str =>
|
||||
upickle.default.read[ContractDescriptorV0TLV](str)(
|
||||
Picklers.contractDescriptorV0
|
||||
using Picklers.contractDescriptorV0
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -148,8 +148,8 @@ case class OracleRoutes(oracle: DLCOracleApi)(implicit
|
||||
oracle.findEvent(eventName).map {
|
||||
case Some(event: OracleEvent) =>
|
||||
val outcomesJson = event.eventDescriptorTLV match {
|
||||
case enum: EnumEventDescriptorV0TLV =>
|
||||
enum.outcomes.map(outcome => Str(outcome.normStr))
|
||||
case e: EnumEventDescriptorV0TLV =>
|
||||
e.outcomes.map(outcome => Str(outcome.normStr))
|
||||
case decomp: DigitDecompositionEventDescriptorV0TLV =>
|
||||
val digits = 0.until(decomp.numDigits.toInt).map { _ =>
|
||||
0
|
||||
|
@ -1,19 +0,0 @@
|
||||
package org.bitcoins.bench.eclair
|
||||
|
||||
import org.bitcoins.bench.eclair.PaymentLog.PaymentLogEntry
|
||||
|
||||
import scala.collection.JavaConverters._
|
||||
|
||||
object EclairBenchUtil {
|
||||
|
||||
def paymentLogValues(): Vector[PaymentLogEntry] = {
|
||||
PaymentLog.paymentLog
|
||||
.values()
|
||||
.asScala
|
||||
.toVector
|
||||
}
|
||||
|
||||
def convertStrings(strings: Vector[String]): java.util.List[String] = {
|
||||
strings.asJava
|
||||
}
|
||||
}
|
@ -33,7 +33,7 @@ class DLCServer(
|
||||
|
||||
IO(Tcp) ! Tcp.Bind(self, bindAddress)
|
||||
|
||||
private[this] var socketOpt: Option[ActorRef] = None
|
||||
private var socketOpt: Option[ActorRef] = None
|
||||
|
||||
override def receive: Receive = LoggingReceive {
|
||||
case Tcp.Bound(localAddress) =>
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -11,29 +11,28 @@ class DLCOracleAppConfigTest extends DLCOracleAppConfigFixture {
|
||||
|
||||
behavior of "DLCOracleAppConfig"
|
||||
|
||||
it must "start the same oracle twice" in {
|
||||
dlcOracleAppConfig: DLCOracleAppConfig =>
|
||||
val started1F = dlcOracleAppConfig.start()
|
||||
val started2F = started1F.flatMap(_ => dlcOracleAppConfig.start())
|
||||
for {
|
||||
_ <- started1F
|
||||
_ <- started2F
|
||||
dlcOracle1 = new DLCOracle()(dlcOracleAppConfig)
|
||||
dlcOracle2 = new DLCOracle()(dlcOracleAppConfig)
|
||||
} yield {
|
||||
assert(dlcOracle1.publicKey == dlcOracle2.publicKey)
|
||||
}
|
||||
it must "start the same oracle twice" in { dlcOracleAppConfig =>
|
||||
val started1F = dlcOracleAppConfig.start()
|
||||
val started2F = started1F.flatMap(_ => dlcOracleAppConfig.start())
|
||||
for {
|
||||
_ <- started1F
|
||||
_ <- started2F
|
||||
dlcOracle1 = new DLCOracle()(dlcOracleAppConfig)
|
||||
dlcOracle2 = new DLCOracle()(dlcOracleAppConfig)
|
||||
} yield {
|
||||
assert(dlcOracle1.publicKey() == dlcOracle2.publicKey())
|
||||
}
|
||||
}
|
||||
|
||||
it must "initialize the oracle, move the seed somewhere else, and then start the oracle again and get the same pubkeys" in {
|
||||
dlcOracleAppConfig: DLCOracleAppConfig =>
|
||||
dlcOracleAppConfig =>
|
||||
val seedFile = dlcOracleAppConfig.seedPath
|
||||
val startedF = dlcOracleAppConfig.start()
|
||||
val pubKeyBeforeMoveF = for {
|
||||
_ <- startedF
|
||||
dlcOracle = new DLCOracle()(dlcOracleAppConfig)
|
||||
} yield {
|
||||
dlcOracle.publicKey
|
||||
dlcOracle.publicKey()
|
||||
}
|
||||
|
||||
// stop old oracle
|
||||
@ -69,14 +68,14 @@ class DLCOracleAppConfigTest extends DLCOracleAppConfigFixture {
|
||||
for {
|
||||
_ <- stoppedF
|
||||
pubKey1 <- pubKeyBeforeMoveF
|
||||
pubKey2 <- dlcOracle2F.map(_.publicKey)
|
||||
pubKey2 <- dlcOracle2F.map(_.publicKey())
|
||||
} yield {
|
||||
assert(pubKey1 == pubKey2)
|
||||
}
|
||||
}
|
||||
|
||||
it must "fail to start the oracle app config if we have different seeds" in {
|
||||
dlcOracleAppConfig: DLCOracleAppConfig =>
|
||||
dlcOracleAppConfig =>
|
||||
val seedFile = dlcOracleAppConfig.seedPath
|
||||
val startedF = dlcOracleAppConfig.start()
|
||||
|
||||
|
@ -59,7 +59,7 @@ case class DLCOracle()(implicit val conf: DLCOracleAppConfig)
|
||||
private val rValueChainIndex = 0
|
||||
|
||||
/** The root private key for this oracle */
|
||||
private[this] val extPrivateKey: ExtPrivateKeyHardened = {
|
||||
private val extPrivateKey: ExtPrivateKeyHardened = {
|
||||
WalletStorage.getPrivateKeyFromDisk(
|
||||
conf.kmConf.seedPath,
|
||||
SegWitTestNet3Priv,
|
||||
@ -83,10 +83,10 @@ case class DLCOracle()(implicit val conf: DLCOracleAppConfig)
|
||||
extPrivateKey.deriveChildPrivKey(path).key
|
||||
}
|
||||
|
||||
override val publicKey: SchnorrPublicKey = signingKey.schnorrPublicKey
|
||||
override def publicKey(): SchnorrPublicKey = signingKey.schnorrPublicKey
|
||||
|
||||
override def stakingAddress(network: BitcoinNetwork): Bech32Address =
|
||||
Bech32Address(P2WPKHWitnessSPKV0(publicKey.publicKey), network)
|
||||
Bech32Address(P2WPKHWitnessSPKV0(publicKey().publicKey), network)
|
||||
|
||||
protected[bitcoins] val rValueDAO: RValueDAO = RValueDAO()
|
||||
protected[bitcoins] val eventDAO: EventDAO = EventDAO()
|
||||
@ -283,7 +283,7 @@ case class DLCOracle()(implicit val conf: DLCOracleAppConfig)
|
||||
|
||||
oracleAnnouncement = OracleAnnouncementV0TLV(
|
||||
announcementSignature = announcementSignature,
|
||||
publicKey = publicKey,
|
||||
publicKey = publicKey(),
|
||||
eventTLV = eventTLV
|
||||
)
|
||||
|
||||
@ -608,7 +608,7 @@ object DLCOracle {
|
||||
def fromDatadir(path: Path, configs: Vector[Config])(implicit
|
||||
ec: ExecutionContext
|
||||
): Future[DLCOracle] = {
|
||||
implicit val appConfig =
|
||||
implicit val appConfig: DLCOracleAppConfig =
|
||||
DLCOracleAppConfig.fromDatadir(datadir = path, configs)
|
||||
val masterXpubDAO: MasterXPubDAO = MasterXPubDAO()(ec, appConfig)
|
||||
val oracle = DLCOracle()
|
||||
@ -617,9 +617,9 @@ object DLCOracle {
|
||||
_ <- appConfig.start()
|
||||
_ <- MasterXPubUtil.checkMasterXPub(oracle.getRootXpub, masterXpubDAO)
|
||||
differentKeyDbs <- oracle.eventDAO.findDifferentPublicKey(
|
||||
oracle.publicKey
|
||||
oracle.publicKey()
|
||||
)
|
||||
fixedDbs = differentKeyDbs.map(_.copy(pubkey = oracle.publicKey))
|
||||
fixedDbs = differentKeyDbs.map(_.copy(pubkey = oracle.publicKey()))
|
||||
_ <- oracle.eventDAO.updateAll(fixedDbs)
|
||||
} yield oracle
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ class EclairRpcClient(
|
||||
Seq(
|
||||
from.map(x => "from" -> x.getEpochSecond.toString),
|
||||
to.map(x => "to" -> x.getEpochSecond.toString)
|
||||
).flatten: _*
|
||||
).flatten*
|
||||
)
|
||||
|
||||
override def channel(channelId: ChannelId): Future[ChannelResult] = {
|
||||
@ -111,7 +111,7 @@ class EclairRpcClient(
|
||||
|
||||
private def channels(nodeId: Option[NodeId]): Future[Vector[ChannelInfo]] = {
|
||||
val params = Seq(nodeId.map(id => "nodeId" -> id.toString)).flatten
|
||||
eclairCall[Vector[ChannelInfo]]("channels", params: _*)
|
||||
eclairCall[Vector[ChannelInfo]]("channels", params*)
|
||||
}
|
||||
|
||||
def channels(): Future[Vector[ChannelInfo]] = channels(nodeId = None)
|
||||
@ -130,7 +130,7 @@ class EclairRpcClient(
|
||||
scriptPubKey.map(x => "scriptPubKey" -> BytesUtil.encodeHex(x.asmBytes))
|
||||
).flatten
|
||||
|
||||
eclairCall[ChannelCommandResult]("close", params: _*)
|
||||
eclairCall[ChannelCommandResult]("close", params*)
|
||||
}
|
||||
|
||||
def close(channelId: ChannelId): Future[ChannelCommandResult] =
|
||||
@ -193,7 +193,7 @@ class EclairRpcClient(
|
||||
Some("invoice" -> invoice.toString),
|
||||
amountMsat.map(x => "amountMsat" -> x.toBigDecimal.toString)
|
||||
).flatten
|
||||
eclairCall[Vector[Route]]("findroute", params: _*)
|
||||
eclairCall[Vector[Route]]("findroute", params*)
|
||||
}
|
||||
|
||||
override def forceClose(
|
||||
@ -262,7 +262,7 @@ class EclairRpcClient(
|
||||
|
||||
// this is unfortunately returned in this format
|
||||
// created channel 30bdf849eb9f72c9b41a09e38a6d83138c2edf332cb116dd7cf0f0dfb66be395
|
||||
val call = eclairCall[String]("open", params: _*)
|
||||
val call = eclairCall[String]("open", params*)
|
||||
// let's just return the chanId
|
||||
// format:
|
||||
// created channel 19e11470b0dd96ed15c56ea8f32e9a3277dcbd570e7392c1c34709adc7ebfdc3 with fundingTxId=c2fdebc7ad0947c3c192730e57bddc77329a2ef3a86ec515ed96ddb07014e119 and fees=24750 sat
|
||||
@ -413,7 +413,7 @@ class EclairRpcClient(
|
||||
paymentPreimage.map(x => "paymentPreimage" -> x.hex)
|
||||
).flatten
|
||||
|
||||
val responseF = eclairCall[InvoiceResult]("createinvoice", params: _*)
|
||||
val responseF = eclairCall[InvoiceResult]("createinvoice", params*)
|
||||
|
||||
responseF.flatMap { res =>
|
||||
Future.fromTry(LnInvoice.fromStringT(res.serialized))
|
||||
@ -515,7 +515,7 @@ class EclairRpcClient(
|
||||
externalId.map(x => "externalId" -> x)
|
||||
).flatten
|
||||
|
||||
eclairCall[PaymentId]("payinvoice", params: _*)
|
||||
eclairCall[PaymentId]("payinvoice", params*)
|
||||
}
|
||||
|
||||
override def getReceivedInfo(
|
||||
@ -541,7 +541,7 @@ class EclairRpcClient(
|
||||
case _: JsError => JsSuccess(None)
|
||||
}
|
||||
}
|
||||
eclairCall[Option[IncomingPayment]]("getreceivedinfo", params: _*)(r)
|
||||
eclairCall[Option[IncomingPayment]]("getreceivedinfo", params*)(r)
|
||||
}
|
||||
|
||||
override def getSentInfo(
|
||||
@ -575,7 +575,7 @@ class EclairRpcClient(
|
||||
externalId.map(x => "externalId" -> x)
|
||||
).flatten
|
||||
|
||||
eclairCall[PaymentId]("sendtonode", params: _*)
|
||||
eclairCall[PaymentId]("sendtonode", params*)
|
||||
}
|
||||
|
||||
def sendToRoute(
|
||||
@ -603,7 +603,7 @@ class EclairRpcClient(
|
||||
parentId.map(x => "parentId" -> x.toString),
|
||||
externalId.map(x => "externalId" -> x)
|
||||
).flatten
|
||||
eclairCall[SendToRouteResult]("sendtoroute", params: _*)
|
||||
eclairCall[SendToRouteResult]("sendtoroute", params*)
|
||||
}
|
||||
|
||||
override def updateRelayFee(
|
||||
@ -640,7 +640,7 @@ class EclairRpcClient(
|
||||
Seq(
|
||||
from.map(x => "from" -> x.toSeconds.toString),
|
||||
to.map(x => "to" -> x.toSeconds.toString)
|
||||
).flatten: _*
|
||||
).flatten*
|
||||
)
|
||||
}
|
||||
|
||||
@ -676,7 +676,7 @@ class EclairRpcClient(
|
||||
Seq(
|
||||
from.map(x => "from" -> x.getEpochSecond.toString),
|
||||
to.map(x => "to" -> x.getEpochSecond.toString)
|
||||
).flatten: _*
|
||||
).flatten*
|
||||
)
|
||||
resF.flatMap(xs =>
|
||||
Future.sequence(
|
||||
@ -727,7 +727,7 @@ class EclairRpcClient(
|
||||
private def eclairCall[T](command: String, parameters: (String, String)*)(
|
||||
implicit reader: Reads[T]
|
||||
): Future[T] = {
|
||||
val request = buildRequest(getDaemon, command, parameters: _*)
|
||||
val request = buildRequest(getDaemon, command, parameters*)
|
||||
|
||||
logger.trace(s"eclair rpc call ${request}")
|
||||
val responseF = sendRequest(request)
|
||||
@ -810,7 +810,7 @@ class EclairRpcClient(
|
||||
HttpRequest(
|
||||
method = HttpMethods.POST,
|
||||
uri,
|
||||
entity = FormData(params: _*).toEntity
|
||||
entity = FormData(params*).toEntity
|
||||
)
|
||||
.addCredentials(
|
||||
HttpCredentials.createBasicHttpCredentials(username, password)
|
||||
|
@ -17,7 +17,7 @@ import org.bitcoins.core.wallet.fee._
|
||||
import org.bitcoins.crypto._
|
||||
import org.bitcoins.testkit.async.TestAsyncUtil
|
||||
import org.bitcoins.testkit.fixtures.DualLndFixture
|
||||
import scodec.bits.{ByteVector, HexStringSyntax}
|
||||
import scodec.bits.ByteVector
|
||||
import signrpc.SignMethod
|
||||
|
||||
import scala.concurrent.{Await, Future}
|
||||
@ -439,7 +439,8 @@ class LndRpcClientPairTest extends DualLndFixture with LndUtils {
|
||||
it must "send and receive a custom message" in { params =>
|
||||
val (_, lndA, lndB) = params
|
||||
|
||||
val customMessage = UnknownTLV(BigSizeUInt(48000), hex"0094355324")
|
||||
val customMessage =
|
||||
UnknownTLV(BigSizeUInt(48000), ByteVector.fromValidHex("0094355324"))
|
||||
|
||||
val subscribeF = lndA.subscribeCustomMessages().runWith(Sink.head)
|
||||
|
||||
|
@ -142,7 +142,7 @@ case class LndRpcClient(instance: LndInstance, binaryOpt: Option[File] = None)(
|
||||
|
||||
// These need to be lazy so we don't try and fetch
|
||||
// the tls certificate before it is generated
|
||||
private[this] lazy val certStreamOpt: Option[InputStream] = {
|
||||
private lazy val certStreamOpt: Option[InputStream] = {
|
||||
instance.certFileOpt match {
|
||||
case Some(file) => Some(new FileInputStream(file))
|
||||
case None =>
|
||||
|
Loading…
Reference in New Issue
Block a user