@atomicfinance/bitcoin-dlc-provider 3.6.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.nvmrc +1 -1
- package/.turbo/turbo-build.log +1 -0
- package/.turbo/turbo-test.log +0 -0
- package/.yalc/@node-dlc/messaging/.nyc_output/2cf48009-1094-4275-bb91-c164c932feb6.json +1 -0
- package/.yalc/@node-dlc/messaging/.nyc_output/processinfo/2cf48009-1094-4275-bb91-c164c932feb6.json +1 -0
- package/.yalc/@node-dlc/messaging/.nyc_output/processinfo/index.json +1 -0
- package/.yalc/@node-dlc/messaging/README.md +24 -0
- package/.yalc/@node-dlc/messaging/__tests__/_test-utils.ts +12 -0
- package/.yalc/@node-dlc/messaging/__tests__/chain/ChainManager.spec.ts +178 -0
- package/.yalc/@node-dlc/messaging/__tests__/compatibility/dlcspecs-compatibility.spec.ts +473 -0
- package/.yalc/@node-dlc/messaging/__tests__/compatibility/rust-dlc-cross-language.spec.ts +342 -0
- package/.yalc/@node-dlc/messaging/__tests__/compatibility/true-serialization-compatibility.spec.ts +611 -0
- package/.yalc/@node-dlc/messaging/__tests__/dlc_message_test.json +155 -0
- package/.yalc/@node-dlc/messaging/__tests__/irc/IrcMessage.spec.ts +94 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/AddressCache.spec.ts +79 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/BatchFundingGroup.spec.ts +72 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/CetAdaptorSignatures.spec.ts +57 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/ContractDescriptor.spec.ts +264 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/ContractInfo.spec.ts +419 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/DigitDecompositionEventDescriptor.spec.ts +59 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/DlcAccept.spec.ts +242 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/DlcCancel.spec.ts +42 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/DlcClose.spec.ts +315 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/DlcOffer.spec.ts +527 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/DlcSign.spec.ts +118 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/DlcTransactions.spec.ts +157 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/EnumEventDescriptor.spec.ts +50 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/EventDescriptor.spec.ts +93 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/FundingInput.spec.ts +84 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/FundingSignatures.spec.ts +83 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/NegotiationFields.spec.ts +328 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/NodeAnnouncementMessage.spec.ts +115 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/OracleAnnouncement.spec.ts +415 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/OracleAttestation.spec.ts +326 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/OracleEvent.spec.ts +143 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/OracleEventContainer.spec.ts +95 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/OracleIdentifier.spec.ts +48 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/OracleInfo.spec.ts +116 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/OrderAccept.spec.ts +77 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/OrderNegotiationFields.spec.ts +216 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/OrderOffer.spec.ts +121 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/OrderPositionInfo.spec.ts +75 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/PayoutCurvePiece.spec.ts +220 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/PayoutFunction.spec.ts +101 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/RoundingIntervals.spec.ts +75 -0
- package/.yalc/@node-dlc/messaging/__tests__/serialize/F64.spec.ts +260 -0
- package/.yalc/@node-dlc/messaging/__tests__/tsconfig.json +8 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/base.css +224 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/block-navigation.js +79 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/favicon.png +0 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/index.html +201 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/MessageType.ts.html +494 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/chain/ChainManager.ts.html +1058 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/chain/ChainMemoryStore.ts.html +182 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/chain/index.html +126 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/domain/Address.ts.html +272 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/domain/index.html +111 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/index.html +141 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/index.ts.html +212 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/irc/IrcMessage.ts.html +563 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/irc/index.html +111 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/AddressCache.ts.html +302 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/BatchFundingGroup.ts.html +503 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/CetAdaptorSignatures.ts.html +347 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/CetAdaptorSignaturesV0.ts.html +347 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/ContractDescriptor.ts.html +1040 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/ContractInfo.ts.html +1382 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/DlcAccept.ts.html +1865 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/DlcCancel.ts.html +251 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/DlcClose.ts.html +986 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/DlcCloseMetadata.ts.html +443 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/DlcIds.ts.html +281 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/DlcInfo.ts.html +323 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/DlcMessage.ts.html +341 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/DlcOffer.ts.html +1895 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/DlcSign.ts.html +1142 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/DlcTransactions.ts.html +719 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/EventDescriptor.ts.html +947 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/FundingInput.ts.html +728 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/FundingSignatures.ts.html +374 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/FundingSignaturesV0.ts.html +374 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/NegotiationFields.ts.html +836 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/NodeAnnouncementMessage.ts.html +515 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleAnnouncement.ts.html +608 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleAnnouncementV0.ts.html +605 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleAttestation.ts.html +956 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleAttestationV0.ts.html +770 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleEvent.ts.html +830 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleEventContainer.ts.html +347 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleEventContainerV0.ts.html +347 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleEventV0.ts.html +827 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleIdentifier.ts.html +314 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleIdentifierV0.ts.html +314 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleInfo.ts.html +1637 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleInfoV0.ts.html +1631 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OrderAccept.ts.html +557 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OrderIrcInfo.ts.html +380 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OrderMetadata.ts.html +437 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OrderNegotiationFields.ts.html +551 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OrderOffer.ts.html +1337 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OrderPositionInfo.ts.html +590 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/PayoutCurvePiece.ts.html +1427 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/PayoutFunction.ts.html +800 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/RoundingIntervals.ts.html +461 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/RoundingIntervalsV0.ts.html +482 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/ScriptWitnessV0.ts.html +269 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/index.html +636 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/serde/SerdeUtils.ts.html +1394 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/serde/index.html +111 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/serialize/F64.ts.html +1136 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/serialize/deserializeTlv.ts.html +125 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/serialize/getTlv.ts.html +143 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/serialize/index.html +141 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/util.ts.html +179 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/validation/index.html +111 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/validation/validate.ts.html +182 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/prettify.css +1 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/prettify.js +2 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/sorter.js +170 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov.info +5394 -0
- package/.yalc/@node-dlc/messaging/dist/MessageType.d.ts +100 -0
- package/.yalc/@node-dlc/messaging/dist/MessageType.js +117 -0
- package/.yalc/@node-dlc/messaging/dist/MessageType.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/chain/ChainManager.d.ts +50 -0
- package/.yalc/@node-dlc/messaging/dist/chain/ChainManager.js +211 -0
- package/.yalc/@node-dlc/messaging/dist/chain/ChainManager.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/chain/ChainMemoryStore.d.ts +14 -0
- package/.yalc/@node-dlc/messaging/dist/chain/ChainMemoryStore.js +28 -0
- package/.yalc/@node-dlc/messaging/dist/chain/ChainMemoryStore.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/chain/DlcStore.d.ts +11 -0
- package/.yalc/@node-dlc/messaging/dist/chain/DlcStore.js +3 -0
- package/.yalc/@node-dlc/messaging/dist/chain/DlcStore.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/chain/IChainFilterChainClient.d.ts +48 -0
- package/.yalc/@node-dlc/messaging/dist/chain/IChainFilterChainClient.js +3 -0
- package/.yalc/@node-dlc/messaging/dist/chain/IChainFilterChainClient.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/domain/Address.d.ts +24 -0
- package/.yalc/@node-dlc/messaging/dist/domain/Address.js +46 -0
- package/.yalc/@node-dlc/messaging/dist/domain/Address.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/index.d.ts +44 -0
- package/.yalc/@node-dlc/messaging/dist/index.js +63 -0
- package/.yalc/@node-dlc/messaging/dist/index.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/irc/IrcMessage.d.ts +43 -0
- package/.yalc/@node-dlc/messaging/dist/irc/IrcMessage.js +116 -0
- package/.yalc/@node-dlc/messaging/dist/irc/IrcMessage.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/AddressCache.d.ts +15 -0
- package/.yalc/@node-dlc/messaging/dist/messages/AddressCache.js +51 -0
- package/.yalc/@node-dlc/messaging/dist/messages/AddressCache.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/BatchFundingGroup.d.ts +61 -0
- package/.yalc/@node-dlc/messaging/dist/messages/BatchFundingGroup.js +113 -0
- package/.yalc/@node-dlc/messaging/dist/messages/BatchFundingGroup.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/CetAdaptorSignatures.d.ts +40 -0
- package/.yalc/@node-dlc/messaging/dist/messages/CetAdaptorSignatures.js +67 -0
- package/.yalc/@node-dlc/messaging/dist/messages/CetAdaptorSignatures.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/ContractDescriptor.d.ts +122 -0
- package/.yalc/@node-dlc/messaging/dist/messages/ContractDescriptor.js +222 -0
- package/.yalc/@node-dlc/messaging/dist/messages/ContractDescriptor.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/ContractInfo.d.ts +135 -0
- package/.yalc/@node-dlc/messaging/dist/messages/ContractInfo.js +304 -0
- package/.yalc/@node-dlc/messaging/dist/messages/ContractInfo.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcAccept.d.ts +145 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcAccept.js +428 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcAccept.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcCancel.d.ts +31 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcCancel.js +51 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcCancel.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcClose.d.ts +68 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcClose.js +210 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcClose.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcCloseMetadata.d.ts +44 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcCloseMetadata.js +74 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcCloseMetadata.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcIds.d.ts +26 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcIds.js +58 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcIds.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcInfo.d.ts +31 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcInfo.js +61 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcInfo.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcMessage.d.ts +23 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcMessage.js +54 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcMessage.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcOffer.d.ts +131 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcOffer.js +418 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcOffer.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcSign.d.ts +96 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcSign.js +267 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcSign.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcTransactions.d.ts +69 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcTransactions.js +149 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcTransactions.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/EventDescriptor.d.ts +106 -0
- package/.yalc/@node-dlc/messaging/dist/messages/EventDescriptor.js +209 -0
- package/.yalc/@node-dlc/messaging/dist/messages/EventDescriptor.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/FundingInput.d.ts +62 -0
- package/.yalc/@node-dlc/messaging/dist/messages/FundingInput.js +163 -0
- package/.yalc/@node-dlc/messaging/dist/messages/FundingInput.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/FundingSignatures.d.ts +36 -0
- package/.yalc/@node-dlc/messaging/dist/messages/FundingSignatures.js +78 -0
- package/.yalc/@node-dlc/messaging/dist/messages/FundingSignatures.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/IWireMessage.d.ts +6 -0
- package/.yalc/@node-dlc/messaging/dist/messages/IWireMessage.js +3 -0
- package/.yalc/@node-dlc/messaging/dist/messages/IWireMessage.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/NegotiationFields.d.ts +86 -0
- package/.yalc/@node-dlc/messaging/dist/messages/NegotiationFields.js +185 -0
- package/.yalc/@node-dlc/messaging/dist/messages/NegotiationFields.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/NodeAnnouncementMessage.d.ts +57 -0
- package/.yalc/@node-dlc/messaging/dist/messages/NodeAnnouncementMessage.js +127 -0
- package/.yalc/@node-dlc/messaging/dist/messages/NodeAnnouncementMessage.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleAnnouncement.d.ts +76 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleAnnouncement.js +131 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleAnnouncement.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleAttestation.d.ts +68 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleAttestation.js +239 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleAttestation.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleEvent.d.ts +90 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleEvent.js +189 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleEvent.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleEventContainer.d.ts +32 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleEventContainer.js +67 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleEventContainer.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleIdentifier.d.ts +32 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleIdentifier.js +58 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleIdentifier.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleIdentifierV0.d.ts +32 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleIdentifierV0.js +58 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleIdentifierV0.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleInfo.d.ts +161 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleInfo.js +390 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleInfo.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleInfoV0.d.ts +161 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleInfoV0.js +387 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleInfoV0.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OrderAccept.d.ts +65 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OrderAccept.js +125 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OrderAccept.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OrderIrcInfo.d.ts +42 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OrderIrcInfo.js +74 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OrderIrcInfo.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OrderMetadata.d.ts +56 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OrderMetadata.js +87 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OrderMetadata.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OrderNegotiationFields.d.ts +69 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OrderNegotiationFields.js +114 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OrderNegotiationFields.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OrderOffer.d.ts +97 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OrderOffer.js +296 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OrderOffer.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OrderPositionInfo.d.ts +50 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OrderPositionInfo.js +125 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OrderPositionInfo.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/PayoutCurvePiece.d.ts +129 -0
- package/.yalc/@node-dlc/messaging/dist/messages/PayoutCurvePiece.js +327 -0
- package/.yalc/@node-dlc/messaging/dist/messages/PayoutCurvePiece.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/PayoutFunction.d.ts +66 -0
- package/.yalc/@node-dlc/messaging/dist/messages/PayoutFunction.js +170 -0
- package/.yalc/@node-dlc/messaging/dist/messages/PayoutFunction.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/RoundingIntervals.d.ts +52 -0
- package/.yalc/@node-dlc/messaging/dist/messages/RoundingIntervals.js +95 -0
- package/.yalc/@node-dlc/messaging/dist/messages/RoundingIntervals.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/ScriptWitnessV0.d.ts +29 -0
- package/.yalc/@node-dlc/messaging/dist/messages/ScriptWitnessV0.js +50 -0
- package/.yalc/@node-dlc/messaging/dist/messages/ScriptWitnessV0.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/Tlv.d.ts +15 -0
- package/.yalc/@node-dlc/messaging/dist/messages/Tlv.js +32 -0
- package/.yalc/@node-dlc/messaging/dist/messages/Tlv.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/serialize/F64.d.ts +154 -0
- package/.yalc/@node-dlc/messaging/dist/serialize/F64.js +307 -0
- package/.yalc/@node-dlc/messaging/dist/serialize/F64.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/serialize/deserializeTlv.d.ts +9 -0
- package/.yalc/@node-dlc/messaging/dist/serialize/deserializeTlv.js +11 -0
- package/.yalc/@node-dlc/messaging/dist/serialize/deserializeTlv.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/serialize/getTlv.d.ts +4 -0
- package/.yalc/@node-dlc/messaging/dist/serialize/getTlv.js +23 -0
- package/.yalc/@node-dlc/messaging/dist/serialize/getTlv.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/serialize/readTlvs.d.ts +8 -0
- package/.yalc/@node-dlc/messaging/dist/serialize/readTlvs.js +33 -0
- package/.yalc/@node-dlc/messaging/dist/serialize/readTlvs.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/util.d.ts +13 -0
- package/.yalc/@node-dlc/messaging/dist/util.js +40 -0
- package/.yalc/@node-dlc/messaging/dist/util.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/validation/validate.d.ts +4 -0
- package/.yalc/@node-dlc/messaging/dist/validation/validate.js +31 -0
- package/.yalc/@node-dlc/messaging/dist/validation/validate.js.map +1 -0
- package/.yalc/@node-dlc/messaging/lib/MessageType.ts +138 -0
- package/.yalc/@node-dlc/messaging/lib/chain/ChainManager.ts +326 -0
- package/.yalc/@node-dlc/messaging/lib/chain/ChainMemoryStore.ts +34 -0
- package/.yalc/@node-dlc/messaging/lib/chain/DlcStore.ts +11 -0
- package/.yalc/@node-dlc/messaging/lib/chain/IChainFilterChainClient.ts +57 -0
- package/.yalc/@node-dlc/messaging/lib/domain/Address.ts +64 -0
- package/.yalc/@node-dlc/messaging/lib/index.ts +44 -0
- package/.yalc/@node-dlc/messaging/lib/irc/IrcMessage.ts +161 -0
- package/.yalc/@node-dlc/messaging/lib/messages/AddressCache.ts +74 -0
- package/.yalc/@node-dlc/messaging/lib/messages/BatchFundingGroup.ts +141 -0
- package/.yalc/@node-dlc/messaging/lib/messages/CetAdaptorSignatures.ts +89 -0
- package/.yalc/@node-dlc/messaging/lib/messages/ContractDescriptor.ts +318 -0
- package/.yalc/@node-dlc/messaging/lib/messages/ContractInfo.ts +434 -0
- package/.yalc/@node-dlc/messaging/lib/messages/DlcAccept.ts +595 -0
- package/.yalc/@node-dlc/messaging/lib/messages/DlcCancel.ts +57 -0
- package/.yalc/@node-dlc/messaging/lib/messages/DlcClose.ts +302 -0
- package/.yalc/@node-dlc/messaging/lib/messages/DlcCloseMetadata.ts +121 -0
- package/.yalc/@node-dlc/messaging/lib/messages/DlcIds.ts +67 -0
- package/.yalc/@node-dlc/messaging/lib/messages/DlcInfo.ts +81 -0
- package/.yalc/@node-dlc/messaging/lib/messages/DlcMessage.ts +87 -0
- package/.yalc/@node-dlc/messaging/lib/messages/DlcOffer.ts +605 -0
- package/.yalc/@node-dlc/messaging/lib/messages/DlcSign.ts +354 -0
- package/.yalc/@node-dlc/messaging/lib/messages/DlcTransactions.ts +213 -0
- package/.yalc/@node-dlc/messaging/lib/messages/EventDescriptor.ts +289 -0
- package/.yalc/@node-dlc/messaging/lib/messages/FundingInput.ts +216 -0
- package/.yalc/@node-dlc/messaging/lib/messages/FundingSignatures.ts +98 -0
- package/.yalc/@node-dlc/messaging/lib/messages/IWireMessage.ts +6 -0
- package/.yalc/@node-dlc/messaging/lib/messages/NegotiationFields.ts +252 -0
- package/.yalc/@node-dlc/messaging/lib/messages/NodeAnnouncementMessage.ts +145 -0
- package/.yalc/@node-dlc/messaging/lib/messages/OracleAnnouncement.ts +176 -0
- package/.yalc/@node-dlc/messaging/lib/messages/OracleAttestation.ts +292 -0
- package/.yalc/@node-dlc/messaging/lib/messages/OracleEvent.ts +250 -0
- package/.yalc/@node-dlc/messaging/lib/messages/OracleEventContainer.ts +89 -0
- package/.yalc/@node-dlc/messaging/lib/messages/OracleIdentifier.ts +78 -0
- package/.yalc/@node-dlc/messaging/lib/messages/OracleInfo.ts +519 -0
- package/.yalc/@node-dlc/messaging/lib/messages/OrderAccept.ts +159 -0
- package/.yalc/@node-dlc/messaging/lib/messages/OrderIrcInfo.ts +100 -0
- package/.yalc/@node-dlc/messaging/lib/messages/OrderMetadata.ts +119 -0
- package/.yalc/@node-dlc/messaging/lib/messages/OrderNegotiationFields.ts +157 -0
- package/.yalc/@node-dlc/messaging/lib/messages/OrderOffer.ts +419 -0
- package/.yalc/@node-dlc/messaging/lib/messages/OrderPositionInfo.ts +170 -0
- package/.yalc/@node-dlc/messaging/lib/messages/PayoutCurvePiece.ts +449 -0
- package/.yalc/@node-dlc/messaging/lib/messages/PayoutFunction.ts +240 -0
- package/.yalc/@node-dlc/messaging/lib/messages/RoundingIntervals.ts +127 -0
- package/.yalc/@node-dlc/messaging/lib/messages/ScriptWitnessV0.ts +63 -0
- package/.yalc/@node-dlc/messaging/lib/messages/Tlv.ts +40 -0
- package/.yalc/@node-dlc/messaging/lib/serialize/F64.ts +352 -0
- package/.yalc/@node-dlc/messaging/lib/serialize/deserializeTlv.ts +15 -0
- package/.yalc/@node-dlc/messaging/lib/serialize/getTlv.ts +21 -0
- package/.yalc/@node-dlc/messaging/lib/serialize/readTlvs.ts +37 -0
- package/.yalc/@node-dlc/messaging/lib/util.ts +33 -0
- package/.yalc/@node-dlc/messaging/lib/validation/validate.ts +34 -0
- package/.yalc/@node-dlc/messaging/package.json +42 -0
- package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/enum_3_of_3_test.json +210 -0
- package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/enum_3_of_5_test.json +468 -0
- package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/enum_and_numerical_3_of_5_test.json +1517 -0
- package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/enum_and_numerical_5_of_5_test.json +545 -0
- package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/enum_and_numerical_with_diff_3_of_5_test.json +4761 -0
- package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/enum_and_numerical_with_diff_5_of_5_test.json +2169 -0
- package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/enum_single_oracle_test.json +164 -0
- package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/single_oracle_numerical_hyperbola_test.json +502 -0
- package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/single_oracle_numerical_test.json +262 -0
- package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/three_of_five_oracle_numerical_with_diff_test.json +4382 -0
- package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/three_of_three_oracle_numerical_test.json +324 -0
- package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/three_of_three_oracle_numerical_with_diff_test.json +652 -0
- package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/two_of_five_oracle_numerical_test.json +1138 -0
- package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/two_of_five_oracle_numerical_with_diff_test.json +2222 -0
- package/.yalc/@node-dlc/messaging/test_vectors/oracle/external_oracle_announcements.json +0 -0
- package/.yalc/@node-dlc/messaging/test_vectors/oracle/oracle_message_test_vectors.json +115 -0
- package/.yalc/@node-dlc/messaging/test_vectors/rust-dlc/accept_msg.json +1465 -0
- package/.yalc/@node-dlc/messaging/test_vectors/rust-dlc/dlc_fee_test.json +12362 -0
- package/.yalc/@node-dlc/messaging/test_vectors/rust-dlc/dlc_fee_test_scripts.json +57 -0
- package/.yalc/@node-dlc/messaging/test_vectors/rust-dlc/dlc_test.json +2766 -0
- package/.yalc/@node-dlc/messaging/test_vectors/rust-dlc/dlc_tx_test.json +2899 -0
- package/.yalc/@node-dlc/messaging/test_vectors/rust-dlc/offer_msg.json +163 -0
- package/.yalc/@node-dlc/messaging/test_vectors/rust-dlc/offer_msg_disjoint.json +352 -0
- package/.yalc/@node-dlc/messaging/test_vectors/rust-dlc/segment_chunk_msg.json +12635 -0
- package/.yalc/@node-dlc/messaging/test_vectors/rust-dlc/segment_start_msg.json +4022 -0
- package/.yalc/@node-dlc/messaging/test_vectors/rust-dlc/sign_msg.json +383 -0
- package/.yalc/@node-dlc/messaging/tsconfig.json +7 -0
- package/.yalc/@node-dlc/messaging/yalc.sig +1 -0
- package/CHANGELOG.md +83 -0
- package/dist/BitcoinDlcProvider.d.ts +17 -16
- package/dist/BitcoinDlcProvider.js +375 -317
- package/dist/BitcoinDlcProvider.js.map +1 -1
- package/dist/utils/Utils.d.ts +6 -6
- package/dist/utils/Utils.js +4 -4
- package/dist/utils/Utils.js.map +1 -1
- package/lib/BitcoinDlcProvider.ts +637 -621
- package/lib/utils/Utils.ts +19 -24
- package/package.json +13 -11
- package/yalc.lock +10 -0
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import { BufferReader, BufferWriter } from '@node-dlc/bufio';
|
|
2
|
+
import { math, verify } from 'bip-schnorr';
|
|
3
|
+
|
|
4
|
+
import { MessageType } from '../MessageType';
|
|
5
|
+
import { IDlcMessage } from './DlcMessage';
|
|
6
|
+
import { OracleAnnouncement } from './OracleAnnouncement';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Oracle attestation providing signatures over an outcome value.
|
|
10
|
+
* This represents the oracle's actual attestation to a specific outcome.
|
|
11
|
+
* Updated to match rust-dlc specification with 2-byte count prefixes.
|
|
12
|
+
*
|
|
13
|
+
* An attestation from an oracle providing signatures over an outcome value.
|
|
14
|
+
* This is what the oracle publishes when they want to attest to a specific outcome.
|
|
15
|
+
*/
|
|
16
|
+
export class OracleAttestation implements IDlcMessage {
|
|
17
|
+
public static type = MessageType.OracleAttestation;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Deserializes an oracle_attestation message
|
|
21
|
+
* @param buf
|
|
22
|
+
*/
|
|
23
|
+
public static deserialize(buf: Buffer): OracleAttestation {
|
|
24
|
+
const instance = new OracleAttestation();
|
|
25
|
+
const reader = new BufferReader(buf);
|
|
26
|
+
|
|
27
|
+
reader.readBigSize(); // read type
|
|
28
|
+
instance.length = reader.readBigSize();
|
|
29
|
+
|
|
30
|
+
// Detect format: old rust-dlc 0.4.0 (no event_id) vs new rust-dlc (with event_id)
|
|
31
|
+
const currentPos = reader.position;
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
// Try reading as new format (with event_id)
|
|
35
|
+
const eventIdLength = reader.readBigSize();
|
|
36
|
+
|
|
37
|
+
// If event ID length is reasonable (0-100 bytes), assume new format
|
|
38
|
+
if (eventIdLength >= BigInt('0') && eventIdLength <= BigInt('100')) {
|
|
39
|
+
if (eventIdLength === BigInt('0')) {
|
|
40
|
+
instance.eventId = '';
|
|
41
|
+
} else {
|
|
42
|
+
const eventIdBuf = reader.readBytes(Number(eventIdLength));
|
|
43
|
+
instance.eventId = eventIdBuf.toString();
|
|
44
|
+
}
|
|
45
|
+
instance.oraclePubkey = reader.readBytes(32);
|
|
46
|
+
} else {
|
|
47
|
+
// Event ID length is unreasonable, probably old format without event_id
|
|
48
|
+
reader.position = currentPos;
|
|
49
|
+
instance.eventId = ''; // Default empty event ID for old format
|
|
50
|
+
instance.oraclePubkey = reader.readBytes(32);
|
|
51
|
+
}
|
|
52
|
+
} catch (error) {
|
|
53
|
+
// If reading fails, assume old format without event_id
|
|
54
|
+
reader.position = currentPos;
|
|
55
|
+
instance.eventId = ''; // Default empty event ID for old format
|
|
56
|
+
instance.oraclePubkey = reader.readBytes(32);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const numSignatures = reader.readUInt16BE();
|
|
60
|
+
|
|
61
|
+
for (let i = 0; i < numSignatures; i++) {
|
|
62
|
+
const signature = reader.readBytes(64);
|
|
63
|
+
instance.signatures.push(signature);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Handle both rust-dlc format (with u16 count prefix) and DLCSpecs format (no count prefix)
|
|
67
|
+
// Try to detect format by checking if next 2 bytes look like a reasonable outcome count
|
|
68
|
+
if (!reader.eof) {
|
|
69
|
+
const currentPos = reader.position;
|
|
70
|
+
|
|
71
|
+
try {
|
|
72
|
+
// Try reading as rust-dlc format (with u16 count prefix)
|
|
73
|
+
const numOutcomes = reader.readUInt16BE();
|
|
74
|
+
|
|
75
|
+
// Validate that this looks like a reasonable count
|
|
76
|
+
// If it's > 1000 or the remaining bytes can't accommodate this many outcomes,
|
|
77
|
+
// it's probably not a count prefix
|
|
78
|
+
const remainingBytes = reader.buffer.length - reader.position;
|
|
79
|
+
|
|
80
|
+
if (
|
|
81
|
+
numOutcomes > 0 &&
|
|
82
|
+
numOutcomes <= 1000 &&
|
|
83
|
+
remainingBytes >= numOutcomes * 2
|
|
84
|
+
) {
|
|
85
|
+
// Looks like rust-dlc format with u16 count prefix
|
|
86
|
+
for (let i = 0; i < numOutcomes; i++) {
|
|
87
|
+
const outcomeLen = reader.readBigSize();
|
|
88
|
+
const outcomeBuf = reader.readBytes(Number(outcomeLen));
|
|
89
|
+
instance.outcomes.push(outcomeBuf.toString());
|
|
90
|
+
}
|
|
91
|
+
} else {
|
|
92
|
+
// Reset and try DLCSpecs format (no count prefix)
|
|
93
|
+
reader.position = currentPos;
|
|
94
|
+
while (!reader.eof) {
|
|
95
|
+
const outcomeLen = reader.readBigSize();
|
|
96
|
+
const outcomeBuf = reader.readBytes(Number(outcomeLen));
|
|
97
|
+
instance.outcomes.push(outcomeBuf.toString());
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
} catch (error) {
|
|
101
|
+
// If reading as rust-dlc format fails, reset and try DLCSpecs format
|
|
102
|
+
reader.position = currentPos;
|
|
103
|
+
while (!reader.eof) {
|
|
104
|
+
const outcomeLen = reader.readBigSize();
|
|
105
|
+
const outcomeBuf = reader.readBytes(Number(outcomeLen));
|
|
106
|
+
instance.outcomes.push(outcomeBuf.toString());
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return instance;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* The type for oracle_attestation message. oracle_attestation = 55400
|
|
116
|
+
*/
|
|
117
|
+
public type = OracleAttestation.type;
|
|
118
|
+
|
|
119
|
+
public length: bigint;
|
|
120
|
+
|
|
121
|
+
/** The identifier of the announcement. */
|
|
122
|
+
public eventId: string;
|
|
123
|
+
|
|
124
|
+
/** The public key of the oracle (32 bytes, x-only). */
|
|
125
|
+
public oraclePubkey: Buffer;
|
|
126
|
+
|
|
127
|
+
/** The signatures over the event outcome (64 bytes each, Schnorr format). */
|
|
128
|
+
public signatures: Buffer[] = [];
|
|
129
|
+
|
|
130
|
+
/** The set of strings representing the outcome value. */
|
|
131
|
+
public outcomes: string[] = [];
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Validates the oracle attestation according to rust-dlc specification.
|
|
135
|
+
* This includes validating signatures and ensuring consistency with announcement.
|
|
136
|
+
* @param announcement The corresponding oracle announcement for validation (optional)
|
|
137
|
+
* @throws Will throw an error if validation fails
|
|
138
|
+
*/
|
|
139
|
+
public validate(announcement?: OracleAnnouncement): void {
|
|
140
|
+
// Basic structure validation
|
|
141
|
+
if (this.signatures.length !== this.outcomes.length) {
|
|
142
|
+
throw new Error('Number of signatures must match number of outcomes');
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (this.signatures.length === 0) {
|
|
146
|
+
throw new Error('Must have at least one signature and outcome');
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Validate event ID
|
|
150
|
+
if (!this.eventId || this.eventId.length === 0) {
|
|
151
|
+
throw new Error('Event ID cannot be empty');
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Validate oracle public key format
|
|
155
|
+
if (!this.oraclePubkey || this.oraclePubkey.length !== 32) {
|
|
156
|
+
throw new Error('Oracle public key must be 32 bytes (x-only format)');
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Validate signature formats
|
|
160
|
+
this.signatures.forEach((sig, index) => {
|
|
161
|
+
if (!sig || sig.length !== 64) {
|
|
162
|
+
throw new Error(
|
|
163
|
+
`Signature at index ${index} must be 64 bytes (Schnorr format)`,
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
// Validate outcomes are not empty
|
|
169
|
+
this.outcomes.forEach((outcome, index) => {
|
|
170
|
+
if (!outcome || outcome.length === 0) {
|
|
171
|
+
throw new Error(`Outcome at index ${index} cannot be empty`);
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
// Verify signatures over outcomes using tagged hash
|
|
176
|
+
this.signatures.forEach((sig, index) => {
|
|
177
|
+
const outcome = this.outcomes[index];
|
|
178
|
+
try {
|
|
179
|
+
const msg = math.taggedHash('DLC/oracle/attestation/v0', outcome);
|
|
180
|
+
verify(this.oraclePubkey, msg, sig);
|
|
181
|
+
} catch (error) {
|
|
182
|
+
throw new Error(
|
|
183
|
+
`Invalid signature for outcome "${outcome}" at index ${index}: ${error.message}`,
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
// If announcement is provided, validate consistency
|
|
189
|
+
if (announcement) {
|
|
190
|
+
this.validateAgainstAnnouncement(announcement);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Validates the attestation against the corresponding oracle announcement.
|
|
196
|
+
* This ensures the attestation is consistent with the original announcement.
|
|
197
|
+
* @param announcement The oracle announcement to validate against
|
|
198
|
+
* @throws Will throw an error if validation fails
|
|
199
|
+
*/
|
|
200
|
+
private validateAgainstAnnouncement(announcement: OracleAnnouncement): void {
|
|
201
|
+
// Validate oracle public key matches announcement
|
|
202
|
+
if (!this.oraclePubkey.equals(announcement.oraclePubkey)) {
|
|
203
|
+
throw new Error('Oracle public key must match announcement');
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// Validate event ID matches
|
|
207
|
+
if (this.eventId !== announcement.getEventId()) {
|
|
208
|
+
throw new Error('Event ID must match announcement');
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// Validate that the number of signatures matches the number of nonces in announcement
|
|
212
|
+
const announcementNonces = announcement.getNonces();
|
|
213
|
+
if (this.signatures.length !== announcementNonces.length) {
|
|
214
|
+
throw new Error(
|
|
215
|
+
'Number of signatures must match number of nonces in announcement',
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// Extract nonces from signatures (first 32 bytes) and compare with announcement nonces
|
|
220
|
+
// This validates that the signatures were created using the committed nonces
|
|
221
|
+
this.signatures.forEach((sig, index) => {
|
|
222
|
+
const nonceFromSig = sig.slice(0, 32);
|
|
223
|
+
const expectedNonce = announcementNonces[index];
|
|
224
|
+
|
|
225
|
+
if (!nonceFromSig.equals(expectedNonce)) {
|
|
226
|
+
throw new Error(
|
|
227
|
+
`Signature nonce mismatch at index ${index}: signature was not created with announced nonce`,
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Returns the nonces used by the oracle to sign the event outcome.
|
|
235
|
+
* This is used for finding the matching oracle announcement.
|
|
236
|
+
* The nonce is extracted from the first 32 bytes of each signature.
|
|
237
|
+
*/
|
|
238
|
+
public getNonces(): Buffer[] {
|
|
239
|
+
return this.signatures.map((sig) => sig.slice(0, 32));
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Converts oracle_attestation to JSON
|
|
244
|
+
*/
|
|
245
|
+
public toJSON(): OracleAttestationJSON {
|
|
246
|
+
return {
|
|
247
|
+
type: this.type,
|
|
248
|
+
eventId: this.eventId,
|
|
249
|
+
oraclePubkey: this.oraclePubkey.toString('hex'),
|
|
250
|
+
signatures: this.signatures.map((sig) => sig.toString('hex')),
|
|
251
|
+
outcomes: this.outcomes,
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Serializes the oracle_attestation message into a Buffer
|
|
257
|
+
*/
|
|
258
|
+
public serialize(): Buffer {
|
|
259
|
+
const writer = new BufferWriter();
|
|
260
|
+
writer.writeBigSize(this.type);
|
|
261
|
+
|
|
262
|
+
const dataWriter = new BufferWriter();
|
|
263
|
+
dataWriter.writeBigSize(this.eventId.length);
|
|
264
|
+
dataWriter.writeBytes(Buffer.from(this.eventId));
|
|
265
|
+
dataWriter.writeBytes(this.oraclePubkey);
|
|
266
|
+
dataWriter.writeUInt16BE(this.signatures.length);
|
|
267
|
+
|
|
268
|
+
for (const signature of this.signatures) {
|
|
269
|
+
dataWriter.writeBytes(signature);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// Write outcomes with u16 count prefix (matching rust-dlc format)
|
|
273
|
+
dataWriter.writeUInt16BE(this.outcomes.length);
|
|
274
|
+
for (const outcome of this.outcomes) {
|
|
275
|
+
dataWriter.writeBigSize(outcome.length);
|
|
276
|
+
dataWriter.writeBytes(Buffer.from(outcome));
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
writer.writeBigSize(dataWriter.size);
|
|
280
|
+
writer.writeBytes(dataWriter.toBuffer());
|
|
281
|
+
|
|
282
|
+
return writer.toBuffer();
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export interface OracleAttestationJSON {
|
|
287
|
+
type: number;
|
|
288
|
+
eventId: string;
|
|
289
|
+
oraclePubkey: string;
|
|
290
|
+
signatures: string[];
|
|
291
|
+
outcomes: string[];
|
|
292
|
+
}
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { BufferReader, BufferWriter } from '@node-dlc/bufio';
|
|
2
|
+
|
|
3
|
+
import { MessageType } from '../MessageType';
|
|
4
|
+
import { getTlv } from '../serialize/getTlv';
|
|
5
|
+
import { IDlcMessage } from './DlcMessage';
|
|
6
|
+
import {
|
|
7
|
+
DigitDecompositionEventDescriptor,
|
|
8
|
+
EnumEventDescriptor,
|
|
9
|
+
EventDescriptor,
|
|
10
|
+
IDigitDecompositionEventDescriptorJSON,
|
|
11
|
+
IEnumEventDescriptorJSON,
|
|
12
|
+
} from './EventDescriptor';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Oracle event containing information about an event and the way that the
|
|
16
|
+
* oracle will attest to it. Updated to be rust-dlc compliant.
|
|
17
|
+
*
|
|
18
|
+
* For users to be able to create DLCs based on a given event, they also
|
|
19
|
+
* need to obtain information about the oracle and the time at which it
|
|
20
|
+
* plans on releasing a signature over the event outcome. OracleEvent
|
|
21
|
+
* messages contain such information, which includes:
|
|
22
|
+
* - the nonce(s) that will be used to sign the event outcome(s)
|
|
23
|
+
* - the earliest time (UTC) at which it plans on releasing a signature
|
|
24
|
+
* over the event outcome, in epoch seconds
|
|
25
|
+
* - the event descriptor
|
|
26
|
+
* - the event ID which can be a name or categorization associated with
|
|
27
|
+
* the event by the oracle
|
|
28
|
+
*/
|
|
29
|
+
export class OracleEvent implements IDlcMessage {
|
|
30
|
+
public static type = MessageType.OracleEvent;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Creates an OracleEvent from JSON data
|
|
34
|
+
* @param json JSON object representing oracle event
|
|
35
|
+
*/
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
|
|
37
|
+
public static fromJSON(json: any): OracleEvent {
|
|
38
|
+
const instance = new OracleEvent();
|
|
39
|
+
|
|
40
|
+
// Parse oracle nonces array
|
|
41
|
+
const nonces = json.oracleNonces || json.oracle_nonces || [];
|
|
42
|
+
instance.oracleNonces = nonces.map((nonce: string) =>
|
|
43
|
+
Buffer.from(nonce, 'hex'),
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
instance.eventMaturityEpoch =
|
|
47
|
+
json.eventMaturityEpoch || json.event_maturity_epoch || 0;
|
|
48
|
+
|
|
49
|
+
// Parse event descriptor
|
|
50
|
+
instance.eventDescriptor = EventDescriptor.fromJSON(
|
|
51
|
+
json.eventDescriptor || json.event_descriptor,
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
instance.eventId = json.eventId || json.event_id || '';
|
|
55
|
+
|
|
56
|
+
return instance;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Deserializes an oracle_event message
|
|
61
|
+
* @param buf
|
|
62
|
+
*/
|
|
63
|
+
public static deserialize(buf: Buffer): OracleEvent {
|
|
64
|
+
const instance = new OracleEvent();
|
|
65
|
+
const reader = new BufferReader(buf);
|
|
66
|
+
|
|
67
|
+
reader.readBigSize(); // read type
|
|
68
|
+
instance.length = reader.readBigSize();
|
|
69
|
+
const nonceCount = reader.readUInt16BE();
|
|
70
|
+
|
|
71
|
+
for (let i = 0; i < nonceCount; i++) {
|
|
72
|
+
instance.oracleNonces.push(reader.readBytes(32));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
instance.eventMaturityEpoch = reader.readUInt32BE();
|
|
76
|
+
instance.eventDescriptor = EventDescriptor.deserialize(getTlv(reader));
|
|
77
|
+
const eventIdLength = reader.readBigSize();
|
|
78
|
+
const eventIdBuf = reader.readBytes(Number(eventIdLength));
|
|
79
|
+
instance.eventId = eventIdBuf.toString();
|
|
80
|
+
|
|
81
|
+
return instance;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* The type for oracle_event message. oracle_event = 55330
|
|
86
|
+
*/
|
|
87
|
+
public type = OracleEvent.type;
|
|
88
|
+
|
|
89
|
+
public length: bigint;
|
|
90
|
+
|
|
91
|
+
/** The nonces that the oracle will use to attest to the event outcome. */
|
|
92
|
+
public oracleNonces: Buffer[] = [];
|
|
93
|
+
|
|
94
|
+
/** The expected maturity of the contract (Unix timestamp). */
|
|
95
|
+
public eventMaturityEpoch: number;
|
|
96
|
+
|
|
97
|
+
/** The description of the event. */
|
|
98
|
+
public eventDescriptor: EventDescriptor;
|
|
99
|
+
|
|
100
|
+
/** The ID of the event. */
|
|
101
|
+
public eventId: string;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Validates correctness of all fields in the message according to rust-dlc specification.
|
|
105
|
+
* This includes validating that the number of nonces matches the expected count for the event type.
|
|
106
|
+
* https://github.com/discreetlogcontracts/dlcspecs/blob/master/Oracle.md
|
|
107
|
+
* @throws Will throw an error if validation fails
|
|
108
|
+
*/
|
|
109
|
+
public validate(): void {
|
|
110
|
+
// Validate event maturity epoch
|
|
111
|
+
if (this.eventMaturityEpoch < 0) {
|
|
112
|
+
throw new Error('eventMaturityEpoch must be greater than or equal to 0');
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Validate event ID
|
|
116
|
+
if (!this.eventId || this.eventId.length === 0) {
|
|
117
|
+
throw new Error('eventId cannot be empty');
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Validate oracle nonces (must be 32 bytes each)
|
|
121
|
+
if (this.oracleNonces.length === 0) {
|
|
122
|
+
throw new Error('Must have at least one oracle nonce');
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
this.oracleNonces.forEach((nonce, index) => {
|
|
126
|
+
if (!nonce || nonce.length !== 32) {
|
|
127
|
+
throw new Error(`Oracle nonce at index ${index} must be 32 bytes`);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
// Validate expected number of nonces based on event descriptor type
|
|
132
|
+
const expectedNbNonces = this.getExpectedNonceCount();
|
|
133
|
+
|
|
134
|
+
if (expectedNbNonces !== this.oracleNonces.length) {
|
|
135
|
+
throw new Error(
|
|
136
|
+
`OracleEvent nonce count mismatch: expected ${expectedNbNonces}, got ${this.oracleNonces.length}`,
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Validate the event descriptor itself
|
|
141
|
+
if (this.eventDescriptor instanceof DigitDecompositionEventDescriptor) {
|
|
142
|
+
this.eventDescriptor.validate();
|
|
143
|
+
}
|
|
144
|
+
// EnumEventDescriptorV0 doesn't have validation requirements beyond basic structure
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Returns the expected number of nonces based on the event descriptor type.
|
|
149
|
+
* This matches the rust-dlc validation logic.
|
|
150
|
+
*/
|
|
151
|
+
private getExpectedNonceCount(): number {
|
|
152
|
+
if (this.eventDescriptor instanceof EnumEventDescriptor) {
|
|
153
|
+
// Enum events require exactly 1 nonce
|
|
154
|
+
return 1;
|
|
155
|
+
} else if (
|
|
156
|
+
this.eventDescriptor instanceof DigitDecompositionEventDescriptor
|
|
157
|
+
) {
|
|
158
|
+
// Digit decomposition events require nbDigits nonces, plus 1 if signed
|
|
159
|
+
const descriptor = this.eventDescriptor;
|
|
160
|
+
return descriptor.isSigned
|
|
161
|
+
? descriptor.nbDigits + 1
|
|
162
|
+
: descriptor.nbDigits;
|
|
163
|
+
} else {
|
|
164
|
+
throw new Error('Unknown event descriptor type');
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Returns whether this event is for enumerated outcomes.
|
|
170
|
+
*/
|
|
171
|
+
public isEnumEvent(): boolean {
|
|
172
|
+
return this.eventDescriptor instanceof EnumEventDescriptor;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Returns whether this event is for numerical outcomes.
|
|
177
|
+
*/
|
|
178
|
+
public isDigitDecompositionEvent(): boolean {
|
|
179
|
+
return this.eventDescriptor instanceof DigitDecompositionEventDescriptor;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Returns the event descriptor as EnumEventDescriptor if it's an enum event.
|
|
184
|
+
* @throws Error if not an enum event
|
|
185
|
+
*/
|
|
186
|
+
public getEnumEventDescriptor(): EnumEventDescriptor {
|
|
187
|
+
if (!this.isEnumEvent()) {
|
|
188
|
+
throw new Error('Event is not an enum event');
|
|
189
|
+
}
|
|
190
|
+
return this.eventDescriptor as EnumEventDescriptor;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Returns the event descriptor as DigitDecompositionEventDescriptor if it's a numerical event.
|
|
195
|
+
* @throws Error if not a numerical event
|
|
196
|
+
*/
|
|
197
|
+
public getDigitDecompositionEventDescriptor(): DigitDecompositionEventDescriptor {
|
|
198
|
+
if (!this.isDigitDecompositionEvent()) {
|
|
199
|
+
throw new Error('Event is not a digit decomposition event');
|
|
200
|
+
}
|
|
201
|
+
return this.eventDescriptor as DigitDecompositionEventDescriptor;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Converts oracle_event to JSON
|
|
206
|
+
*/
|
|
207
|
+
public toJSON(): IOracleEventJSON {
|
|
208
|
+
return {
|
|
209
|
+
oracleNonces: this.oracleNonces.map((oracle) => oracle.toString('hex')),
|
|
210
|
+
eventMaturityEpoch: this.eventMaturityEpoch,
|
|
211
|
+
eventDescriptor: this.eventDescriptor.toJSON(),
|
|
212
|
+
eventId: this.eventId,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Serializes the oracle_event message into a Buffer
|
|
218
|
+
*/
|
|
219
|
+
public serialize(): Buffer {
|
|
220
|
+
const writer = new BufferWriter();
|
|
221
|
+
writer.writeBigSize(this.type);
|
|
222
|
+
|
|
223
|
+
const dataWriter = new BufferWriter();
|
|
224
|
+
dataWriter.writeUInt16BE(this.oracleNonces.length);
|
|
225
|
+
|
|
226
|
+
for (const nonce of this.oracleNonces) {
|
|
227
|
+
dataWriter.writeBytes(nonce);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
dataWriter.writeUInt32BE(this.eventMaturityEpoch);
|
|
231
|
+
dataWriter.writeBytes(this.eventDescriptor.serialize());
|
|
232
|
+
dataWriter.writeBigSize(this.eventId.length);
|
|
233
|
+
dataWriter.writeBytes(Buffer.from(this.eventId));
|
|
234
|
+
|
|
235
|
+
writer.writeBigSize(dataWriter.size);
|
|
236
|
+
writer.writeBytes(dataWriter.toBuffer());
|
|
237
|
+
|
|
238
|
+
return writer.toBuffer();
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export interface IOracleEventJSON {
|
|
243
|
+
type?: number; // Made optional for rust-dlc compatibility
|
|
244
|
+
oracleNonces: string[];
|
|
245
|
+
eventMaturityEpoch: number;
|
|
246
|
+
eventDescriptor:
|
|
247
|
+
| IEnumEventDescriptorJSON
|
|
248
|
+
| IDigitDecompositionEventDescriptorJSON;
|
|
249
|
+
eventId: string;
|
|
250
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { BufferReader, BufferWriter } from '@node-dlc/bufio';
|
|
2
|
+
|
|
3
|
+
import { MessageType } from '../MessageType';
|
|
4
|
+
import { getTlv } from '../serialize/getTlv';
|
|
5
|
+
import { IDlcMessage } from './DlcMessage';
|
|
6
|
+
import { OracleAnnouncement } from './OracleAnnouncement';
|
|
7
|
+
import { OracleAttestation } from './OracleAttestation';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* OracleEventContainer contains information about the oracles to be used in
|
|
11
|
+
* executing a DLC.
|
|
12
|
+
*/
|
|
13
|
+
export class OracleEventContainer implements IDlcMessage {
|
|
14
|
+
public static type = MessageType.OracleEventContainer;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Deserializes an oracle_info_v0 message
|
|
18
|
+
* @param buf
|
|
19
|
+
*/
|
|
20
|
+
public static deserialize(buf: Buffer): OracleEventContainer {
|
|
21
|
+
const instance = new OracleEventContainer();
|
|
22
|
+
const reader = new BufferReader(buf);
|
|
23
|
+
|
|
24
|
+
reader.readBigSize(); // read type
|
|
25
|
+
instance.length = reader.readBigSize();
|
|
26
|
+
|
|
27
|
+
const oracleNameLength = reader.readBigSize();
|
|
28
|
+
const oracleNameBuf = reader.readBytes(Number(oracleNameLength));
|
|
29
|
+
instance.oracleName = oracleNameBuf.toString();
|
|
30
|
+
|
|
31
|
+
const uriLength = reader.readBigSize();
|
|
32
|
+
const uriBuf = reader.readBytes(Number(uriLength));
|
|
33
|
+
instance.uri = uriBuf.toString();
|
|
34
|
+
|
|
35
|
+
instance.announcement = OracleAnnouncement.deserialize(getTlv(reader));
|
|
36
|
+
|
|
37
|
+
instance.attestation = OracleAttestation.deserialize(getTlv(reader));
|
|
38
|
+
|
|
39
|
+
const outcomeLength = reader.readBigSize();
|
|
40
|
+
const outcomeBuf = reader.readBytes(Number(outcomeLength));
|
|
41
|
+
instance.outcome = outcomeBuf.toString();
|
|
42
|
+
|
|
43
|
+
return instance;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The type for oracle_info_v0 message. oracle_info_v0 = 42770
|
|
48
|
+
*/
|
|
49
|
+
public type = OracleEventContainer.type;
|
|
50
|
+
|
|
51
|
+
public length: bigint;
|
|
52
|
+
|
|
53
|
+
public oracleName: string;
|
|
54
|
+
|
|
55
|
+
public uri: string;
|
|
56
|
+
|
|
57
|
+
public announcement: OracleAnnouncement;
|
|
58
|
+
|
|
59
|
+
public attestation: OracleAttestation;
|
|
60
|
+
|
|
61
|
+
public outcome: string;
|
|
62
|
+
|
|
63
|
+
public validate(): void {
|
|
64
|
+
this.announcement.validate();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Serializes the oracle_info_v0 message into a Buffer
|
|
69
|
+
*/
|
|
70
|
+
public serialize(): Buffer {
|
|
71
|
+
const writer = new BufferWriter();
|
|
72
|
+
writer.writeBigSize(this.type);
|
|
73
|
+
|
|
74
|
+
const dataWriter = new BufferWriter();
|
|
75
|
+
dataWriter.writeBigSize(this.oracleName.length);
|
|
76
|
+
dataWriter.writeBytes(Buffer.from(this.oracleName));
|
|
77
|
+
dataWriter.writeBigSize(this.uri.length);
|
|
78
|
+
dataWriter.writeBytes(Buffer.from(this.uri));
|
|
79
|
+
dataWriter.writeBytes(this.announcement.serialize());
|
|
80
|
+
dataWriter.writeBytes(this.attestation.serialize());
|
|
81
|
+
dataWriter.writeBigSize(this.outcome.length);
|
|
82
|
+
dataWriter.writeBytes(Buffer.from(this.outcome));
|
|
83
|
+
|
|
84
|
+
writer.writeBigSize(dataWriter.size);
|
|
85
|
+
writer.writeBytes(dataWriter.toBuffer());
|
|
86
|
+
|
|
87
|
+
return writer.toBuffer();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { BufferReader, BufferWriter } from '@node-dlc/bufio';
|
|
2
|
+
|
|
3
|
+
import { MessageType } from '../MessageType';
|
|
4
|
+
import { IDlcMessage } from './DlcMessage';
|
|
5
|
+
|
|
6
|
+
export class OracleIdentifier implements IDlcMessage {
|
|
7
|
+
public static type = MessageType.OracleIdentifier;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Deserializes an oracle_event message
|
|
11
|
+
* @param buf
|
|
12
|
+
*/
|
|
13
|
+
public static deserialize(buf: Buffer): OracleIdentifier {
|
|
14
|
+
const instance = new OracleIdentifier();
|
|
15
|
+
const reader = new BufferReader(buf);
|
|
16
|
+
|
|
17
|
+
reader.readBigSize(); // read type
|
|
18
|
+
instance.length = reader.readBigSize();
|
|
19
|
+
|
|
20
|
+
const oracleNameLength = reader.readBigSize();
|
|
21
|
+
const oracleNameBuf = reader.readBytes(Number(oracleNameLength));
|
|
22
|
+
instance.oracleName = oracleNameBuf.toString();
|
|
23
|
+
instance.oraclePubkey = reader.readBytes(32);
|
|
24
|
+
|
|
25
|
+
return instance;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The type for oracle_identifier message. oracle_identifier = 61472
|
|
30
|
+
*/
|
|
31
|
+
public type = OracleIdentifier.type;
|
|
32
|
+
|
|
33
|
+
public length: bigint;
|
|
34
|
+
|
|
35
|
+
public oracleName: string;
|
|
36
|
+
|
|
37
|
+
public oraclePubkey: Buffer;
|
|
38
|
+
|
|
39
|
+
public validate(): void {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Converts oracle_event to JSON
|
|
45
|
+
*/
|
|
46
|
+
public toJSON(): IOracleIdentifierJSON {
|
|
47
|
+
return {
|
|
48
|
+
type: this.type,
|
|
49
|
+
oracleName: this.oracleName,
|
|
50
|
+
oraclePubkey: this.oraclePubkey.toString('hex'),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Serializes the oracle_event message into a Buffer
|
|
56
|
+
*/
|
|
57
|
+
public serialize(): Buffer {
|
|
58
|
+
const writer = new BufferWriter();
|
|
59
|
+
writer.writeBigSize(this.type);
|
|
60
|
+
|
|
61
|
+
const dataWriter = new BufferWriter();
|
|
62
|
+
dataWriter.writeBigSize(this.oracleName.length);
|
|
63
|
+
dataWriter.writeBytes(Buffer.from(this.oracleName));
|
|
64
|
+
|
|
65
|
+
dataWriter.writeBytes(this.oraclePubkey);
|
|
66
|
+
|
|
67
|
+
writer.writeBigSize(dataWriter.size);
|
|
68
|
+
writer.writeBytes(dataWriter.toBuffer());
|
|
69
|
+
|
|
70
|
+
return writer.toBuffer();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface IOracleIdentifierJSON {
|
|
75
|
+
type: number;
|
|
76
|
+
oracleName: string;
|
|
77
|
+
oraclePubkey: string;
|
|
78
|
+
}
|