mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-02-22 06:31:55 +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
|
||||
}
|
||||
|
||||
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,
|
||||
nonceDbs)
|
||||
|
||||
oracleSigs = DLCUtil.buildOracleSignatures(announcements =
|
||||
announcementTLVs,
|
||||
attestments = sigs.toVector)
|
||||
oracleSigs = DLCUtil.buildOracleSignaturesNaive(
|
||||
announcements = announcementTLVs,
|
||||
attestments = sigs.toVector)
|
||||
|
||||
tx <- executeDLC(contractId, oracleSigs)
|
||||
} yield tx
|
||||
|
|
Loading…
Add table
Reference in a new issue