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 arity: Int = 1
|
||||||
override def reads: String => ContractDescriptorTLV = { str =>
|
override def reads: String => ContractDescriptorTLV = { str =>
|
||||||
upickle.default.read[ContractDescriptorV0TLV](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 {
|
oracle.findEvent(eventName).map {
|
||||||
case Some(event: OracleEvent) =>
|
case Some(event: OracleEvent) =>
|
||||||
val outcomesJson = event.eventDescriptorTLV match {
|
val outcomesJson = event.eventDescriptorTLV match {
|
||||||
case enum: EnumEventDescriptorV0TLV =>
|
case e: EnumEventDescriptorV0TLV =>
|
||||||
enum.outcomes.map(outcome => Str(outcome.normStr))
|
e.outcomes.map(outcome => Str(outcome.normStr))
|
||||||
case decomp: DigitDecompositionEventDescriptorV0TLV =>
|
case decomp: DigitDecompositionEventDescriptorV0TLV =>
|
||||||
val digits = 0.until(decomp.numDigits.toInt).map { _ =>
|
val digits = 0.until(decomp.numDigits.toInt).map { _ =>
|
||||||
0
|
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)
|
IO(Tcp) ! Tcp.Bind(self, bindAddress)
|
||||||
|
|
||||||
private[this] var socketOpt: Option[ActorRef] = None
|
private var socketOpt: Option[ActorRef] = None
|
||||||
|
|
||||||
override def receive: Receive = LoggingReceive {
|
override def receive: Receive = LoggingReceive {
|
||||||
case Tcp.Bound(localAddress) =>
|
case Tcp.Bound(localAddress) =>
|
||||||
|
@ -30,50 +30,50 @@ class DLCOracleTest extends DLCOracleFixture {
|
|||||||
|
|
||||||
behavior of "DLCOracle"
|
behavior of "DLCOracle"
|
||||||
|
|
||||||
it must "correctly initialize" in { dlcOracle: DLCOracle =>
|
it must "correctly initialize" in { dlcOracle =>
|
||||||
dlcOracle.conf.exists().map(assert(_))
|
dlcOracle.conf.exists().map(assert(_))
|
||||||
}
|
}
|
||||||
|
|
||||||
it must "start with no events" in { dlcOracle: DLCOracle =>
|
it must "start with no events" in { dlcOracle =>
|
||||||
dlcOracle.listEventDbs().map { events =>
|
dlcOracle.listEventDbs().map { events =>
|
||||||
assert(events.isEmpty)
|
assert(events.isEmpty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
it must "start with no pending events" in { dlcOracle: DLCOracle =>
|
it must "start with no pending events" in { dlcOracle =>
|
||||||
dlcOracle.listPendingEventDbs().map { events =>
|
dlcOracle.listPendingEventDbs().map { events =>
|
||||||
assert(events.isEmpty)
|
assert(events.isEmpty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
it must "not find an event it doesn't have" in { dlcOracle: DLCOracle =>
|
it must "not find an event it doesn't have" in { dlcOracle =>
|
||||||
val dummyEvent = TLVGen.oracleEventV0TLV.sampleSome
|
val dummyEvent = TLVGen.oracleEventV0TLV.sampleSome
|
||||||
dlcOracle.findEvent(dummyEvent).map { eventOpt =>
|
dlcOracle.findEvent(dummyEvent).map { eventOpt =>
|
||||||
assert(eventOpt.isEmpty)
|
assert(eventOpt.isEmpty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
it must "calculate the correct staking address" in { dlcOracle: DLCOracle =>
|
it must "calculate the correct staking address" in { dlcOracle =>
|
||||||
forAllAsync(ChainParamsGenerator.bitcoinNetworkParams) { network =>
|
forAllAsync(ChainParamsGenerator.bitcoinNetworkParams) { network =>
|
||||||
val expected =
|
val expected =
|
||||||
Bech32Address(
|
Bech32Address(
|
||||||
P2WPKHWitnessSPKV0(dlcOracle.publicKey.publicKey),
|
P2WPKHWitnessSPKV0(dlcOracle.publicKey().publicKey),
|
||||||
network
|
network
|
||||||
)
|
)
|
||||||
assert(dlcOracle.stakingAddress(network) == expected)
|
assert(dlcOracle.stakingAddress(network) == expected)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
it must "correctly sign a message" in { dlcOracle: DLCOracle =>
|
it must "correctly sign a message" in { dlcOracle =>
|
||||||
val message = "hello world"
|
val message = "hello world"
|
||||||
val signature = dlcOracle.signMessage(message)
|
val signature = dlcOracle.signMessage(message)
|
||||||
assert(
|
assert(
|
||||||
dlcOracle.publicKey.verify(CryptoUtil.sha256(message).bytes, signature)
|
dlcOracle.publicKey().verify(CryptoUtil.sha256(message).bytes, signature)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
it must "get the correctly sorted nonces in an announcement " in {
|
it must "get the correctly sorted nonces in an announcement " in {
|
||||||
dlcOracle: DLCOracle =>
|
dlcOracle =>
|
||||||
val eventName = "test"
|
val eventName = "test"
|
||||||
val descriptorTLV =
|
val descriptorTLV =
|
||||||
DigitDecompositionEventDescriptorV0TLV(
|
DigitDecompositionEventDescriptorV0TLV(
|
||||||
@ -110,8 +110,7 @@ class DLCOracleTest extends DLCOracleFixture {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
it must "have same keys with different network configs" in {
|
it must "have same keys with different network configs" in { oracleA =>
|
||||||
oracleA: DLCOracle =>
|
|
||||||
// set to mainnet and give separate db
|
// set to mainnet and give separate db
|
||||||
val newConf = oracleA.conf.newConfigOfType(
|
val newConf = oracleA.conf.newConfigOfType(
|
||||||
Vector(
|
Vector(
|
||||||
@ -122,7 +121,7 @@ class DLCOracleTest extends DLCOracleFixture {
|
|||||||
|
|
||||||
newConf.start().flatMap { _ =>
|
newConf.start().flatMap { _ =>
|
||||||
val oracleB = new DLCOracle()(newConf)
|
val oracleB = new DLCOracle()(newConf)
|
||||||
assert(oracleA.publicKey == oracleB.publicKey)
|
assert(oracleA.publicKey() == oracleB.publicKey())
|
||||||
|
|
||||||
val eventName = "test"
|
val eventName = "test"
|
||||||
val descriptorTLV =
|
val descriptorTLV =
|
||||||
@ -168,8 +167,7 @@ class DLCOracleTest extends DLCOracleFixture {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
it must "create a new event and list it with pending" in {
|
it must "create a new event and list it with pending" in { dlcOracle =>
|
||||||
dlcOracle: DLCOracle =>
|
|
||||||
val time = futureTime
|
val time = futureTime
|
||||||
|
|
||||||
for {
|
for {
|
||||||
@ -181,8 +179,7 @@ class DLCOracleTest extends DLCOracleFixture {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
it must "create the same event twice and list them" in {
|
it must "create the same event twice and list them" in { dlcOracle =>
|
||||||
dlcOracle: DLCOracle =>
|
|
||||||
val time = futureTime
|
val time = futureTime
|
||||||
|
|
||||||
for {
|
for {
|
||||||
@ -195,8 +192,7 @@ class DLCOracleTest extends DLCOracleFixture {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
it must "create two events and use incrementing key indexes" in {
|
it must "create two events and use incrementing key indexes" in { dlcOracle =>
|
||||||
dlcOracle: DLCOracle =>
|
|
||||||
val create1F =
|
val create1F =
|
||||||
dlcOracle.createNewDigitDecompAnnouncement(
|
dlcOracle.createNewDigitDecompAnnouncement(
|
||||||
eventName = "test1",
|
eventName = "test1",
|
||||||
@ -230,8 +226,7 @@ class DLCOracleTest extends DLCOracleFixture {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
it must "fail to create an event with the same name" in {
|
it must "fail to create an event with the same name" in { dlcOracle =>
|
||||||
dlcOracle: DLCOracle =>
|
|
||||||
for {
|
for {
|
||||||
_ <- dlcOracle.createNewAnnouncement("test", futureTime, testDescriptor)
|
_ <- dlcOracle.createNewAnnouncement("test", futureTime, testDescriptor)
|
||||||
res <- recoverToSucceededIf[IllegalArgumentException](
|
res <- recoverToSucceededIf[IllegalArgumentException](
|
||||||
@ -240,8 +235,7 @@ class DLCOracleTest extends DLCOracleFixture {
|
|||||||
} yield res
|
} yield res
|
||||||
}
|
}
|
||||||
|
|
||||||
it must "create an enum new event and get its details" in {
|
it must "create an enum new event and get its details" in { dlcOracle =>
|
||||||
dlcOracle: DLCOracle =>
|
|
||||||
val time = futureTime
|
val time = futureTime
|
||||||
val eventName = "test"
|
val eventName = "test"
|
||||||
|
|
||||||
@ -259,7 +253,7 @@ class DLCOracleTest extends DLCOracleFixture {
|
|||||||
assert(event.eventName == eventName)
|
assert(event.eventName == eventName)
|
||||||
assert(event.eventDescriptorTLV == testDescriptor)
|
assert(event.eventDescriptorTLV == testDescriptor)
|
||||||
assert(event.signingVersion == SigningVersion.latest)
|
assert(event.signingVersion == SigningVersion.latest)
|
||||||
assert(event.pubkey == dlcOracle.publicKey)
|
assert(event.pubkey == dlcOracle.publicKey())
|
||||||
assert(event.maturationTime.getEpochSecond == time.getEpochSecond)
|
assert(event.maturationTime.getEpochSecond == time.getEpochSecond)
|
||||||
|
|
||||||
val expectedEventTLV =
|
val expectedEventTLV =
|
||||||
@ -285,12 +279,12 @@ class DLCOracleTest extends DLCOracleFixture {
|
|||||||
SigningVersion.latest.calcAnnouncementHash(event.eventTLV)
|
SigningVersion.latest.calcAnnouncementHash(event.eventTLV)
|
||||||
|
|
||||||
assert(
|
assert(
|
||||||
dlcOracle.publicKey.verify(announceBytes, event.announcementSignature)
|
dlcOracle.publicKey().verify(announceBytes, event.announcementSignature)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
it must "create and sign an enum event" in { dlcOracle: DLCOracle =>
|
it must "create and sign an enum event" in { dlcOracle =>
|
||||||
val descriptor = TLVGen.enumEventDescriptorV0TLV.sampleSome
|
val descriptor = TLVGen.enumEventDescriptorV0TLV.sampleSome
|
||||||
val outcome = descriptor.outcomes.head
|
val outcome = descriptor.outcomes.head
|
||||||
|
|
||||||
@ -316,7 +310,7 @@ class DLCOracleTest extends DLCOracleFixture {
|
|||||||
|
|
||||||
val hash = SigningVersion.latest.calcOutcomeHash(outcome)
|
val hash = SigningVersion.latest.calcOutcomeHash(outcome)
|
||||||
|
|
||||||
assert(dlcOracle.publicKey.verify(hash, sig))
|
assert(dlcOracle.publicKey().verify(hash, sig))
|
||||||
assert(
|
assert(
|
||||||
SchnorrDigitalSignature(
|
SchnorrDigitalSignature(
|
||||||
completedEvent.nonces.head,
|
completedEvent.nonces.head,
|
||||||
@ -336,7 +330,7 @@ class DLCOracleTest extends DLCOracleFixture {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
it must "create and sign a large range event" in { dlcOracle: DLCOracle =>
|
it must "create and sign a large range event" in { dlcOracle =>
|
||||||
val outcome = -321L
|
val outcome = -321L
|
||||||
|
|
||||||
for {
|
for {
|
||||||
@ -370,7 +364,7 @@ class DLCOracleTest extends DLCOracleFixture {
|
|||||||
// Sign Signature Check
|
// Sign Signature Check
|
||||||
val signHash = SigningVersion.latest.calcOutcomeHash("-")
|
val signHash = SigningVersion.latest.calcOutcomeHash("-")
|
||||||
val signSig = completedEvent.signatures.head
|
val signSig = completedEvent.signatures.head
|
||||||
assert(dlcOracle.publicKey.verify(signHash, signSig))
|
assert(dlcOracle.publicKey().verify(signHash, signSig))
|
||||||
assert(
|
assert(
|
||||||
SchnorrDigitalSignature(
|
SchnorrDigitalSignature(
|
||||||
completedEvent.nonces.head,
|
completedEvent.nonces.head,
|
||||||
@ -384,7 +378,7 @@ class DLCOracleTest extends DLCOracleFixture {
|
|||||||
DigitDecompositionAttestation(3).bytes
|
DigitDecompositionAttestation(3).bytes
|
||||||
)
|
)
|
||||||
val sig100 = completedEvent.signatures(1)
|
val sig100 = completedEvent.signatures(1)
|
||||||
assert(dlcOracle.publicKey.verify(hash100, sig100))
|
assert(dlcOracle.publicKey().verify(hash100, sig100))
|
||||||
assert(
|
assert(
|
||||||
SchnorrDigitalSignature(
|
SchnorrDigitalSignature(
|
||||||
completedEvent.nonces(1),
|
completedEvent.nonces(1),
|
||||||
@ -398,7 +392,7 @@ class DLCOracleTest extends DLCOracleFixture {
|
|||||||
DigitDecompositionAttestation(2).bytes
|
DigitDecompositionAttestation(2).bytes
|
||||||
)
|
)
|
||||||
val sig10 = completedEvent.signatures(2)
|
val sig10 = completedEvent.signatures(2)
|
||||||
assert(dlcOracle.publicKey.verify(hash10, sig10))
|
assert(dlcOracle.publicKey().verify(hash10, sig10))
|
||||||
assert(
|
assert(
|
||||||
SchnorrDigitalSignature(
|
SchnorrDigitalSignature(
|
||||||
completedEvent.nonces(2),
|
completedEvent.nonces(2),
|
||||||
@ -412,7 +406,7 @@ class DLCOracleTest extends DLCOracleFixture {
|
|||||||
DigitDecompositionAttestation(1).bytes
|
DigitDecompositionAttestation(1).bytes
|
||||||
)
|
)
|
||||||
val sig1 = completedEvent.signatures(3)
|
val sig1 = completedEvent.signatures(3)
|
||||||
assert(dlcOracle.publicKey.verify(hash1, sig1))
|
assert(dlcOracle.publicKey().verify(hash1, sig1))
|
||||||
assert(
|
assert(
|
||||||
SchnorrDigitalSignature(
|
SchnorrDigitalSignature(
|
||||||
completedEvent.nonces(3),
|
completedEvent.nonces(3),
|
||||||
@ -425,8 +419,7 @@ class DLCOracleTest extends DLCOracleFixture {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
it must "create and sign a non-base 10 large range event" in {
|
it must "create and sign a non-base 10 large range event" in { dlcOracle =>
|
||||||
dlcOracle: DLCOracle =>
|
|
||||||
val outcome = -1931L
|
val outcome = -1931L
|
||||||
|
|
||||||
for {
|
for {
|
||||||
@ -461,7 +454,7 @@ class DLCOracleTest extends DLCOracleFixture {
|
|||||||
val signHash =
|
val signHash =
|
||||||
SigningVersion.latest.calcOutcomeHash("-")
|
SigningVersion.latest.calcOutcomeHash("-")
|
||||||
val signSig = completedEvent.signatures.head
|
val signSig = completedEvent.signatures.head
|
||||||
assert(dlcOracle.publicKey.verify(signHash, signSig))
|
assert(dlcOracle.publicKey().verify(signHash, signSig))
|
||||||
assert(
|
assert(
|
||||||
SchnorrDigitalSignature(
|
SchnorrDigitalSignature(
|
||||||
completedEvent.nonces.head,
|
completedEvent.nonces.head,
|
||||||
@ -475,7 +468,7 @@ class DLCOracleTest extends DLCOracleFixture {
|
|||||||
DigitDecompositionAttestation(7).bytes
|
DigitDecompositionAttestation(7).bytes
|
||||||
)
|
)
|
||||||
val sig100 = completedEvent.signatures(1)
|
val sig100 = completedEvent.signatures(1)
|
||||||
assert(dlcOracle.publicKey.verify(hash100, sig100))
|
assert(dlcOracle.publicKey().verify(hash100, sig100))
|
||||||
assert(
|
assert(
|
||||||
SchnorrDigitalSignature(
|
SchnorrDigitalSignature(
|
||||||
completedEvent.nonces(1),
|
completedEvent.nonces(1),
|
||||||
@ -489,7 +482,7 @@ class DLCOracleTest extends DLCOracleFixture {
|
|||||||
DigitDecompositionAttestation(8).bytes
|
DigitDecompositionAttestation(8).bytes
|
||||||
)
|
)
|
||||||
val sig10 = completedEvent.signatures(2)
|
val sig10 = completedEvent.signatures(2)
|
||||||
assert(dlcOracle.publicKey.verify(hash10, sig10))
|
assert(dlcOracle.publicKey().verify(hash10, sig10))
|
||||||
assert(
|
assert(
|
||||||
SchnorrDigitalSignature(
|
SchnorrDigitalSignature(
|
||||||
completedEvent.nonces(2),
|
completedEvent.nonces(2),
|
||||||
@ -503,7 +496,7 @@ class DLCOracleTest extends DLCOracleFixture {
|
|||||||
DigitDecompositionAttestation(11).bytes
|
DigitDecompositionAttestation(11).bytes
|
||||||
)
|
)
|
||||||
val sig1 = completedEvent.signatures(3)
|
val sig1 = completedEvent.signatures(3)
|
||||||
assert(dlcOracle.publicKey.verify(hash1, sig1))
|
assert(dlcOracle.publicKey().verify(hash1, sig1))
|
||||||
assert(
|
assert(
|
||||||
SchnorrDigitalSignature(
|
SchnorrDigitalSignature(
|
||||||
completedEvent.nonces(3),
|
completedEvent.nonces(3),
|
||||||
@ -517,7 +510,7 @@ class DLCOracleTest extends DLCOracleFixture {
|
|||||||
}
|
}
|
||||||
|
|
||||||
it must "create and sign a large range event with digits of 0" in {
|
it must "create and sign a large range event with digits of 0" in {
|
||||||
dlcOracle: DLCOracle =>
|
dlcOracle =>
|
||||||
val outcome = 2
|
val outcome = 2
|
||||||
|
|
||||||
for {
|
for {
|
||||||
@ -553,7 +546,7 @@ class DLCOracleTest extends DLCOracleFixture {
|
|||||||
DigitDecompositionAttestation(0).bytes
|
DigitDecompositionAttestation(0).bytes
|
||||||
)
|
)
|
||||||
val sig100 = completedEvent.signatures.head
|
val sig100 = completedEvent.signatures.head
|
||||||
assert(dlcOracle.publicKey.verify(hash100, sig100))
|
assert(dlcOracle.publicKey().verify(hash100, sig100))
|
||||||
assert(
|
assert(
|
||||||
SchnorrDigitalSignature(
|
SchnorrDigitalSignature(
|
||||||
completedEvent.nonces.head,
|
completedEvent.nonces.head,
|
||||||
@ -567,7 +560,7 @@ class DLCOracleTest extends DLCOracleFixture {
|
|||||||
DigitDecompositionAttestation(1).bytes
|
DigitDecompositionAttestation(1).bytes
|
||||||
)
|
)
|
||||||
val sig10 = completedEvent.signatures(1)
|
val sig10 = completedEvent.signatures(1)
|
||||||
assert(dlcOracle.publicKey.verify(hash10, sig10))
|
assert(dlcOracle.publicKey().verify(hash10, sig10))
|
||||||
assert(
|
assert(
|
||||||
SchnorrDigitalSignature(
|
SchnorrDigitalSignature(
|
||||||
completedEvent.nonces(1),
|
completedEvent.nonces(1),
|
||||||
@ -581,7 +574,7 @@ class DLCOracleTest extends DLCOracleFixture {
|
|||||||
DigitDecompositionAttestation(0).bytes
|
DigitDecompositionAttestation(0).bytes
|
||||||
)
|
)
|
||||||
val sig1 = completedEvent.signatures(2)
|
val sig1 = completedEvent.signatures(2)
|
||||||
assert(dlcOracle.publicKey.verify(hash1, sig1))
|
assert(dlcOracle.publicKey().verify(hash1, sig1))
|
||||||
assert(
|
assert(
|
||||||
SchnorrDigitalSignature(
|
SchnorrDigitalSignature(
|
||||||
completedEvent.nonces(2),
|
completedEvent.nonces(2),
|
||||||
@ -595,7 +588,7 @@ class DLCOracleTest extends DLCOracleFixture {
|
|||||||
}
|
}
|
||||||
|
|
||||||
it must "create and sign a decomp event with a large num digits" in {
|
it must "create and sign a decomp event with a large num digits" in {
|
||||||
dlcOracle: DLCOracle =>
|
dlcOracle =>
|
||||||
// trying make sure we don't regress on
|
// trying make sure we don't regress on
|
||||||
// https://github.com/bitcoin-s/bitcoin-s/issues/3431
|
// https://github.com/bitcoin-s/bitcoin-s/issues/3431
|
||||||
|
|
||||||
@ -629,7 +622,7 @@ class DLCOracleTest extends DLCOracleFixture {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
it must "correctly track pending events" in { dlcOracle: DLCOracle =>
|
it must "correctly track pending events" in { dlcOracle =>
|
||||||
val outcome = enumOutcomes.head
|
val outcome = enumOutcomes.head
|
||||||
for {
|
for {
|
||||||
announcement <-
|
announcement <-
|
||||||
@ -656,16 +649,14 @@ class DLCOracleTest extends DLCOracleFixture {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
it must "fail to sign an event that doesn't exist" in {
|
it must "fail to sign an event that doesn't exist" in { dlcOracle =>
|
||||||
dlcOracle: DLCOracle =>
|
|
||||||
val dummyNonce = SchnorrNonce(ECPublicKey.freshPublicKey.bytes.tail)
|
val dummyNonce = SchnorrNonce(ECPublicKey.freshPublicKey.bytes.tail)
|
||||||
recoverToSucceededIf[RuntimeException](
|
recoverToSucceededIf[RuntimeException](
|
||||||
dlcOracle.createAttestation(dummyNonce, EnumAttestation("testOutcomes"))
|
dlcOracle.createAttestation(dummyNonce, EnumAttestation("testOutcomes"))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
it must "fail to sign an enum outcome that doesn't exist" in {
|
it must "fail to sign an enum outcome that doesn't exist" in { dlcOracle =>
|
||||||
dlcOracle: DLCOracle =>
|
|
||||||
recoverToSucceededIf[RuntimeException] {
|
recoverToSucceededIf[RuntimeException] {
|
||||||
for {
|
for {
|
||||||
announcement <-
|
announcement <-
|
||||||
@ -688,7 +679,7 @@ class DLCOracleTest extends DLCOracleFixture {
|
|||||||
}
|
}
|
||||||
|
|
||||||
it must "sign a negative number for a unsigned digit decomp event that results in 0" in {
|
it must "sign a negative number for a unsigned digit decomp event that results in 0" in {
|
||||||
dlcOracle: DLCOracle =>
|
dlcOracle =>
|
||||||
for {
|
for {
|
||||||
announcement <-
|
announcement <-
|
||||||
dlcOracle.createNewDigitDecompAnnouncement(
|
dlcOracle.createNewDigitDecompAnnouncement(
|
||||||
@ -712,8 +703,7 @@ class DLCOracleTest extends DLCOracleFixture {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
it must "fail to sign an event with an outside nonce" in {
|
it must "fail to sign an event with an outside nonce" in { dlcOracle =>
|
||||||
dlcOracle: DLCOracle =>
|
|
||||||
val ecKey = ECPublicKey.freshPublicKey
|
val ecKey = ECPublicKey.freshPublicKey
|
||||||
val publicKey = ecKey.schnorrPublicKey
|
val publicKey = ecKey.schnorrPublicKey
|
||||||
val nonce = ecKey.schnorrNonce
|
val nonce = ecKey.schnorrNonce
|
||||||
@ -753,7 +743,7 @@ class DLCOracleTest extends DLCOracleFixture {
|
|||||||
}
|
}
|
||||||
|
|
||||||
it must "fail to sign an event with a nonce not in the event db" in {
|
it must "fail to sign an event with a nonce not in the event db" in {
|
||||||
dlcOracle: DLCOracle =>
|
dlcOracle =>
|
||||||
val ecKey = ECPublicKey.freshPublicKey
|
val ecKey = ECPublicKey.freshPublicKey
|
||||||
val nonce = ecKey.schnorrNonce
|
val nonce = ecKey.schnorrNonce
|
||||||
|
|
||||||
@ -771,29 +761,26 @@ class DLCOracleTest extends DLCOracleFixture {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
it must "fail to create an enum event with no outcomes" in {
|
it must "fail to create an enum event with no outcomes" in { dlcOracle =>
|
||||||
dlcOracle: DLCOracle =>
|
|
||||||
assertThrows[IllegalArgumentException] {
|
assertThrows[IllegalArgumentException] {
|
||||||
dlcOracle.createNewEnumAnnouncement("test", futureTime, Vector.empty)
|
dlcOracle.createNewEnumAnnouncement("test", futureTime, Vector.empty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
it must "fail to create an event with duplicate outcomes" in {
|
it must "fail to create an event with duplicate outcomes" in { dlcOracle =>
|
||||||
dlcOracle: DLCOracle =>
|
|
||||||
val outcomes = enumOutcomes :+ enumOutcomes.head
|
val outcomes = enumOutcomes :+ enumOutcomes.head
|
||||||
assertThrows[IllegalArgumentException] {
|
assertThrows[IllegalArgumentException] {
|
||||||
dlcOracle.createNewEnumAnnouncement("test", futureTime, outcomes)
|
dlcOracle.createNewEnumAnnouncement("test", futureTime, outcomes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
it must "fail to create an event in the past" in { dlcOracle: DLCOracle =>
|
it must "fail to create an event in the past" in { dlcOracle =>
|
||||||
assertThrows[IllegalArgumentException] {
|
assertThrows[IllegalArgumentException] {
|
||||||
dlcOracle.createNewAnnouncement("test", Instant.EPOCH, testDescriptor)
|
dlcOracle.createNewAnnouncement("test", Instant.EPOCH, testDescriptor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
it must "create and sign a signed digit decomposition event" in {
|
it must "create and sign a signed digit decomposition event" in { dlcOracle =>
|
||||||
dlcOracle: DLCOracle =>
|
|
||||||
val eventName = "signed"
|
val eventName = "signed"
|
||||||
val maturationTime = futureTime
|
val maturationTime = futureTime
|
||||||
val descriptor =
|
val descriptor =
|
||||||
@ -826,7 +813,7 @@ class DLCOracleTest extends DLCOracleFixture {
|
|||||||
}
|
}
|
||||||
|
|
||||||
it must "create and sign a unsigned digit decomposition event" in {
|
it must "create and sign a unsigned digit decomposition event" in {
|
||||||
dlcOracle: DLCOracle =>
|
dlcOracle =>
|
||||||
val eventName = "unsigned"
|
val eventName = "unsigned"
|
||||||
val maturationTime = futureTime
|
val maturationTime = futureTime
|
||||||
val descriptor =
|
val descriptor =
|
||||||
@ -859,7 +846,7 @@ class DLCOracleTest extends DLCOracleFixture {
|
|||||||
}
|
}
|
||||||
|
|
||||||
it must "fail to verify a unsigned digit decomposition event " in {
|
it must "fail to verify a unsigned digit decomposition event " in {
|
||||||
dlcOracle: DLCOracle =>
|
dlcOracle =>
|
||||||
val eventName1 = "unsigned1"
|
val eventName1 = "unsigned1"
|
||||||
val eventName2 = "unsigned2"
|
val eventName2 = "unsigned2"
|
||||||
val maturationTime = futureTime
|
val maturationTime = futureTime
|
||||||
@ -917,8 +904,7 @@ class DLCOracleTest extends DLCOracleFixture {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
it must "create and delete signatures for an enum event" in {
|
it must "create and delete signatures for an enum event" in { dlcOracle =>
|
||||||
dlcOracle: DLCOracle =>
|
|
||||||
val descriptor = TLVGen.enumEventDescriptorV0TLV.sampleSome
|
val descriptor = TLVGen.enumEventDescriptorV0TLV.sampleSome
|
||||||
val outcome = descriptor.outcomes.head
|
val outcome = descriptor.outcomes.head
|
||||||
|
|
||||||
@ -954,8 +940,7 @@ class DLCOracleTest extends DLCOracleFixture {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
it must "create and delete signatures for a decomp event" in {
|
it must "create and delete signatures for a decomp event" in { dlcOracle =>
|
||||||
dlcOracle: DLCOracle =>
|
|
||||||
val descriptor =
|
val descriptor =
|
||||||
UnsignedDigitDecompositionEventDescriptor(
|
UnsignedDigitDecompositionEventDescriptor(
|
||||||
UInt16(2),
|
UInt16(2),
|
||||||
@ -992,7 +977,7 @@ class DLCOracleTest extends DLCOracleFixture {
|
|||||||
}
|
}
|
||||||
|
|
||||||
it must "fail to delete signatures for an unsigned enum event" in {
|
it must "fail to delete signatures for an unsigned enum event" in {
|
||||||
dlcOracle: DLCOracle =>
|
dlcOracle =>
|
||||||
val descriptor =
|
val descriptor =
|
||||||
UnsignedDigitDecompositionEventDescriptor(
|
UnsignedDigitDecompositionEventDescriptor(
|
||||||
UInt16(2),
|
UInt16(2),
|
||||||
@ -1016,7 +1001,7 @@ class DLCOracleTest extends DLCOracleFixture {
|
|||||||
}
|
}
|
||||||
|
|
||||||
it must "fail to delete signatures for an unsigned decomp event" in {
|
it must "fail to delete signatures for an unsigned decomp event" in {
|
||||||
dlcOracle: DLCOracle =>
|
dlcOracle =>
|
||||||
val descriptor = TLVGen.enumEventDescriptorV0TLV.sampleSome
|
val descriptor = TLVGen.enumEventDescriptorV0TLV.sampleSome
|
||||||
|
|
||||||
for {
|
for {
|
||||||
@ -1097,7 +1082,7 @@ class DLCOracleTest extends DLCOracleFixture {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
it must "delete enum attestation" in { dlcOracle: DLCOracle =>
|
it must "delete enum attestation" in { dlcOracle =>
|
||||||
val eventName = "test"
|
val eventName = "test"
|
||||||
val createdF =
|
val createdF =
|
||||||
dlcOracle.createNewAnnouncement(eventName, futureTime, testDescriptor)
|
dlcOracle.createNewAnnouncement(eventName, futureTime, testDescriptor)
|
||||||
@ -1112,7 +1097,7 @@ class DLCOracleTest extends DLCOracleFixture {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
it must "delete numeric attestations" in { dlcOracle: DLCOracle =>
|
it must "delete numeric attestations" in { dlcOracle =>
|
||||||
val eventName = "test"
|
val eventName = "test"
|
||||||
val createdF =
|
val createdF =
|
||||||
dlcOracle.createNewDigitDecompAnnouncement(
|
dlcOracle.createNewDigitDecompAnnouncement(
|
||||||
@ -1137,7 +1122,7 @@ class DLCOracleTest extends DLCOracleFixture {
|
|||||||
}
|
}
|
||||||
|
|
||||||
it must "delete attestations, and then delete the announcement" in {
|
it must "delete attestations, and then delete the announcement" in {
|
||||||
dlcOracle: DLCOracle =>
|
dlcOracle =>
|
||||||
val eventName = "test"
|
val eventName = "test"
|
||||||
val createdF =
|
val createdF =
|
||||||
dlcOracle.createNewDigitDecompAnnouncement(
|
dlcOracle.createNewDigitDecompAnnouncement(
|
||||||
@ -1161,7 +1146,7 @@ class DLCOracleTest extends DLCOracleFixture {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
it must "set and retrieve oracle name" in { dlcOracle: DLCOracle =>
|
it must "set and retrieve oracle name" in { dlcOracle =>
|
||||||
for {
|
for {
|
||||||
emptyNameOpt <- dlcOracle.oracleName()
|
emptyNameOpt <- dlcOracle.oracleName()
|
||||||
_ <- dlcOracle.setOracleName("test name")
|
_ <- dlcOracle.setOracleName("test name")
|
||||||
@ -1172,8 +1157,8 @@ class DLCOracleTest extends DLCOracleFixture {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
it must "export staking address wif" in { dlcOracle: DLCOracle =>
|
it must "export staking address wif" in { dlcOracle =>
|
||||||
val pubKey = dlcOracle.publicKey
|
val pubKey = dlcOracle.publicKey()
|
||||||
val wif = dlcOracle.exportSigningKeyWIF
|
val wif = dlcOracle.exportSigningKeyWIF
|
||||||
val privKey = ECPrivateKeyUtil.fromWIFToPrivateKey(wif)
|
val privKey = ECPrivateKeyUtil.fromWIFToPrivateKey(wif)
|
||||||
assert(privKey.toPrivateKey.schnorrPublicKey == pubKey)
|
assert(privKey.toPrivateKey.schnorrPublicKey == pubKey)
|
||||||
|
@ -11,8 +11,7 @@ class DLCOracleAppConfigTest extends DLCOracleAppConfigFixture {
|
|||||||
|
|
||||||
behavior of "DLCOracleAppConfig"
|
behavior of "DLCOracleAppConfig"
|
||||||
|
|
||||||
it must "start the same oracle twice" in {
|
it must "start the same oracle twice" in { dlcOracleAppConfig =>
|
||||||
dlcOracleAppConfig: DLCOracleAppConfig =>
|
|
||||||
val started1F = dlcOracleAppConfig.start()
|
val started1F = dlcOracleAppConfig.start()
|
||||||
val started2F = started1F.flatMap(_ => dlcOracleAppConfig.start())
|
val started2F = started1F.flatMap(_ => dlcOracleAppConfig.start())
|
||||||
for {
|
for {
|
||||||
@ -21,19 +20,19 @@ class DLCOracleAppConfigTest extends DLCOracleAppConfigFixture {
|
|||||||
dlcOracle1 = new DLCOracle()(dlcOracleAppConfig)
|
dlcOracle1 = new DLCOracle()(dlcOracleAppConfig)
|
||||||
dlcOracle2 = new DLCOracle()(dlcOracleAppConfig)
|
dlcOracle2 = new DLCOracle()(dlcOracleAppConfig)
|
||||||
} yield {
|
} yield {
|
||||||
assert(dlcOracle1.publicKey == dlcOracle2.publicKey)
|
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 {
|
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 seedFile = dlcOracleAppConfig.seedPath
|
||||||
val startedF = dlcOracleAppConfig.start()
|
val startedF = dlcOracleAppConfig.start()
|
||||||
val pubKeyBeforeMoveF = for {
|
val pubKeyBeforeMoveF = for {
|
||||||
_ <- startedF
|
_ <- startedF
|
||||||
dlcOracle = new DLCOracle()(dlcOracleAppConfig)
|
dlcOracle = new DLCOracle()(dlcOracleAppConfig)
|
||||||
} yield {
|
} yield {
|
||||||
dlcOracle.publicKey
|
dlcOracle.publicKey()
|
||||||
}
|
}
|
||||||
|
|
||||||
// stop old oracle
|
// stop old oracle
|
||||||
@ -69,14 +68,14 @@ class DLCOracleAppConfigTest extends DLCOracleAppConfigFixture {
|
|||||||
for {
|
for {
|
||||||
_ <- stoppedF
|
_ <- stoppedF
|
||||||
pubKey1 <- pubKeyBeforeMoveF
|
pubKey1 <- pubKeyBeforeMoveF
|
||||||
pubKey2 <- dlcOracle2F.map(_.publicKey)
|
pubKey2 <- dlcOracle2F.map(_.publicKey())
|
||||||
} yield {
|
} yield {
|
||||||
assert(pubKey1 == pubKey2)
|
assert(pubKey1 == pubKey2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
it must "fail to start the oracle app config if we have different seeds" in {
|
it must "fail to start the oracle app config if we have different seeds" in {
|
||||||
dlcOracleAppConfig: DLCOracleAppConfig =>
|
dlcOracleAppConfig =>
|
||||||
val seedFile = dlcOracleAppConfig.seedPath
|
val seedFile = dlcOracleAppConfig.seedPath
|
||||||
val startedF = dlcOracleAppConfig.start()
|
val startedF = dlcOracleAppConfig.start()
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ case class DLCOracle()(implicit val conf: DLCOracleAppConfig)
|
|||||||
private val rValueChainIndex = 0
|
private val rValueChainIndex = 0
|
||||||
|
|
||||||
/** The root private key for this oracle */
|
/** The root private key for this oracle */
|
||||||
private[this] val extPrivateKey: ExtPrivateKeyHardened = {
|
private val extPrivateKey: ExtPrivateKeyHardened = {
|
||||||
WalletStorage.getPrivateKeyFromDisk(
|
WalletStorage.getPrivateKeyFromDisk(
|
||||||
conf.kmConf.seedPath,
|
conf.kmConf.seedPath,
|
||||||
SegWitTestNet3Priv,
|
SegWitTestNet3Priv,
|
||||||
@ -83,10 +83,10 @@ case class DLCOracle()(implicit val conf: DLCOracleAppConfig)
|
|||||||
extPrivateKey.deriveChildPrivKey(path).key
|
extPrivateKey.deriveChildPrivKey(path).key
|
||||||
}
|
}
|
||||||
|
|
||||||
override val publicKey: SchnorrPublicKey = signingKey.schnorrPublicKey
|
override def publicKey(): SchnorrPublicKey = signingKey.schnorrPublicKey
|
||||||
|
|
||||||
override def stakingAddress(network: BitcoinNetwork): Bech32Address =
|
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 rValueDAO: RValueDAO = RValueDAO()
|
||||||
protected[bitcoins] val eventDAO: EventDAO = EventDAO()
|
protected[bitcoins] val eventDAO: EventDAO = EventDAO()
|
||||||
@ -283,7 +283,7 @@ case class DLCOracle()(implicit val conf: DLCOracleAppConfig)
|
|||||||
|
|
||||||
oracleAnnouncement = OracleAnnouncementV0TLV(
|
oracleAnnouncement = OracleAnnouncementV0TLV(
|
||||||
announcementSignature = announcementSignature,
|
announcementSignature = announcementSignature,
|
||||||
publicKey = publicKey,
|
publicKey = publicKey(),
|
||||||
eventTLV = eventTLV
|
eventTLV = eventTLV
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -608,7 +608,7 @@ object DLCOracle {
|
|||||||
def fromDatadir(path: Path, configs: Vector[Config])(implicit
|
def fromDatadir(path: Path, configs: Vector[Config])(implicit
|
||||||
ec: ExecutionContext
|
ec: ExecutionContext
|
||||||
): Future[DLCOracle] = {
|
): Future[DLCOracle] = {
|
||||||
implicit val appConfig =
|
implicit val appConfig: DLCOracleAppConfig =
|
||||||
DLCOracleAppConfig.fromDatadir(datadir = path, configs)
|
DLCOracleAppConfig.fromDatadir(datadir = path, configs)
|
||||||
val masterXpubDAO: MasterXPubDAO = MasterXPubDAO()(ec, appConfig)
|
val masterXpubDAO: MasterXPubDAO = MasterXPubDAO()(ec, appConfig)
|
||||||
val oracle = DLCOracle()
|
val oracle = DLCOracle()
|
||||||
@ -617,9 +617,9 @@ object DLCOracle {
|
|||||||
_ <- appConfig.start()
|
_ <- appConfig.start()
|
||||||
_ <- MasterXPubUtil.checkMasterXPub(oracle.getRootXpub, masterXpubDAO)
|
_ <- MasterXPubUtil.checkMasterXPub(oracle.getRootXpub, masterXpubDAO)
|
||||||
differentKeyDbs <- oracle.eventDAO.findDifferentPublicKey(
|
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)
|
_ <- oracle.eventDAO.updateAll(fixedDbs)
|
||||||
} yield oracle
|
} yield oracle
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ class EclairRpcClient(
|
|||||||
Seq(
|
Seq(
|
||||||
from.map(x => "from" -> x.getEpochSecond.toString),
|
from.map(x => "from" -> x.getEpochSecond.toString),
|
||||||
to.map(x => "to" -> x.getEpochSecond.toString)
|
to.map(x => "to" -> x.getEpochSecond.toString)
|
||||||
).flatten: _*
|
).flatten*
|
||||||
)
|
)
|
||||||
|
|
||||||
override def channel(channelId: ChannelId): Future[ChannelResult] = {
|
override def channel(channelId: ChannelId): Future[ChannelResult] = {
|
||||||
@ -111,7 +111,7 @@ class EclairRpcClient(
|
|||||||
|
|
||||||
private def channels(nodeId: Option[NodeId]): Future[Vector[ChannelInfo]] = {
|
private def channels(nodeId: Option[NodeId]): Future[Vector[ChannelInfo]] = {
|
||||||
val params = Seq(nodeId.map(id => "nodeId" -> id.toString)).flatten
|
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)
|
def channels(): Future[Vector[ChannelInfo]] = channels(nodeId = None)
|
||||||
@ -130,7 +130,7 @@ class EclairRpcClient(
|
|||||||
scriptPubKey.map(x => "scriptPubKey" -> BytesUtil.encodeHex(x.asmBytes))
|
scriptPubKey.map(x => "scriptPubKey" -> BytesUtil.encodeHex(x.asmBytes))
|
||||||
).flatten
|
).flatten
|
||||||
|
|
||||||
eclairCall[ChannelCommandResult]("close", params: _*)
|
eclairCall[ChannelCommandResult]("close", params*)
|
||||||
}
|
}
|
||||||
|
|
||||||
def close(channelId: ChannelId): Future[ChannelCommandResult] =
|
def close(channelId: ChannelId): Future[ChannelCommandResult] =
|
||||||
@ -193,7 +193,7 @@ class EclairRpcClient(
|
|||||||
Some("invoice" -> invoice.toString),
|
Some("invoice" -> invoice.toString),
|
||||||
amountMsat.map(x => "amountMsat" -> x.toBigDecimal.toString)
|
amountMsat.map(x => "amountMsat" -> x.toBigDecimal.toString)
|
||||||
).flatten
|
).flatten
|
||||||
eclairCall[Vector[Route]]("findroute", params: _*)
|
eclairCall[Vector[Route]]("findroute", params*)
|
||||||
}
|
}
|
||||||
|
|
||||||
override def forceClose(
|
override def forceClose(
|
||||||
@ -262,7 +262,7 @@ class EclairRpcClient(
|
|||||||
|
|
||||||
// this is unfortunately returned in this format
|
// this is unfortunately returned in this format
|
||||||
// created channel 30bdf849eb9f72c9b41a09e38a6d83138c2edf332cb116dd7cf0f0dfb66be395
|
// created channel 30bdf849eb9f72c9b41a09e38a6d83138c2edf332cb116dd7cf0f0dfb66be395
|
||||||
val call = eclairCall[String]("open", params: _*)
|
val call = eclairCall[String]("open", params*)
|
||||||
// let's just return the chanId
|
// let's just return the chanId
|
||||||
// format:
|
// format:
|
||||||
// created channel 19e11470b0dd96ed15c56ea8f32e9a3277dcbd570e7392c1c34709adc7ebfdc3 with fundingTxId=c2fdebc7ad0947c3c192730e57bddc77329a2ef3a86ec515ed96ddb07014e119 and fees=24750 sat
|
// created channel 19e11470b0dd96ed15c56ea8f32e9a3277dcbd570e7392c1c34709adc7ebfdc3 with fundingTxId=c2fdebc7ad0947c3c192730e57bddc77329a2ef3a86ec515ed96ddb07014e119 and fees=24750 sat
|
||||||
@ -413,7 +413,7 @@ class EclairRpcClient(
|
|||||||
paymentPreimage.map(x => "paymentPreimage" -> x.hex)
|
paymentPreimage.map(x => "paymentPreimage" -> x.hex)
|
||||||
).flatten
|
).flatten
|
||||||
|
|
||||||
val responseF = eclairCall[InvoiceResult]("createinvoice", params: _*)
|
val responseF = eclairCall[InvoiceResult]("createinvoice", params*)
|
||||||
|
|
||||||
responseF.flatMap { res =>
|
responseF.flatMap { res =>
|
||||||
Future.fromTry(LnInvoice.fromStringT(res.serialized))
|
Future.fromTry(LnInvoice.fromStringT(res.serialized))
|
||||||
@ -515,7 +515,7 @@ class EclairRpcClient(
|
|||||||
externalId.map(x => "externalId" -> x)
|
externalId.map(x => "externalId" -> x)
|
||||||
).flatten
|
).flatten
|
||||||
|
|
||||||
eclairCall[PaymentId]("payinvoice", params: _*)
|
eclairCall[PaymentId]("payinvoice", params*)
|
||||||
}
|
}
|
||||||
|
|
||||||
override def getReceivedInfo(
|
override def getReceivedInfo(
|
||||||
@ -541,7 +541,7 @@ class EclairRpcClient(
|
|||||||
case _: JsError => JsSuccess(None)
|
case _: JsError => JsSuccess(None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
eclairCall[Option[IncomingPayment]]("getreceivedinfo", params: _*)(r)
|
eclairCall[Option[IncomingPayment]]("getreceivedinfo", params*)(r)
|
||||||
}
|
}
|
||||||
|
|
||||||
override def getSentInfo(
|
override def getSentInfo(
|
||||||
@ -575,7 +575,7 @@ class EclairRpcClient(
|
|||||||
externalId.map(x => "externalId" -> x)
|
externalId.map(x => "externalId" -> x)
|
||||||
).flatten
|
).flatten
|
||||||
|
|
||||||
eclairCall[PaymentId]("sendtonode", params: _*)
|
eclairCall[PaymentId]("sendtonode", params*)
|
||||||
}
|
}
|
||||||
|
|
||||||
def sendToRoute(
|
def sendToRoute(
|
||||||
@ -603,7 +603,7 @@ class EclairRpcClient(
|
|||||||
parentId.map(x => "parentId" -> x.toString),
|
parentId.map(x => "parentId" -> x.toString),
|
||||||
externalId.map(x => "externalId" -> x)
|
externalId.map(x => "externalId" -> x)
|
||||||
).flatten
|
).flatten
|
||||||
eclairCall[SendToRouteResult]("sendtoroute", params: _*)
|
eclairCall[SendToRouteResult]("sendtoroute", params*)
|
||||||
}
|
}
|
||||||
|
|
||||||
override def updateRelayFee(
|
override def updateRelayFee(
|
||||||
@ -640,7 +640,7 @@ class EclairRpcClient(
|
|||||||
Seq(
|
Seq(
|
||||||
from.map(x => "from" -> x.toSeconds.toString),
|
from.map(x => "from" -> x.toSeconds.toString),
|
||||||
to.map(x => "to" -> x.toSeconds.toString)
|
to.map(x => "to" -> x.toSeconds.toString)
|
||||||
).flatten: _*
|
).flatten*
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -676,7 +676,7 @@ class EclairRpcClient(
|
|||||||
Seq(
|
Seq(
|
||||||
from.map(x => "from" -> x.getEpochSecond.toString),
|
from.map(x => "from" -> x.getEpochSecond.toString),
|
||||||
to.map(x => "to" -> x.getEpochSecond.toString)
|
to.map(x => "to" -> x.getEpochSecond.toString)
|
||||||
).flatten: _*
|
).flatten*
|
||||||
)
|
)
|
||||||
resF.flatMap(xs =>
|
resF.flatMap(xs =>
|
||||||
Future.sequence(
|
Future.sequence(
|
||||||
@ -727,7 +727,7 @@ class EclairRpcClient(
|
|||||||
private def eclairCall[T](command: String, parameters: (String, String)*)(
|
private def eclairCall[T](command: String, parameters: (String, String)*)(
|
||||||
implicit reader: Reads[T]
|
implicit reader: Reads[T]
|
||||||
): Future[T] = {
|
): Future[T] = {
|
||||||
val request = buildRequest(getDaemon, command, parameters: _*)
|
val request = buildRequest(getDaemon, command, parameters*)
|
||||||
|
|
||||||
logger.trace(s"eclair rpc call ${request}")
|
logger.trace(s"eclair rpc call ${request}")
|
||||||
val responseF = sendRequest(request)
|
val responseF = sendRequest(request)
|
||||||
@ -810,7 +810,7 @@ class EclairRpcClient(
|
|||||||
HttpRequest(
|
HttpRequest(
|
||||||
method = HttpMethods.POST,
|
method = HttpMethods.POST,
|
||||||
uri,
|
uri,
|
||||||
entity = FormData(params: _*).toEntity
|
entity = FormData(params*).toEntity
|
||||||
)
|
)
|
||||||
.addCredentials(
|
.addCredentials(
|
||||||
HttpCredentials.createBasicHttpCredentials(username, password)
|
HttpCredentials.createBasicHttpCredentials(username, password)
|
||||||
|
@ -17,7 +17,7 @@ import org.bitcoins.core.wallet.fee._
|
|||||||
import org.bitcoins.crypto._
|
import org.bitcoins.crypto._
|
||||||
import org.bitcoins.testkit.async.TestAsyncUtil
|
import org.bitcoins.testkit.async.TestAsyncUtil
|
||||||
import org.bitcoins.testkit.fixtures.DualLndFixture
|
import org.bitcoins.testkit.fixtures.DualLndFixture
|
||||||
import scodec.bits.{ByteVector, HexStringSyntax}
|
import scodec.bits.ByteVector
|
||||||
import signrpc.SignMethod
|
import signrpc.SignMethod
|
||||||
|
|
||||||
import scala.concurrent.{Await, Future}
|
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 =>
|
it must "send and receive a custom message" in { params =>
|
||||||
val (_, lndA, lndB) = 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)
|
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
|
// These need to be lazy so we don't try and fetch
|
||||||
// the tls certificate before it is generated
|
// the tls certificate before it is generated
|
||||||
private[this] lazy val certStreamOpt: Option[InputStream] = {
|
private lazy val certStreamOpt: Option[InputStream] = {
|
||||||
instance.certFileOpt match {
|
instance.certFileOpt match {
|
||||||
case Some(file) => Some(new FileInputStream(file))
|
case Some(file) => Some(new FileInputStream(file))
|
||||||
case None =>
|
case None =>
|
||||||
|
Loading…
Reference in New Issue
Block a user