@atomicfinance/bitcoin-dlc-provider 3.6.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (375) hide show
  1. package/.nvmrc +1 -1
  2. package/.turbo/turbo-build.log +1 -0
  3. package/.turbo/turbo-test.log +0 -0
  4. package/.yalc/@node-dlc/messaging/.nyc_output/2cf48009-1094-4275-bb91-c164c932feb6.json +1 -0
  5. package/.yalc/@node-dlc/messaging/.nyc_output/processinfo/2cf48009-1094-4275-bb91-c164c932feb6.json +1 -0
  6. package/.yalc/@node-dlc/messaging/.nyc_output/processinfo/index.json +1 -0
  7. package/.yalc/@node-dlc/messaging/README.md +24 -0
  8. package/.yalc/@node-dlc/messaging/__tests__/_test-utils.ts +12 -0
  9. package/.yalc/@node-dlc/messaging/__tests__/chain/ChainManager.spec.ts +178 -0
  10. package/.yalc/@node-dlc/messaging/__tests__/compatibility/dlcspecs-compatibility.spec.ts +473 -0
  11. package/.yalc/@node-dlc/messaging/__tests__/compatibility/rust-dlc-cross-language.spec.ts +342 -0
  12. package/.yalc/@node-dlc/messaging/__tests__/compatibility/true-serialization-compatibility.spec.ts +611 -0
  13. package/.yalc/@node-dlc/messaging/__tests__/dlc_message_test.json +155 -0
  14. package/.yalc/@node-dlc/messaging/__tests__/irc/IrcMessage.spec.ts +94 -0
  15. package/.yalc/@node-dlc/messaging/__tests__/messages/AddressCache.spec.ts +79 -0
  16. package/.yalc/@node-dlc/messaging/__tests__/messages/BatchFundingGroup.spec.ts +72 -0
  17. package/.yalc/@node-dlc/messaging/__tests__/messages/CetAdaptorSignatures.spec.ts +57 -0
  18. package/.yalc/@node-dlc/messaging/__tests__/messages/ContractDescriptor.spec.ts +264 -0
  19. package/.yalc/@node-dlc/messaging/__tests__/messages/ContractInfo.spec.ts +419 -0
  20. package/.yalc/@node-dlc/messaging/__tests__/messages/DigitDecompositionEventDescriptor.spec.ts +59 -0
  21. package/.yalc/@node-dlc/messaging/__tests__/messages/DlcAccept.spec.ts +242 -0
  22. package/.yalc/@node-dlc/messaging/__tests__/messages/DlcCancel.spec.ts +42 -0
  23. package/.yalc/@node-dlc/messaging/__tests__/messages/DlcClose.spec.ts +315 -0
  24. package/.yalc/@node-dlc/messaging/__tests__/messages/DlcOffer.spec.ts +527 -0
  25. package/.yalc/@node-dlc/messaging/__tests__/messages/DlcSign.spec.ts +118 -0
  26. package/.yalc/@node-dlc/messaging/__tests__/messages/DlcTransactions.spec.ts +157 -0
  27. package/.yalc/@node-dlc/messaging/__tests__/messages/EnumEventDescriptor.spec.ts +50 -0
  28. package/.yalc/@node-dlc/messaging/__tests__/messages/EventDescriptor.spec.ts +93 -0
  29. package/.yalc/@node-dlc/messaging/__tests__/messages/FundingInput.spec.ts +84 -0
  30. package/.yalc/@node-dlc/messaging/__tests__/messages/FundingSignatures.spec.ts +83 -0
  31. package/.yalc/@node-dlc/messaging/__tests__/messages/NegotiationFields.spec.ts +328 -0
  32. package/.yalc/@node-dlc/messaging/__tests__/messages/NodeAnnouncementMessage.spec.ts +115 -0
  33. package/.yalc/@node-dlc/messaging/__tests__/messages/OracleAnnouncement.spec.ts +415 -0
  34. package/.yalc/@node-dlc/messaging/__tests__/messages/OracleAttestation.spec.ts +326 -0
  35. package/.yalc/@node-dlc/messaging/__tests__/messages/OracleEvent.spec.ts +143 -0
  36. package/.yalc/@node-dlc/messaging/__tests__/messages/OracleEventContainer.spec.ts +95 -0
  37. package/.yalc/@node-dlc/messaging/__tests__/messages/OracleIdentifier.spec.ts +48 -0
  38. package/.yalc/@node-dlc/messaging/__tests__/messages/OracleInfo.spec.ts +116 -0
  39. package/.yalc/@node-dlc/messaging/__tests__/messages/OrderAccept.spec.ts +77 -0
  40. package/.yalc/@node-dlc/messaging/__tests__/messages/OrderNegotiationFields.spec.ts +216 -0
  41. package/.yalc/@node-dlc/messaging/__tests__/messages/OrderOffer.spec.ts +121 -0
  42. package/.yalc/@node-dlc/messaging/__tests__/messages/OrderPositionInfo.spec.ts +75 -0
  43. package/.yalc/@node-dlc/messaging/__tests__/messages/PayoutCurvePiece.spec.ts +220 -0
  44. package/.yalc/@node-dlc/messaging/__tests__/messages/PayoutFunction.spec.ts +101 -0
  45. package/.yalc/@node-dlc/messaging/__tests__/messages/RoundingIntervals.spec.ts +75 -0
  46. package/.yalc/@node-dlc/messaging/__tests__/serialize/F64.spec.ts +260 -0
  47. package/.yalc/@node-dlc/messaging/__tests__/tsconfig.json +8 -0
  48. package/.yalc/@node-dlc/messaging/coverage/lcov-report/base.css +224 -0
  49. package/.yalc/@node-dlc/messaging/coverage/lcov-report/block-navigation.js +79 -0
  50. package/.yalc/@node-dlc/messaging/coverage/lcov-report/favicon.png +0 -0
  51. package/.yalc/@node-dlc/messaging/coverage/lcov-report/index.html +201 -0
  52. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/MessageType.ts.html +494 -0
  53. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/chain/ChainManager.ts.html +1058 -0
  54. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/chain/ChainMemoryStore.ts.html +182 -0
  55. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/chain/index.html +126 -0
  56. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/domain/Address.ts.html +272 -0
  57. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/domain/index.html +111 -0
  58. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/index.html +141 -0
  59. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/index.ts.html +212 -0
  60. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/irc/IrcMessage.ts.html +563 -0
  61. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/irc/index.html +111 -0
  62. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/AddressCache.ts.html +302 -0
  63. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/BatchFundingGroup.ts.html +503 -0
  64. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/CetAdaptorSignatures.ts.html +347 -0
  65. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/CetAdaptorSignaturesV0.ts.html +347 -0
  66. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/ContractDescriptor.ts.html +1040 -0
  67. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/ContractInfo.ts.html +1382 -0
  68. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/DlcAccept.ts.html +1865 -0
  69. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/DlcCancel.ts.html +251 -0
  70. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/DlcClose.ts.html +986 -0
  71. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/DlcCloseMetadata.ts.html +443 -0
  72. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/DlcIds.ts.html +281 -0
  73. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/DlcInfo.ts.html +323 -0
  74. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/DlcMessage.ts.html +341 -0
  75. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/DlcOffer.ts.html +1895 -0
  76. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/DlcSign.ts.html +1142 -0
  77. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/DlcTransactions.ts.html +719 -0
  78. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/EventDescriptor.ts.html +947 -0
  79. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/FundingInput.ts.html +728 -0
  80. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/FundingSignatures.ts.html +374 -0
  81. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/FundingSignaturesV0.ts.html +374 -0
  82. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/NegotiationFields.ts.html +836 -0
  83. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/NodeAnnouncementMessage.ts.html +515 -0
  84. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleAnnouncement.ts.html +608 -0
  85. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleAnnouncementV0.ts.html +605 -0
  86. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleAttestation.ts.html +956 -0
  87. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleAttestationV0.ts.html +770 -0
  88. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleEvent.ts.html +830 -0
  89. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleEventContainer.ts.html +347 -0
  90. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleEventContainerV0.ts.html +347 -0
  91. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleEventV0.ts.html +827 -0
  92. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleIdentifier.ts.html +314 -0
  93. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleIdentifierV0.ts.html +314 -0
  94. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleInfo.ts.html +1637 -0
  95. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleInfoV0.ts.html +1631 -0
  96. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OrderAccept.ts.html +557 -0
  97. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OrderIrcInfo.ts.html +380 -0
  98. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OrderMetadata.ts.html +437 -0
  99. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OrderNegotiationFields.ts.html +551 -0
  100. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OrderOffer.ts.html +1337 -0
  101. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OrderPositionInfo.ts.html +590 -0
  102. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/PayoutCurvePiece.ts.html +1427 -0
  103. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/PayoutFunction.ts.html +800 -0
  104. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/RoundingIntervals.ts.html +461 -0
  105. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/RoundingIntervalsV0.ts.html +482 -0
  106. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/ScriptWitnessV0.ts.html +269 -0
  107. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/index.html +636 -0
  108. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/serde/SerdeUtils.ts.html +1394 -0
  109. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/serde/index.html +111 -0
  110. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/serialize/F64.ts.html +1136 -0
  111. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/serialize/deserializeTlv.ts.html +125 -0
  112. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/serialize/getTlv.ts.html +143 -0
  113. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/serialize/index.html +141 -0
  114. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/util.ts.html +179 -0
  115. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/validation/index.html +111 -0
  116. package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/validation/validate.ts.html +182 -0
  117. package/.yalc/@node-dlc/messaging/coverage/lcov-report/prettify.css +1 -0
  118. package/.yalc/@node-dlc/messaging/coverage/lcov-report/prettify.js +2 -0
  119. package/.yalc/@node-dlc/messaging/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  120. package/.yalc/@node-dlc/messaging/coverage/lcov-report/sorter.js +170 -0
  121. package/.yalc/@node-dlc/messaging/coverage/lcov.info +5394 -0
  122. package/.yalc/@node-dlc/messaging/dist/MessageType.d.ts +100 -0
  123. package/.yalc/@node-dlc/messaging/dist/MessageType.js +117 -0
  124. package/.yalc/@node-dlc/messaging/dist/MessageType.js.map +1 -0
  125. package/.yalc/@node-dlc/messaging/dist/chain/ChainManager.d.ts +50 -0
  126. package/.yalc/@node-dlc/messaging/dist/chain/ChainManager.js +211 -0
  127. package/.yalc/@node-dlc/messaging/dist/chain/ChainManager.js.map +1 -0
  128. package/.yalc/@node-dlc/messaging/dist/chain/ChainMemoryStore.d.ts +14 -0
  129. package/.yalc/@node-dlc/messaging/dist/chain/ChainMemoryStore.js +28 -0
  130. package/.yalc/@node-dlc/messaging/dist/chain/ChainMemoryStore.js.map +1 -0
  131. package/.yalc/@node-dlc/messaging/dist/chain/DlcStore.d.ts +11 -0
  132. package/.yalc/@node-dlc/messaging/dist/chain/DlcStore.js +3 -0
  133. package/.yalc/@node-dlc/messaging/dist/chain/DlcStore.js.map +1 -0
  134. package/.yalc/@node-dlc/messaging/dist/chain/IChainFilterChainClient.d.ts +48 -0
  135. package/.yalc/@node-dlc/messaging/dist/chain/IChainFilterChainClient.js +3 -0
  136. package/.yalc/@node-dlc/messaging/dist/chain/IChainFilterChainClient.js.map +1 -0
  137. package/.yalc/@node-dlc/messaging/dist/domain/Address.d.ts +24 -0
  138. package/.yalc/@node-dlc/messaging/dist/domain/Address.js +46 -0
  139. package/.yalc/@node-dlc/messaging/dist/domain/Address.js.map +1 -0
  140. package/.yalc/@node-dlc/messaging/dist/index.d.ts +44 -0
  141. package/.yalc/@node-dlc/messaging/dist/index.js +63 -0
  142. package/.yalc/@node-dlc/messaging/dist/index.js.map +1 -0
  143. package/.yalc/@node-dlc/messaging/dist/irc/IrcMessage.d.ts +43 -0
  144. package/.yalc/@node-dlc/messaging/dist/irc/IrcMessage.js +116 -0
  145. package/.yalc/@node-dlc/messaging/dist/irc/IrcMessage.js.map +1 -0
  146. package/.yalc/@node-dlc/messaging/dist/messages/AddressCache.d.ts +15 -0
  147. package/.yalc/@node-dlc/messaging/dist/messages/AddressCache.js +51 -0
  148. package/.yalc/@node-dlc/messaging/dist/messages/AddressCache.js.map +1 -0
  149. package/.yalc/@node-dlc/messaging/dist/messages/BatchFundingGroup.d.ts +61 -0
  150. package/.yalc/@node-dlc/messaging/dist/messages/BatchFundingGroup.js +113 -0
  151. package/.yalc/@node-dlc/messaging/dist/messages/BatchFundingGroup.js.map +1 -0
  152. package/.yalc/@node-dlc/messaging/dist/messages/CetAdaptorSignatures.d.ts +40 -0
  153. package/.yalc/@node-dlc/messaging/dist/messages/CetAdaptorSignatures.js +67 -0
  154. package/.yalc/@node-dlc/messaging/dist/messages/CetAdaptorSignatures.js.map +1 -0
  155. package/.yalc/@node-dlc/messaging/dist/messages/ContractDescriptor.d.ts +122 -0
  156. package/.yalc/@node-dlc/messaging/dist/messages/ContractDescriptor.js +222 -0
  157. package/.yalc/@node-dlc/messaging/dist/messages/ContractDescriptor.js.map +1 -0
  158. package/.yalc/@node-dlc/messaging/dist/messages/ContractInfo.d.ts +135 -0
  159. package/.yalc/@node-dlc/messaging/dist/messages/ContractInfo.js +304 -0
  160. package/.yalc/@node-dlc/messaging/dist/messages/ContractInfo.js.map +1 -0
  161. package/.yalc/@node-dlc/messaging/dist/messages/DlcAccept.d.ts +145 -0
  162. package/.yalc/@node-dlc/messaging/dist/messages/DlcAccept.js +428 -0
  163. package/.yalc/@node-dlc/messaging/dist/messages/DlcAccept.js.map +1 -0
  164. package/.yalc/@node-dlc/messaging/dist/messages/DlcCancel.d.ts +31 -0
  165. package/.yalc/@node-dlc/messaging/dist/messages/DlcCancel.js +51 -0
  166. package/.yalc/@node-dlc/messaging/dist/messages/DlcCancel.js.map +1 -0
  167. package/.yalc/@node-dlc/messaging/dist/messages/DlcClose.d.ts +68 -0
  168. package/.yalc/@node-dlc/messaging/dist/messages/DlcClose.js +210 -0
  169. package/.yalc/@node-dlc/messaging/dist/messages/DlcClose.js.map +1 -0
  170. package/.yalc/@node-dlc/messaging/dist/messages/DlcCloseMetadata.d.ts +44 -0
  171. package/.yalc/@node-dlc/messaging/dist/messages/DlcCloseMetadata.js +74 -0
  172. package/.yalc/@node-dlc/messaging/dist/messages/DlcCloseMetadata.js.map +1 -0
  173. package/.yalc/@node-dlc/messaging/dist/messages/DlcIds.d.ts +26 -0
  174. package/.yalc/@node-dlc/messaging/dist/messages/DlcIds.js +58 -0
  175. package/.yalc/@node-dlc/messaging/dist/messages/DlcIds.js.map +1 -0
  176. package/.yalc/@node-dlc/messaging/dist/messages/DlcInfo.d.ts +31 -0
  177. package/.yalc/@node-dlc/messaging/dist/messages/DlcInfo.js +61 -0
  178. package/.yalc/@node-dlc/messaging/dist/messages/DlcInfo.js.map +1 -0
  179. package/.yalc/@node-dlc/messaging/dist/messages/DlcMessage.d.ts +23 -0
  180. package/.yalc/@node-dlc/messaging/dist/messages/DlcMessage.js +54 -0
  181. package/.yalc/@node-dlc/messaging/dist/messages/DlcMessage.js.map +1 -0
  182. package/.yalc/@node-dlc/messaging/dist/messages/DlcOffer.d.ts +131 -0
  183. package/.yalc/@node-dlc/messaging/dist/messages/DlcOffer.js +418 -0
  184. package/.yalc/@node-dlc/messaging/dist/messages/DlcOffer.js.map +1 -0
  185. package/.yalc/@node-dlc/messaging/dist/messages/DlcSign.d.ts +96 -0
  186. package/.yalc/@node-dlc/messaging/dist/messages/DlcSign.js +267 -0
  187. package/.yalc/@node-dlc/messaging/dist/messages/DlcSign.js.map +1 -0
  188. package/.yalc/@node-dlc/messaging/dist/messages/DlcTransactions.d.ts +69 -0
  189. package/.yalc/@node-dlc/messaging/dist/messages/DlcTransactions.js +149 -0
  190. package/.yalc/@node-dlc/messaging/dist/messages/DlcTransactions.js.map +1 -0
  191. package/.yalc/@node-dlc/messaging/dist/messages/EventDescriptor.d.ts +106 -0
  192. package/.yalc/@node-dlc/messaging/dist/messages/EventDescriptor.js +209 -0
  193. package/.yalc/@node-dlc/messaging/dist/messages/EventDescriptor.js.map +1 -0
  194. package/.yalc/@node-dlc/messaging/dist/messages/FundingInput.d.ts +62 -0
  195. package/.yalc/@node-dlc/messaging/dist/messages/FundingInput.js +163 -0
  196. package/.yalc/@node-dlc/messaging/dist/messages/FundingInput.js.map +1 -0
  197. package/.yalc/@node-dlc/messaging/dist/messages/FundingSignatures.d.ts +36 -0
  198. package/.yalc/@node-dlc/messaging/dist/messages/FundingSignatures.js +78 -0
  199. package/.yalc/@node-dlc/messaging/dist/messages/FundingSignatures.js.map +1 -0
  200. package/.yalc/@node-dlc/messaging/dist/messages/IWireMessage.d.ts +6 -0
  201. package/.yalc/@node-dlc/messaging/dist/messages/IWireMessage.js +3 -0
  202. package/.yalc/@node-dlc/messaging/dist/messages/IWireMessage.js.map +1 -0
  203. package/.yalc/@node-dlc/messaging/dist/messages/NegotiationFields.d.ts +86 -0
  204. package/.yalc/@node-dlc/messaging/dist/messages/NegotiationFields.js +185 -0
  205. package/.yalc/@node-dlc/messaging/dist/messages/NegotiationFields.js.map +1 -0
  206. package/.yalc/@node-dlc/messaging/dist/messages/NodeAnnouncementMessage.d.ts +57 -0
  207. package/.yalc/@node-dlc/messaging/dist/messages/NodeAnnouncementMessage.js +127 -0
  208. package/.yalc/@node-dlc/messaging/dist/messages/NodeAnnouncementMessage.js.map +1 -0
  209. package/.yalc/@node-dlc/messaging/dist/messages/OracleAnnouncement.d.ts +76 -0
  210. package/.yalc/@node-dlc/messaging/dist/messages/OracleAnnouncement.js +131 -0
  211. package/.yalc/@node-dlc/messaging/dist/messages/OracleAnnouncement.js.map +1 -0
  212. package/.yalc/@node-dlc/messaging/dist/messages/OracleAttestation.d.ts +68 -0
  213. package/.yalc/@node-dlc/messaging/dist/messages/OracleAttestation.js +239 -0
  214. package/.yalc/@node-dlc/messaging/dist/messages/OracleAttestation.js.map +1 -0
  215. package/.yalc/@node-dlc/messaging/dist/messages/OracleEvent.d.ts +90 -0
  216. package/.yalc/@node-dlc/messaging/dist/messages/OracleEvent.js +189 -0
  217. package/.yalc/@node-dlc/messaging/dist/messages/OracleEvent.js.map +1 -0
  218. package/.yalc/@node-dlc/messaging/dist/messages/OracleEventContainer.d.ts +32 -0
  219. package/.yalc/@node-dlc/messaging/dist/messages/OracleEventContainer.js +67 -0
  220. package/.yalc/@node-dlc/messaging/dist/messages/OracleEventContainer.js.map +1 -0
  221. package/.yalc/@node-dlc/messaging/dist/messages/OracleIdentifier.d.ts +32 -0
  222. package/.yalc/@node-dlc/messaging/dist/messages/OracleIdentifier.js +58 -0
  223. package/.yalc/@node-dlc/messaging/dist/messages/OracleIdentifier.js.map +1 -0
  224. package/.yalc/@node-dlc/messaging/dist/messages/OracleIdentifierV0.d.ts +32 -0
  225. package/.yalc/@node-dlc/messaging/dist/messages/OracleIdentifierV0.js +58 -0
  226. package/.yalc/@node-dlc/messaging/dist/messages/OracleIdentifierV0.js.map +1 -0
  227. package/.yalc/@node-dlc/messaging/dist/messages/OracleInfo.d.ts +161 -0
  228. package/.yalc/@node-dlc/messaging/dist/messages/OracleInfo.js +390 -0
  229. package/.yalc/@node-dlc/messaging/dist/messages/OracleInfo.js.map +1 -0
  230. package/.yalc/@node-dlc/messaging/dist/messages/OracleInfoV0.d.ts +161 -0
  231. package/.yalc/@node-dlc/messaging/dist/messages/OracleInfoV0.js +387 -0
  232. package/.yalc/@node-dlc/messaging/dist/messages/OracleInfoV0.js.map +1 -0
  233. package/.yalc/@node-dlc/messaging/dist/messages/OrderAccept.d.ts +65 -0
  234. package/.yalc/@node-dlc/messaging/dist/messages/OrderAccept.js +125 -0
  235. package/.yalc/@node-dlc/messaging/dist/messages/OrderAccept.js.map +1 -0
  236. package/.yalc/@node-dlc/messaging/dist/messages/OrderIrcInfo.d.ts +42 -0
  237. package/.yalc/@node-dlc/messaging/dist/messages/OrderIrcInfo.js +74 -0
  238. package/.yalc/@node-dlc/messaging/dist/messages/OrderIrcInfo.js.map +1 -0
  239. package/.yalc/@node-dlc/messaging/dist/messages/OrderMetadata.d.ts +56 -0
  240. package/.yalc/@node-dlc/messaging/dist/messages/OrderMetadata.js +87 -0
  241. package/.yalc/@node-dlc/messaging/dist/messages/OrderMetadata.js.map +1 -0
  242. package/.yalc/@node-dlc/messaging/dist/messages/OrderNegotiationFields.d.ts +69 -0
  243. package/.yalc/@node-dlc/messaging/dist/messages/OrderNegotiationFields.js +114 -0
  244. package/.yalc/@node-dlc/messaging/dist/messages/OrderNegotiationFields.js.map +1 -0
  245. package/.yalc/@node-dlc/messaging/dist/messages/OrderOffer.d.ts +97 -0
  246. package/.yalc/@node-dlc/messaging/dist/messages/OrderOffer.js +296 -0
  247. package/.yalc/@node-dlc/messaging/dist/messages/OrderOffer.js.map +1 -0
  248. package/.yalc/@node-dlc/messaging/dist/messages/OrderPositionInfo.d.ts +50 -0
  249. package/.yalc/@node-dlc/messaging/dist/messages/OrderPositionInfo.js +125 -0
  250. package/.yalc/@node-dlc/messaging/dist/messages/OrderPositionInfo.js.map +1 -0
  251. package/.yalc/@node-dlc/messaging/dist/messages/PayoutCurvePiece.d.ts +129 -0
  252. package/.yalc/@node-dlc/messaging/dist/messages/PayoutCurvePiece.js +327 -0
  253. package/.yalc/@node-dlc/messaging/dist/messages/PayoutCurvePiece.js.map +1 -0
  254. package/.yalc/@node-dlc/messaging/dist/messages/PayoutFunction.d.ts +66 -0
  255. package/.yalc/@node-dlc/messaging/dist/messages/PayoutFunction.js +170 -0
  256. package/.yalc/@node-dlc/messaging/dist/messages/PayoutFunction.js.map +1 -0
  257. package/.yalc/@node-dlc/messaging/dist/messages/RoundingIntervals.d.ts +52 -0
  258. package/.yalc/@node-dlc/messaging/dist/messages/RoundingIntervals.js +95 -0
  259. package/.yalc/@node-dlc/messaging/dist/messages/RoundingIntervals.js.map +1 -0
  260. package/.yalc/@node-dlc/messaging/dist/messages/ScriptWitnessV0.d.ts +29 -0
  261. package/.yalc/@node-dlc/messaging/dist/messages/ScriptWitnessV0.js +50 -0
  262. package/.yalc/@node-dlc/messaging/dist/messages/ScriptWitnessV0.js.map +1 -0
  263. package/.yalc/@node-dlc/messaging/dist/messages/Tlv.d.ts +15 -0
  264. package/.yalc/@node-dlc/messaging/dist/messages/Tlv.js +32 -0
  265. package/.yalc/@node-dlc/messaging/dist/messages/Tlv.js.map +1 -0
  266. package/.yalc/@node-dlc/messaging/dist/serialize/F64.d.ts +154 -0
  267. package/.yalc/@node-dlc/messaging/dist/serialize/F64.js +307 -0
  268. package/.yalc/@node-dlc/messaging/dist/serialize/F64.js.map +1 -0
  269. package/.yalc/@node-dlc/messaging/dist/serialize/deserializeTlv.d.ts +9 -0
  270. package/.yalc/@node-dlc/messaging/dist/serialize/deserializeTlv.js +11 -0
  271. package/.yalc/@node-dlc/messaging/dist/serialize/deserializeTlv.js.map +1 -0
  272. package/.yalc/@node-dlc/messaging/dist/serialize/getTlv.d.ts +4 -0
  273. package/.yalc/@node-dlc/messaging/dist/serialize/getTlv.js +23 -0
  274. package/.yalc/@node-dlc/messaging/dist/serialize/getTlv.js.map +1 -0
  275. package/.yalc/@node-dlc/messaging/dist/serialize/readTlvs.d.ts +8 -0
  276. package/.yalc/@node-dlc/messaging/dist/serialize/readTlvs.js +33 -0
  277. package/.yalc/@node-dlc/messaging/dist/serialize/readTlvs.js.map +1 -0
  278. package/.yalc/@node-dlc/messaging/dist/util.d.ts +13 -0
  279. package/.yalc/@node-dlc/messaging/dist/util.js +40 -0
  280. package/.yalc/@node-dlc/messaging/dist/util.js.map +1 -0
  281. package/.yalc/@node-dlc/messaging/dist/validation/validate.d.ts +4 -0
  282. package/.yalc/@node-dlc/messaging/dist/validation/validate.js +31 -0
  283. package/.yalc/@node-dlc/messaging/dist/validation/validate.js.map +1 -0
  284. package/.yalc/@node-dlc/messaging/lib/MessageType.ts +138 -0
  285. package/.yalc/@node-dlc/messaging/lib/chain/ChainManager.ts +326 -0
  286. package/.yalc/@node-dlc/messaging/lib/chain/ChainMemoryStore.ts +34 -0
  287. package/.yalc/@node-dlc/messaging/lib/chain/DlcStore.ts +11 -0
  288. package/.yalc/@node-dlc/messaging/lib/chain/IChainFilterChainClient.ts +57 -0
  289. package/.yalc/@node-dlc/messaging/lib/domain/Address.ts +64 -0
  290. package/.yalc/@node-dlc/messaging/lib/index.ts +44 -0
  291. package/.yalc/@node-dlc/messaging/lib/irc/IrcMessage.ts +161 -0
  292. package/.yalc/@node-dlc/messaging/lib/messages/AddressCache.ts +74 -0
  293. package/.yalc/@node-dlc/messaging/lib/messages/BatchFundingGroup.ts +141 -0
  294. package/.yalc/@node-dlc/messaging/lib/messages/CetAdaptorSignatures.ts +89 -0
  295. package/.yalc/@node-dlc/messaging/lib/messages/ContractDescriptor.ts +318 -0
  296. package/.yalc/@node-dlc/messaging/lib/messages/ContractInfo.ts +434 -0
  297. package/.yalc/@node-dlc/messaging/lib/messages/DlcAccept.ts +595 -0
  298. package/.yalc/@node-dlc/messaging/lib/messages/DlcCancel.ts +57 -0
  299. package/.yalc/@node-dlc/messaging/lib/messages/DlcClose.ts +302 -0
  300. package/.yalc/@node-dlc/messaging/lib/messages/DlcCloseMetadata.ts +121 -0
  301. package/.yalc/@node-dlc/messaging/lib/messages/DlcIds.ts +67 -0
  302. package/.yalc/@node-dlc/messaging/lib/messages/DlcInfo.ts +81 -0
  303. package/.yalc/@node-dlc/messaging/lib/messages/DlcMessage.ts +87 -0
  304. package/.yalc/@node-dlc/messaging/lib/messages/DlcOffer.ts +605 -0
  305. package/.yalc/@node-dlc/messaging/lib/messages/DlcSign.ts +354 -0
  306. package/.yalc/@node-dlc/messaging/lib/messages/DlcTransactions.ts +213 -0
  307. package/.yalc/@node-dlc/messaging/lib/messages/EventDescriptor.ts +289 -0
  308. package/.yalc/@node-dlc/messaging/lib/messages/FundingInput.ts +216 -0
  309. package/.yalc/@node-dlc/messaging/lib/messages/FundingSignatures.ts +98 -0
  310. package/.yalc/@node-dlc/messaging/lib/messages/IWireMessage.ts +6 -0
  311. package/.yalc/@node-dlc/messaging/lib/messages/NegotiationFields.ts +252 -0
  312. package/.yalc/@node-dlc/messaging/lib/messages/NodeAnnouncementMessage.ts +145 -0
  313. package/.yalc/@node-dlc/messaging/lib/messages/OracleAnnouncement.ts +176 -0
  314. package/.yalc/@node-dlc/messaging/lib/messages/OracleAttestation.ts +292 -0
  315. package/.yalc/@node-dlc/messaging/lib/messages/OracleEvent.ts +250 -0
  316. package/.yalc/@node-dlc/messaging/lib/messages/OracleEventContainer.ts +89 -0
  317. package/.yalc/@node-dlc/messaging/lib/messages/OracleIdentifier.ts +78 -0
  318. package/.yalc/@node-dlc/messaging/lib/messages/OracleInfo.ts +519 -0
  319. package/.yalc/@node-dlc/messaging/lib/messages/OrderAccept.ts +159 -0
  320. package/.yalc/@node-dlc/messaging/lib/messages/OrderIrcInfo.ts +100 -0
  321. package/.yalc/@node-dlc/messaging/lib/messages/OrderMetadata.ts +119 -0
  322. package/.yalc/@node-dlc/messaging/lib/messages/OrderNegotiationFields.ts +157 -0
  323. package/.yalc/@node-dlc/messaging/lib/messages/OrderOffer.ts +419 -0
  324. package/.yalc/@node-dlc/messaging/lib/messages/OrderPositionInfo.ts +170 -0
  325. package/.yalc/@node-dlc/messaging/lib/messages/PayoutCurvePiece.ts +449 -0
  326. package/.yalc/@node-dlc/messaging/lib/messages/PayoutFunction.ts +240 -0
  327. package/.yalc/@node-dlc/messaging/lib/messages/RoundingIntervals.ts +127 -0
  328. package/.yalc/@node-dlc/messaging/lib/messages/ScriptWitnessV0.ts +63 -0
  329. package/.yalc/@node-dlc/messaging/lib/messages/Tlv.ts +40 -0
  330. package/.yalc/@node-dlc/messaging/lib/serialize/F64.ts +352 -0
  331. package/.yalc/@node-dlc/messaging/lib/serialize/deserializeTlv.ts +15 -0
  332. package/.yalc/@node-dlc/messaging/lib/serialize/getTlv.ts +21 -0
  333. package/.yalc/@node-dlc/messaging/lib/serialize/readTlvs.ts +37 -0
  334. package/.yalc/@node-dlc/messaging/lib/util.ts +33 -0
  335. package/.yalc/@node-dlc/messaging/lib/validation/validate.ts +34 -0
  336. package/.yalc/@node-dlc/messaging/package.json +42 -0
  337. package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/enum_3_of_3_test.json +210 -0
  338. package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/enum_3_of_5_test.json +468 -0
  339. package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/enum_and_numerical_3_of_5_test.json +1517 -0
  340. package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/enum_and_numerical_5_of_5_test.json +545 -0
  341. package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/enum_and_numerical_with_diff_3_of_5_test.json +4761 -0
  342. package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/enum_and_numerical_with_diff_5_of_5_test.json +2169 -0
  343. package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/enum_single_oracle_test.json +164 -0
  344. package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/single_oracle_numerical_hyperbola_test.json +502 -0
  345. package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/single_oracle_numerical_test.json +262 -0
  346. package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/three_of_five_oracle_numerical_with_diff_test.json +4382 -0
  347. package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/three_of_three_oracle_numerical_test.json +324 -0
  348. package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/three_of_three_oracle_numerical_with_diff_test.json +652 -0
  349. package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/two_of_five_oracle_numerical_test.json +1138 -0
  350. package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/two_of_five_oracle_numerical_with_diff_test.json +2222 -0
  351. package/.yalc/@node-dlc/messaging/test_vectors/oracle/external_oracle_announcements.json +0 -0
  352. package/.yalc/@node-dlc/messaging/test_vectors/oracle/oracle_message_test_vectors.json +115 -0
  353. package/.yalc/@node-dlc/messaging/test_vectors/rust-dlc/accept_msg.json +1465 -0
  354. package/.yalc/@node-dlc/messaging/test_vectors/rust-dlc/dlc_fee_test.json +12362 -0
  355. package/.yalc/@node-dlc/messaging/test_vectors/rust-dlc/dlc_fee_test_scripts.json +57 -0
  356. package/.yalc/@node-dlc/messaging/test_vectors/rust-dlc/dlc_test.json +2766 -0
  357. package/.yalc/@node-dlc/messaging/test_vectors/rust-dlc/dlc_tx_test.json +2899 -0
  358. package/.yalc/@node-dlc/messaging/test_vectors/rust-dlc/offer_msg.json +163 -0
  359. package/.yalc/@node-dlc/messaging/test_vectors/rust-dlc/offer_msg_disjoint.json +352 -0
  360. package/.yalc/@node-dlc/messaging/test_vectors/rust-dlc/segment_chunk_msg.json +12635 -0
  361. package/.yalc/@node-dlc/messaging/test_vectors/rust-dlc/segment_start_msg.json +4022 -0
  362. package/.yalc/@node-dlc/messaging/test_vectors/rust-dlc/sign_msg.json +383 -0
  363. package/.yalc/@node-dlc/messaging/tsconfig.json +7 -0
  364. package/.yalc/@node-dlc/messaging/yalc.sig +1 -0
  365. package/CHANGELOG.md +83 -0
  366. package/dist/BitcoinDlcProvider.d.ts +17 -16
  367. package/dist/BitcoinDlcProvider.js +375 -317
  368. package/dist/BitcoinDlcProvider.js.map +1 -1
  369. package/dist/utils/Utils.d.ts +6 -6
  370. package/dist/utils/Utils.js +4 -4
  371. package/dist/utils/Utils.js.map +1 -1
  372. package/lib/BitcoinDlcProvider.ts +637 -621
  373. package/lib/utils/Utils.ts +19 -24
  374. package/package.json +13 -11
  375. package/yalc.lock +10 -0
