mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-02-22 22:36:34 +01:00
Change DLCUtil.buildOracleSignatures
(#4061)
This commit is contained in:
parent
48189d5c1d
commit
e2b9c458e4
2 changed files with 23 additions and 3 deletions
|
@ -295,4 +295,24 @@ object DLCUtil {
|
||||||
|
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def buildOracleSignaturesNaive(
|
||||||
|
announcements: OrderedAnnouncements,
|
||||||
|
attestments: Vector[OracleAttestmentTLV]): Vector[OracleSignatures] = {
|
||||||
|
|
||||||
|
attestments.foldLeft(Vector.empty[OracleSignatures]) { (acc, sig) =>
|
||||||
|
// Nonces should be unique so searching for the first nonce should be safe
|
||||||
|
val firstNonce = sig.sigs.head.rx
|
||||||
|
announcements
|
||||||
|
.find(
|
||||||
|
_.eventTLV.nonces.headOption
|
||||||
|
.contains(firstNonce)) match {
|
||||||
|
case Some(announcement) =>
|
||||||
|
acc :+ OracleSignatures(SingleOracleInfo(announcement), sig.sigs)
|
||||||
|
case None =>
|
||||||
|
throw new RuntimeException(
|
||||||
|
s"Cannot find announcement for associated public key, ${sig.publicKey.hex}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1421,9 +1421,9 @@ abstract class DLCWallet
|
||||||
announcementData,
|
announcementData,
|
||||||
nonceDbs)
|
nonceDbs)
|
||||||
|
|
||||||
oracleSigs = DLCUtil.buildOracleSignatures(announcements =
|
oracleSigs = DLCUtil.buildOracleSignaturesNaive(
|
||||||
announcementTLVs,
|
announcements = announcementTLVs,
|
||||||
attestments = sigs.toVector)
|
attestments = sigs.toVector)
|
||||||
|
|
||||||
tx <- executeDLC(contractId, oracleSigs)
|
tx <- executeDLC(contractId, oracleSigs)
|
||||||
} yield tx
|
} yield tx
|
||||||
|
|
Loading…
Add table
Reference in a new issue