@atomicfinance/types 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.
Files changed (370) hide show
  1. package/.turbo/turbo-build.log +1 -0
  2. package/.turbo/turbo-test.log +0 -0
  3. package/.yalc/@node-dlc/messaging/.nyc_output/2cf48009-1094-4275-bb91-c164c932feb6.json +1 -0
  4. package/.yalc/@node-dlc/messaging/.nyc_output/processinfo/2cf48009-1094-4275-bb91-c164c932feb6.json +1 -0
  5. package/.yalc/@node-dlc/messaging/.nyc_output/processinfo/index.json +1 -0
  6. package/.yalc/@node-dlc/messaging/README.md +24 -0
  7. package/.yalc/@node-dlc/messaging/__tests__/_test-utils.ts +12 -0
  8. package/.yalc/@node-dlc/messaging/__tests__/chain/ChainManager.spec.ts +178 -0
  9. package/.yalc/@node-dlc/messaging/__tests__/compatibility/dlcspecs-compatibility.spec.ts +473 -0
  10. package/.yalc/@node-dlc/messaging/__tests__/compatibility/rust-dlc-cross-language.spec.ts +342 -0
  11. package/.yalc/@node-dlc/messaging/__tests__/compatibility/true-serialization-compatibility.spec.ts +611 -0
  12. package/.yalc/@node-dlc/messaging/__tests__/dlc_message_test.json +155 -0
  13. package/.yalc/@node-dlc/messaging/__tests__/irc/IrcMessage.spec.ts +94 -0
  14. package/.yalc/@node-dlc/messaging/__tests__/messages/AddressCache.spec.ts +79 -0
  15. package/.yalc/@node-dlc/messaging/__tests__/messages/BatchFundingGroup.spec.ts +72 -0
  16. package/.yalc/@node-dlc/messaging/__tests__/messages/CetAdaptorSignatures.spec.ts +57 -0
  17. package/.yalc/@node-dlc/messaging/__tests__/messages/ContractDescriptor.spec.ts +264 -0
  18. package/.yalc/@node-dlc/messaging/__tests__/messages/ContractInfo.spec.ts +419 -0
  19. package/.yalc/@node-dlc/messaging/__tests__/messages/DigitDecompositionEventDescriptor.spec.ts +59 -0
  20. package/.yalc/@node-dlc/messaging/__tests__/messages/DlcAccept.spec.ts +242 -0
  21. package/.yalc/@node-dlc/messaging/__tests__/messages/DlcCancel.spec.ts +42 -0
  22. package/.yalc/@node-dlc/messaging/__tests__/messages/DlcClose.spec.ts +315 -0
  23. package/.yalc/@node-dlc/messaging/__tests__/messages/DlcOffer.spec.ts +527 -0
  24. package/.yalc/@node-dlc/messaging/__tests__/messages/DlcSign.spec.ts +118 -0
  25. package/.yalc/@node-dlc/messaging/__tests__/messages/DlcTransactions.spec.ts +157 -0
  26. package/.yalc/@node-dlc/messaging/__tests__/messages/EnumEventDescriptor.spec.ts +50 -0
  27. package/.yalc/@node-dlc/messaging/__tests__/messages/EventDescriptor.spec.ts +93 -0
  28. package/.yalc/@node-dlc/messaging/__tests__/messages/FundingInput.spec.ts +84 -0
  29. package/.yalc/@node-dlc/messaging/__tests__/messages/FundingSignatures.spec.ts +83 -0
  30. package/.yalc/@node-dlc/messaging/__tests__/messages/NegotiationFields.spec.ts +328 -0
  31. package/.yalc/@node-dlc/messaging/__tests__/messages/NodeAnnouncementMessage.spec.ts +115 -0
  32. package/.yalc/@node-dlc/messaging/__tests__/messages/OracleAnnouncement.spec.ts +415 -0
  33. package/.yalc/@node-dlc/messaging/__tests__/messages/OracleAttestation.spec.ts +326 -0
  34. package/.yalc/@node-dlc/messaging/__tests__/messages/OracleEvent.spec.ts +143 -0
  35. package/.yalc/@node-dlc/messaging/__tests__/messages/OracleEventContainer.spec.ts +95 -0
  36. package/.yalc/@node-dlc/messaging/__tests__/messages/OracleIdentifier.spec.ts +48 -0
  37. package/.yalc/@node-dlc/messaging/__tests__/messages/OracleInfo.spec.ts +116 -0
  38. package/.yalc/@node-dlc/messaging/__tests__/messages/OrderAccept.spec.ts +77 -0
  39. package/.yalc/@node-dlc/messaging/__tests__/messages/OrderNegotiationFields.spec.ts +216 -0
  40. package/.yalc/@node-dlc/messaging/__tests__/messages/OrderOffer.spec.ts +121 -0
  41. package/.yalc/@node-dlc/messaging/__tests__/messages/OrderPositionInfo.spec.ts +75 -0
  42. package/.yalc/@node-dlc/messaging/__tests__/messages/PayoutCurvePiece.spec.ts +220 -0
  43. package/.yalc/@node-dlc/messaging/__tests__/messages/PayoutFunction.spec.ts +101 -0
  44. package/.yalc/@node-dlc/messaging/__tests__/messages/RoundingIntervals.spec.ts +75 -0
  45. package/.yalc/@node-dlc/messaging/__tests__/serialize/F64.spec.ts +260 -0
  46. package/.yalc/@node-dlc/messaging/__tests__/tsconfig.json +8 -0
  47. package/.yalc/@node-dlc/messaging/coverage/lcov-report/base.css +224 -0
  48. package/.yalc/@node-dlc/messaging/coverage/lcov-report/block-navigation.js +79 -0
  49. package/.yalc/@node-dlc/messaging/coverage/lcov-report/favicon.png +0 -0
  50. package/.yalc/@node-dlc/messaging/coverage/lcov-report/index.html +201 -0
  51. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/MessageType.ts.html +494 -0
  52. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/chain/ChainManager.ts.html +1058 -0
  53. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/chain/ChainMemoryStore.ts.html +182 -0
  54. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/chain/index.html +126 -0
  55. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/domain/Address.ts.html +272 -0
  56. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/domain/index.html +111 -0
  57. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/index.html +141 -0
  58. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/index.ts.html +212 -0
  59. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/irc/IrcMessage.ts.html +563 -0
  60. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/irc/index.html +111 -0
  61. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/AddressCache.ts.html +302 -0
  62. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/BatchFundingGroup.ts.html +503 -0
  63. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/CetAdaptorSignatures.ts.html +347 -0
  64. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/CetAdaptorSignaturesV0.ts.html +347 -0
  65. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/ContractDescriptor.ts.html +1040 -0
  66. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/ContractInfo.ts.html +1382 -0
  67. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/DlcAccept.ts.html +1865 -0
  68. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/DlcCancel.ts.html +251 -0
  69. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/DlcClose.ts.html +986 -0
  70. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/DlcCloseMetadata.ts.html +443 -0
  71. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/DlcIds.ts.html +281 -0
  72. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/DlcInfo.ts.html +323 -0
  73. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/DlcMessage.ts.html +341 -0
  74. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/DlcOffer.ts.html +1895 -0
  75. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/DlcSign.ts.html +1142 -0
  76. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/DlcTransactions.ts.html +719 -0
  77. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/EventDescriptor.ts.html +947 -0
  78. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/FundingInput.ts.html +728 -0
  79. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/FundingSignatures.ts.html +374 -0
  80. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/FundingSignaturesV0.ts.html +374 -0
  81. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/NegotiationFields.ts.html +836 -0
  82. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/NodeAnnouncementMessage.ts.html +515 -0
  83. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleAnnouncement.ts.html +608 -0
  84. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleAnnouncementV0.ts.html +605 -0
  85. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleAttestation.ts.html +956 -0
  86. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleAttestationV0.ts.html +770 -0
  87. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleEvent.ts.html +830 -0
  88. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleEventContainer.ts.html +347 -0
  89. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleEventContainerV0.ts.html +347 -0
  90. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleEventV0.ts.html +827 -0
  91. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleIdentifier.ts.html +314 -0
  92. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleIdentifierV0.ts.html +314 -0
  93. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleInfo.ts.html +1637 -0
  94. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleInfoV0.ts.html +1631 -0
  95. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OrderAccept.ts.html +557 -0
  96. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OrderIrcInfo.ts.html +380 -0
  97. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OrderMetadata.ts.html +437 -0
  98. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OrderNegotiationFields.ts.html +551 -0
  99. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OrderOffer.ts.html +1337 -0
  100. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OrderPositionInfo.ts.html +590 -0
  101. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/PayoutCurvePiece.ts.html +1427 -0
  102. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/PayoutFunction.ts.html +800 -0
  103. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/RoundingIntervals.ts.html +461 -0
  104. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/RoundingIntervalsV0.ts.html +482 -0
  105. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/ScriptWitnessV0.ts.html +269 -0
  106. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/index.html +636 -0
  107. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/serde/SerdeUtils.ts.html +1394 -0
  108. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/serde/index.html +111 -0
  109. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/serialize/F64.ts.html +1136 -0
  110. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/serialize/deserializeTlv.ts.html +125 -0
  111. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/serialize/getTlv.ts.html +143 -0
  112. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/serialize/index.html +141 -0
  113. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/util.ts.html +179 -0
  114. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/validation/index.html +111 -0
  115. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/validation/validate.ts.html +182 -0
  116. package/.yalc/@node-dlc/messaging/coverage/lcov-report/prettify.css +1 -0
  117. package/.yalc/@node-dlc/messaging/coverage/lcov-report/prettify.js +2 -0
  118. package/.yalc/@node-dlc/messaging/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  119. package/.yalc/@node-dlc/messaging/coverage/lcov-report/sorter.js +170 -0
  120. package/.yalc/@node-dlc/messaging/coverage/lcov.info +5394 -0
  121. package/.yalc/@node-dlc/messaging/dist/MessageType.d.ts +100 -0
  122. package/.yalc/@node-dlc/messaging/dist/MessageType.js +117 -0
  123. package/.yalc/@node-dlc/messaging/dist/MessageType.js.map +1 -0
  124. package/.yalc/@node-dlc/messaging/dist/chain/ChainManager.d.ts +50 -0
  125. package/.yalc/@node-dlc/messaging/dist/chain/ChainManager.js +211 -0
  126. package/.yalc/@node-dlc/messaging/dist/chain/ChainManager.js.map +1 -0
  127. package/.yalc/@node-dlc/messaging/dist/chain/ChainMemoryStore.d.ts +14 -0
  128. package/.yalc/@node-dlc/messaging/dist/chain/ChainMemoryStore.js +28 -0
  129. package/.yalc/@node-dlc/messaging/dist/chain/ChainMemoryStore.js.map +1 -0
  130. package/.yalc/@node-dlc/messaging/dist/chain/DlcStore.d.ts +11 -0
  131. package/.yalc/@node-dlc/messaging/dist/chain/DlcStore.js +3 -0
  132. package/.yalc/@node-dlc/messaging/dist/chain/DlcStore.js.map +1 -0
  133. package/.yalc/@node-dlc/messaging/dist/chain/IChainFilterChainClient.d.ts +48 -0
  134. package/.yalc/@node-dlc/messaging/dist/chain/IChainFilterChainClient.js +3 -0
  135. package/.yalc/@node-dlc/messaging/dist/chain/IChainFilterChainClient.js.map +1 -0
  136. package/.yalc/@node-dlc/messaging/dist/domain/Address.d.ts +24 -0
  137. package/.yalc/@node-dlc/messaging/dist/domain/Address.js +46 -0
  138. package/.yalc/@node-dlc/messaging/dist/domain/Address.js.map +1 -0
  139. package/.yalc/@node-dlc/messaging/dist/index.d.ts +44 -0
  140. package/.yalc/@node-dlc/messaging/dist/index.js +63 -0
  141. package/.yalc/@node-dlc/messaging/dist/index.js.map +1 -0
  142. package/.yalc/@node-dlc/messaging/dist/irc/IrcMessage.d.ts +43 -0
  143. package/.yalc/@node-dlc/messaging/dist/irc/IrcMessage.js +116 -0
  144. package/.yalc/@node-dlc/messaging/dist/irc/IrcMessage.js.map +1 -0
  145. package/.yalc/@node-dlc/messaging/dist/messages/AddressCache.d.ts +15 -0
  146. package/.yalc/@node-dlc/messaging/dist/messages/AddressCache.js +51 -0
  147. package/.yalc/@node-dlc/messaging/dist/messages/AddressCache.js.map +1 -0
  148. package/.yalc/@node-dlc/messaging/dist/messages/BatchFundingGroup.d.ts +61 -0
  149. package/.yalc/@node-dlc/messaging/dist/messages/BatchFundingGroup.js +113 -0
  150. package/.yalc/@node-dlc/messaging/dist/messages/BatchFundingGroup.js.map +1 -0
  151. package/.yalc/@node-dlc/messaging/dist/messages/CetAdaptorSignatures.d.ts +40 -0
  152. package/.yalc/@node-dlc/messaging/dist/messages/CetAdaptorSignatures.js +67 -0
  153. package/.yalc/@node-dlc/messaging/dist/messages/CetAdaptorSignatures.js.map +1 -0
  154. package/.yalc/@node-dlc/messaging/dist/messages/ContractDescriptor.d.ts +122 -0
  155. package/.yalc/@node-dlc/messaging/dist/messages/ContractDescriptor.js +222 -0
  156. package/.yalc/@node-dlc/messaging/dist/messages/ContractDescriptor.js.map +1 -0
  157. package/.yalc/@node-dlc/messaging/dist/messages/ContractInfo.d.ts +135 -0
  158. package/.yalc/@node-dlc/messaging/dist/messages/ContractInfo.js +304 -0
  159. package/.yalc/@node-dlc/messaging/dist/messages/ContractInfo.js.map +1 -0
  160. package/.yalc/@node-dlc/messaging/dist/messages/DlcAccept.d.ts +145 -0
  161. package/.yalc/@node-dlc/messaging/dist/messages/DlcAccept.js +428 -0
  162. package/.yalc/@node-dlc/messaging/dist/messages/DlcAccept.js.map +1 -0
  163. package/.yalc/@node-dlc/messaging/dist/messages/DlcCancel.d.ts +31 -0
  164. package/.yalc/@node-dlc/messaging/dist/messages/DlcCancel.js +51 -0
  165. package/.yalc/@node-dlc/messaging/dist/messages/DlcCancel.js.map +1 -0
  166. package/.yalc/@node-dlc/messaging/dist/messages/DlcClose.d.ts +68 -0
  167. package/.yalc/@node-dlc/messaging/dist/messages/DlcClose.js +210 -0
  168. package/.yalc/@node-dlc/messaging/dist/messages/DlcClose.js.map +1 -0
  169. package/.yalc/@node-dlc/messaging/dist/messages/DlcCloseMetadata.d.ts +44 -0
  170. package/.yalc/@node-dlc/messaging/dist/messages/DlcCloseMetadata.js +74 -0
  171. package/.yalc/@node-dlc/messaging/dist/messages/DlcCloseMetadata.js.map +1 -0
  172. package/.yalc/@node-dlc/messaging/dist/messages/DlcIds.d.ts +26 -0
  173. package/.yalc/@node-dlc/messaging/dist/messages/DlcIds.js +58 -0
  174. package/.yalc/@node-dlc/messaging/dist/messages/DlcIds.js.map +1 -0
  175. package/.yalc/@node-dlc/messaging/dist/messages/DlcInfo.d.ts +31 -0
  176. package/.yalc/@node-dlc/messaging/dist/messages/DlcInfo.js +61 -0
  177. package/.yalc/@node-dlc/messaging/dist/messages/DlcInfo.js.map +1 -0
  178. package/.yalc/@node-dlc/messaging/dist/messages/DlcMessage.d.ts +23 -0
  179. package/.yalc/@node-dlc/messaging/dist/messages/DlcMessage.js +54 -0
  180. package/.yalc/@node-dlc/messaging/dist/messages/DlcMessage.js.map +1 -0
  181. package/.yalc/@node-dlc/messaging/dist/messages/DlcOffer.d.ts +131 -0
  182. package/.yalc/@node-dlc/messaging/dist/messages/DlcOffer.js +418 -0
  183. package/.yalc/@node-dlc/messaging/dist/messages/DlcOffer.js.map +1 -0
  184. package/.yalc/@node-dlc/messaging/dist/messages/DlcSign.d.ts +96 -0
  185. package/.yalc/@node-dlc/messaging/dist/messages/DlcSign.js +267 -0
  186. package/.yalc/@node-dlc/messaging/dist/messages/DlcSign.js.map +1 -0
  187. package/.yalc/@node-dlc/messaging/dist/messages/DlcTransactions.d.ts +69 -0
  188. package/.yalc/@node-dlc/messaging/dist/messages/DlcTransactions.js +149 -0
  189. package/.yalc/@node-dlc/messaging/dist/messages/DlcTransactions.js.map +1 -0
  190. package/.yalc/@node-dlc/messaging/dist/messages/EventDescriptor.d.ts +106 -0
  191. package/.yalc/@node-dlc/messaging/dist/messages/EventDescriptor.js +209 -0
  192. package/.yalc/@node-dlc/messaging/dist/messages/EventDescriptor.js.map +1 -0
  193. package/.yalc/@node-dlc/messaging/dist/messages/FundingInput.d.ts +62 -0
  194. package/.yalc/@node-dlc/messaging/dist/messages/FundingInput.js +163 -0
  195. package/.yalc/@node-dlc/messaging/dist/messages/FundingInput.js.map +1 -0
  196. package/.yalc/@node-dlc/messaging/dist/messages/FundingSignatures.d.ts +36 -0
  197. package/.yalc/@node-dlc/messaging/dist/messages/FundingSignatures.js +78 -0
  198. package/.yalc/@node-dlc/messaging/dist/messages/FundingSignatures.js.map +1 -0
  199. package/.yalc/@node-dlc/messaging/dist/messages/IWireMessage.d.ts +6 -0
  200. package/.yalc/@node-dlc/messaging/dist/messages/IWireMessage.js +3 -0
  201. package/.yalc/@node-dlc/messaging/dist/messages/IWireMessage.js.map +1 -0
  202. package/.yalc/@node-dlc/messaging/dist/messages/NegotiationFields.d.ts +86 -0
  203. package/.yalc/@node-dlc/messaging/dist/messages/NegotiationFields.js +185 -0
  204. package/.yalc/@node-dlc/messaging/dist/messages/NegotiationFields.js.map +1 -0
  205. package/.yalc/@node-dlc/messaging/dist/messages/NodeAnnouncementMessage.d.ts +57 -0
  206. package/.yalc/@node-dlc/messaging/dist/messages/NodeAnnouncementMessage.js +127 -0
  207. package/.yalc/@node-dlc/messaging/dist/messages/NodeAnnouncementMessage.js.map +1 -0
  208. package/.yalc/@node-dlc/messaging/dist/messages/OracleAnnouncement.d.ts +76 -0
  209. package/.yalc/@node-dlc/messaging/dist/messages/OracleAnnouncement.js +131 -0
  210. package/.yalc/@node-dlc/messaging/dist/messages/OracleAnnouncement.js.map +1 -0
  211. package/.yalc/@node-dlc/messaging/dist/messages/OracleAttestation.d.ts +68 -0
  212. package/.yalc/@node-dlc/messaging/dist/messages/OracleAttestation.js +239 -0
  213. package/.yalc/@node-dlc/messaging/dist/messages/OracleAttestation.js.map +1 -0
  214. package/.yalc/@node-dlc/messaging/dist/messages/OracleEvent.d.ts +90 -0
  215. package/.yalc/@node-dlc/messaging/dist/messages/OracleEvent.js +189 -0
  216. package/.yalc/@node-dlc/messaging/dist/messages/OracleEvent.js.map +1 -0
  217. package/.yalc/@node-dlc/messaging/dist/messages/OracleEventContainer.d.ts +32 -0
  218. package/.yalc/@node-dlc/messaging/dist/messages/OracleEventContainer.js +67 -0
  219. package/.yalc/@node-dlc/messaging/dist/messages/OracleEventContainer.js.map +1 -0
  220. package/.yalc/@node-dlc/messaging/dist/messages/OracleIdentifier.d.ts +32 -0
  221. package/.yalc/@node-dlc/messaging/dist/messages/OracleIdentifier.js +58 -0
  222. package/.yalc/@node-dlc/messaging/dist/messages/OracleIdentifier.js.map +1 -0
  223. package/.yalc/@node-dlc/messaging/dist/messages/OracleIdentifierV0.d.ts +32 -0
  224. package/.yalc/@node-dlc/messaging/dist/messages/OracleIdentifierV0.js +58 -0
  225. package/.yalc/@node-dlc/messaging/dist/messages/OracleIdentifierV0.js.map +1 -0
  226. package/.yalc/@node-dlc/messaging/dist/messages/OracleInfo.d.ts +161 -0
  227. package/.yalc/@node-dlc/messaging/dist/messages/OracleInfo.js +390 -0
  228. package/.yalc/@node-dlc/messaging/dist/messages/OracleInfo.js.map +1 -0
  229. package/.yalc/@node-dlc/messaging/dist/messages/OracleInfoV0.d.ts +161 -0
  230. package/.yalc/@node-dlc/messaging/dist/messages/OracleInfoV0.js +387 -0
  231. package/.yalc/@node-dlc/messaging/dist/messages/OracleInfoV0.js.map +1 -0
  232. package/.yalc/@node-dlc/messaging/dist/messages/OrderAccept.d.ts +65 -0
  233. package/.yalc/@node-dlc/messaging/dist/messages/OrderAccept.js +125 -0
  234. package/.yalc/@node-dlc/messaging/dist/messages/OrderAccept.js.map +1 -0
  235. package/.yalc/@node-dlc/messaging/dist/messages/OrderIrcInfo.d.ts +42 -0
  236. package/.yalc/@node-dlc/messaging/dist/messages/OrderIrcInfo.js +74 -0
  237. package/.yalc/@node-dlc/messaging/dist/messages/OrderIrcInfo.js.map +1 -0
  238. package/.yalc/@node-dlc/messaging/dist/messages/OrderMetadata.d.ts +56 -0
  239. package/.yalc/@node-dlc/messaging/dist/messages/OrderMetadata.js +87 -0
  240. package/.yalc/@node-dlc/messaging/dist/messages/OrderMetadata.js.map +1 -0
  241. package/.yalc/@node-dlc/messaging/dist/messages/OrderNegotiationFields.d.ts +69 -0
  242. package/.yalc/@node-dlc/messaging/dist/messages/OrderNegotiationFields.js +114 -0
  243. package/.yalc/@node-dlc/messaging/dist/messages/OrderNegotiationFields.js.map +1 -0
  244. package/.yalc/@node-dlc/messaging/dist/messages/OrderOffer.d.ts +97 -0
  245. package/.yalc/@node-dlc/messaging/dist/messages/OrderOffer.js +296 -0
  246. package/.yalc/@node-dlc/messaging/dist/messages/OrderOffer.js.map +1 -0
  247. package/.yalc/@node-dlc/messaging/dist/messages/OrderPositionInfo.d.ts +50 -0
  248. package/.yalc/@node-dlc/messaging/dist/messages/OrderPositionInfo.js +125 -0
  249. package/.yalc/@node-dlc/messaging/dist/messages/OrderPositionInfo.js.map +1 -0
  250. package/.yalc/@node-dlc/messaging/dist/messages/PayoutCurvePiece.d.ts +129 -0
  251. package/.yalc/@node-dlc/messaging/dist/messages/PayoutCurvePiece.js +327 -0
  252. package/.yalc/@node-dlc/messaging/dist/messages/PayoutCurvePiece.js.map +1 -0
  253. package/.yalc/@node-dlc/messaging/dist/messages/PayoutFunction.d.ts +66 -0
  254. package/.yalc/@node-dlc/messaging/dist/messages/PayoutFunction.js +170 -0
  255. package/.yalc/@node-dlc/messaging/dist/messages/PayoutFunction.js.map +1 -0
  256. package/.yalc/@node-dlc/messaging/dist/messages/RoundingIntervals.d.ts +52 -0
  257. package/.yalc/@node-dlc/messaging/dist/messages/RoundingIntervals.js +95 -0
  258. package/.yalc/@node-dlc/messaging/dist/messages/RoundingIntervals.js.map +1 -0
  259. package/.yalc/@node-dlc/messaging/dist/messages/ScriptWitnessV0.d.ts +29 -0
  260. package/.yalc/@node-dlc/messaging/dist/messages/ScriptWitnessV0.js +50 -0
  261. package/.yalc/@node-dlc/messaging/dist/messages/ScriptWitnessV0.js.map +1 -0
  262. package/.yalc/@node-dlc/messaging/dist/messages/Tlv.d.ts +15 -0
  263. package/.yalc/@node-dlc/messaging/dist/messages/Tlv.js +32 -0
  264. package/.yalc/@node-dlc/messaging/dist/messages/Tlv.js.map +1 -0
  265. package/.yalc/@node-dlc/messaging/dist/serialize/F64.d.ts +154 -0
  266. package/.yalc/@node-dlc/messaging/dist/serialize/F64.js +307 -0
  267. package/.yalc/@node-dlc/messaging/dist/serialize/F64.js.map +1 -0
  268. package/.yalc/@node-dlc/messaging/dist/serialize/deserializeTlv.d.ts +9 -0
  269. package/.yalc/@node-dlc/messaging/dist/serialize/deserializeTlv.js +11 -0
  270. package/.yalc/@node-dlc/messaging/dist/serialize/deserializeTlv.js.map +1 -0
  271. package/.yalc/@node-dlc/messaging/dist/serialize/getTlv.d.ts +4 -0
  272. package/.yalc/@node-dlc/messaging/dist/serialize/getTlv.js +23 -0
  273. package/.yalc/@node-dlc/messaging/dist/serialize/getTlv.js.map +1 -0
  274. package/.yalc/@node-dlc/messaging/dist/serialize/readTlvs.d.ts +8 -0
  275. package/.yalc/@node-dlc/messaging/dist/serialize/readTlvs.js +33 -0
  276. package/.yalc/@node-dlc/messaging/dist/serialize/readTlvs.js.map +1 -0
  277. package/.yalc/@node-dlc/messaging/dist/util.d.ts +13 -0
  278. package/.yalc/@node-dlc/messaging/dist/util.js +40 -0
  279. package/.yalc/@node-dlc/messaging/dist/util.js.map +1 -0
  280. package/.yalc/@node-dlc/messaging/dist/validation/validate.d.ts +4 -0
  281. package/.yalc/@node-dlc/messaging/dist/validation/validate.js +31 -0
  282. package/.yalc/@node-dlc/messaging/dist/validation/validate.js.map +1 -0
  283. package/.yalc/@node-dlc/messaging/lib/MessageType.ts +138 -0
  284. package/.yalc/@node-dlc/messaging/lib/chain/ChainManager.ts +326 -0
  285. package/.yalc/@node-dlc/messaging/lib/chain/ChainMemoryStore.ts +34 -0
  286. package/.yalc/@node-dlc/messaging/lib/chain/DlcStore.ts +11 -0
  287. package/.yalc/@node-dlc/messaging/lib/chain/IChainFilterChainClient.ts +57 -0
  288. package/.yalc/@node-dlc/messaging/lib/domain/Address.ts +64 -0
  289. package/.yalc/@node-dlc/messaging/lib/index.ts +44 -0
  290. package/.yalc/@node-dlc/messaging/lib/irc/IrcMessage.ts +161 -0
  291. package/.yalc/@node-dlc/messaging/lib/messages/AddressCache.ts +74 -0
  292. package/.yalc/@node-dlc/messaging/lib/messages/BatchFundingGroup.ts +141 -0
  293. package/.yalc/@node-dlc/messaging/lib/messages/CetAdaptorSignatures.ts +89 -0
  294. package/.yalc/@node-dlc/messaging/lib/messages/ContractDescriptor.ts +318 -0
  295. package/.yalc/@node-dlc/messaging/lib/messages/ContractInfo.ts +434 -0
  296. package/.yalc/@node-dlc/messaging/lib/messages/DlcAccept.ts +595 -0
  297. package/.yalc/@node-dlc/messaging/lib/messages/DlcCancel.ts +57 -0
  298. package/.yalc/@node-dlc/messaging/lib/messages/DlcClose.ts +302 -0
  299. package/.yalc/@node-dlc/messaging/lib/messages/DlcCloseMetadata.ts +121 -0
  300. package/.yalc/@node-dlc/messaging/lib/messages/DlcIds.ts +67 -0
  301. package/.yalc/@node-dlc/messaging/lib/messages/DlcInfo.ts +81 -0
  302. package/.yalc/@node-dlc/messaging/lib/messages/DlcMessage.ts +87 -0
  303. package/.yalc/@node-dlc/messaging/lib/messages/DlcOffer.ts +605 -0
  304. package/.yalc/@node-dlc/messaging/lib/messages/DlcSign.ts +354 -0
  305. package/.yalc/@node-dlc/messaging/lib/messages/DlcTransactions.ts +213 -0
  306. package/.yalc/@node-dlc/messaging/lib/messages/EventDescriptor.ts +289 -0
  307. package/.yalc/@node-dlc/messaging/lib/messages/FundingInput.ts +216 -0
  308. package/.yalc/@node-dlc/messaging/lib/messages/FundingSignatures.ts +98 -0
  309. package/.yalc/@node-dlc/messaging/lib/messages/IWireMessage.ts +6 -0
  310. package/.yalc/@node-dlc/messaging/lib/messages/NegotiationFields.ts +252 -0
  311. package/.yalc/@node-dlc/messaging/lib/messages/NodeAnnouncementMessage.ts +145 -0
  312. package/.yalc/@node-dlc/messaging/lib/messages/OracleAnnouncement.ts +176 -0
  313. package/.yalc/@node-dlc/messaging/lib/messages/OracleAttestation.ts +292 -0
  314. package/.yalc/@node-dlc/messaging/lib/messages/OracleEvent.ts +250 -0
  315. package/.yalc/@node-dlc/messaging/lib/messages/OracleEventContainer.ts +89 -0
  316. package/.yalc/@node-dlc/messaging/lib/messages/OracleIdentifier.ts +78 -0
  317. package/.yalc/@node-dlc/messaging/lib/messages/OracleInfo.ts +519 -0
  318. package/.yalc/@node-dlc/messaging/lib/messages/OrderAccept.ts +159 -0
  319. package/.yalc/@node-dlc/messaging/lib/messages/OrderIrcInfo.ts +100 -0
  320. package/.yalc/@node-dlc/messaging/lib/messages/OrderMetadata.ts +119 -0
  321. package/.yalc/@node-dlc/messaging/lib/messages/OrderNegotiationFields.ts +157 -0
  322. package/.yalc/@node-dlc/messaging/lib/messages/OrderOffer.ts +419 -0
  323. package/.yalc/@node-dlc/messaging/lib/messages/OrderPositionInfo.ts +170 -0
  324. package/.yalc/@node-dlc/messaging/lib/messages/PayoutCurvePiece.ts +449 -0
  325. package/.yalc/@node-dlc/messaging/lib/messages/PayoutFunction.ts +240 -0
  326. package/.yalc/@node-dlc/messaging/lib/messages/RoundingIntervals.ts +127 -0
  327. package/.yalc/@node-dlc/messaging/lib/messages/ScriptWitnessV0.ts +63 -0
  328. package/.yalc/@node-dlc/messaging/lib/messages/Tlv.ts +40 -0
  329. package/.yalc/@node-dlc/messaging/lib/serialize/F64.ts +352 -0
  330. package/.yalc/@node-dlc/messaging/lib/serialize/deserializeTlv.ts +15 -0
  331. package/.yalc/@node-dlc/messaging/lib/serialize/getTlv.ts +21 -0
  332. package/.yalc/@node-dlc/messaging/lib/serialize/readTlvs.ts +37 -0
  333. package/.yalc/@node-dlc/messaging/lib/util.ts +33 -0
  334. package/.yalc/@node-dlc/messaging/lib/validation/validate.ts +34 -0
  335. package/.yalc/@node-dlc/messaging/package.json +42 -0
  336. package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/enum_3_of_3_test.json +210 -0
  337. package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/enum_3_of_5_test.json +468 -0
  338. package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/enum_and_numerical_3_of_5_test.json +1517 -0
  339. package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/enum_and_numerical_5_of_5_test.json +545 -0
  340. package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/enum_and_numerical_with_diff_3_of_5_test.json +4761 -0
  341. package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/enum_and_numerical_with_diff_5_of_5_test.json +2169 -0
  342. package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/enum_single_oracle_test.json +164 -0
  343. package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/single_oracle_numerical_hyperbola_test.json +502 -0
  344. package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/single_oracle_numerical_test.json +262 -0
  345. package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/three_of_five_oracle_numerical_with_diff_test.json +4382 -0
  346. package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/three_of_three_oracle_numerical_test.json +324 -0
  347. package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/three_of_three_oracle_numerical_with_diff_test.json +652 -0
  348. package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/two_of_five_oracle_numerical_test.json +1138 -0
  349. package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/two_of_five_oracle_numerical_with_diff_test.json +2222 -0
  350. package/.yalc/@node-dlc/messaging/test_vectors/oracle/external_oracle_announcements.json +0 -0
  351. package/.yalc/@node-dlc/messaging/test_vectors/oracle/oracle_message_test_vectors.json +115 -0
  352. package/.yalc/@node-dlc/messaging/test_vectors/rust-dlc/accept_msg.json +1465 -0
  353. package/.yalc/@node-dlc/messaging/test_vectors/rust-dlc/dlc_fee_test.json +12362 -0
  354. package/.yalc/@node-dlc/messaging/test_vectors/rust-dlc/dlc_fee_test_scripts.json +57 -0
  355. package/.yalc/@node-dlc/messaging/test_vectors/rust-dlc/dlc_test.json +2766 -0
  356. package/.yalc/@node-dlc/messaging/test_vectors/rust-dlc/dlc_tx_test.json +2899 -0
  357. package/.yalc/@node-dlc/messaging/test_vectors/rust-dlc/offer_msg.json +163 -0
  358. package/.yalc/@node-dlc/messaging/test_vectors/rust-dlc/offer_msg_disjoint.json +352 -0
  359. package/.yalc/@node-dlc/messaging/test_vectors/rust-dlc/segment_chunk_msg.json +12635 -0
  360. package/.yalc/@node-dlc/messaging/test_vectors/rust-dlc/segment_start_msg.json +4022 -0
  361. package/.yalc/@node-dlc/messaging/test_vectors/rust-dlc/sign_msg.json +383 -0
  362. package/.yalc/@node-dlc/messaging/tsconfig.json +7 -0
  363. package/.yalc/@node-dlc/messaging/yalc.sig +1 -0
  364. package/CHANGELOG.md +70 -0
  365. package/dist/dlc.d.ts +3 -3
  366. package/dist/models/Output.js.map +1 -1
  367. package/lib/dlc.ts +4 -14
  368. package/lib/models/Output.ts +4 -1
  369. package/package.json +4 -4
  370. package/yalc.lock +10 -0