@@ -0,0 +1,595 @@
1
+ import { Script, Sequence, Tx } from '@node-dlc/bitcoin';
2
+ import { BufferReader, BufferWriter, StreamReader } from '@node-dlc/bufio';
3
+ import { hash160 } from '@node-dlc/crypto';
4
+ import { BitcoinNetwork } from 'bitcoin-networks';
5
+ import { address } from 'bitcoinjs-lib';
6
+ import secp256k1 from 'secp256k1';
7
+
8
+ import { MessageType, PROTOCOL_VERSION } from '../MessageType';
9
+ import { deserializeTlv } from '../serialize/deserializeTlv';
10
+ import { getTlv, skipTlv } from '../serialize/getTlv';
11
+ import { bigIntToNumber, toBigInt } from '../util';
12
+ import { BatchFundingGroup, IBatchFundingGroupJSON } from './BatchFundingGroup';
13
+ import {
14
+ CetAdaptorSignatures,
15
+ ICetAdaptorSignaturesJSON,
16
+ } from './CetAdaptorSignatures';
17
+ import { IDlcMessage } from './DlcMessage';
18
+ import { FundingInput, IFundingInputJSON } from './FundingInput';
19
+ import {
20
+ INegotiationFieldsV0JSON,
21
+ INegotiationFieldsV1JSON,
22
+ INegotiationFieldsV2JSON,
23
+ NegotiationFields,
24
+ } from './NegotiationFields';
25
+
26
+ /**
27
+ * DlcAccept contains information about a node and indicates its
28
+ * acceptance of the new DLC, as well as its CET and refund
29
+ * transaction signatures. This is the second step toward creating
30
+ * the funding transaction and closing transactions.
31
+ * Updated to support dlcspecs PR #163 format.
32
+ */
33
+ export class DlcAccept implements IDlcMessage {
34
+ public static type = MessageType.DlcAccept;
35
+
36
+ /**
37
+ * Creates a DlcAccept from JSON data (e.g., from test vectors)
38
+ * Handles both our internal format and external test vector formats
39
+ * @param json JSON object representing a DLC accept
40
+ */
41
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
42
+ public static fromJSON(json: any): DlcAccept {
43
+ const instance = new DlcAccept();
44
+
45
+ // Helper function to parse DER-encoded signature and extract raw r,s values (64 bytes total)
46
+ const parseDerSignature = (hexSig: string): Buffer => {
47
+ const sigBuffer = Buffer.from(hexSig, 'hex');
48
+
49
+ // If it's already 64 bytes, assume it's raw
50
+ if (sigBuffer.length === 64) {
51
+ return sigBuffer;
52
+ }
53
+
54
+ // Use secp256k1.signatureImport to parse DER signature
55
+ try {
56
+ const rawSig = secp256k1.signatureImport(sigBuffer);
57
+ return Buffer.from(rawSig);
58
+ } catch (ex) {
59
+ throw new Error(`Invalid DER signature: ${ex.message}`);
60
+ }
61
+ };
62
+
63
+ // Handle both internal and external field naming conventions
64
+ instance.protocolVersion =
65
+ json.protocolVersion || json.protocol_version || PROTOCOL_VERSION;
66
+ instance.temporaryContractId = Buffer.from(
67
+ json.temporaryContractId ||
68
+ json.tempContractId ||
69
+ json.temporary_contract_id,
70
+ 'hex',
71
+ );
72
+
73
+ instance.acceptCollateral = toBigInt(
74
+ json.acceptCollateral ||
75
+ json.acceptCollateralSatoshis ||
76
+ json.accept_collateral,
77
+ );
78
+
79
+ // Handle field name variations between formats
80
+ instance.fundingPubkey = Buffer.from(
81
+ json.fundingPubkey || json.fundingPubKey || json.funding_pubkey,
82
+ 'hex',
83
+ );
84
+ instance.payoutSpk = Buffer.from(
85
+ json.payoutSpk || json.payoutSPK || json.payout_spk,
86
+ 'hex',
87
+ );
88
+ instance.payoutSerialId = toBigInt(
89
+ json.payoutSerialId || json.payout_serial_id,
90
+ );
91
+
92
+ instance.changeSpk = Buffer.from(
93
+ json.changeSpk || json.changeSPK || json.change_spk,
94
+ 'hex',
95
+ );
96
+ instance.changeSerialId = toBigInt(
97
+ json.changeSerialId || json.change_serial_id,
98
+ );
99
+
100
+ // Parse FundingInputs
101
+ instance.fundingInputs = DlcAccept.parseFundingInputsFromJSON(
102
+ json.fundingInputs || json.funding_inputs || [],
103
+ );
104
+
105
+ // Parse CET adaptor signatures
106
+ instance.cetAdaptorSignatures = DlcAccept.parseCetAdaptorSignaturesFromJSON(
107
+ json.cetAdaptorSignatures || json.cet_adaptor_signatures,
108
+ );
109
+
110
+ // Parse refund signature - handle DER encoding
111
+ const refundSigHex = json.refundSignature || json.refund_signature;
112
+ instance.refundSignature = parseDerSignature(refundSigHex);
113
+
114
+ // Parse optional negotiation fields
115
+ if (json.negotiationFields || json.negotiation_fields) {
116
+ instance.negotiationFields = DlcAccept.parseNegotiationFieldsFromJSON(
117
+ json.negotiationFields || json.negotiation_fields,
118
+ );
119
+ }
120
+
121
+ return instance;
122
+ }
123
+
124
+ /**
125
+ * Parses FundingInputs from JSON
126
+ * @param fundingInputsJson Array of JSON objects representing funding inputs
127
+ */
128
+ private static parseFundingInputsFromJSON(
129
+ fundingInputsJson: any[],
130
+ ): FundingInput[] {
131
+ return fundingInputsJson.map((inputJson) => {
132
+ // Use the existing FundingInput.fromJSON method which handles all the field mapping correctly
133
+ return FundingInput.fromJSON(inputJson) as FundingInput;
134
+ });
135
+ }
136
+
137
+ /**
138
+ * Parses CetAdaptorSignatures from JSON
139
+ * @param cetSigsJson JSON object representing CET adaptor signatures
140
+ */
141
+ private static parseCetAdaptorSignaturesFromJSON(
142
+ cetSigsJson: any,
143
+ ): CetAdaptorSignatures {
144
+ const instance = new CetAdaptorSignatures();
145
+
146
+ if (
147
+ cetSigsJson.ecdsaAdaptorSignatures ||
148
+ cetSigsJson.ecdsa_adaptor_signatures
149
+ ) {
150
+ const ecdsaSigs =
151
+ cetSigsJson.ecdsaAdaptorSignatures ||
152
+ cetSigsJson.ecdsa_adaptor_signatures;
153
+ instance.sigs = ecdsaSigs.map((sig: any) => {
154
+ // The test vectors use 'signature' field, but our internal format uses encryptedSig/dleqProof
155
+ // Adaptor signatures have different format than regular ECDSA (65 bytes + 97 bytes)
156
+ const sigBuffer = Buffer.from(sig.signature, 'hex');
157
+ return {
158
+ encryptedSig: sigBuffer.slice(0, 65), // First 65 bytes
159
+ dleqProof:
160
+ sigBuffer.length > 65 ? sigBuffer.slice(65, 162) : Buffer.alloc(97), // Next 97 bytes or empty
161
+ };
162
+ });
163
+ }
164
+
165
+ return instance;
166
+ }
167
+
168
+ /**
169
+ * Parses NegotiationFields from JSON
170
+ * @param negotiationJson JSON object representing negotiation fields
171
+ */
172
+ private static parseNegotiationFieldsFromJSON(
173
+ negotiationJson: any,
174
+ ): NegotiationFields {
175
+ return NegotiationFields.fromJSON(negotiationJson);
176
+ }
177
+
178
+ /**
179
+ * Deserializes an accept_dlc message
180
+ * @param buf
181
+ */
182
+ public static deserialize(buf: Buffer, parseCets = true): DlcAccept {
183
+ const instance = new DlcAccept();
184
+ const reader = new BufferReader(buf);
185
+
186
+ reader.readUInt16BE(); // read type
187
+
188
+ // New fields as per dlcspecs PR #163
189
+ instance.protocolVersion = reader.readUInt32BE();
190
+ instance.temporaryContractId = reader.readBytes(32);
191
+ instance.acceptCollateral = reader.readUInt64BE();
192
+ instance.fundingPubkey = reader.readBytes(33);
193
+ const payoutSpkLen = reader.readUInt16BE();
194
+ instance.payoutSpk = reader.readBytes(payoutSpkLen);
195
+ instance.payoutSerialId = reader.readUInt64BE();
196
+
197
+ // Changed from u16 to bigsize as per dlcspecs PR #163
198
+ const fundingInputsLen = Number(reader.readBigSize());
199
+ for (let i = 0; i < fundingInputsLen; i++) {
200
+ // FundingInput body is serialized directly without TLV wrapper in rust-dlc format
201
+ const fundingInput = FundingInput.deserializeBody(
202
+ reader.buffer.subarray(reader.position),
203
+ );
204
+ instance.fundingInputs.push(fundingInput);
205
+
206
+ // Skip past the FundingInput we just read
207
+ const fundingInputLength = fundingInput.serializeBody().length;
208
+ reader.position += fundingInputLength;
209
+ }
210
+
211
+ const changeSpkLen = reader.readUInt16BE();
212
+ instance.changeSpk = reader.readBytes(changeSpkLen);
213
+ instance.changeSerialId = reader.readUInt64BE();
214
+
215
+ if (parseCets) {
216
+ // Read CET adaptor signatures directly to match serialize format (no TLV wrapping)
217
+ instance.cetAdaptorSignatures = CetAdaptorSignatures.deserialize(
218
+ reader.buffer.subarray(reader.position),
219
+ );
220
+
221
+ // Skip past the CET adaptor signatures we just read
222
+ const cetLength = instance.cetAdaptorSignatures.serialize().length;
223
+ reader.position += cetLength;
224
+ } else {
225
+ instance.cetAdaptorSignatures = new CetAdaptorSignatures();
226
+ }
227
+
228
+ instance.refundSignature = reader.readBytes(64);
229
+
230
+ // negotiation_fields is now optional as per dlcspecs PR #163
231
+ // Check if there's enough data left for the new format fields (backward compatibility)
232
+ // The old format ends exactly after refundSignature. If there's more data, it should be new format.
233
+ const remainingBytes = reader.buffer.length - reader.position;
234
+
235
+ if (remainingBytes > 0) {
236
+ // Only try to parse new fields if we have a reasonable amount of extra data
237
+ // A single stray byte is likely not valid new format data
238
+ if (remainingBytes >= 1) {
239
+ try {
240
+ const hasNegotiationFields = reader.readUInt8();
241
+ if (hasNegotiationFields === 0x01) {
242
+ instance.negotiationFields = NegotiationFields.deserialize(
243
+ getTlv(reader),
244
+ );
245
+ }
246
+
247
+ // Parse TLV stream as per dlcspecs PR #163
248
+ // Only continue if there's still data left after the hasNegotiationFields flag
249
+ while (reader.position < reader.buffer.length) {
250
+ const buf = getTlv(reader);
251
+ const tlvReader = new BufferReader(buf);
252
+ const { type } = deserializeTlv(tlvReader);
253
+
254
+ switch (Number(type)) {
255
+ case MessageType.BatchFundingGroup:
256
+ if (!instance.batchFundingGroups) {
257
+ instance.batchFundingGroups = [];
258
+ }
259
+ instance.batchFundingGroups.push(
260
+ BatchFundingGroup.deserialize(buf),
261
+ );
262
+ break;
263
+ default:
264
+ // Store unknown TLVs for future compatibility
265
+ if (!instance.unknownTlvs) {
266
+ instance.unknownTlvs = [];
267
+ }
268
+ instance.unknownTlvs.push({ type: Number(type), data: buf });
269
+ break;
270
+ }
271
+ }
272
+ } catch (error) {
273
+ // If parsing new format fails, assume it's old format and ignore the extra bytes
274
+ // This provides backward compatibility for malformed or old format data
275
+ // Silently ignore parsing errors for backward compatibility
276
+ }
277
+ }
278
+ }
279
+
280
+ return instance;
281
+ }
282
+
283
+ /**
284
+ * The type for accept_dlc message. accept_dlc = 42780
285
+ */
286
+ public type = DlcAccept.type;
287
+
288
+ // New fields as per dlcspecs PR #163
289
+ public protocolVersion: number = PROTOCOL_VERSION; // Default to current protocol version
290
+
291
+ // Existing fields
292
+ public temporaryContractId: Buffer;
293
+
294
+ public acceptCollateral: bigint;
295
+
296
+ public fundingPubkey: Buffer;
297
+
298
+ public payoutSpk: Buffer;
299
+
300
+ public payoutSerialId: bigint;
301
+
302
+ public fundingInputs: FundingInput[] = [];
303
+
304
+ public changeSpk: Buffer;
305
+
306
+ public changeSerialId: bigint;
307
+
308
+ public cetAdaptorSignatures: CetAdaptorSignatures;
309
+
310
+ public refundSignature: Buffer;
311
+
312
+ // negotiation_fields is now optional
313
+ public negotiationFields?: NegotiationFields;
314
+
315
+ public batchFundingGroups?: BatchFundingGroup[];
316
+
317
+ // Store unknown TLVs for forward compatibility
318
+ public unknownTlvs?: Array<{ type: number; data: Buffer }>;
319
+
320
+ /**
321
+ * Get funding, change and payout address from DlcAccept
322
+ * @param network Bitcoin Network
323
+ * @returns {IDlcAcceptAddresses}
324
+ */
325
+ public getAddresses(network: BitcoinNetwork): IDlcAcceptAddresses {
326
+ const fundingSPK = Script.p2wpkhLock(hash160(this.fundingPubkey))
327
+ .serialize()
328
+ .slice(1);
329
+ const fundingAddress = address.fromOutputScript(fundingSPK, network);
330
+ const changeAddress = address.fromOutputScript(this.changeSpk, network);
331
+ const payoutAddress = address.fromOutputScript(this.payoutSpk, network);
332
+
333
+ return {
334
+ fundingAddress,
335
+ changeAddress,
336
+ payoutAddress,
337
+ };
338
+ }
339
+
340
+ /**
341
+ * Validates correctness of all fields
342
+ * Updated validation rules as per dlcspecs PR #163
343
+ * https://github.com/discreetlogcontracts/dlcspecs/blob/master/Protocol.md#the-accept_dlc-message
344
+ * @throws Will throw an error if validation fails
345
+ */
346
+ public validate(): void {
347
+ // 1. Type is set automatically in class
348
+ // 2. protocol_version validation
349
+ if (this.protocolVersion !== PROTOCOL_VERSION) {
350
+ throw new Error(
351
+ `Unsupported protocol version: ${this.protocolVersion}, expected: ${PROTOCOL_VERSION}`,
352
+ );
353
+ }
354
+
355
+ // 3. temporary_contract_id must match the one from offer_dlc
356
+ if (!this.temporaryContractId || this.temporaryContractId.length !== 32) {
357
+ throw new Error('temporaryContractId must be 32 bytes');
358
+ }
359
+
360
+ // 4. payout_spk and change_spk must be standard script pubkeys
361
+ try {
362
+ address.fromOutputScript(this.payoutSpk);
363
+ } catch (e) {
364
+ throw new Error('payoutSpk is invalid');
365
+ }
366
+
367
+ try {
368
+ address.fromOutputScript(this.changeSpk);
369
+ } catch (e) {
370
+ throw new Error('changeSpk is invalid');
371
+ }
372
+
373
+ // 5. funding_pubkey must be a valid secp256k1 pubkey in compressed format
374
+ // https://github.com/bitcoin/bips/blob/master/bip-0137.mediawiki#background-on-ecdsa-signatures
375
+
376
+ if (secp256k1.publicKeyVerify(Buffer.from(this.fundingPubkey))) {
377
+ if (this.fundingPubkey[0] != 0x02 && this.fundingPubkey[0] != 0x03) {
378
+ throw new Error('fundingPubkey must be in compressed format');
379
+ }
380
+ } else {
381
+ throw new Error('fundingPubkey is not a valid secp256k1 key');
382
+ }
383
+
384
+ // 6. inputSerialId must be unique for each input
385
+ const inputSerialIds = this.fundingInputs.map(
386
+ (input: FundingInput) => input.inputSerialId,
387
+ );
388
+
389
+ if (new Set(inputSerialIds).size !== inputSerialIds.length) {
390
+ throw new Error('inputSerialIds must be unique');
391
+ }
392
+
393
+ // 7. Ensure funding inputs are segwit
394
+ this.fundingInputs.forEach((input: FundingInput) => input.validate());
395
+
396
+ // 8. validate funding amount
397
+ const fundingAmount = this.fundingInputs.reduce((acc, fundingInput) => {
398
+ const input = fundingInput as FundingInput;
399
+ return acc + input.prevTx.outputs[input.prevTxVout].value.sats;
400
+ }, BigInt(0));
401
+ if (this.acceptCollateral >= fundingAmount) {
402
+ throw new Error('fundingAmount must be greater than acceptCollateral');
403
+ }
404
+ }
405
+
406
+ /**
407
+ * Converts accept_dlc to JSON (canonical rust-dlc format)
408
+ */
409
+ public toJSON(): IDlcAcceptJSON {
410
+ // Convert raw signature back to DER format for canonical rust-dlc JSON
411
+ const derRefundSignature = secp256k1.signatureExport(this.refundSignature);
412
+
413
+ return {
414
+ protocolVersion: this.protocolVersion,
415
+ temporaryContractId: this.temporaryContractId.toString('hex'),
416
+ acceptCollateral: bigIntToNumber(this.acceptCollateral),
417
+ fundingPubkey: this.fundingPubkey.toString('hex'), // lowercase 'k'
418
+ payoutSpk: this.payoutSpk.toString('hex'), // lowercase
419
+ payoutSerialId: bigIntToNumber(this.payoutSerialId),
420
+ fundingInputs: this.fundingInputs.map((input) => input.toJSON()),
421
+ changeSpk: this.changeSpk.toString('hex'), // lowercase
422
+ changeSerialId: bigIntToNumber(this.changeSerialId),
423
+ cetAdaptorSignatures: this.cetAdaptorSignatures.toJSON(),
424
+ refundSignature: Buffer.from(derRefundSignature).toString('hex'),
425
+ negotiationFields: this.negotiationFields?.toJSON(),
426
+ };
427
+ }
428
+
429
+ /**
430
+ * Serializes the accept_dlc message into a Buffer
431
+ * Updated serialization format as per dlcspecs PR #163
432
+ */
433
+ public serialize(): Buffer {
434
+ const writer = new BufferWriter();
435
+ writer.writeUInt16BE(this.type);
436
+
437
+ // New fields as per dlcspecs PR #163
438
+ writer.writeUInt32BE(this.protocolVersion);
439
+ writer.writeBytes(this.temporaryContractId);
440
+ writer.writeUInt64BE(this.acceptCollateral);
441
+ writer.writeBytes(this.fundingPubkey);
442
+ writer.writeUInt16BE(this.payoutSpk.length);
443
+ writer.writeBytes(this.payoutSpk);
444
+ writer.writeUInt64BE(this.payoutSerialId);
445
+
446
+ // Changed from u16 to bigsize as per dlcspecs PR #163
447
+ writer.writeBigSize(this.fundingInputs.length);
448
+
449
+ for (const fundingInput of this.fundingInputs) {
450
+ // Use serializeBody() to match rust-dlc behavior - funding inputs in vec are serialized without TLV wrapper
451
+ writer.writeBytes(fundingInput.serializeBody());
452
+ }
453
+
454
+ writer.writeUInt16BE(this.changeSpk.length);
455
+ writer.writeBytes(this.changeSpk);
456
+ writer.writeUInt64BE(this.changeSerialId);
457
+ writer.writeBytes(this.cetAdaptorSignatures.serialize());
458
+ writer.writeBytes(this.refundSignature);
459
+
460
+ // negotiation_fields is now optional as per dlcspecs PR #163
461
+ if (this.negotiationFields) {
462
+ writer.writeUInt8(0x01); // present
463
+ writer.writeBytes(this.negotiationFields.serialize());
464
+ } else {
465
+ writer.writeUInt8(0x00); // absent
466
+ }
467
+
468
+ // TLV stream as per dlcspecs PR #163
469
+ if (this.batchFundingGroups)
470
+ this.batchFundingGroups.forEach((fundingInfo) =>
471
+ writer.writeBytes(fundingInfo.serialize()),
472
+ );
473
+
474
+ // Write unknown TLVs for forward compatibility
475
+ if (this.unknownTlvs) {
476
+ this.unknownTlvs.forEach((tlv) => {
477
+ writer.writeBytes(tlv.data);
478
+ });
479
+ }
480
+
481
+ return writer.toBuffer();
482
+ }
483
+
484
+ public withoutSigs(): DlcAcceptWithoutSigs {
485
+ return new DlcAcceptWithoutSigs(
486
+ this.protocolVersion,
487
+ this.temporaryContractId,
488
+ this.acceptCollateral,
489
+ this.fundingPubkey,
490
+ this.payoutSpk,
491
+ this.payoutSerialId,
492
+ this.fundingInputs,
493
+ this.changeSpk,
494
+ this.changeSerialId,
495
+ this.negotiationFields,
496
+ this.batchFundingGroups,
497
+ );
498
+ }
499
+ }
500
+
501
+ export class DlcAcceptWithoutSigs {
502
+ constructor(
503
+ readonly protocolVersion: number,
504
+ readonly temporaryContractId: Buffer,
505
+ readonly acceptCollateral: bigint,
506
+ readonly fundingPubkey: Buffer,
507
+ readonly payoutSpk: Buffer,
508
+ readonly payoutSerialId: bigint,
509
+ readonly fundingInputs: FundingInput[],
510
+ readonly changeSpk: Buffer,
511
+ readonly changeSerialId: bigint,
512
+ readonly negotiationFields?: NegotiationFields,
513
+ readonly batchFundingGroups?: BatchFundingGroup[],
514
+ ) {}
515
+ }
516
+
517
+ export interface IDlcAcceptJSON {
518
+ protocolVersion: number;
519
+ temporaryContractId: string;
520
+ acceptCollateral: number;
521
+ fundingPubkey: string;
522
+ payoutSpk: string;
523
+ payoutSerialId: number;
524
+ fundingInputs: IFundingInputJSON[];
525
+ changeSpk: string;
526
+ changeSerialId: number;
527
+ cetAdaptorSignatures: ICetAdaptorSignaturesJSON;
528
+ refundSignature: string;
529
+ negotiationFields?: // Now optional
530
+ | INegotiationFieldsV0JSON
531
+ | INegotiationFieldsV1JSON
532
+ | INegotiationFieldsV2JSON;
533
+ }
534
+
535
+ export interface IDlcAcceptAddresses {
536
+ fundingAddress: string;
537
+ changeAddress: string;
538
+ payoutAddress: string;
539
+ }
540
+
541
+ export class DlcAcceptContainer {
542
+ private accepts: DlcAccept[] = [];
543
+
544
+ /**
545
+ * Adds a DlcAccept to the container.
546
+ * @param accept The DlcAccept to add.
547
+ */
548
+ public addAccept(accept: DlcAccept): void {
549
+ this.accepts.push(accept);
550
+ }
551
+
552
+ /**
553
+ * Returns all DlcAccepts in the container.
554
+ * @returns An array of DlcAccept instances.
555
+ */
556
+ public getAccepts(): DlcAccept[] {
557
+ return this.accepts;
558
+ }
559
+
560
+ /**
561
+ * Serializes all DlcAccepts in the container to a Buffer.
562
+ * @returns A Buffer containing the serialized DlcAccepts.
563
+ */
564
+ public serialize(): Buffer {
565
+ const writer = new BufferWriter();
566
+ // Write the number of accepts in the container first.
567
+ writer.writeBigSize(this.accepts.length);
568
+ // Serialize each accept and write it.
569
+ this.accepts.forEach((accept) => {
570
+ const serializedAccept = accept.serialize();
571
+ // Optionally, write the length of the serialized accept for easier deserialization.
572
+ writer.writeBigSize(serializedAccept.length);
573
+ writer.writeBytes(serializedAccept);
574
+ });
575
+ return writer.toBuffer();
576
+ }
577
+
578
+ /**
579
+ * Deserializes a Buffer into a DlcAcceptContainer with DlcAccepts.
580
+ * @param buf The Buffer to deserialize.
581
+ * @returns A DlcAcceptContainer instance.
582
+ */
583
+ public static deserialize(buf: Buffer, parseCets = true): DlcAcceptContainer {
584
+ const reader = new BufferReader(buf);
585
+ const container = new DlcAcceptContainer();
586
+ const acceptsCount = reader.readBigSize();
587
+ for (let i = 0; i < acceptsCount; i++) {
588
+ const acceptLength = reader.readBigSize();
589
+ const acceptBuf = reader.readBytes(Number(acceptLength));
590
+ const accept = DlcAccept.deserialize(acceptBuf, parseCets);
591
+ container.addAccept(accept);
592
+ }
593
+ return container;
594
+ }
595
+ }
@@ -0,0 +1,57 @@
1
+ import { BufferReader, BufferWriter } from '@node-dlc/bufio';
2
+
3
+ import { MessageType } from '../MessageType';
4
+ import { IDlcMessage } from './DlcMessage';
5
+
6
+ /**
7
+ * DlcCancel message contains information about a node's desire to cancel
8
+ * a DLC contract negotiation.
9
+ */
10
+ export class DlcCancel implements IDlcMessage {
11
+ public static type = MessageType.DlcCancel;
12
+
13
+ /**
14
+ * Deserializes a dlc_cancel message
15
+ * @param buf
16
+ */
17
+ public static deserialize(buf: Buffer): DlcCancel {
18
+ const instance = new DlcCancel();
19
+ const reader = new BufferReader(buf);
20
+
21
+ reader.readUInt16BE(); // read type
22
+ instance.contractId = reader.readBytes(32);
23
+ instance.cancelType = reader.readUInt8();
24
+
25
+ return instance;
26
+ }
27
+
28
+ /**
29
+ * The type for dlc_cancel message. dlc_cancel = 52172
30
+ */
31
+ public type = DlcCancel.type;
32
+
33
+ public contractId: Buffer;
34
+
35
+ public cancelType: CancelType = 0;
36
+
37
+ /**
38
+ * Serializes the dlc_cancel message into a Buffer
39
+ */
40
+ public serialize(): Buffer {
41
+ const writer = new BufferWriter();
42
+ writer.writeUInt16BE(this.type);
43
+ writer.writeBytes(this.contractId);
44
+ writer.writeUInt8(this.cancelType);
45
+
46
+ return writer.toBuffer();
47
+ }
48
+ }
49
+
50
+ export enum CancelType {
51
+ Unknown = 0,
52
+ Market = 1,
53
+ Error = 2,
54
+ }
55
+
56
+ // Backward compatibility alias
57
+ export const DlcCancelV0 = DlcCancel;