@atomicfinance/types 3.6.1 → 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/.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 +64 -0
- package/dist/dlc.d.ts +3 -3
- package/dist/models/Output.js.map +1 -1
- package/lib/dlc.ts +4 -14
- package/lib/models/Output.ts +4 -1
- package/package.json +4 -4
- package/yalc.lock +10 -0
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
import { BufferReader, BufferWriter } from '@node-dlc/bufio';
|
|
2
|
+
import { BitcoinNetwork } from 'bitcoin-networks';
|
|
3
|
+
|
|
4
|
+
import { IOrderMetadataJSON } from '..';
|
|
5
|
+
import { MessageType, PROTOCOL_VERSION } from '../MessageType';
|
|
6
|
+
import { deserializeTlv } from '../serialize/deserializeTlv';
|
|
7
|
+
import { getTlv } from '../serialize/getTlv';
|
|
8
|
+
import { bigIntToNumber, toBigInt } from '../util';
|
|
9
|
+
import { BatchFundingGroup, IBatchFundingGroupJSON } from './BatchFundingGroup';
|
|
10
|
+
import {
|
|
11
|
+
ContractInfo,
|
|
12
|
+
IContractInfoV0JSON,
|
|
13
|
+
IContractInfoV1JSON,
|
|
14
|
+
} from './ContractInfo';
|
|
15
|
+
import { IDlcMessage } from './DlcMessage';
|
|
16
|
+
import {
|
|
17
|
+
IOrderIrcInfoJSON,
|
|
18
|
+
OrderIrcInfo,
|
|
19
|
+
OrderIrcInfoV0,
|
|
20
|
+
} from './OrderIrcInfo';
|
|
21
|
+
import { OrderMetadata, OrderMetadataV0 } from './OrderMetadata';
|
|
22
|
+
import { IOrderPositionInfoJSON, OrderPositionInfo } from './OrderPositionInfo';
|
|
23
|
+
|
|
24
|
+
const LOCKTIME_THRESHOLD = 500000000;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* OrderOffer message contains information about a node and indicates its
|
|
28
|
+
* desire to enter into a new contract. This is the first step toward
|
|
29
|
+
* order negotiation. This is a simpler message than DlcOffer.
|
|
30
|
+
*/
|
|
31
|
+
export class OrderOffer implements IDlcMessage {
|
|
32
|
+
public static type = MessageType.OrderOffer;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Creates an OrderOffer from JSON data
|
|
36
|
+
* @param json JSON object representing an order offer
|
|
37
|
+
*/
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
|
|
39
|
+
public static fromJSON(json: any): OrderOffer {
|
|
40
|
+
const instance = new OrderOffer();
|
|
41
|
+
|
|
42
|
+
// Basic fields with field name variations
|
|
43
|
+
instance.protocolVersion =
|
|
44
|
+
json.protocolVersion || json.protocol_version || PROTOCOL_VERSION;
|
|
45
|
+
instance.contractFlags = Buffer.from(
|
|
46
|
+
json.contractFlags || json.contract_flags || '00',
|
|
47
|
+
'hex',
|
|
48
|
+
);
|
|
49
|
+
instance.chainHash = Buffer.from(json.chainHash || json.chain_hash, 'hex');
|
|
50
|
+
instance.temporaryContractId = Buffer.from(
|
|
51
|
+
json.temporaryContractId || json.temporary_contract_id,
|
|
52
|
+
'hex',
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
// Use toBigInt helper to handle BigInt values from json-bigint
|
|
56
|
+
instance.offerCollateral = toBigInt(
|
|
57
|
+
json.offerCollateral ||
|
|
58
|
+
json.offerCollateralSatoshis ||
|
|
59
|
+
json.offer_collateral,
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
instance.feeRatePerVb = toBigInt(json.feeRatePerVb || json.fee_rate_per_vb);
|
|
63
|
+
instance.cetLocktime = json.cetLocktime || json.cet_locktime || 0;
|
|
64
|
+
instance.refundLocktime = json.refundLocktime || json.refund_locktime || 0;
|
|
65
|
+
|
|
66
|
+
// Use ContractInfo.fromJSON() - proper delegation
|
|
67
|
+
instance.contractInfo = ContractInfo.fromJSON(
|
|
68
|
+
json.contractInfo || json.contract_info,
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
return instance;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Deserializes an order_offer message
|
|
76
|
+
* @param buf
|
|
77
|
+
*/
|
|
78
|
+
public static deserialize(buf: Buffer): OrderOffer {
|
|
79
|
+
const instance = new OrderOffer();
|
|
80
|
+
const reader = new BufferReader(buf);
|
|
81
|
+
|
|
82
|
+
const type = reader.readUInt16BE(); // read type
|
|
83
|
+
|
|
84
|
+
// Validate type matches expected OrderOffer type
|
|
85
|
+
if (type !== MessageType.OrderOffer) {
|
|
86
|
+
throw new Error(
|
|
87
|
+
`Invalid message type. Expected ${MessageType.OrderOffer}, got ${type}`,
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// BACKWARD COMPATIBILITY: Detect old vs new format
|
|
92
|
+
const nextBytes = reader.buffer.subarray(
|
|
93
|
+
reader.position,
|
|
94
|
+
reader.position + 5,
|
|
95
|
+
);
|
|
96
|
+
const possibleProtocolVersion = nextBytes.readUInt32BE(0);
|
|
97
|
+
const possibleContractFlags = nextBytes.readUInt8(4);
|
|
98
|
+
|
|
99
|
+
// Heuristic: protocol_version should be 1, contract_flags should be 0
|
|
100
|
+
const isNewFormat =
|
|
101
|
+
possibleProtocolVersion >= 1 &&
|
|
102
|
+
possibleProtocolVersion <= 10 &&
|
|
103
|
+
possibleContractFlags === 0;
|
|
104
|
+
|
|
105
|
+
if (isNewFormat) {
|
|
106
|
+
// New format with protocol_version
|
|
107
|
+
instance.protocolVersion = reader.readUInt32BE();
|
|
108
|
+
instance.contractFlags = reader.readBytes(1);
|
|
109
|
+
} else {
|
|
110
|
+
// Old format without protocol_version
|
|
111
|
+
instance.protocolVersion = 1; // Default to version 1
|
|
112
|
+
instance.contractFlags = reader.readBytes(1);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
instance.chainHash = reader.readBytes(32);
|
|
116
|
+
instance.temporaryContractId = reader.readBytes(32);
|
|
117
|
+
|
|
118
|
+
// ContractInfo is serialized as sibling type in dlcspecs PR #163 format
|
|
119
|
+
instance.contractInfo = ContractInfo.deserialize(
|
|
120
|
+
reader.buffer.subarray(reader.position),
|
|
121
|
+
);
|
|
122
|
+
// Skip past the ContractInfo we just read
|
|
123
|
+
const contractInfoLength = instance.contractInfo.serialize().length;
|
|
124
|
+
reader.position += contractInfoLength;
|
|
125
|
+
|
|
126
|
+
instance.offerCollateral = reader.readUInt64BE();
|
|
127
|
+
instance.feeRatePerVb = reader.readUInt64BE();
|
|
128
|
+
instance.cetLocktime = reader.readUInt32BE();
|
|
129
|
+
instance.refundLocktime = reader.readUInt32BE();
|
|
130
|
+
|
|
131
|
+
// Parse TLV stream as per dlcspecs PR #163
|
|
132
|
+
while (!reader.eof) {
|
|
133
|
+
const buf = getTlv(reader);
|
|
134
|
+
const tlvReader = new BufferReader(buf);
|
|
135
|
+
const { type } = deserializeTlv(tlvReader);
|
|
136
|
+
|
|
137
|
+
switch (Number(type)) {
|
|
138
|
+
case MessageType.OrderMetadataV0:
|
|
139
|
+
instance.metadata = OrderMetadataV0.deserialize(buf);
|
|
140
|
+
break;
|
|
141
|
+
case MessageType.OrderIrcInfoV0:
|
|
142
|
+
instance.ircInfo = OrderIrcInfoV0.deserialize(buf);
|
|
143
|
+
break;
|
|
144
|
+
case MessageType.OrderPositionInfoV0:
|
|
145
|
+
instance.positionInfo = OrderPositionInfo.deserialize(buf);
|
|
146
|
+
break;
|
|
147
|
+
case MessageType.BatchFundingGroup:
|
|
148
|
+
if (!instance.batchFundingGroups) {
|
|
149
|
+
instance.batchFundingGroups = [];
|
|
150
|
+
}
|
|
151
|
+
instance.batchFundingGroups.push(BatchFundingGroup.deserialize(buf));
|
|
152
|
+
break;
|
|
153
|
+
default:
|
|
154
|
+
// Store unknown TLVs for future compatibility
|
|
155
|
+
if (!instance.unknownTlvs) {
|
|
156
|
+
instance.unknownTlvs = [];
|
|
157
|
+
}
|
|
158
|
+
instance.unknownTlvs.push({ type: Number(type), data: buf });
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return instance;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* The type for order_offer message. order_offer = 62770
|
|
168
|
+
*/
|
|
169
|
+
public type = OrderOffer.type;
|
|
170
|
+
|
|
171
|
+
// New fields as per dlcspecs PR #163
|
|
172
|
+
public protocolVersion: number = PROTOCOL_VERSION; // Default to current protocol version
|
|
173
|
+
|
|
174
|
+
public temporaryContractId: Buffer; // New field for contract identification
|
|
175
|
+
|
|
176
|
+
// Existing fields
|
|
177
|
+
public contractFlags: Buffer;
|
|
178
|
+
|
|
179
|
+
public chainHash: Buffer;
|
|
180
|
+
|
|
181
|
+
public contractInfo: ContractInfo;
|
|
182
|
+
|
|
183
|
+
public offerCollateral: bigint;
|
|
184
|
+
|
|
185
|
+
public feeRatePerVb: bigint;
|
|
186
|
+
|
|
187
|
+
public cetLocktime: number;
|
|
188
|
+
|
|
189
|
+
public refundLocktime: number;
|
|
190
|
+
|
|
191
|
+
public metadata?: OrderMetadata;
|
|
192
|
+
|
|
193
|
+
public ircInfo?: OrderIrcInfo;
|
|
194
|
+
|
|
195
|
+
public positionInfo?: OrderPositionInfo;
|
|
196
|
+
|
|
197
|
+
public batchFundingGroups?: BatchFundingGroup[];
|
|
198
|
+
|
|
199
|
+
// Store unknown TLVs for forward compatibility
|
|
200
|
+
public unknownTlvs?: Array<{ type: number; data: Buffer }>;
|
|
201
|
+
|
|
202
|
+
// Legacy property for backward compatibility
|
|
203
|
+
public get offerCollateralSatoshis(): bigint {
|
|
204
|
+
return this.offerCollateral;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
public set offerCollateralSatoshis(value: bigint) {
|
|
208
|
+
this.offerCollateral = value;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
public validate(): void {
|
|
212
|
+
// 1. Type is set automatically in class
|
|
213
|
+
// 2. protocol_version validation
|
|
214
|
+
if (this.protocolVersion !== PROTOCOL_VERSION) {
|
|
215
|
+
throw new Error(
|
|
216
|
+
`Unsupported protocol version: ${this.protocolVersion}, expected: ${PROTOCOL_VERSION}`,
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// 3. temporary_contract_id validation
|
|
221
|
+
if (!this.temporaryContractId || this.temporaryContractId.length !== 32) {
|
|
222
|
+
throw new Error('temporaryContractId must be 32 bytes');
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// 4. contract_flags field is ignored
|
|
226
|
+
// 5. chain_hash must be validated as input by end user
|
|
227
|
+
|
|
228
|
+
// 6. offer_collateral must be greater than or equal to 1000
|
|
229
|
+
if (this.offerCollateral < 1000) {
|
|
230
|
+
throw new Error('offer_collateral must be greater than or equal to 1000');
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (this.cetLocktime < 0) {
|
|
234
|
+
throw new Error('cet_locktime must be greater than or equal to 0');
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
if (this.refundLocktime < 0) {
|
|
238
|
+
throw new Error('refund_locktime must be greater than or equal to 0');
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// 7. cet_locktime and refund_locktime must either both be unix timestamps, or both be block heights.
|
|
242
|
+
if (
|
|
243
|
+
!(
|
|
244
|
+
(this.cetLocktime < LOCKTIME_THRESHOLD &&
|
|
245
|
+
this.refundLocktime < LOCKTIME_THRESHOLD) ||
|
|
246
|
+
(this.cetLocktime >= LOCKTIME_THRESHOLD &&
|
|
247
|
+
this.refundLocktime >= LOCKTIME_THRESHOLD)
|
|
248
|
+
)
|
|
249
|
+
) {
|
|
250
|
+
throw new Error('cetLocktime and refundLocktime must be in same units');
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// 8. cetLocktime must be less than refundLocktime
|
|
254
|
+
if (this.cetLocktime >= this.refundLocktime) {
|
|
255
|
+
throw new Error('cetLocktime must be less than refundLocktime');
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// validate contractInfo
|
|
259
|
+
this.contractInfo.validate();
|
|
260
|
+
|
|
261
|
+
// totalCollateral should be > offerCollateral (logical validation)
|
|
262
|
+
if (this.contractInfo.getTotalCollateral() <= this.offerCollateral) {
|
|
263
|
+
throw new Error('totalCollateral should be greater than offerCollateral');
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Converts order_offer to JSON
|
|
269
|
+
*/
|
|
270
|
+
public toJSON(): IOrderOfferJSON {
|
|
271
|
+
const tlvs = [];
|
|
272
|
+
|
|
273
|
+
if (this.metadata) tlvs.push(this.metadata.toJSON());
|
|
274
|
+
if (this.ircInfo) tlvs.push(this.ircInfo.toJSON());
|
|
275
|
+
if (this.positionInfo) tlvs.push(this.positionInfo.toJSON());
|
|
276
|
+
if (this.batchFundingGroups)
|
|
277
|
+
this.batchFundingGroups.forEach((fundingInfo) =>
|
|
278
|
+
tlvs.push(fundingInfo.toJSON()),
|
|
279
|
+
);
|
|
280
|
+
|
|
281
|
+
// Include unknown TLVs for debugging
|
|
282
|
+
if (this.unknownTlvs) {
|
|
283
|
+
this.unknownTlvs.forEach((tlv) =>
|
|
284
|
+
tlvs.push({ type: tlv.type, data: tlv.data.toString('hex') }),
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
return {
|
|
289
|
+
type: this.type,
|
|
290
|
+
protocolVersion: this.protocolVersion,
|
|
291
|
+
temporaryContractId: this.temporaryContractId.toString('hex'),
|
|
292
|
+
contractFlags: Number(this.contractFlags[0]),
|
|
293
|
+
chainHash: this.chainHash.toString('hex'),
|
|
294
|
+
contractInfo: this.contractInfo.toJSON(),
|
|
295
|
+
offerCollateral: bigIntToNumber(this.offerCollateral),
|
|
296
|
+
offerCollateralSatoshis: bigIntToNumber(this.offerCollateral), // Legacy field
|
|
297
|
+
feeRatePerVb: bigIntToNumber(this.feeRatePerVb),
|
|
298
|
+
cetLocktime: this.cetLocktime,
|
|
299
|
+
refundLocktime: this.refundLocktime,
|
|
300
|
+
tlvs,
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Serializes the order_offer message into a Buffer
|
|
306
|
+
*/
|
|
307
|
+
public serialize(): Buffer {
|
|
308
|
+
const writer = new BufferWriter();
|
|
309
|
+
writer.writeUInt16BE(this.type);
|
|
310
|
+
|
|
311
|
+
// New fields as per dlcspecs PR #163
|
|
312
|
+
writer.writeUInt32BE(this.protocolVersion);
|
|
313
|
+
writer.writeBytes(this.contractFlags);
|
|
314
|
+
writer.writeBytes(this.chainHash);
|
|
315
|
+
writer.writeBytes(this.temporaryContractId); // New field
|
|
316
|
+
|
|
317
|
+
writer.writeBytes(this.contractInfo.serialize());
|
|
318
|
+
writer.writeUInt64BE(this.offerCollateral);
|
|
319
|
+
writer.writeUInt64BE(this.feeRatePerVb);
|
|
320
|
+
writer.writeUInt32BE(this.cetLocktime);
|
|
321
|
+
writer.writeUInt32BE(this.refundLocktime);
|
|
322
|
+
|
|
323
|
+
// TLV stream as per dlcspecs PR #163
|
|
324
|
+
if (this.metadata) writer.writeBytes(this.metadata.serialize());
|
|
325
|
+
if (this.ircInfo) writer.writeBytes(this.ircInfo.serialize());
|
|
326
|
+
if (this.positionInfo) writer.writeBytes(this.positionInfo.serialize());
|
|
327
|
+
if (this.batchFundingGroups)
|
|
328
|
+
this.batchFundingGroups.forEach((fundingInfo) =>
|
|
329
|
+
writer.writeBytes(fundingInfo.serialize()),
|
|
330
|
+
);
|
|
331
|
+
|
|
332
|
+
// Write unknown TLVs for forward compatibility
|
|
333
|
+
if (this.unknownTlvs) {
|
|
334
|
+
this.unknownTlvs.forEach((tlv) => {
|
|
335
|
+
writer.writeBytes(tlv.data);
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
return writer.toBuffer();
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
export interface IOrderOfferJSON {
|
|
344
|
+
type: number;
|
|
345
|
+
protocolVersion: number;
|
|
346
|
+
temporaryContractId: string;
|
|
347
|
+
contractFlags: number;
|
|
348
|
+
chainHash: string;
|
|
349
|
+
contractInfo: IContractInfoV0JSON | IContractInfoV1JSON;
|
|
350
|
+
offerCollateral: number;
|
|
351
|
+
offerCollateralSatoshis: number; // Legacy field for backward compatibility
|
|
352
|
+
feeRatePerVb: number;
|
|
353
|
+
cetLocktime: number;
|
|
354
|
+
refundLocktime: number;
|
|
355
|
+
tlvs: (
|
|
356
|
+
| IOrderMetadataJSON
|
|
357
|
+
| IOrderIrcInfoJSON
|
|
358
|
+
| IOrderPositionInfoJSON
|
|
359
|
+
| IBatchFundingGroupJSON
|
|
360
|
+
| any
|
|
361
|
+
)[];
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
export class OrderOfferContainer {
|
|
365
|
+
private offers: OrderOffer[] = [];
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Adds an OrderOffer to the container.
|
|
369
|
+
* @param offer The OrderOffer to add.
|
|
370
|
+
*/
|
|
371
|
+
public addOffer(offer: OrderOffer): void {
|
|
372
|
+
this.offers.push(offer);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Returns all OrderOffers in the container.
|
|
377
|
+
* @returns An array of OrderOffer instances.
|
|
378
|
+
*/
|
|
379
|
+
public getOffers(): OrderOffer[] {
|
|
380
|
+
return this.offers;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Serializes all OrderOffers in the container to a Buffer.
|
|
385
|
+
* @returns A Buffer containing the serialized OrderOffers.
|
|
386
|
+
*/
|
|
387
|
+
public serialize(): Buffer {
|
|
388
|
+
const writer = new BufferWriter();
|
|
389
|
+
// Write the number of offers in the container first.
|
|
390
|
+
writer.writeBigSize(this.offers.length);
|
|
391
|
+
// Serialize each offer and write it.
|
|
392
|
+
this.offers.forEach((offer) => {
|
|
393
|
+
const serializedOffer = offer.serialize();
|
|
394
|
+
// Optionally, write the length of the serialized offer for easier deserialization.
|
|
395
|
+
writer.writeBigSize(serializedOffer.length);
|
|
396
|
+
writer.writeBytes(serializedOffer);
|
|
397
|
+
});
|
|
398
|
+
return writer.toBuffer();
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Deserializes a Buffer into an OrderOfferContainer with OrderOffers.
|
|
403
|
+
* @param buf The Buffer to deserialize.
|
|
404
|
+
* @returns An OrderOfferContainer instance.
|
|
405
|
+
*/
|
|
406
|
+
public static deserialize(buf: Buffer): OrderOfferContainer {
|
|
407
|
+
const reader = new BufferReader(buf);
|
|
408
|
+
const container = new OrderOfferContainer();
|
|
409
|
+
const offersCount = reader.readBigSize();
|
|
410
|
+
for (let i = 0; i < offersCount; i++) {
|
|
411
|
+
// Optionally, read the length of the serialized offer if it was written during serialization.
|
|
412
|
+
const offerLength = reader.readBigSize();
|
|
413
|
+
const offerBuf = reader.readBytes(Number(offerLength));
|
|
414
|
+
const offer = OrderOffer.deserialize(offerBuf);
|
|
415
|
+
container.addOffer(offer);
|
|
416
|
+
}
|
|
417
|
+
return container;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { BufferReader, BufferWriter } from '@node-dlc/bufio';
|
|
2
|
+
|
|
3
|
+
import { MessageType } from '../MessageType';
|
|
4
|
+
import { IDlcMessage } from './DlcMessage';
|
|
5
|
+
|
|
6
|
+
export type DlcParty = 'offeror' | 'acceptor' | 'neither';
|
|
7
|
+
|
|
8
|
+
export abstract class OrderPositionInfo {
|
|
9
|
+
public static deserialize(buf: Buffer): OrderPositionInfo {
|
|
10
|
+
const reader = new BufferReader(buf);
|
|
11
|
+
|
|
12
|
+
const type = Number(reader.readBigSize());
|
|
13
|
+
|
|
14
|
+
switch (type) {
|
|
15
|
+
case MessageType.OrderPositionInfoV0:
|
|
16
|
+
return OrderPositionInfoV0.deserialize(buf);
|
|
17
|
+
default:
|
|
18
|
+
throw new Error(`Order cso info TLV type must be OrderPositionInfoV0`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public abstract type: number;
|
|
23
|
+
|
|
24
|
+
public abstract toJSON(): IOrderPositionInfoJSON;
|
|
25
|
+
|
|
26
|
+
public abstract serialize(): Buffer;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* OrderCsoInfo message
|
|
31
|
+
*/
|
|
32
|
+
export class OrderPositionInfoV0
|
|
33
|
+
extends OrderPositionInfo
|
|
34
|
+
implements IDlcMessage {
|
|
35
|
+
public static type = MessageType.OrderPositionInfoV0;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Deserializes an offer_dlc_v0 message
|
|
39
|
+
* @param buf
|
|
40
|
+
*/
|
|
41
|
+
public static deserialize(buf: Buffer): OrderPositionInfoV0 {
|
|
42
|
+
const instance = new OrderPositionInfoV0();
|
|
43
|
+
const reader = new BufferReader(buf);
|
|
44
|
+
|
|
45
|
+
reader.readBigSize(); // read type
|
|
46
|
+
instance.length = reader.readBigSize();
|
|
47
|
+
|
|
48
|
+
const encodedShiftForFees = reader.readUInt8();
|
|
49
|
+
if (encodedShiftForFees === 0) {
|
|
50
|
+
instance.shiftForFees = 'neither';
|
|
51
|
+
} else if (encodedShiftForFees === 1) {
|
|
52
|
+
instance.shiftForFees = 'offeror';
|
|
53
|
+
} else if (encodedShiftForFees === 2) {
|
|
54
|
+
instance.shiftForFees = 'acceptor';
|
|
55
|
+
} else {
|
|
56
|
+
throw new Error(`Invalid shift for fees value: ${encodedShiftForFees}`);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
instance.fees = reader.readUInt64BE();
|
|
60
|
+
|
|
61
|
+
if (!reader.eof) {
|
|
62
|
+
const instrumentNameLength = reader.readBigSize();
|
|
63
|
+
const instrumentName = reader.readBytes(Number(instrumentNameLength));
|
|
64
|
+
instance.instrumentName = instrumentName.toString();
|
|
65
|
+
|
|
66
|
+
instance.contractSize = reader.readUInt64BE();
|
|
67
|
+
|
|
68
|
+
const direction = reader.readUInt8();
|
|
69
|
+
if (direction === 0) {
|
|
70
|
+
instance.direction = 'neither';
|
|
71
|
+
} else if (direction === 1) {
|
|
72
|
+
instance.direction = 'buy';
|
|
73
|
+
} else if (direction === 2) {
|
|
74
|
+
instance.direction = 'sell';
|
|
75
|
+
} else {
|
|
76
|
+
throw new Error(`Invalid direction value: ${direction}`);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
instance.price = reader.readUInt64BE();
|
|
80
|
+
|
|
81
|
+
instance.extraPrecision = reader.readUInt16BE();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return instance;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The type for order_metadata_v0 message. order_metadata_v0 = 62774
|
|
89
|
+
*/
|
|
90
|
+
public type = OrderPositionInfoV0.type;
|
|
91
|
+
|
|
92
|
+
public length: bigint;
|
|
93
|
+
|
|
94
|
+
public shiftForFees: DlcParty = 'neither';
|
|
95
|
+
|
|
96
|
+
public fees = BigInt(0);
|
|
97
|
+
|
|
98
|
+
public instrumentName: string | undefined = undefined;
|
|
99
|
+
|
|
100
|
+
public contractSize = BigInt(0);
|
|
101
|
+
|
|
102
|
+
public direction: 'buy' | 'sell' | 'neither' = 'neither';
|
|
103
|
+
|
|
104
|
+
public price = BigInt(0); // Can be BTC or USD depending on the instrument
|
|
105
|
+
|
|
106
|
+
public extraPrecision = 0;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Converts order_metadata_v0 to JSON
|
|
110
|
+
*/
|
|
111
|
+
public toJSON(): IOrderPositionInfoJSON {
|
|
112
|
+
return {
|
|
113
|
+
type: this.type,
|
|
114
|
+
shiftForFees: this.shiftForFees,
|
|
115
|
+
fees: Number(this.fees),
|
|
116
|
+
instrumentName: this.instrumentName,
|
|
117
|
+
direction: this.direction,
|
|
118
|
+
price: Number(this.price),
|
|
119
|
+
extraPrecision: this.extraPrecision,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Serializes the oracle_event message into a Buffer
|
|
125
|
+
*/
|
|
126
|
+
public serialize(): Buffer {
|
|
127
|
+
const writer = new BufferWriter();
|
|
128
|
+
writer.writeBigSize(this.type);
|
|
129
|
+
|
|
130
|
+
const dataWriter = new BufferWriter();
|
|
131
|
+
dataWriter.writeUInt8(
|
|
132
|
+
this.shiftForFees === 'neither'
|
|
133
|
+
? 0
|
|
134
|
+
: this.shiftForFees === 'offeror'
|
|
135
|
+
? 1
|
|
136
|
+
: 2,
|
|
137
|
+
);
|
|
138
|
+
dataWriter.writeUInt64BE(this.fees);
|
|
139
|
+
|
|
140
|
+
if (this.instrumentName) {
|
|
141
|
+
dataWriter.writeBigSize(this.instrumentName.length);
|
|
142
|
+
dataWriter.writeBytes(Buffer.from(this.instrumentName));
|
|
143
|
+
|
|
144
|
+
dataWriter.writeUInt64BE(this.contractSize);
|
|
145
|
+
|
|
146
|
+
dataWriter.writeUInt8(
|
|
147
|
+
this.direction === 'neither' ? 0 : this.direction === 'buy' ? 1 : 2,
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
dataWriter.writeUInt64BE(this.price);
|
|
151
|
+
|
|
152
|
+
dataWriter.writeUInt16BE(this.extraPrecision);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
writer.writeBigSize(dataWriter.size);
|
|
156
|
+
writer.writeBytes(dataWriter.toBuffer());
|
|
157
|
+
|
|
158
|
+
return writer.toBuffer();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export interface IOrderPositionInfoJSON {
|
|
163
|
+
type: number;
|
|
164
|
+
shiftForFees: string;
|
|
165
|
+
fees: number;
|
|
166
|
+
instrumentName: string;
|
|
167
|
+
direction: string;
|
|
168
|
+
price: number;
|
|
169
|
+
extraPrecision: number;
|
|
170
|
+
}
|