@@ -0,0 +1,267 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.DlcSignContainer = exports.DlcSign = void 0;
7
+ const bufio_1 = require("@node-dlc/bufio");
8
+ const secp256k1_1 = __importDefault(require("secp256k1"));
9
+ const MessageType_1 = require("../MessageType");
10
+ const deserializeTlv_1 = require("../serialize/deserializeTlv");
11
+ const getTlv_1 = require("../serialize/getTlv");
12
+ const BatchFundingGroup_1 = require("./BatchFundingGroup");
13
+ const CetAdaptorSignatures_1 = require("./CetAdaptorSignatures");
14
+ const FundingSignatures_1 = require("./FundingSignatures");
15
+ const ScriptWitnessV0_1 = require("./ScriptWitnessV0");
16
+ /**
17
+ * DlcSign gives all of the initiator's signatures, which allows the
18
+ * receiver to broadcast the funding transaction with both parties being
19
+ * fully committed to all closing transactions.
20
+ * Updated to support dlcspecs PR #163 format.
21
+ */
22
+ class DlcSign {
23
+ constructor() {
24
+ /**
25
+ * The type for sign_dlc message. sign_dlc = 42782
26
+ */
27
+ this.type = DlcSign.type;
28
+ // New fields as per dlcspecs PR #163
29
+ this.protocolVersion = MessageType_1.PROTOCOL_VERSION; // Default to current protocol version
30
+ }
31
+ /**
32
+ * Creates a DlcSign from JSON data (e.g., from test vectors)
33
+ * Handles both our internal format and external test vector formats
34
+ * @param json JSON object representing a DLC sign
35
+ */
36
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
37
+ static fromJSON(json) {
38
+ const instance = new DlcSign();
39
+ // Helper function to parse DER-encoded signature and extract raw r,s values (64 bytes total)
40
+ const parseDerSignature = (hexSig) => {
41
+ const sigBuffer = Buffer.from(hexSig, 'hex');
42
+ // If it's already 64 bytes, assume it's raw
43
+ if (sigBuffer.length === 64) {
44
+ return sigBuffer;
45
+ }
46
+ // Use secp256k1.signatureImport to parse DER signature
47
+ try {
48
+ const rawSig = secp256k1_1.default.signatureImport(sigBuffer);
49
+ return Buffer.from(rawSig);
50
+ }
51
+ catch (ex) {
52
+ throw new Error(`Invalid DER signature: ${ex.message}`);
53
+ }
54
+ };
55
+ // Handle both internal and external field naming conventions
56
+ instance.protocolVersion =
57
+ json.protocolVersion || json.protocol_version || MessageType_1.PROTOCOL_VERSION;
58
+ instance.contractId = Buffer.from(json.contractId || json.contract_id, 'hex');
59
+ // Parse CET adaptor signatures
60
+ instance.cetAdaptorSignatures = DlcSign.parseCetAdaptorSignaturesFromJSON(json.cetAdaptorSignatures || json.cet_adaptor_signatures);
61
+ // Parse refund signature - handle DER encoding
62
+ const refundSigHex = json.refundSignature || json.refund_signature;
63
+ instance.refundSignature = parseDerSignature(refundSigHex);
64
+ // Parse funding signatures
65
+ instance.fundingSignatures = DlcSign.parseFundingSignaturesFromJSON(json.fundingSignatures || json.funding_signatures);
66
+ return instance;
67
+ }
68
+ /**
69
+ * Parses CetAdaptorSignatures from JSON
70
+ * @param cetSigsJson JSON object representing CET adaptor signatures
71
+ */
72
+ static parseCetAdaptorSignaturesFromJSON(cetSigsJson) {
73
+ const instance = new CetAdaptorSignatures_1.CetAdaptorSignatures();
74
+ if (cetSigsJson.ecdsaAdaptorSignatures ||
75
+ cetSigsJson.ecdsa_adaptor_signatures) {
76
+ const ecdsaSigs = cetSigsJson.ecdsaAdaptorSignatures ||
77
+ cetSigsJson.ecdsa_adaptor_signatures;
78
+ instance.sigs = ecdsaSigs.map((sig) => {
79
+ // The test vectors use 'signature' field, but our internal format uses encryptedSig/dleqProof
80
+ // For now, we'll parse the signature as encryptedSig and leave dleqProof empty
81
+ const sigBuffer = Buffer.from(sig.signature, 'hex');
82
+ return {
83
+ encryptedSig: sigBuffer.slice(0, 65),
84
+ dleqProof: sigBuffer.length > 65 ? sigBuffer.slice(65, 162) : Buffer.alloc(97), // Next 97 bytes or empty
85
+ };
86
+ });
87
+ }
88
+ return instance;
89
+ }
90
+ /**
91
+ * Parses FundingSignatures from JSON
92
+ * @param fundingSigsJson JSON object representing funding signatures
93
+ */
94
+ static parseFundingSignaturesFromJSON(fundingSigsJson) {
95
+ const instance = new FundingSignatures_1.FundingSignatures();
96
+ if (fundingSigsJson.fundingSignatures ||
97
+ fundingSigsJson.funding_signatures) {
98
+ const fundingSigs = fundingSigsJson.fundingSignatures || fundingSigsJson.funding_signatures;
99
+ instance.witnessElements = fundingSigs.map((sig) => (sig.witnessElements || sig.witness_elements || []).map((element) => {
100
+ // Create a ScriptWitnessV0 instance for each witness element
101
+ const witness = new ScriptWitnessV0_1.ScriptWitnessV0();
102
+ witness.witness = Buffer.from(element.witness || element, 'hex');
103
+ return witness;
104
+ }));
105
+ }
106
+ return instance;
107
+ }
108
+ /**
109
+ * Deserializes a sign_dlc message
110
+ * @param buf
111
+ */
112
+ static deserialize(buf) {
113
+ const instance = new DlcSign();
114
+ const reader = new bufio_1.BufferReader(buf);
115
+ reader.readUInt16BE(); // read type
116
+ // New fields as per dlcspecs PR #163
117
+ instance.protocolVersion = reader.readUInt32BE();
118
+ instance.contractId = reader.readBytes(32);
119
+ // Read CET adaptor signatures directly to match serialize format (no TLV wrapping)
120
+ instance.cetAdaptorSignatures = CetAdaptorSignatures_1.CetAdaptorSignatures.deserialize(reader.buffer.subarray(reader.position));
121
+ // Skip past the CET adaptor signatures we just read
122
+ const cetLength = instance.cetAdaptorSignatures.serialize().length;
123
+ reader.position += cetLength;
124
+ instance.refundSignature = reader.readBytes(64);
125
+ // Read funding signatures directly to match serialize format (no TLV wrapping)
126
+ instance.fundingSignatures = FundingSignatures_1.FundingSignatures.deserialize(reader.buffer.subarray(reader.position));
127
+ // Skip past the funding signatures we just read
128
+ const fundingLength = instance.fundingSignatures.serialize().length;
129
+ reader.position += fundingLength;
130
+ // Parse TLV stream as per dlcspecs PR #163
131
+ while (!reader.eof) {
132
+ const buf = (0, getTlv_1.getTlv)(reader);
133
+ const tlvReader = new bufio_1.BufferReader(buf);
134
+ const { type } = (0, deserializeTlv_1.deserializeTlv)(tlvReader);
135
+ switch (Number(type)) {
136
+ case MessageType_1.MessageType.BatchFundingGroup:
137
+ if (!instance.batchFundingGroups) {
138
+ instance.batchFundingGroups = [];
139
+ }
140
+ instance.batchFundingGroups.push(BatchFundingGroup_1.BatchFundingGroup.deserialize(buf));
141
+ break;
142
+ default:
143
+ // Store unknown TLVs for future compatibility
144
+ if (!instance.unknownTlvs) {
145
+ instance.unknownTlvs = [];
146
+ }
147
+ instance.unknownTlvs.push({ type: Number(type), data: buf });
148
+ break;
149
+ }
150
+ }
151
+ return instance;
152
+ }
153
+ /**
154
+ * Validates correctness of all fields
155
+ * Updated validation rules as per dlcspecs PR #163
156
+ * @throws Will throw an error if validation fails
157
+ */
158
+ validate() {
159
+ // 1. Type is set automatically in class
160
+ // 2. protocol_version validation
161
+ if (this.protocolVersion !== MessageType_1.PROTOCOL_VERSION) {
162
+ throw new Error(`Unsupported protocol version: ${this.protocolVersion}, expected: ${MessageType_1.PROTOCOL_VERSION}`);
163
+ }
164
+ // 3. contract_id must be 32 bytes
165
+ if (!this.contractId || this.contractId.length !== 32) {
166
+ throw new Error('contractId must be 32 bytes');
167
+ }
168
+ // 4. Other validations would depend on specific business logic
169
+ // TODO: Add more specific validation rules as needed
170
+ }
171
+ /**
172
+ * Converts sign_dlc to JSON (canonical rust-dlc format)
173
+ */
174
+ toJSON() {
175
+ // Convert raw signature back to DER format for canonical rust-dlc JSON
176
+ const derRefundSignature = secp256k1_1.default.signatureExport(this.refundSignature);
177
+ return {
178
+ protocolVersion: this.protocolVersion,
179
+ contractId: this.contractId.toString('hex'),
180
+ cetAdaptorSignatures: this.cetAdaptorSignatures.toJSON(),
181
+ refundSignature: Buffer.from(derRefundSignature).toString('hex'),
182
+ fundingSignatures: this.fundingSignatures.toJSON(),
183
+ };
184
+ }
185
+ /**
186
+ * Serializes the sign_dlc message into a Buffer
187
+ * Updated serialization format as per dlcspecs PR #163
188
+ */
189
+ serialize() {
190
+ const writer = new bufio_1.BufferWriter();
191
+ writer.writeUInt16BE(this.type);
192
+ // New fields as per dlcspecs PR #163
193
+ writer.writeUInt32BE(this.protocolVersion);
194
+ writer.writeBytes(this.contractId);
195
+ writer.writeBytes(this.cetAdaptorSignatures.serialize());
196
+ writer.writeBytes(this.refundSignature);
197
+ writer.writeBytes(this.fundingSignatures.serialize());
198
+ // TLV stream as per dlcspecs PR #163
199
+ if (this.batchFundingGroups)
200
+ this.batchFundingGroups.forEach((fundingInfo) => writer.writeBytes(fundingInfo.serialize()));
201
+ // Write unknown TLVs for forward compatibility
202
+ if (this.unknownTlvs) {
203
+ this.unknownTlvs.forEach((tlv) => {
204
+ writer.writeBytes(tlv.data);
205
+ });
206
+ }
207
+ return writer.toBuffer();
208
+ }
209
+ }
210
+ exports.DlcSign = DlcSign;
211
+ DlcSign.type = MessageType_1.MessageType.DlcSign;
212
+ class DlcSignContainer {
213
+ constructor() {
214
+ this.signs = [];
215
+ }
216
+ /**
217
+ * Adds a DlcSign to the container.
218
+ * @param sign The DlcSign to add.
219
+ */
220
+ addSign(sign) {
221
+ this.signs.push(sign);
222
+ }
223
+ /**
224
+ * Returns all DlcSigns in the container.
225
+ * @returns An array of DlcSign instances.
226
+ */
227
+ getSigns() {
228
+ return this.signs;
229
+ }
230
+ /**
231
+ * Serializes all DlcSigns in the container to a Buffer.
232
+ * @returns A Buffer containing the serialized DlcSigns.
233
+ */
234
+ serialize() {
235
+ const writer = new bufio_1.BufferWriter();
236
+ // Write the number of signs in the container first.
237
+ writer.writeBigSize(this.signs.length);
238
+ // Serialize each sign and write it.
239
+ this.signs.forEach((sign) => {
240
+ const serializedSign = sign.serialize();
241
+ // Optionally, write the length of the serialized sign for easier deserialization.
242
+ writer.writeBigSize(serializedSign.length);
243
+ writer.writeBytes(serializedSign);
244
+ });
245
+ return writer.toBuffer();
246
+ }
247
+ /**
248
+ * Deserializes a Buffer into a DlcSignContainer with DlcSigns.
249
+ * @param buf The Buffer to deserialize.
250
+ * @returns A DlcSignContainer instance.
251
+ */
252
+ static deserialize(buf) {
253
+ const reader = new bufio_1.BufferReader(buf);
254
+ const container = new DlcSignContainer();
255
+ const signsCount = reader.readBigSize();
256
+ for (let i = 0; i < signsCount; i++) {
257
+ // Optionally, read the length of the serialized sign if it was written during serialization.
258
+ const signLength = reader.readBigSize();
259
+ const signBuf = reader.readBytes(Number(signLength));
260
+ const sign = DlcSign.deserialize(signBuf);
261
+ container.addSign(sign);
262
+ }
263
+ return container;
264
+ }
265
+ }
266
+ exports.DlcSignContainer = DlcSignContainer;
267
+ //# sourceMappingURL=DlcSign.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DlcSign.js","sourceRoot":"","sources":["../../lib/messages/DlcSign.ts"],"names":[],"mappings":";;;;;;AAAA,2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1B,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;YACxC,kFAAkF;YAClF,MAAM,CAAC,YAAY,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;YAC3C,MAAM,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;QACpC,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,WAAW,CAAC,GAAW;QACnC,MAAM,MAAM,GAAG,IAAI,oBAAY,CAAC,GAAG,CAAC,CAAC;QACrC,MAAM,SAAS,GAAG,IAAI,gBAAgB,EAAE,CAAC;QACzC,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;QACxC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,EAAE,CAAC,EAAE,EAAE;YACnC,6FAA6F;YAC7F,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;YACxC,MAAM,OAAO,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;YACrD,MAAM,IAAI,GAAG,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;YAC1C,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SACzB;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAvDD,4CAuDC"}
@@ -0,0 +1,69 @@
1
+ /// <reference types="node" />
2
+ import { Tx } from '@node-dlc/bitcoin';
3
+ import { MessageType } from '../MessageType';
4
+ import { IDlcMessage } from './DlcMessage';
5
+ /**
6
+ * DlcTransactions message contains information about state of DLC
7
+ * contract such as fundtx and closetx
8
+ */
9
+ export declare class DlcTransactions implements IDlcMessage {
10
+ static type: MessageType;
11
+ /**
12
+ * Deserializes a dlc_transactions message
13
+ * @param buf
14
+ */
15
+ static deserialize(buf: Buffer, parseCets?: boolean): DlcTransactions;
16
+ /**
17
+ * The type for dlc_transactions message. dlc_transactions = 61230
18
+ */
19
+ type: MessageType;
20
+ contractId: Buffer;
21
+ fundTx: Tx;
22
+ fundTxVout: number;
23
+ fundEpoch: BlockEpoch;
24
+ fundBroadcastHeight: number;
25
+ refundTx: Tx;
26
+ cets: Tx[];
27
+ closeEpoch: BlockEpoch;
28
+ closeTxHash: Buffer;
29
+ closeType: CloseType;
30
+ closeBroadcastHeight: number;
31
+ /**
32
+ * Converts dlc_transactions to JSON
33
+ */
34
+ toJSON(): IDlcTransactionsJSON;
35
+ /**
36
+ * Serializes the dlc_transactions message into a Buffer
37
+ */
38
+ serialize(): Buffer;
39
+ }
40
+ export interface IDlcTransactionsJSON {
41
+ type: number;
42
+ contractId: string;
43
+ fundTx: string;
44
+ fundTxVout: number;
45
+ fundEpoch: IBlockEpochJSON;
46
+ fundBroadcastHeight: number;
47
+ refundTx: string;
48
+ cets: string[];
49
+ closeEpoch: IBlockEpochJSON;
50
+ closeTxHash: string;
51
+ closeType: string;
52
+ closeBroadcastHeight: number;
53
+ }
54
+ export interface IBlockEpochJSON {
55
+ hash: string;
56
+ height: number;
57
+ }
58
+ export interface BlockEpoch {
59
+ hash: Buffer;
60
+ height: number;
61
+ }
62
+ export declare enum CloseType {
63
+ NotClosed = 0,
64
+ ExecuteClose = 1,
65
+ RefundClose = 2,
66
+ CooperativeClose = 3
67
+ }
68
+ export declare const DlcTransactionsV0: typeof DlcTransactions;
69
+ export type IDlcTransactionsV0JSON = IDlcTransactionsJSON;
@@ -0,0 +1,149 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DlcTransactionsV0 = exports.CloseType = exports.DlcTransactions = void 0;
4
+ const bitcoin_1 = require("@node-dlc/bitcoin");
5
+ const bufio_1 = require("@node-dlc/bufio");
6
+ const MessageType_1 = require("../MessageType");
7
+ /**
8
+ * DlcTransactions message contains information about state of DLC
9
+ * contract such as fundtx and closetx
10
+ */
11
+ class DlcTransactions {
12
+ constructor() {
13
+ /**
14
+ * The type for dlc_transactions message. dlc_transactions = 61230
15
+ */
16
+ this.type = DlcTransactions.type;
17
+ this.fundEpoch = {
18
+ hash: Buffer.alloc(32),
19
+ height: 0,
20
+ };
21
+ this.fundBroadcastHeight = 0;
22
+ this.cets = [];
23
+ this.closeEpoch = {
24
+ hash: Buffer.alloc(32),
25
+ height: 0,
26
+ };
27
+ this.closeTxHash = Buffer.alloc(32);
28
+ this.closeType = 0;
29
+ this.closeBroadcastHeight = 0;
30
+ }
31
+ /**
32
+ * Deserializes a dlc_transactions message
33
+ * @param buf
34
+ */
35
+ static deserialize(buf, parseCets = true) {
36
+ const instance = new DlcTransactions();
37
+ const reader = new bufio_1.BufferReader(buf);
38
+ reader.readUInt16BE(); // read type
39
+ instance.contractId = reader.readBytes(32);
40
+ const fundTxLen = reader.readUInt16BE();
41
+ instance.fundTx = bitcoin_1.Tx.decode(bufio_1.StreamReader.fromBuffer(reader.readBytes(fundTxLen)));
42
+ instance.fundTxVout = reader.readUInt32BE();
43
+ const fundHash = reader.readBytes(32);
44
+ const fundHeight = reader.readUInt32BE();
45
+ instance.fundEpoch = {
46
+ hash: fundHash,
47
+ height: fundHeight,
48
+ };
49
+ instance.fundBroadcastHeight = reader.readUInt32BE();
50
+ const refundTxLen = reader.readUInt16BE();
51
+ instance.refundTx = bitcoin_1.Tx.decode(bufio_1.StreamReader.fromBuffer(reader.readBytes(refundTxLen)));
52
+ const numCets = reader.readBigSize(); // num_cets
53
+ for (let i = 0; i < numCets; i++) {
54
+ const cetLen = reader.readUInt16BE();
55
+ if (parseCets || i === 0) {
56
+ instance.cets.push(bitcoin_1.Tx.decode(bufio_1.StreamReader.fromBuffer(reader.readBytes(cetLen))));
57
+ }
58
+ else {
59
+ reader.readBytes(cetLen);
60
+ }
61
+ }
62
+ const closeHash = reader.readBytes(32);
63
+ const closeHeight = reader.readUInt32BE();
64
+ instance.closeEpoch = {
65
+ hash: closeHash,
66
+ height: closeHeight,
67
+ };
68
+ instance.closeTxHash = reader.readBytes(32);
69
+ instance.closeType = reader.readUInt8();
70
+ instance.closeBroadcastHeight = reader.readUInt32BE();
71
+ return instance;
72
+ }
73
+ /**
74
+ * Converts dlc_transactions to JSON
75
+ */
76
+ toJSON() {
77
+ return {
78
+ type: this.type,
79
+ contractId: this.contractId.toString('hex'),
80
+ fundTx: this.fundTx.serialize().toString('hex'),
81
+ fundTxVout: this.fundTxVout,
82
+ fundEpoch: {
83
+ hash: this.fundEpoch.hash.toString('hex'),
84
+ height: this.fundEpoch.height,
85
+ },
86
+ fundBroadcastHeight: this.fundBroadcastHeight,
87
+ refundTx: this.refundTx.serialize().toString('hex'),
88
+ cets: this.cets.map((cet) => cet.serialize().toString('hex')),
89
+ closeEpoch: {
90
+ hash: this.closeEpoch.hash.toString('hex'),
91
+ height: this.closeEpoch.height,
92
+ },
93
+ closeTxHash: this.closeTxHash.toString('hex'),
94
+ closeType: closeTypeToStr(this.closeType),
95
+ closeBroadcastHeight: this.closeBroadcastHeight,
96
+ };
97
+ }
98
+ /**
99
+ * Serializes the dlc_transactions message into a Buffer
100
+ */
101
+ serialize() {
102
+ const writer = new bufio_1.BufferWriter();
103
+ writer.writeUInt16BE(this.type);
104
+ writer.writeBytes(this.contractId);
105
+ writer.writeUInt16BE(this.fundTx.serialize().length);
106
+ writer.writeBytes(this.fundTx.serialize());
107
+ writer.writeUInt32BE(this.fundTxVout);
108
+ writer.writeBytes(this.fundEpoch.hash);
109
+ writer.writeUInt32BE(this.fundEpoch.height);
110
+ writer.writeUInt32BE(this.fundBroadcastHeight);
111
+ writer.writeUInt16BE(this.refundTx.serialize().length);
112
+ writer.writeBytes(this.refundTx.serialize());
113
+ writer.writeBigSize(this.cets.length);
114
+ for (const cet of this.cets) {
115
+ writer.writeUInt16BE(cet.serialize().length);
116
+ writer.writeBytes(cet.serialize());
117
+ }
118
+ writer.writeBytes(this.closeEpoch.hash);
119
+ writer.writeUInt32BE(this.closeEpoch.height);
120
+ writer.writeBytes(this.closeTxHash);
121
+ writer.writeUInt8(this.closeType);
122
+ writer.writeUInt32BE(this.closeBroadcastHeight);
123
+ return writer.toBuffer();
124
+ }
125
+ }
126
+ exports.DlcTransactions = DlcTransactions;
127
+ DlcTransactions.type = MessageType_1.MessageType.DlcTransactions;
128
+ const closeTypeToStr = (closeType) => {
129
+ switch (closeType) {
130
+ case CloseType.ExecuteClose:
131
+ return 'ExecuteClose';
132
+ case CloseType.RefundClose:
133
+ return 'RefundClose';
134
+ case CloseType.CooperativeClose:
135
+ return 'CooperativeClose';
136
+ default:
137
+ return 'NotClosed';
138
+ }
139
+ };
140
+ var CloseType;
141
+ (function (CloseType) {
142
+ CloseType[CloseType["NotClosed"] = 0] = "NotClosed";
143
+ CloseType[CloseType["ExecuteClose"] = 1] = "ExecuteClose";
144
+ CloseType[CloseType["RefundClose"] = 2] = "RefundClose";
145
+ CloseType[CloseType["CooperativeClose"] = 3] = "CooperativeClose";
146
+ })(CloseType = exports.CloseType || (exports.CloseType = {}));
147
+ // Backward compatibility aliases
148
+ exports.DlcTransactionsV0 = DlcTransactions;
149
+ //# sourceMappingURL=DlcTransactions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DlcTransactions.js","sourceRoot":"","sources":["../../lib/messages/DlcTransactions.ts"],"names":[],"mappings":";;;AAAA,+CAAuC;AACvC,2CAA2E;AAE3E,gDAA6C;AAG7C;;;GAGG;AACH,MAAa,eAAe;IAA5B;QAgEE;;WAEG;QACI,SAAI,GAAG,eAAe,CAAC,IAAI,CAAC;QAQ5B,cAAS,GAAe;YAC7B,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YACtB,MAAM,EAAE,CAAC;SACV,CAAC;QAEK,wBAAmB,GAAG,CAAC,CAAC;QAIxB,SAAI,GAAS,EAAE,CAAC;QAEhB,eAAU,GAAe;YAC9B,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YACtB,MAAM,EAAE,CAAC;SACV,CAAC;QAEK,g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C;KACtB;AACH,CAAC,CAAC;AA2BF,IAAY,SAKX;AALD,WAAY,SAAS;IACnB,mDAAa,CAAA;IACb,yDAAgB,CAAA;IAChB,uDAAe,CAAA;IACf,iEAAoB,CAAA;AACtB,CAAC,EALW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAKpB;AAED,iCAAiC;AACpB,QAAA,iBAAiB,GAAG,eAAe,CAAC"}
@@ -0,0 +1,106 @@
1
+ /// <reference types="node" />
2
+ import { MessageType } from '../MessageType';
3
+ import { IDlcMessage } from './DlcMessage';
4
+ export declare abstract class EventDescriptor {
5
+ static deserialize(buf: Buffer): EnumEventDescriptor | DigitDecompositionEventDescriptor;
6
+ /**
7
+ * Creates an EventDescriptor from JSON data
8
+ * @param json JSON object representing event descriptor
9
+ */
10
+ static fromJSON(json: any): EventDescriptor;
11
+ abstract type: number;
12
+ abstract length: bigint;
13
+ abstract toJSON(): IEnumEventDescriptorJSON | IDigitDecompositionEventDescriptorJSON;
14
+ abstract serialize(): Buffer;
15
+ }
16
+ /**
17
+ * EnumEventDescriptor message contains the event outcomes for enumerated events.
18
+ * Simplified class name (removed V0 suffix).
19
+ */
20
+ export declare class EnumEventDescriptor extends EventDescriptor implements IDlcMessage {
21
+ static type: MessageType;
22
+ /**
23
+ * Creates an EnumEventDescriptor from JSON data
24
+ * @param json JSON object representing an enum event descriptor
25
+ */
26
+ static fromJSON(json: any): EnumEventDescriptor;
27
+ /**
28
+ * Deserializes an enum_event_descriptor_v0 message
29
+ * @param buf
30
+ */
31
+ static deserialize(buf: Buffer): EnumEventDescriptor;
32
+ /**
33
+ * The type for enum_event_descriptor_v0 message. enum_event_descriptor_v0 = 55302
34
+ */
35
+ type: MessageType;
36
+ length: bigint;
37
+ outcomes: string[];
38
+ /**
39
+ * Converts enum_event_descriptor to JSON
40
+ */
41
+ toJSON(): IEnumEventDescriptorJSON;
42
+ /**
43
+ * Serializes the enum_event_descriptor_v0 message into a Buffer
44
+ */
45
+ serialize(): Buffer;
46
+ }
47
+ export declare const EnumEventDescriptorV0: typeof EnumEventDescriptor;
48
+ export type EnumEventDescriptorV0 = EnumEventDescriptor;
49
+ /**
50
+ * DigitDecompositionEventDescriptor is a simple enumeration of outcomes.
51
+ * Simplified class name (removed V0 suffix).
52
+ */
53
+ export declare class DigitDecompositionEventDescriptor extends EventDescriptor implements IDlcMessage {
54
+ static type: MessageType;
55
+ /**
56
+ * Creates a DigitDecompositionEventDescriptor from JSON data
57
+ * @param json JSON object representing digit decomposition event descriptor
58
+ */
59
+ static fromJSON(json: any): DigitDecompositionEventDescriptor;
60
+ /**
61
+ * Deserializes an digit_decomposition_event_descriptor message
62
+ * @param buf
63
+ */
64
+ static deserialize(buf: Buffer): DigitDecompositionEventDescriptor;
65
+ /**
66
+ * The type for digit_decomposition_event_descriptor message. digit_decomposition_event_descriptor = 55306
67
+ */
68
+ type: MessageType;
69
+ length: bigint;
70
+ base: number;
71
+ isSigned: boolean;
72
+ unit: string;
73
+ precision: number;
74
+ nbDigits: number;
75
+ /**
76
+ * Validates correctness of all fields in the message
77
+ * https://github.com/discreetlogcontracts/dlcspecs/blob/master/Oracle.md
78
+ * @throws Will throw an error if validation fails
79
+ */
80
+ validate(): void;
81
+ /**
82
+ * Converts digit_decomposition_event_descriptor to JSON (canonical rust-dlc format)
83
+ */
84
+ toJSON(): IDigitDecompositionEventDescriptorJSON;
85
+ /**
86
+ * Serializes the digit_decomposition_event_descriptor message into a Buffer
87
+ */
88
+ serialize(): Buffer;
89
+ }
90
+ export declare const DigitDecompositionEventDescriptorV0: typeof DigitDecompositionEventDescriptor;
91
+ export type DigitDecompositionEventDescriptorV0 = DigitDecompositionEventDescriptor;
92
+ export interface IEnumEventDescriptorJSON {
93
+ enumEvent: {
94
+ outcomes: string[];
95
+ };
96
+ }
97
+ export interface IDigitDecompositionEventDescriptorJSON {
98
+ type: number;
99
+ base: number;
100
+ isSigned: boolean;
101
+ unit: string;
102
+ precision: number;
103
+ nbDigits: number;
104
+ }
105
+ export type IEnumEventDescriptorV0JSON = IEnumEventDescriptorJSON;
106
+ export type IDigitDecompositionEventDescriptorV0JSON = IDigitDecompositionEventDescriptorJSON;