@atomicfinance/bitcoin-dlc-provider 3.6.1 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.nvmrc +1 -1
- package/.yalc/@node-dlc/messaging/.nyc_output/2cf48009-1094-4275-bb91-c164c932feb6.json +1 -0
- package/.yalc/@node-dlc/messaging/.nyc_output/processinfo/2cf48009-1094-4275-bb91-c164c932feb6.json +1 -0
- package/.yalc/@node-dlc/messaging/.nyc_output/processinfo/index.json +1 -0
- package/.yalc/@node-dlc/messaging/README.md +24 -0
- package/.yalc/@node-dlc/messaging/__tests__/_test-utils.ts +12 -0
- package/.yalc/@node-dlc/messaging/__tests__/chain/ChainManager.spec.ts +178 -0
- package/.yalc/@node-dlc/messaging/__tests__/compatibility/dlcspecs-compatibility.spec.ts +473 -0
- package/.yalc/@node-dlc/messaging/__tests__/compatibility/rust-dlc-cross-language.spec.ts +342 -0
- package/.yalc/@node-dlc/messaging/__tests__/compatibility/true-serialization-compatibility.spec.ts +611 -0
- package/.yalc/@node-dlc/messaging/__tests__/dlc_message_test.json +155 -0
- package/.yalc/@node-dlc/messaging/__tests__/irc/IrcMessage.spec.ts +94 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/AddressCache.spec.ts +79 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/BatchFundingGroup.spec.ts +72 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/CetAdaptorSignatures.spec.ts +57 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/ContractDescriptor.spec.ts +264 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/ContractInfo.spec.ts +419 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/DigitDecompositionEventDescriptor.spec.ts +59 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/DlcAccept.spec.ts +242 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/DlcCancel.spec.ts +42 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/DlcClose.spec.ts +315 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/DlcOffer.spec.ts +527 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/DlcSign.spec.ts +118 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/DlcTransactions.spec.ts +157 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/EnumEventDescriptor.spec.ts +50 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/EventDescriptor.spec.ts +93 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/FundingInput.spec.ts +84 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/FundingSignatures.spec.ts +83 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/NegotiationFields.spec.ts +328 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/NodeAnnouncementMessage.spec.ts +115 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/OracleAnnouncement.spec.ts +415 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/OracleAttestation.spec.ts +326 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/OracleEvent.spec.ts +143 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/OracleEventContainer.spec.ts +95 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/OracleIdentifier.spec.ts +48 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/OracleInfo.spec.ts +116 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/OrderAccept.spec.ts +77 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/OrderNegotiationFields.spec.ts +216 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/OrderOffer.spec.ts +121 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/OrderPositionInfo.spec.ts +75 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/PayoutCurvePiece.spec.ts +220 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/PayoutFunction.spec.ts +101 -0
- package/.yalc/@node-dlc/messaging/__tests__/messages/RoundingIntervals.spec.ts +75 -0
- package/.yalc/@node-dlc/messaging/__tests__/serialize/F64.spec.ts +260 -0
- package/.yalc/@node-dlc/messaging/__tests__/tsconfig.json +8 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/base.css +224 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/block-navigation.js +79 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/favicon.png +0 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/index.html +201 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/MessageType.ts.html +494 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/chain/ChainManager.ts.html +1058 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/chain/ChainMemoryStore.ts.html +182 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/chain/index.html +126 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/domain/Address.ts.html +272 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/domain/index.html +111 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/index.html +141 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/index.ts.html +212 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/irc/IrcMessage.ts.html +563 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/irc/index.html +111 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/AddressCache.ts.html +302 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/BatchFundingGroup.ts.html +503 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/CetAdaptorSignatures.ts.html +347 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/CetAdaptorSignaturesV0.ts.html +347 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/ContractDescriptor.ts.html +1040 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/ContractInfo.ts.html +1382 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/DlcAccept.ts.html +1865 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/DlcCancel.ts.html +251 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/DlcClose.ts.html +986 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/DlcCloseMetadata.ts.html +443 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/DlcIds.ts.html +281 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/DlcInfo.ts.html +323 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/DlcMessage.ts.html +341 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/DlcOffer.ts.html +1895 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/DlcSign.ts.html +1142 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/DlcTransactions.ts.html +719 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/EventDescriptor.ts.html +947 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/FundingInput.ts.html +728 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/FundingSignatures.ts.html +374 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/FundingSignaturesV0.ts.html +374 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/NegotiationFields.ts.html +836 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/NodeAnnouncementMessage.ts.html +515 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleAnnouncement.ts.html +608 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleAnnouncementV0.ts.html +605 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleAttestation.ts.html +956 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleAttestationV0.ts.html +770 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleEvent.ts.html +830 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleEventContainer.ts.html +347 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleEventContainerV0.ts.html +347 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleEventV0.ts.html +827 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleIdentifier.ts.html +314 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleIdentifierV0.ts.html +314 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleInfo.ts.html +1637 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OracleInfoV0.ts.html +1631 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OrderAccept.ts.html +557 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OrderIrcInfo.ts.html +380 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OrderMetadata.ts.html +437 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OrderNegotiationFields.ts.html +551 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OrderOffer.ts.html +1337 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/OrderPositionInfo.ts.html +590 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/PayoutCurvePiece.ts.html +1427 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/PayoutFunction.ts.html +800 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/RoundingIntervals.ts.html +461 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/RoundingIntervalsV0.ts.html +482 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/ScriptWitnessV0.ts.html +269 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/messages/index.html +636 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/serde/SerdeUtils.ts.html +1394 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/serde/index.html +111 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/serialize/F64.ts.html +1136 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/serialize/deserializeTlv.ts.html +125 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/serialize/getTlv.ts.html +143 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/serialize/index.html +141 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/util.ts.html +179 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/validation/index.html +111 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/lib/validation/validate.ts.html +182 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/prettify.css +1 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/prettify.js +2 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov-report/sorter.js +170 -0
- package/.yalc/@node-dlc/messaging/coverage/lcov.info +5394 -0
- package/.yalc/@node-dlc/messaging/dist/MessageType.d.ts +100 -0
- package/.yalc/@node-dlc/messaging/dist/MessageType.js +117 -0
- package/.yalc/@node-dlc/messaging/dist/MessageType.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/chain/ChainManager.d.ts +50 -0
- package/.yalc/@node-dlc/messaging/dist/chain/ChainManager.js +211 -0
- package/.yalc/@node-dlc/messaging/dist/chain/ChainManager.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/chain/ChainMemoryStore.d.ts +14 -0
- package/.yalc/@node-dlc/messaging/dist/chain/ChainMemoryStore.js +28 -0
- package/.yalc/@node-dlc/messaging/dist/chain/ChainMemoryStore.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/chain/DlcStore.d.ts +11 -0
- package/.yalc/@node-dlc/messaging/dist/chain/DlcStore.js +3 -0
- package/.yalc/@node-dlc/messaging/dist/chain/DlcStore.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/chain/IChainFilterChainClient.d.ts +48 -0
- package/.yalc/@node-dlc/messaging/dist/chain/IChainFilterChainClient.js +3 -0
- package/.yalc/@node-dlc/messaging/dist/chain/IChainFilterChainClient.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/domain/Address.d.ts +24 -0
- package/.yalc/@node-dlc/messaging/dist/domain/Address.js +46 -0
- package/.yalc/@node-dlc/messaging/dist/domain/Address.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/index.d.ts +44 -0
- package/.yalc/@node-dlc/messaging/dist/index.js +63 -0
- package/.yalc/@node-dlc/messaging/dist/index.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/irc/IrcMessage.d.ts +43 -0
- package/.yalc/@node-dlc/messaging/dist/irc/IrcMessage.js +116 -0
- package/.yalc/@node-dlc/messaging/dist/irc/IrcMessage.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/AddressCache.d.ts +15 -0
- package/.yalc/@node-dlc/messaging/dist/messages/AddressCache.js +51 -0
- package/.yalc/@node-dlc/messaging/dist/messages/AddressCache.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/BatchFundingGroup.d.ts +61 -0
- package/.yalc/@node-dlc/messaging/dist/messages/BatchFundingGroup.js +113 -0
- package/.yalc/@node-dlc/messaging/dist/messages/BatchFundingGroup.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/CetAdaptorSignatures.d.ts +40 -0
- package/.yalc/@node-dlc/messaging/dist/messages/CetAdaptorSignatures.js +67 -0
- package/.yalc/@node-dlc/messaging/dist/messages/CetAdaptorSignatures.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/ContractDescriptor.d.ts +122 -0
- package/.yalc/@node-dlc/messaging/dist/messages/ContractDescriptor.js +222 -0
- package/.yalc/@node-dlc/messaging/dist/messages/ContractDescriptor.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/ContractInfo.d.ts +135 -0
- package/.yalc/@node-dlc/messaging/dist/messages/ContractInfo.js +304 -0
- package/.yalc/@node-dlc/messaging/dist/messages/ContractInfo.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcAccept.d.ts +145 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcAccept.js +428 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcAccept.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcCancel.d.ts +31 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcCancel.js +51 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcCancel.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcClose.d.ts +68 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcClose.js +210 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcClose.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcCloseMetadata.d.ts +44 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcCloseMetadata.js +74 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcCloseMetadata.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcIds.d.ts +26 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcIds.js +58 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcIds.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcInfo.d.ts +31 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcInfo.js +61 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcInfo.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcMessage.d.ts +23 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcMessage.js +54 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcMessage.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcOffer.d.ts +131 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcOffer.js +418 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcOffer.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcSign.d.ts +96 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcSign.js +267 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcSign.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcTransactions.d.ts +69 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcTransactions.js +149 -0
- package/.yalc/@node-dlc/messaging/dist/messages/DlcTransactions.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/EventDescriptor.d.ts +106 -0
- package/.yalc/@node-dlc/messaging/dist/messages/EventDescriptor.js +209 -0
- package/.yalc/@node-dlc/messaging/dist/messages/EventDescriptor.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/FundingInput.d.ts +62 -0
- package/.yalc/@node-dlc/messaging/dist/messages/FundingInput.js +163 -0
- package/.yalc/@node-dlc/messaging/dist/messages/FundingInput.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/FundingSignatures.d.ts +36 -0
- package/.yalc/@node-dlc/messaging/dist/messages/FundingSignatures.js +78 -0
- package/.yalc/@node-dlc/messaging/dist/messages/FundingSignatures.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/IWireMessage.d.ts +6 -0
- package/.yalc/@node-dlc/messaging/dist/messages/IWireMessage.js +3 -0
- package/.yalc/@node-dlc/messaging/dist/messages/IWireMessage.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/NegotiationFields.d.ts +86 -0
- package/.yalc/@node-dlc/messaging/dist/messages/NegotiationFields.js +185 -0
- package/.yalc/@node-dlc/messaging/dist/messages/NegotiationFields.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/NodeAnnouncementMessage.d.ts +57 -0
- package/.yalc/@node-dlc/messaging/dist/messages/NodeAnnouncementMessage.js +127 -0
- package/.yalc/@node-dlc/messaging/dist/messages/NodeAnnouncementMessage.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleAnnouncement.d.ts +76 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleAnnouncement.js +131 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleAnnouncement.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleAttestation.d.ts +68 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleAttestation.js +239 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleAttestation.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleEvent.d.ts +90 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleEvent.js +189 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleEvent.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleEventContainer.d.ts +32 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleEventContainer.js +67 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleEventContainer.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleIdentifier.d.ts +32 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleIdentifier.js +58 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleIdentifier.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleIdentifierV0.d.ts +32 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleIdentifierV0.js +58 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleIdentifierV0.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleInfo.d.ts +161 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleInfo.js +390 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleInfo.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleInfoV0.d.ts +161 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleInfoV0.js +387 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OracleInfoV0.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OrderAccept.d.ts +65 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OrderAccept.js +125 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OrderAccept.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OrderIrcInfo.d.ts +42 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OrderIrcInfo.js +74 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OrderIrcInfo.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OrderMetadata.d.ts +56 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OrderMetadata.js +87 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OrderMetadata.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OrderNegotiationFields.d.ts +69 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OrderNegotiationFields.js +114 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OrderNegotiationFields.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OrderOffer.d.ts +97 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OrderOffer.js +296 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OrderOffer.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OrderPositionInfo.d.ts +50 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OrderPositionInfo.js +125 -0
- package/.yalc/@node-dlc/messaging/dist/messages/OrderPositionInfo.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/PayoutCurvePiece.d.ts +129 -0
- package/.yalc/@node-dlc/messaging/dist/messages/PayoutCurvePiece.js +327 -0
- package/.yalc/@node-dlc/messaging/dist/messages/PayoutCurvePiece.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/PayoutFunction.d.ts +66 -0
- package/.yalc/@node-dlc/messaging/dist/messages/PayoutFunction.js +170 -0
- package/.yalc/@node-dlc/messaging/dist/messages/PayoutFunction.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/RoundingIntervals.d.ts +52 -0
- package/.yalc/@node-dlc/messaging/dist/messages/RoundingIntervals.js +95 -0
- package/.yalc/@node-dlc/messaging/dist/messages/RoundingIntervals.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/ScriptWitnessV0.d.ts +29 -0
- package/.yalc/@node-dlc/messaging/dist/messages/ScriptWitnessV0.js +50 -0
- package/.yalc/@node-dlc/messaging/dist/messages/ScriptWitnessV0.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/messages/Tlv.d.ts +15 -0
- package/.yalc/@node-dlc/messaging/dist/messages/Tlv.js +32 -0
- package/.yalc/@node-dlc/messaging/dist/messages/Tlv.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/serialize/F64.d.ts +154 -0
- package/.yalc/@node-dlc/messaging/dist/serialize/F64.js +307 -0
- package/.yalc/@node-dlc/messaging/dist/serialize/F64.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/serialize/deserializeTlv.d.ts +9 -0
- package/.yalc/@node-dlc/messaging/dist/serialize/deserializeTlv.js +11 -0
- package/.yalc/@node-dlc/messaging/dist/serialize/deserializeTlv.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/serialize/getTlv.d.ts +4 -0
- package/.yalc/@node-dlc/messaging/dist/serialize/getTlv.js +23 -0
- package/.yalc/@node-dlc/messaging/dist/serialize/getTlv.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/serialize/readTlvs.d.ts +8 -0
- package/.yalc/@node-dlc/messaging/dist/serialize/readTlvs.js +33 -0
- package/.yalc/@node-dlc/messaging/dist/serialize/readTlvs.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/util.d.ts +13 -0
- package/.yalc/@node-dlc/messaging/dist/util.js +40 -0
- package/.yalc/@node-dlc/messaging/dist/util.js.map +1 -0
- package/.yalc/@node-dlc/messaging/dist/validation/validate.d.ts +4 -0
- package/.yalc/@node-dlc/messaging/dist/validation/validate.js +31 -0
- package/.yalc/@node-dlc/messaging/dist/validation/validate.js.map +1 -0
- package/.yalc/@node-dlc/messaging/lib/MessageType.ts +138 -0
- package/.yalc/@node-dlc/messaging/lib/chain/ChainManager.ts +326 -0
- package/.yalc/@node-dlc/messaging/lib/chain/ChainMemoryStore.ts +34 -0
- package/.yalc/@node-dlc/messaging/lib/chain/DlcStore.ts +11 -0
- package/.yalc/@node-dlc/messaging/lib/chain/IChainFilterChainClient.ts +57 -0
- package/.yalc/@node-dlc/messaging/lib/domain/Address.ts +64 -0
- package/.yalc/@node-dlc/messaging/lib/index.ts +44 -0
- package/.yalc/@node-dlc/messaging/lib/irc/IrcMessage.ts +161 -0
- package/.yalc/@node-dlc/messaging/lib/messages/AddressCache.ts +74 -0
- package/.yalc/@node-dlc/messaging/lib/messages/BatchFundingGroup.ts +141 -0
- package/.yalc/@node-dlc/messaging/lib/messages/CetAdaptorSignatures.ts +89 -0
- package/.yalc/@node-dlc/messaging/lib/messages/ContractDescriptor.ts +318 -0
- package/.yalc/@node-dlc/messaging/lib/messages/ContractInfo.ts +434 -0
- package/.yalc/@node-dlc/messaging/lib/messages/DlcAccept.ts +595 -0
- package/.yalc/@node-dlc/messaging/lib/messages/DlcCancel.ts +57 -0
- package/.yalc/@node-dlc/messaging/lib/messages/DlcClose.ts +302 -0
- package/.yalc/@node-dlc/messaging/lib/messages/DlcCloseMetadata.ts +121 -0
- package/.yalc/@node-dlc/messaging/lib/messages/DlcIds.ts +67 -0
- package/.yalc/@node-dlc/messaging/lib/messages/DlcInfo.ts +81 -0
- package/.yalc/@node-dlc/messaging/lib/messages/DlcMessage.ts +87 -0
- package/.yalc/@node-dlc/messaging/lib/messages/DlcOffer.ts +605 -0
- package/.yalc/@node-dlc/messaging/lib/messages/DlcSign.ts +354 -0
- package/.yalc/@node-dlc/messaging/lib/messages/DlcTransactions.ts +213 -0
- package/.yalc/@node-dlc/messaging/lib/messages/EventDescriptor.ts +289 -0
- package/.yalc/@node-dlc/messaging/lib/messages/FundingInput.ts +216 -0
- package/.yalc/@node-dlc/messaging/lib/messages/FundingSignatures.ts +98 -0
- package/.yalc/@node-dlc/messaging/lib/messages/IWireMessage.ts +6 -0
- package/.yalc/@node-dlc/messaging/lib/messages/NegotiationFields.ts +252 -0
- package/.yalc/@node-dlc/messaging/lib/messages/NodeAnnouncementMessage.ts +145 -0
- package/.yalc/@node-dlc/messaging/lib/messages/OracleAnnouncement.ts +176 -0
- package/.yalc/@node-dlc/messaging/lib/messages/OracleAttestation.ts +292 -0
- package/.yalc/@node-dlc/messaging/lib/messages/OracleEvent.ts +250 -0
- package/.yalc/@node-dlc/messaging/lib/messages/OracleEventContainer.ts +89 -0
- package/.yalc/@node-dlc/messaging/lib/messages/OracleIdentifier.ts +78 -0
- package/.yalc/@node-dlc/messaging/lib/messages/OracleInfo.ts +519 -0
- package/.yalc/@node-dlc/messaging/lib/messages/OrderAccept.ts +159 -0
- package/.yalc/@node-dlc/messaging/lib/messages/OrderIrcInfo.ts +100 -0
- package/.yalc/@node-dlc/messaging/lib/messages/OrderMetadata.ts +119 -0
- package/.yalc/@node-dlc/messaging/lib/messages/OrderNegotiationFields.ts +157 -0
- package/.yalc/@node-dlc/messaging/lib/messages/OrderOffer.ts +419 -0
- package/.yalc/@node-dlc/messaging/lib/messages/OrderPositionInfo.ts +170 -0
- package/.yalc/@node-dlc/messaging/lib/messages/PayoutCurvePiece.ts +449 -0
- package/.yalc/@node-dlc/messaging/lib/messages/PayoutFunction.ts +240 -0
- package/.yalc/@node-dlc/messaging/lib/messages/RoundingIntervals.ts +127 -0
- package/.yalc/@node-dlc/messaging/lib/messages/ScriptWitnessV0.ts +63 -0
- package/.yalc/@node-dlc/messaging/lib/messages/Tlv.ts +40 -0
- package/.yalc/@node-dlc/messaging/lib/serialize/F64.ts +352 -0
- package/.yalc/@node-dlc/messaging/lib/serialize/deserializeTlv.ts +15 -0
- package/.yalc/@node-dlc/messaging/lib/serialize/getTlv.ts +21 -0
- package/.yalc/@node-dlc/messaging/lib/serialize/readTlvs.ts +37 -0
- package/.yalc/@node-dlc/messaging/lib/util.ts +33 -0
- package/.yalc/@node-dlc/messaging/lib/validation/validate.ts +34 -0
- package/.yalc/@node-dlc/messaging/package.json +42 -0
- package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/enum_3_of_3_test.json +210 -0
- package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/enum_3_of_5_test.json +468 -0
- package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/enum_and_numerical_3_of_5_test.json +1517 -0
- package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/enum_and_numerical_5_of_5_test.json +545 -0
- package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/enum_and_numerical_with_diff_3_of_5_test.json +4761 -0
- package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/enum_and_numerical_with_diff_5_of_5_test.json +2169 -0
- package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/enum_single_oracle_test.json +164 -0
- package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/single_oracle_numerical_hyperbola_test.json +502 -0
- package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/single_oracle_numerical_test.json +262 -0
- package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/three_of_five_oracle_numerical_with_diff_test.json +4382 -0
- package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/three_of_three_oracle_numerical_test.json +324 -0
- package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/three_of_three_oracle_numerical_with_diff_test.json +652 -0
- package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/two_of_five_oracle_numerical_test.json +1138 -0
- package/.yalc/@node-dlc/messaging/test_vectors/dlcspecs/two_of_five_oracle_numerical_with_diff_test.json +2222 -0
- package/.yalc/@node-dlc/messaging/test_vectors/oracle/external_oracle_announcements.json +0 -0
- package/.yalc/@node-dlc/messaging/test_vectors/oracle/oracle_message_test_vectors.json +115 -0
- package/.yalc/@node-dlc/messaging/test_vectors/rust-dlc/accept_msg.json +1465 -0
- package/.yalc/@node-dlc/messaging/test_vectors/rust-dlc/dlc_fee_test.json +12362 -0
- package/.yalc/@node-dlc/messaging/test_vectors/rust-dlc/dlc_fee_test_scripts.json +57 -0
- package/.yalc/@node-dlc/messaging/test_vectors/rust-dlc/dlc_test.json +2766 -0
- package/.yalc/@node-dlc/messaging/test_vectors/rust-dlc/dlc_tx_test.json +2899 -0
- package/.yalc/@node-dlc/messaging/test_vectors/rust-dlc/offer_msg.json +163 -0
- package/.yalc/@node-dlc/messaging/test_vectors/rust-dlc/offer_msg_disjoint.json +352 -0
- package/.yalc/@node-dlc/messaging/test_vectors/rust-dlc/segment_chunk_msg.json +12635 -0
- package/.yalc/@node-dlc/messaging/test_vectors/rust-dlc/segment_start_msg.json +4022 -0
- package/.yalc/@node-dlc/messaging/test_vectors/rust-dlc/sign_msg.json +383 -0
- package/.yalc/@node-dlc/messaging/tsconfig.json +7 -0
- package/.yalc/@node-dlc/messaging/yalc.sig +1 -0
- package/CHANGELOG.md +72 -0
- package/dist/BitcoinDlcProvider.d.ts +17 -16
- package/dist/BitcoinDlcProvider.js +345 -315
- package/dist/BitcoinDlcProvider.js.map +1 -1
- package/dist/utils/Utils.d.ts +6 -6
- package/dist/utils/Utils.js +4 -4
- package/dist/utils/Utils.js.map +1 -1
- package/lib/BitcoinDlcProvider.ts +624 -612
- package/lib/utils/Utils.ts +19 -24
- package/package.json +10 -10
- package/yalc.lock +10 -0
|
@@ -61,42 +61,44 @@ import {
|
|
|
61
61
|
} from '@node-dlc/core';
|
|
62
62
|
import { hash160, sha256, xor } from '@node-dlc/crypto';
|
|
63
63
|
import {
|
|
64
|
-
|
|
64
|
+
CetAdaptorSignatures,
|
|
65
65
|
ContractDescriptor,
|
|
66
|
-
|
|
67
|
-
ContractDescriptorV1,
|
|
66
|
+
ContractDescriptorType,
|
|
68
67
|
ContractInfo,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
ContractInfoType,
|
|
69
|
+
DigitDecompositionEventDescriptor,
|
|
70
|
+
DisjointContractInfo,
|
|
72
71
|
DlcAccept,
|
|
73
|
-
DlcAcceptV0,
|
|
74
72
|
DlcClose,
|
|
75
73
|
DlcCloseMetadata,
|
|
76
|
-
DlcCloseV0,
|
|
77
74
|
DlcOffer,
|
|
78
|
-
DlcOfferV0,
|
|
79
75
|
DlcSign,
|
|
80
|
-
DlcSignV0,
|
|
81
76
|
DlcTransactions,
|
|
82
|
-
|
|
77
|
+
EnumeratedDescriptor,
|
|
78
|
+
EnumEventDescriptor,
|
|
79
|
+
F64,
|
|
83
80
|
FundingInput,
|
|
84
|
-
|
|
85
|
-
FundingSignaturesV0,
|
|
81
|
+
FundingSignatures,
|
|
86
82
|
HyperbolaPayoutCurvePiece,
|
|
87
83
|
MessageType,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
84
|
+
MultiOracleInfo,
|
|
85
|
+
NumericalDescriptor,
|
|
86
|
+
OracleAttestation,
|
|
87
|
+
OracleEvent,
|
|
88
|
+
OracleInfo,
|
|
89
|
+
PayoutCurvePieceType,
|
|
90
|
+
PayoutFunction,
|
|
92
91
|
PayoutFunctionV0,
|
|
93
92
|
PolynomialPayoutCurvePiece,
|
|
94
93
|
ScriptWitnessV0,
|
|
94
|
+
SingleContractInfo,
|
|
95
|
+
SingleOracleInfo,
|
|
95
96
|
} from '@node-dlc/messaging';
|
|
96
97
|
import assert from 'assert';
|
|
97
98
|
import BigNumber from 'bignumber.js';
|
|
98
99
|
import { BitcoinNetwork, chainHashFromNetwork } from 'bitcoin-networks';
|
|
99
100
|
import { address, payments, Psbt, script } from 'bitcoinjs-lib';
|
|
101
|
+
import crypto from 'crypto';
|
|
100
102
|
import { ECPairInterface } from 'ecpair';
|
|
101
103
|
import * as ecc from 'tiny-secp256k1';
|
|
102
104
|
|
|
@@ -110,7 +112,8 @@ import {
|
|
|
110
112
|
|
|
111
113
|
export default class BitcoinDlcProvider
|
|
112
114
|
extends Provider
|
|
113
|
-
implements Partial<DlcProvider>
|
|
115
|
+
implements Partial<DlcProvider>
|
|
116
|
+
{
|
|
114
117
|
_network: BitcoinNetwork;
|
|
115
118
|
_cfdDlcJs: any;
|
|
116
119
|
|
|
@@ -197,24 +200,21 @@ export default class BitcoinDlcProvider
|
|
|
197
200
|
fixedInputs: Input[],
|
|
198
201
|
): Promise<InitializeResponse> {
|
|
199
202
|
const network = await this.getConnectedNetwork();
|
|
200
|
-
const payoutAddress: Address =
|
|
201
|
-
false
|
|
202
|
-
);
|
|
203
|
+
const payoutAddress: Address =
|
|
204
|
+
await this.client.wallet.getUnusedAddress(false);
|
|
203
205
|
const payoutSPK: Buffer = address.toOutputScript(
|
|
204
206
|
payoutAddress.address,
|
|
205
207
|
network,
|
|
206
208
|
);
|
|
207
|
-
const changeAddress: Address =
|
|
208
|
-
true
|
|
209
|
-
);
|
|
209
|
+
const changeAddress: Address =
|
|
210
|
+
await this.client.wallet.getUnusedAddress(true);
|
|
210
211
|
const changeSPK: Buffer = address.toOutputScript(
|
|
211
212
|
changeAddress.address,
|
|
212
213
|
network,
|
|
213
214
|
);
|
|
214
215
|
|
|
215
|
-
const fundingAddress: Address =
|
|
216
|
-
false
|
|
217
|
-
);
|
|
216
|
+
const fundingAddress: Address =
|
|
217
|
+
await this.client.wallet.getUnusedAddress(false);
|
|
218
218
|
const fundingPubKey: Buffer = Buffer.from(fundingAddress.publicKey, 'hex');
|
|
219
219
|
|
|
220
220
|
if (fundingAddress.address === payoutAddress.address)
|
|
@@ -267,26 +267,23 @@ export default class BitcoinDlcProvider
|
|
|
267
267
|
|
|
268
268
|
const changeSerialId: bigint = generateSerialId();
|
|
269
269
|
|
|
270
|
-
const changeAddress: Address =
|
|
271
|
-
true
|
|
272
|
-
);
|
|
270
|
+
const changeAddress: Address =
|
|
271
|
+
await this.client.wallet.getUnusedAddress(true);
|
|
273
272
|
const changeSPK: Buffer = address.toOutputScript(
|
|
274
273
|
changeAddress.address,
|
|
275
274
|
network,
|
|
276
275
|
);
|
|
277
276
|
|
|
278
277
|
for (let i = 0; i < collaterals.length; i++) {
|
|
279
|
-
const payoutAddress: Address =
|
|
280
|
-
false
|
|
281
|
-
);
|
|
278
|
+
const payoutAddress: Address =
|
|
279
|
+
await this.client.wallet.getUnusedAddress(false);
|
|
282
280
|
const payoutSPK: Buffer = address.toOutputScript(
|
|
283
281
|
payoutAddress.address,
|
|
284
282
|
network,
|
|
285
283
|
);
|
|
286
284
|
|
|
287
|
-
const fundingAddress: Address =
|
|
288
|
-
false
|
|
289
|
-
);
|
|
285
|
+
const fundingAddress: Address =
|
|
286
|
+
await this.client.wallet.getUnusedAddress(false);
|
|
290
287
|
const fundingPubKey: Buffer = Buffer.from(
|
|
291
288
|
fundingAddress.publicKey,
|
|
292
289
|
'hex',
|
|
@@ -317,35 +314,29 @@ export default class BitcoinDlcProvider
|
|
|
317
314
|
*/
|
|
318
315
|
|
|
319
316
|
private GetPayoutsFromPayoutFunction(
|
|
320
|
-
|
|
321
|
-
contractDescriptor:
|
|
322
|
-
oracleInfo:
|
|
317
|
+
dlcOffer: DlcOffer,
|
|
318
|
+
contractDescriptor: NumericalDescriptor,
|
|
319
|
+
oracleInfo: OracleInfo,
|
|
323
320
|
totalCollateral: bigint,
|
|
324
321
|
): GetPayoutsResponse {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
const dlcOffer = _dlcOffer as DlcOfferV0;
|
|
328
|
-
if (contractDescriptor.payoutFunction.type !== MessageType.PayoutFunctionV0)
|
|
329
|
-
throw Error('PayoutFunction must be V0');
|
|
330
|
-
const payoutFunction = contractDescriptor.payoutFunction as PayoutFunctionV0;
|
|
331
|
-
if (payoutFunction.pieces.length === 0)
|
|
322
|
+
const payoutFunction = contractDescriptor.payoutFunction as PayoutFunction;
|
|
323
|
+
if (payoutFunction.payoutFunctionPieces.length === 0)
|
|
332
324
|
throw Error('PayoutFunction must have at least once PayoutCurvePiece');
|
|
333
|
-
if (payoutFunction.
|
|
325
|
+
if (payoutFunction.payoutFunctionPieces.length > 1)
|
|
334
326
|
throw Error('More than one PayoutCurvePiece not supported');
|
|
335
|
-
const payoutCurvePiece = payoutFunction.
|
|
327
|
+
const payoutCurvePiece = payoutFunction.payoutFunctionPieces[0]
|
|
336
328
|
.payoutCurvePiece as HyperbolaPayoutCurvePiece;
|
|
337
329
|
if (
|
|
338
|
-
payoutCurvePiece.
|
|
339
|
-
payoutCurvePiece.type !== MessageType.OldHyperbolaPayoutCurvePiece
|
|
330
|
+
payoutCurvePiece.payoutCurvePieceType !== PayoutCurvePieceType.Hyperbola
|
|
340
331
|
)
|
|
341
332
|
throw Error('Must be HyperbolaPayoutCurvePiece');
|
|
342
|
-
if (payoutCurvePiece.b
|
|
333
|
+
if (!payoutCurvePiece.b.eq(F64.ZERO) || !payoutCurvePiece.c.eq(F64.ZERO))
|
|
343
334
|
throw Error('b and c HyperbolaPayoutCurvePiece values must be 0');
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
eventDescriptor
|
|
348
|
-
)
|
|
335
|
+
// Cast to SingleOracleInfo to access announcement property
|
|
336
|
+
const singleOracleInfo = oracleInfo as SingleOracleInfo;
|
|
337
|
+
const eventDescriptor = singleOracleInfo.announcement.oracleEvent
|
|
338
|
+
.eventDescriptor as DigitDecompositionEventDescriptor;
|
|
339
|
+
if (eventDescriptor.type !== MessageType.DigitDecompositionEventDescriptor)
|
|
349
340
|
throw Error('Only DigitDecomposition Oracle Events supported');
|
|
350
341
|
|
|
351
342
|
const roundingIntervals = contractDescriptor.roundingIntervals;
|
|
@@ -368,13 +359,13 @@ export default class BitcoinDlcProvider
|
|
|
368
359
|
});
|
|
369
360
|
});
|
|
370
361
|
|
|
371
|
-
const rValuesMessagesList = this.GenerateMessages(
|
|
362
|
+
const rValuesMessagesList = this.GenerateMessages(singleOracleInfo);
|
|
372
363
|
|
|
373
364
|
const { payouts, messagesList } = outputsToPayouts(
|
|
374
365
|
payoutGroups,
|
|
375
366
|
rValuesMessagesList,
|
|
376
|
-
dlcOffer.
|
|
377
|
-
dlcOffer.contractInfo.totalCollateral - dlcOffer.
|
|
367
|
+
dlcOffer.offerCollateral,
|
|
368
|
+
dlcOffer.contractInfo.totalCollateral - dlcOffer.offerCollateral,
|
|
378
369
|
true,
|
|
379
370
|
);
|
|
380
371
|
|
|
@@ -382,30 +373,23 @@ export default class BitcoinDlcProvider
|
|
|
382
373
|
}
|
|
383
374
|
|
|
384
375
|
private GetPayoutsFromPolynomialPayoutFunction(
|
|
385
|
-
|
|
386
|
-
contractDescriptor:
|
|
387
|
-
oracleInfo:
|
|
376
|
+
dlcOffer: DlcOffer,
|
|
377
|
+
contractDescriptor: NumericalDescriptor,
|
|
378
|
+
oracleInfo: SingleOracleInfo,
|
|
388
379
|
totalCollateral: bigint,
|
|
389
380
|
): GetPayoutsResponse {
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
const dlcOffer = _dlcOffer as DlcOfferV0;
|
|
393
|
-
if (contractDescriptor.payoutFunction.type !== MessageType.PayoutFunctionV0)
|
|
394
|
-
throw Error('PayoutFunction must be V0');
|
|
395
|
-
const payoutFunction = contractDescriptor.payoutFunction as PayoutFunctionV0;
|
|
396
|
-
if (payoutFunction.pieces.length === 0)
|
|
381
|
+
const payoutFunction = contractDescriptor.payoutFunction as PayoutFunction;
|
|
382
|
+
if (payoutFunction.payoutFunctionPieces.length === 0)
|
|
397
383
|
throw Error('PayoutFunction must have at least once PayoutCurvePiece');
|
|
398
|
-
for (const piece of payoutFunction.
|
|
384
|
+
for (const piece of payoutFunction.payoutFunctionPieces) {
|
|
399
385
|
if (
|
|
400
386
|
piece.payoutCurvePiece.type !== MessageType.PolynomialPayoutCurvePiece
|
|
401
387
|
)
|
|
402
388
|
throw Error('Must be PolynomialPayoutCurvePiece');
|
|
403
389
|
}
|
|
404
390
|
const eventDescriptor = oracleInfo.announcement.oracleEvent
|
|
405
|
-
.eventDescriptor as
|
|
406
|
-
if (
|
|
407
|
-
eventDescriptor.type !== MessageType.DigitDecompositionEventDescriptorV0
|
|
408
|
-
)
|
|
391
|
+
.eventDescriptor as DigitDecompositionEventDescriptor;
|
|
392
|
+
if (eventDescriptor.type !== MessageType.DigitDecompositionEventDescriptor)
|
|
409
393
|
throw Error('Only DigitDecomposition Oracle Events supported');
|
|
410
394
|
|
|
411
395
|
const roundingIntervals = contractDescriptor.roundingIntervals;
|
|
@@ -433,17 +417,15 @@ export default class BitcoinDlcProvider
|
|
|
433
417
|
const { payouts, messagesList } = outputsToPayouts(
|
|
434
418
|
payoutGroups,
|
|
435
419
|
rValuesMessagesList,
|
|
436
|
-
dlcOffer.
|
|
437
|
-
dlcOffer.contractInfo.totalCollateral - dlcOffer.
|
|
420
|
+
dlcOffer.offerCollateral,
|
|
421
|
+
dlcOffer.contractInfo.totalCollateral - dlcOffer.offerCollateral,
|
|
438
422
|
true,
|
|
439
423
|
);
|
|
440
424
|
|
|
441
425
|
return { payouts, payoutGroups, messagesList };
|
|
442
426
|
}
|
|
443
427
|
|
|
444
|
-
private GetPayouts(
|
|
445
|
-
const { dlcOffer } = checkTypes({ _dlcOffer });
|
|
446
|
-
|
|
428
|
+
private GetPayouts(dlcOffer: DlcOffer): GetPayoutsResponse[] {
|
|
447
429
|
const contractInfo = dlcOffer.contractInfo;
|
|
448
430
|
const totalCollateral = contractInfo.totalCollateral;
|
|
449
431
|
const contractOraclePairs = this.GetContractOraclePairs(contractInfo);
|
|
@@ -489,70 +471,90 @@ export default class BitcoinDlcProvider
|
|
|
489
471
|
);
|
|
490
472
|
}
|
|
491
473
|
|
|
474
|
+
private GetPayoutsFromEnumeratedDescriptor(
|
|
475
|
+
dlcOffer: DlcOffer,
|
|
476
|
+
contractDescriptor: EnumeratedDescriptor,
|
|
477
|
+
oracleInfo: OracleInfo,
|
|
478
|
+
totalCollateral: bigint,
|
|
479
|
+
): GetPayoutsResponse {
|
|
480
|
+
const payoutGroups: PayoutGroup[] = [];
|
|
481
|
+
const rValuesMessagesList = this.GenerateMessages(
|
|
482
|
+
oracleInfo as SingleOracleInfo,
|
|
483
|
+
);
|
|
484
|
+
|
|
485
|
+
// For enumerated descriptors, each outcome creates one payout
|
|
486
|
+
// Each outcome maps to one index in the oracle's possible outcomes
|
|
487
|
+
contractDescriptor.outcomes.forEach((outcome, index) => {
|
|
488
|
+
payoutGroups.push({
|
|
489
|
+
payout: outcome.localPayout,
|
|
490
|
+
groups: [[index]], // Simple index-based grouping for enum outcomes
|
|
491
|
+
});
|
|
492
|
+
});
|
|
493
|
+
|
|
494
|
+
const { payouts, messagesList } = outputsToPayouts(
|
|
495
|
+
payoutGroups,
|
|
496
|
+
rValuesMessagesList,
|
|
497
|
+
dlcOffer.offerCollateral,
|
|
498
|
+
totalCollateral - dlcOffer.offerCollateral,
|
|
499
|
+
true,
|
|
500
|
+
);
|
|
501
|
+
|
|
502
|
+
return { payouts, payoutGroups, messagesList };
|
|
503
|
+
}
|
|
504
|
+
|
|
492
505
|
private GetPayoutsFromContractDescriptor(
|
|
493
|
-
dlcOffer:
|
|
506
|
+
dlcOffer: DlcOffer,
|
|
494
507
|
contractDescriptor: ContractDescriptor,
|
|
495
|
-
oracleInfo:
|
|
508
|
+
oracleInfo: OracleInfo,
|
|
496
509
|
totalCollateral: bigint,
|
|
497
510
|
) {
|
|
498
|
-
switch (contractDescriptor.
|
|
499
|
-
case
|
|
500
|
-
|
|
511
|
+
switch (contractDescriptor.contractDescriptorType) {
|
|
512
|
+
case ContractDescriptorType.Enumerated: {
|
|
513
|
+
return this.GetPayoutsFromEnumeratedDescriptor(
|
|
514
|
+
dlcOffer,
|
|
515
|
+
contractDescriptor as EnumeratedDescriptor,
|
|
516
|
+
oracleInfo,
|
|
517
|
+
totalCollateral,
|
|
518
|
+
);
|
|
501
519
|
}
|
|
502
|
-
case
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
case MessageType.PolynomialPayoutCurvePiece:
|
|
526
|
-
return this.GetPayoutsFromPolynomialPayoutFunction(
|
|
527
|
-
dlcOffer,
|
|
528
|
-
contractDescriptor as ContractDescriptorV1,
|
|
529
|
-
oracleInfo,
|
|
530
|
-
totalCollateral,
|
|
531
|
-
);
|
|
532
|
-
}
|
|
520
|
+
case ContractDescriptorType.NumericOutcome: {
|
|
521
|
+
const numericalDescriptor = contractDescriptor as NumericalDescriptor;
|
|
522
|
+
const payoutFunction = numericalDescriptor.payoutFunction;
|
|
523
|
+
|
|
524
|
+
// TODO: add a better check for this
|
|
525
|
+
const payoutCurvePiece =
|
|
526
|
+
payoutFunction.payoutFunctionPieces[0].payoutCurvePiece;
|
|
527
|
+
|
|
528
|
+
switch (payoutCurvePiece.payoutCurvePieceType) {
|
|
529
|
+
case PayoutCurvePieceType.Hyperbola:
|
|
530
|
+
return this.GetPayoutsFromPayoutFunction(
|
|
531
|
+
dlcOffer,
|
|
532
|
+
numericalDescriptor,
|
|
533
|
+
oracleInfo,
|
|
534
|
+
totalCollateral,
|
|
535
|
+
);
|
|
536
|
+
case PayoutCurvePieceType.Polynomial:
|
|
537
|
+
return this.GetPayoutsFromPolynomialPayoutFunction(
|
|
538
|
+
dlcOffer,
|
|
539
|
+
numericalDescriptor,
|
|
540
|
+
oracleInfo as SingleOracleInfo,
|
|
541
|
+
totalCollateral,
|
|
542
|
+
);
|
|
533
543
|
}
|
|
534
|
-
break;
|
|
535
|
-
default: {
|
|
536
|
-
throw Error('ContractDescriptor must be V0 or V1');
|
|
537
544
|
}
|
|
538
545
|
}
|
|
539
546
|
}
|
|
540
547
|
|
|
541
548
|
public async createDlcTxs(
|
|
542
|
-
|
|
543
|
-
|
|
549
|
+
dlcOffer: DlcOffer,
|
|
550
|
+
dlcAccept: DlcAccept,
|
|
544
551
|
): Promise<CreateDlcTxsResponse> {
|
|
545
|
-
const
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
const
|
|
551
|
-
const remoteFundPubkey = dlcAccept.fundingPubKey.toString('hex');
|
|
552
|
-
const localFinalScriptPubkey = dlcOffer.payoutSPK.toString('hex');
|
|
553
|
-
const remoteFinalScriptPubkey = dlcAccept.payoutSPK.toString('hex');
|
|
554
|
-
const localChangeScriptPubkey = dlcOffer.changeSPK.toString('hex');
|
|
555
|
-
const remoteChangeScriptPubkey = dlcAccept.changeSPK.toString('hex');
|
|
552
|
+
const localFundPubkey = dlcOffer.fundingPubkey.toString('hex');
|
|
553
|
+
const remoteFundPubkey = dlcAccept.fundingPubkey.toString('hex');
|
|
554
|
+
const localFinalScriptPubkey = dlcOffer.payoutSpk.toString('hex');
|
|
555
|
+
const remoteFinalScriptPubkey = dlcAccept.payoutSpk.toString('hex');
|
|
556
|
+
const localChangeScriptPubkey = dlcOffer.changeSpk.toString('hex');
|
|
557
|
+
const remoteChangeScriptPubkey = dlcAccept.changeSpk.toString('hex');
|
|
556
558
|
|
|
557
559
|
const localInputs: Utxo[] = await Promise.all(
|
|
558
560
|
dlcOffer.fundingInputs.map(async (fundingInput) => {
|
|
@@ -582,27 +584,27 @@ export default class BitcoinDlcProvider
|
|
|
582
584
|
let messagesList: Messages[] = [];
|
|
583
585
|
|
|
584
586
|
if (
|
|
585
|
-
dlcOffer.contractInfo.type === MessageType.
|
|
586
|
-
(dlcOffer.contractInfo as
|
|
587
|
-
|
|
587
|
+
dlcOffer.contractInfo.type === MessageType.SingleContractInfo &&
|
|
588
|
+
(dlcOffer.contractInfo as SingleContractInfo).contractDescriptor.type ===
|
|
589
|
+
ContractDescriptorType.Enumerated
|
|
588
590
|
) {
|
|
589
|
-
for (const outcome of (
|
|
590
|
-
.
|
|
591
|
+
for (const outcome of (
|
|
592
|
+
(dlcOffer.contractInfo as SingleContractInfo)
|
|
593
|
+
.contractDescriptor as EnumeratedDescriptor
|
|
594
|
+
).outcomes) {
|
|
591
595
|
payouts.push({
|
|
592
596
|
local: outcome.localPayout,
|
|
593
597
|
remote:
|
|
594
|
-
dlcOffer.
|
|
595
|
-
dlcAccept.
|
|
598
|
+
dlcOffer.offerCollateral +
|
|
599
|
+
dlcAccept.acceptCollateral -
|
|
596
600
|
outcome.localPayout,
|
|
597
601
|
});
|
|
598
|
-
messagesList.push({ messages: [outcome.outcome
|
|
602
|
+
messagesList.push({ messages: [outcome.outcome] });
|
|
599
603
|
}
|
|
600
604
|
} else {
|
|
601
605
|
const payoutResponses = this.GetPayouts(dlcOffer);
|
|
602
|
-
const {
|
|
603
|
-
|
|
604
|
-
messagesList: tempMessagesList,
|
|
605
|
-
} = this.FlattenPayouts(payoutResponses);
|
|
606
|
+
const { payouts: tempPayouts, messagesList: tempMessagesList } =
|
|
607
|
+
this.FlattenPayouts(payoutResponses);
|
|
606
608
|
payouts = tempPayouts;
|
|
607
609
|
messagesList = tempMessagesList;
|
|
608
610
|
}
|
|
@@ -614,11 +616,11 @@ export default class BitcoinDlcProvider
|
|
|
614
616
|
remoteFundPubkey,
|
|
615
617
|
remoteFinalScriptPubkey,
|
|
616
618
|
localInputAmount,
|
|
617
|
-
localCollateralAmount: dlcOffer.
|
|
619
|
+
localCollateralAmount: dlcOffer.offerCollateral,
|
|
618
620
|
localPayoutSerialId: dlcOffer.payoutSerialId,
|
|
619
621
|
localChangeSerialId: dlcOffer.changeSerialId,
|
|
620
622
|
remoteInputAmount,
|
|
621
|
-
remoteCollateralAmount: dlcAccept.
|
|
623
|
+
remoteCollateralAmount: dlcAccept.acceptCollateral,
|
|
622
624
|
remotePayoutSerialId: dlcAccept.payoutSerialId,
|
|
623
625
|
remoteChangeSerialId: dlcAccept.changeSerialId,
|
|
624
626
|
refundLocktime: dlcOffer.refundLocktime,
|
|
@@ -633,7 +635,7 @@ export default class BitcoinDlcProvider
|
|
|
633
635
|
|
|
634
636
|
const dlcTxs = await this.CreateDlcTransactions(dlcTxRequest);
|
|
635
637
|
|
|
636
|
-
const dlcTransactions = new
|
|
638
|
+
const dlcTransactions = new DlcTransactions();
|
|
637
639
|
dlcTransactions.fundTx = Tx.decode(StreamReader.fromHex(dlcTxs.fundTxHex));
|
|
638
640
|
dlcTransactions.fundTxVout = [
|
|
639
641
|
BigInt(dlcOffer.changeSerialId),
|
|
@@ -653,30 +655,23 @@ export default class BitcoinDlcProvider
|
|
|
653
655
|
}
|
|
654
656
|
|
|
655
657
|
public async createBatchDlcTxs(
|
|
656
|
-
|
|
657
|
-
|
|
658
|
+
dlcOffers: DlcOffer[],
|
|
659
|
+
dlcAccepts: DlcAccept[],
|
|
658
660
|
): Promise<CreateBatchDlcTxsResponse> {
|
|
659
|
-
const dlcOffers = _dlcOffers.map((dlcOffer) => {
|
|
660
|
-
return checkTypes({ _dlcOffer: dlcOffer }).dlcOffer;
|
|
661
|
-
});
|
|
662
|
-
const dlcAccepts = _dlcAccepts.map((dlcAccept) => {
|
|
663
|
-
return checkTypes({ _dlcAccept: dlcAccept }).dlcAccept;
|
|
664
|
-
});
|
|
665
|
-
|
|
666
661
|
const localFundPubkeys = dlcOffers.map((dlcOffer) =>
|
|
667
|
-
dlcOffer.
|
|
662
|
+
dlcOffer.fundingPubkey.toString('hex'),
|
|
668
663
|
);
|
|
669
664
|
const remoteFundPubkeys = dlcAccepts.map((dlcAccept) =>
|
|
670
|
-
dlcAccept.
|
|
665
|
+
dlcAccept.fundingPubkey.toString('hex'),
|
|
671
666
|
);
|
|
672
667
|
const localFinalScriptPubkeys = dlcOffers.map((dlcOffer) =>
|
|
673
|
-
dlcOffer.
|
|
668
|
+
dlcOffer.payoutSpk.toString('hex'),
|
|
674
669
|
);
|
|
675
670
|
const remoteFinalScriptPubkeys = dlcAccepts.map((dlcAccept) =>
|
|
676
|
-
dlcAccept.
|
|
671
|
+
dlcAccept.payoutSpk.toString('hex'),
|
|
677
672
|
);
|
|
678
|
-
const localChangeScriptPubkey = dlcOffers[0].
|
|
679
|
-
const remoteChangeScriptPubkey = dlcAccepts[0].
|
|
673
|
+
const localChangeScriptPubkey = dlcOffers[0].changeSpk.toString('hex');
|
|
674
|
+
const remoteChangeScriptPubkey = dlcAccepts[0].changeSpk.toString('hex');
|
|
680
675
|
|
|
681
676
|
const localInputs: Utxo[] = await Promise.all(
|
|
682
677
|
dlcOffers[0].fundingInputs.map(async (fundingInput) => {
|
|
@@ -730,7 +725,7 @@ export default class BitcoinDlcProvider
|
|
|
730
725
|
remoteFinalScriptPubkeys,
|
|
731
726
|
localInputAmount,
|
|
732
727
|
localCollateralAmounts: dlcOffers.map(
|
|
733
|
-
(dlcOffer) => dlcOffer.
|
|
728
|
+
(dlcOffer) => dlcOffer.offerCollateral,
|
|
734
729
|
),
|
|
735
730
|
localPayoutSerialIds: dlcOffers.map(
|
|
736
731
|
(dlcOffer) => dlcOffer.payoutSerialId,
|
|
@@ -738,7 +733,7 @@ export default class BitcoinDlcProvider
|
|
|
738
733
|
localChangeSerialId: dlcOffers[0].changeSerialId,
|
|
739
734
|
remoteInputAmount,
|
|
740
735
|
remoteCollateralAmounts: dlcAccepts.map(
|
|
741
|
-
(dlcAccept) => dlcAccept.
|
|
736
|
+
(dlcAccept) => dlcAccept.acceptCollateral,
|
|
742
737
|
),
|
|
743
738
|
remotePayoutSerialIds: dlcAccepts.map(
|
|
744
739
|
(dlcAccept) => dlcAccept.payoutSerialId,
|
|
@@ -758,11 +753,11 @@ export default class BitcoinDlcProvider
|
|
|
758
753
|
|
|
759
754
|
const dlcTxs = await this.CreateBatchDlcTransactions(batchDlcTxRequest);
|
|
760
755
|
|
|
761
|
-
const dlcTransactionsList:
|
|
756
|
+
const dlcTransactionsList: DlcTransactions[] = [];
|
|
762
757
|
|
|
763
758
|
let start = 0;
|
|
764
759
|
for (let i = 0; i < dlcTxs.refundTxHexList.length; i++) {
|
|
765
|
-
const dlcTransactions = new
|
|
760
|
+
const dlcTransactions = new DlcTransactions();
|
|
766
761
|
|
|
767
762
|
dlcTransactions.fundTx = Tx.decode(
|
|
768
763
|
StreamReader.fromHex(dlcTxs.fundTxHex),
|
|
@@ -796,15 +791,27 @@ export default class BitcoinDlcProvider
|
|
|
796
791
|
return { dlcTransactionsList, nestedMessagesList };
|
|
797
792
|
}
|
|
798
793
|
|
|
799
|
-
private GenerateEnumMessages(oracleEvent:
|
|
800
|
-
|
|
794
|
+
private GenerateEnumMessages(oracleEvent: OracleEvent): Messages[] {
|
|
795
|
+
const eventDescriptor = oracleEvent.eventDescriptor as EnumEventDescriptor;
|
|
796
|
+
|
|
797
|
+
// For enum events, each oracle has one nonce and can attest to one of the possible outcomes
|
|
798
|
+
const messagesList: Messages[] = [];
|
|
799
|
+
|
|
800
|
+
// For enum events, hash the outcomes to match the contract descriptor format
|
|
801
|
+
const messages = eventDescriptor.outcomes.map((outcome) =>
|
|
802
|
+
sha256(Buffer.from(outcome)).toString('hex'),
|
|
803
|
+
);
|
|
804
|
+
messagesList.push({ messages });
|
|
805
|
+
|
|
806
|
+
return messagesList;
|
|
801
807
|
}
|
|
802
808
|
|
|
803
809
|
private GenerateDigitDecompositionMessages(
|
|
804
|
-
oracleEvent:
|
|
810
|
+
oracleEvent: OracleEvent,
|
|
805
811
|
): Messages[] {
|
|
806
812
|
const oracleNonces = oracleEvent.oracleNonces;
|
|
807
|
-
const eventDescriptor =
|
|
813
|
+
const eventDescriptor =
|
|
814
|
+
oracleEvent.eventDescriptor as DigitDecompositionEventDescriptor;
|
|
808
815
|
|
|
809
816
|
const messagesList: Messages[] = [];
|
|
810
817
|
oracleNonces.forEach(() => {
|
|
@@ -819,13 +826,31 @@ export default class BitcoinDlcProvider
|
|
|
819
826
|
return messagesList;
|
|
820
827
|
}
|
|
821
828
|
|
|
822
|
-
private GenerateMessages(oracleInfo:
|
|
823
|
-
|
|
829
|
+
private GenerateMessages(oracleInfo: OracleInfo): Messages[] {
|
|
830
|
+
// Handle both SingleOracleInfo and MultiOracleInfo using type property instead of instanceof
|
|
831
|
+
let oracleEvent: OracleEvent;
|
|
832
|
+
|
|
833
|
+
if (oracleInfo.type === MessageType.SingleOracleInfo) {
|
|
834
|
+
const singleOracleInfo = oracleInfo as SingleOracleInfo;
|
|
835
|
+
oracleEvent = singleOracleInfo.announcement.oracleEvent;
|
|
836
|
+
} else if (oracleInfo.type === MessageType.MultiOracleInfo) {
|
|
837
|
+
const multiOracleInfo = oracleInfo as MultiOracleInfo;
|
|
838
|
+
// For multi-oracle, use the first announcement for now
|
|
839
|
+
// TODO: This might need more sophisticated handling for multi-oracle scenarios
|
|
840
|
+
if (multiOracleInfo.announcements.length === 0) {
|
|
841
|
+
throw Error('MultiOracleInfo must have at least one announcement');
|
|
842
|
+
}
|
|
843
|
+
oracleEvent = multiOracleInfo.announcements[0].oracleEvent;
|
|
844
|
+
} else {
|
|
845
|
+
throw Error(
|
|
846
|
+
`OracleInfo must be SingleOracleInfo or MultiOracleInfo, got type: ${oracleInfo.type}`,
|
|
847
|
+
);
|
|
848
|
+
}
|
|
824
849
|
|
|
825
850
|
switch (oracleEvent.eventDescriptor.type) {
|
|
826
|
-
case MessageType.
|
|
851
|
+
case MessageType.EnumEventDescriptor:
|
|
827
852
|
return this.GenerateEnumMessages(oracleEvent);
|
|
828
|
-
case MessageType.
|
|
853
|
+
case MessageType.DigitDecompositionEventDescriptor:
|
|
829
854
|
return this.GenerateDigitDecompositionMessages(oracleEvent);
|
|
830
855
|
default:
|
|
831
856
|
throw Error('EventDescriptor must be Enum or DigitDecomposition');
|
|
@@ -834,22 +859,21 @@ export default class BitcoinDlcProvider
|
|
|
834
859
|
|
|
835
860
|
private GetContractOraclePairs(
|
|
836
861
|
_contractInfo: ContractInfo,
|
|
837
|
-
): { contractDescriptor: ContractDescriptor; oracleInfo:
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
throw Error('ContractInfo must be V0 or V1');
|
|
862
|
+
): { contractDescriptor: ContractDescriptor; oracleInfo: OracleInfo }[] {
|
|
863
|
+
// Use contractInfoType property instead of instanceof for more reliable type checking
|
|
864
|
+
if (_contractInfo.contractInfoType === ContractInfoType.Single) {
|
|
865
|
+
const singleInfo = _contractInfo as SingleContractInfo;
|
|
866
|
+
return [
|
|
867
|
+
{
|
|
868
|
+
contractDescriptor: singleInfo.contractDescriptor,
|
|
869
|
+
oracleInfo: singleInfo.oracleInfo,
|
|
870
|
+
},
|
|
871
|
+
];
|
|
872
|
+
} else if (_contractInfo.contractInfoType === ContractInfoType.Disjoint) {
|
|
873
|
+
const disjointInfo = _contractInfo as DisjointContractInfo;
|
|
874
|
+
return disjointInfo.contractOraclePairs;
|
|
875
|
+
} else {
|
|
876
|
+
throw Error('ContractInfo must be Single or Disjoint');
|
|
853
877
|
}
|
|
854
878
|
}
|
|
855
879
|
|
|
@@ -870,7 +894,7 @@ export default class BitcoinDlcProvider
|
|
|
870
894
|
const cetsHex = dlcTxs.cets.map((cet) => cet.serialize().toString('hex'));
|
|
871
895
|
|
|
872
896
|
const fundingSPK = Script.p2wpkhLock(
|
|
873
|
-
hash160(isOfferer ? dlcOffer.
|
|
897
|
+
hash160(isOfferer ? dlcOffer.fundingPubkey : dlcAccept.fundingPubkey),
|
|
874
898
|
)
|
|
875
899
|
.serialize()
|
|
876
900
|
.slice(1);
|
|
@@ -894,12 +918,16 @@ export default class BitcoinDlcProvider
|
|
|
894
918
|
const sigs: ISig[][] = [];
|
|
895
919
|
|
|
896
920
|
if (
|
|
897
|
-
dlcOffer.contractInfo.
|
|
898
|
-
(dlcOffer.contractInfo as
|
|
921
|
+
dlcOffer.contractInfo.contractInfoType === ContractInfoType.Single &&
|
|
922
|
+
(dlcOffer.contractInfo as SingleContractInfo).contractDescriptor.type ===
|
|
899
923
|
MessageType.ContractDescriptorV0
|
|
900
924
|
) {
|
|
901
925
|
for (const [_, { oracleInfo }] of contractOraclePairs.entries()) {
|
|
902
|
-
|
|
926
|
+
if (oracleInfo.type !== MessageType.SingleOracleInfo) {
|
|
927
|
+
throw new Error('Only SingleOracleInfo supported in this context');
|
|
928
|
+
}
|
|
929
|
+
const oracleAnnouncement = (oracleInfo as SingleOracleInfo)
|
|
930
|
+
.announcement;
|
|
903
931
|
|
|
904
932
|
const adaptorSigRequestPromises: Promise<AdaptorPair[]>[] = [];
|
|
905
933
|
|
|
@@ -912,8 +940,8 @@ export default class BitcoinDlcProvider
|
|
|
912
940
|
privkey: fundPrivateKey,
|
|
913
941
|
fundTxId: dlcTxs.fundTx.txId.toString(),
|
|
914
942
|
fundVout: dlcTxs.fundTxVout,
|
|
915
|
-
localFundPubkey: dlcOffer.
|
|
916
|
-
remoteFundPubkey: dlcAccept.
|
|
943
|
+
localFundPubkey: dlcOffer.fundingPubkey.toString('hex'),
|
|
944
|
+
remoteFundPubkey: dlcAccept.fundingPubkey.toString('hex'),
|
|
917
945
|
fundInputAmount: dlcTxs.fundTx.outputs[dlcTxs.fundTxVout].value.sats,
|
|
918
946
|
oraclePubkey: oracleAnnouncement.oraclePubkey.toString('hex'),
|
|
919
947
|
oracleRValues: oracleAnnouncement.oracleEvent.oracleNonces.map(
|
|
@@ -923,9 +951,8 @@ export default class BitcoinDlcProvider
|
|
|
923
951
|
|
|
924
952
|
adaptorSigRequestPromises.push(
|
|
925
953
|
(async () => {
|
|
926
|
-
const response =
|
|
927
|
-
cetSignRequest
|
|
928
|
-
);
|
|
954
|
+
const response =
|
|
955
|
+
await this.CreateCetAdaptorSignatures(cetSignRequest);
|
|
929
956
|
return response.adaptorPairs;
|
|
930
957
|
})(),
|
|
931
958
|
);
|
|
@@ -947,7 +974,11 @@ export default class BitcoinDlcProvider
|
|
|
947
974
|
const indices = this.GetIndicesFromPayouts(this.GetPayouts(_dlcOffer));
|
|
948
975
|
|
|
949
976
|
for (const [index, { oracleInfo }] of contractOraclePairs.entries()) {
|
|
950
|
-
|
|
977
|
+
if (oracleInfo.type !== MessageType.SingleOracleInfo) {
|
|
978
|
+
throw new Error('Only SingleOracleInfo supported in this context');
|
|
979
|
+
}
|
|
980
|
+
const oracleAnnouncement = (oracleInfo as SingleOracleInfo)
|
|
981
|
+
.announcement;
|
|
951
982
|
|
|
952
983
|
const startingIndex = indices[index].startingMessagesIndex,
|
|
953
984
|
endingIndex = indices[index + 1].startingMessagesIndex;
|
|
@@ -971,8 +1002,8 @@ export default class BitcoinDlcProvider
|
|
|
971
1002
|
privkey: fundPrivateKey,
|
|
972
1003
|
fundTxId: dlcTxs.fundTx.txId.toString(),
|
|
973
1004
|
fundVout: dlcTxs.fundTxVout,
|
|
974
|
-
localFundPubkey: dlcOffer.
|
|
975
|
-
remoteFundPubkey: dlcAccept.
|
|
1005
|
+
localFundPubkey: dlcOffer.fundingPubkey.toString('hex'),
|
|
1006
|
+
remoteFundPubkey: dlcAccept.fundingPubkey.toString('hex'),
|
|
976
1007
|
fundInputAmount:
|
|
977
1008
|
dlcTxs.fundTx.outputs[dlcTxs.fundTxVout].value.sats,
|
|
978
1009
|
oraclePubkey: oracleAnnouncement.oraclePubkey.toString('hex'),
|
|
@@ -983,9 +1014,8 @@ export default class BitcoinDlcProvider
|
|
|
983
1014
|
|
|
984
1015
|
adaptorSigRequestPromises.push(
|
|
985
1016
|
(async () => {
|
|
986
|
-
const response =
|
|
987
|
-
cetSignRequest
|
|
988
|
-
);
|
|
1017
|
+
const response =
|
|
1018
|
+
await this.CreateCetAdaptorSignatures(cetSignRequest);
|
|
989
1019
|
return response.adaptorPairs;
|
|
990
1020
|
})(),
|
|
991
1021
|
);
|
|
@@ -1011,8 +1041,8 @@ export default class BitcoinDlcProvider
|
|
|
1011
1041
|
privkey: fundPrivateKey,
|
|
1012
1042
|
fundTxId: dlcTxs.fundTx.txId.toString(),
|
|
1013
1043
|
fundVout: dlcTxs.fundTxVout,
|
|
1014
|
-
localFundPubkey: dlcOffer.
|
|
1015
|
-
remoteFundPubkey: dlcAccept.
|
|
1044
|
+
localFundPubkey: dlcOffer.fundingPubkey.toString('hex'),
|
|
1045
|
+
remoteFundPubkey: dlcAccept.fundingPubkey.toString('hex'),
|
|
1016
1046
|
fundInputAmount: dlcTxs.fundTx.outputs[dlcTxs.fundTxVout].value.sats,
|
|
1017
1047
|
};
|
|
1018
1048
|
|
|
@@ -1021,7 +1051,7 @@ export default class BitcoinDlcProvider
|
|
|
1021
1051
|
'hex',
|
|
1022
1052
|
);
|
|
1023
1053
|
|
|
1024
|
-
const cetSignatures = new
|
|
1054
|
+
const cetSignatures = new CetAdaptorSignatures();
|
|
1025
1055
|
cetSignatures.sigs = sigs.flat();
|
|
1026
1056
|
|
|
1027
1057
|
return { cetSignatures, refundSignature };
|
|
@@ -1049,17 +1079,21 @@ export default class BitcoinDlcProvider
|
|
|
1049
1079
|
);
|
|
1050
1080
|
|
|
1051
1081
|
if (
|
|
1052
|
-
dlcOffer.contractInfo.type === MessageType.
|
|
1053
|
-
(dlcOffer.contractInfo as
|
|
1082
|
+
dlcOffer.contractInfo.type === MessageType.SingleContractInfo &&
|
|
1083
|
+
(dlcOffer.contractInfo as SingleContractInfo).contractDescriptor.type ===
|
|
1054
1084
|
MessageType.ContractDescriptorV0
|
|
1055
1085
|
) {
|
|
1056
1086
|
for (const [_, { oracleInfo }] of contractOraclePairs.entries()) {
|
|
1057
|
-
|
|
1087
|
+
if (oracleInfo.type !== MessageType.SingleOracleInfo) {
|
|
1088
|
+
throw new Error('Only SingleOracleInfo supported in this context');
|
|
1089
|
+
}
|
|
1090
|
+
const oracleAnnouncement = (oracleInfo as SingleOracleInfo)
|
|
1091
|
+
.announcement;
|
|
1058
1092
|
|
|
1059
1093
|
const oracleEventCetsHex = cetsHex;
|
|
1060
1094
|
const oracleEventSigs = isOfferer
|
|
1061
|
-
? dlcAccept.
|
|
1062
|
-
: dlcSign.
|
|
1095
|
+
? dlcAccept.cetAdaptorSignatures.sigs
|
|
1096
|
+
: dlcSign.cetAdaptorSignatures.sigs;
|
|
1063
1097
|
|
|
1064
1098
|
const sigsValidity: Promise<boolean>[] = [];
|
|
1065
1099
|
|
|
@@ -1073,21 +1107,23 @@ export default class BitcoinDlcProvider
|
|
|
1073
1107
|
};
|
|
1074
1108
|
});
|
|
1075
1109
|
|
|
1076
|
-
const verifyCetAdaptorSignaturesRequest: VerifyCetAdaptorSignaturesRequest =
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1110
|
+
const verifyCetAdaptorSignaturesRequest: VerifyCetAdaptorSignaturesRequest =
|
|
1111
|
+
{
|
|
1112
|
+
cetsHex: tempCetsHex,
|
|
1113
|
+
messagesList: tempMessagesList,
|
|
1114
|
+
oraclePubkey: oracleAnnouncement.oraclePubkey.toString('hex'),
|
|
1115
|
+
oracleRValues: oracleAnnouncement.oracleEvent.oracleNonces.map(
|
|
1116
|
+
(nonce) => nonce.toString('hex'),
|
|
1117
|
+
),
|
|
1118
|
+
adaptorPairs: tempAdaptorPairs,
|
|
1119
|
+
localFundPubkey: dlcOffer.fundingPubkey.toString('hex'),
|
|
1120
|
+
remoteFundPubkey: dlcAccept.fundingPubkey.toString('hex'),
|
|
1121
|
+
fundTxId: dlcTxs.fundTx.txId.toString(),
|
|
1122
|
+
fundVout: dlcTxs.fundTxVout,
|
|
1123
|
+
fundInputAmount:
|
|
1124
|
+
dlcTxs.fundTx.outputs[dlcTxs.fundTxVout].value.sats,
|
|
1125
|
+
verifyRemote: isOfferer,
|
|
1126
|
+
};
|
|
1091
1127
|
|
|
1092
1128
|
sigsValidity.push(
|
|
1093
1129
|
(async () => {
|
|
@@ -1105,8 +1141,8 @@ export default class BitcoinDlcProvider
|
|
|
1105
1141
|
signature: isOfferer
|
|
1106
1142
|
? dlcAccept.refundSignature.toString('hex')
|
|
1107
1143
|
: dlcSign.refundSignature.toString('hex'),
|
|
1108
|
-
localFundPubkey: dlcOffer.
|
|
1109
|
-
remoteFundPubkey: dlcAccept.
|
|
1144
|
+
localFundPubkey: dlcOffer.fundingPubkey.toString('hex'),
|
|
1145
|
+
remoteFundPubkey: dlcAccept.fundingPubkey.toString('hex'),
|
|
1110
1146
|
fundTxId: dlcTxs.fundTx.txId.toString(),
|
|
1111
1147
|
fundVout: dlcTxs.fundTxVout,
|
|
1112
1148
|
fundInputAmount: dlcTxs.fundTx.outputs[dlcTxs.fundTxVout].value.sats,
|
|
@@ -1127,7 +1163,11 @@ export default class BitcoinDlcProvider
|
|
|
1127
1163
|
const indices = this.GetIndicesFromPayouts(this.GetPayouts(_dlcOffer));
|
|
1128
1164
|
|
|
1129
1165
|
for (const [index, { oracleInfo }] of contractOraclePairs.entries()) {
|
|
1130
|
-
|
|
1166
|
+
if (oracleInfo.type !== MessageType.SingleOracleInfo) {
|
|
1167
|
+
throw new Error('Only SingleOracleInfo supported in this context');
|
|
1168
|
+
}
|
|
1169
|
+
const oracleAnnouncement = (oracleInfo as SingleOracleInfo)
|
|
1170
|
+
.announcement;
|
|
1131
1171
|
|
|
1132
1172
|
const startingIndex = indices[index].startingMessagesIndex,
|
|
1133
1173
|
endingIndex = indices[index + 1].startingMessagesIndex;
|
|
@@ -1137,9 +1177,10 @@ export default class BitcoinDlcProvider
|
|
|
1137
1177
|
endingIndex,
|
|
1138
1178
|
);
|
|
1139
1179
|
const oracleEventCetsHex = cetsHex.slice(startingIndex, endingIndex);
|
|
1140
|
-
const oracleEventSigs = (
|
|
1141
|
-
|
|
1142
|
-
|
|
1180
|
+
const oracleEventSigs = (
|
|
1181
|
+
isOfferer
|
|
1182
|
+
? dlcAccept.cetAdaptorSignatures.sigs
|
|
1183
|
+
: dlcSign.cetAdaptorSignatures.sigs
|
|
1143
1184
|
).slice(startingIndex, endingIndex);
|
|
1144
1185
|
|
|
1145
1186
|
const sigsValidity: Promise<boolean>[] = [];
|
|
@@ -1155,22 +1196,23 @@ export default class BitcoinDlcProvider
|
|
|
1155
1196
|
};
|
|
1156
1197
|
});
|
|
1157
1198
|
|
|
1158
|
-
const verifyCetAdaptorSignaturesRequest: VerifyCetAdaptorSignaturesRequest =
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1199
|
+
const verifyCetAdaptorSignaturesRequest: VerifyCetAdaptorSignaturesRequest =
|
|
1200
|
+
{
|
|
1201
|
+
cetsHex: tempCetsHex,
|
|
1202
|
+
messagesList: tempMessagesList,
|
|
1203
|
+
oraclePubkey: oracleAnnouncement.oraclePubkey.toString('hex'),
|
|
1204
|
+
oracleRValues: oracleAnnouncement.oracleEvent.oracleNonces.map(
|
|
1205
|
+
(nonce) => nonce.toString('hex'),
|
|
1206
|
+
),
|
|
1207
|
+
adaptorPairs: tempAdaptorPairs,
|
|
1208
|
+
localFundPubkey: dlcOffer.fundingPubkey.toString('hex'),
|
|
1209
|
+
remoteFundPubkey: dlcAccept.fundingPubkey.toString('hex'),
|
|
1210
|
+
fundTxId: dlcTxs.fundTx.txId.toString(),
|
|
1211
|
+
fundVout: dlcTxs.fundTxVout,
|
|
1212
|
+
fundInputAmount:
|
|
1213
|
+
dlcTxs.fundTx.outputs[dlcTxs.fundTxVout].value.sats,
|
|
1214
|
+
verifyRemote: isOfferer,
|
|
1215
|
+
};
|
|
1174
1216
|
|
|
1175
1217
|
sigsValidity.push(
|
|
1176
1218
|
(async () => {
|
|
@@ -1189,8 +1231,8 @@ export default class BitcoinDlcProvider
|
|
|
1189
1231
|
signature: isOfferer
|
|
1190
1232
|
? dlcAccept.refundSignature.toString('hex')
|
|
1191
1233
|
: dlcSign.refundSignature.toString('hex'),
|
|
1192
|
-
localFundPubkey: dlcOffer.
|
|
1193
|
-
remoteFundPubkey: dlcAccept.
|
|
1234
|
+
localFundPubkey: dlcOffer.fundingPubkey.toString('hex'),
|
|
1235
|
+
remoteFundPubkey: dlcAccept.fundingPubkey.toString('hex'),
|
|
1194
1236
|
fundTxId: dlcTxs.fundTx.txId.toString(),
|
|
1195
1237
|
fundVout: dlcTxs.fundTxVout,
|
|
1196
1238
|
fundInputAmount: dlcTxs.fundTx.outputs[dlcTxs.fundTxVout].value.sats,
|
|
@@ -1213,7 +1255,7 @@ export default class BitcoinDlcProvider
|
|
|
1213
1255
|
_dlcAccept: DlcAccept,
|
|
1214
1256
|
_dlcTxs: DlcTransactions,
|
|
1215
1257
|
isOfferer: boolean,
|
|
1216
|
-
): Promise<
|
|
1258
|
+
): Promise<FundingSignatures> {
|
|
1217
1259
|
const { dlcOffer, dlcAccept, dlcTxs } = checkTypes({
|
|
1218
1260
|
_dlcOffer,
|
|
1219
1261
|
_dlcAccept,
|
|
@@ -1267,26 +1309,19 @@ export default class BitcoinDlcProvider
|
|
|
1267
1309
|
witnessElements.push([sigWitness, pubKeyWitness]);
|
|
1268
1310
|
}
|
|
1269
1311
|
|
|
1270
|
-
const fundingSignatures = new
|
|
1312
|
+
const fundingSignatures = new FundingSignatures();
|
|
1271
1313
|
fundingSignatures.witnessElements = witnessElements;
|
|
1272
1314
|
|
|
1273
1315
|
return fundingSignatures;
|
|
1274
1316
|
}
|
|
1275
1317
|
|
|
1276
1318
|
private async VerifyFundingSigs(
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1319
|
+
dlcOffer: DlcOffer,
|
|
1320
|
+
dlcAccept: DlcAccept,
|
|
1321
|
+
dlcSign: DlcSign,
|
|
1322
|
+
dlcTxs: DlcTransactions,
|
|
1281
1323
|
isOfferer: boolean,
|
|
1282
1324
|
): Promise<void> {
|
|
1283
|
-
const { dlcOffer, dlcAccept, dlcSign, dlcTxs } = checkTypes({
|
|
1284
|
-
_dlcOffer,
|
|
1285
|
-
_dlcAccept,
|
|
1286
|
-
_dlcSign,
|
|
1287
|
-
_dlcTxs,
|
|
1288
|
-
});
|
|
1289
|
-
|
|
1290
1325
|
const sigsValidity: Promise<boolean>[] = [];
|
|
1291
1326
|
for (let i = 0; i < dlcSign.fundingSignatures.witnessElements.length; i++) {
|
|
1292
1327
|
const witnessElement = dlcSign.fundingSignatures.witnessElements[i];
|
|
@@ -1294,8 +1329,8 @@ export default class BitcoinDlcProvider
|
|
|
1294
1329
|
const pubkey = witnessElement[1].witness.toString('hex');
|
|
1295
1330
|
|
|
1296
1331
|
const fundingInput = isOfferer
|
|
1297
|
-
? (dlcAccept.fundingInputs[i] as
|
|
1298
|
-
: (dlcOffer.fundingInputs[i] as
|
|
1332
|
+
? (dlcAccept.fundingInputs[i] as FundingInput)
|
|
1333
|
+
: (dlcOffer.fundingInputs[i] as FundingInput);
|
|
1299
1334
|
|
|
1300
1335
|
const verifyFundSigRequest: VerifyFundTxSignatureRequest = {
|
|
1301
1336
|
fundTxHex: dlcTxs.fundTx.serialize().toString('hex'),
|
|
@@ -1309,9 +1344,8 @@ export default class BitcoinDlcProvider
|
|
|
1309
1344
|
|
|
1310
1345
|
sigsValidity.push(
|
|
1311
1346
|
(async () => {
|
|
1312
|
-
const response =
|
|
1313
|
-
verifyFundSigRequest
|
|
1314
|
-
);
|
|
1347
|
+
const response =
|
|
1348
|
+
await this.VerifyFundTxSignature(verifyFundSigRequest);
|
|
1315
1349
|
return response.valid;
|
|
1316
1350
|
})(),
|
|
1317
1351
|
);
|
|
@@ -1325,19 +1359,12 @@ export default class BitcoinDlcProvider
|
|
|
1325
1359
|
}
|
|
1326
1360
|
|
|
1327
1361
|
private async CreateFundingTx(
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
fundingSignatures:
|
|
1362
|
+
dlcOffer: DlcOffer,
|
|
1363
|
+
dlcAccept: DlcAccept,
|
|
1364
|
+
dlcSign: DlcSign,
|
|
1365
|
+
dlcTxs: DlcTransactions,
|
|
1366
|
+
fundingSignatures: FundingSignatures,
|
|
1333
1367
|
): Promise<Tx> {
|
|
1334
|
-
const { dlcOffer, dlcAccept, dlcSign, dlcTxs } = checkTypes({
|
|
1335
|
-
_dlcOffer,
|
|
1336
|
-
_dlcAccept,
|
|
1337
|
-
_dlcSign,
|
|
1338
|
-
_dlcTxs,
|
|
1339
|
-
});
|
|
1340
|
-
|
|
1341
1368
|
const witnessElements = [
|
|
1342
1369
|
...dlcSign.fundingSignatures.witnessElements,
|
|
1343
1370
|
...fundingSignatures.witnessElements,
|
|
@@ -1355,7 +1382,7 @@ export default class BitcoinDlcProvider
|
|
|
1355
1382
|
const signature = witnessElement[0].witness.toString('hex');
|
|
1356
1383
|
const pubkey = witnessElement[1].witness.toString('hex');
|
|
1357
1384
|
|
|
1358
|
-
const fundingInput = fundingInputs[i] as
|
|
1385
|
+
const fundingInput = fundingInputs[i] as FundingInput;
|
|
1359
1386
|
|
|
1360
1387
|
const addSignRequest: AddSignatureToFundTransactionRequest = {
|
|
1361
1388
|
fundTxHex,
|
|
@@ -1375,15 +1402,13 @@ export default class BitcoinDlcProvider
|
|
|
1375
1402
|
}
|
|
1376
1403
|
|
|
1377
1404
|
async FindOutcomeIndexFromPolynomialPayoutCurvePiece(
|
|
1378
|
-
|
|
1379
|
-
contractDescriptor:
|
|
1405
|
+
dlcOffer: DlcOffer,
|
|
1406
|
+
contractDescriptor: NumericalDescriptor,
|
|
1380
1407
|
contractOraclePairIndex: number,
|
|
1381
1408
|
polynomialPayoutCurvePiece: PolynomialPayoutCurvePiece,
|
|
1382
|
-
oracleAttestation:
|
|
1409
|
+
oracleAttestation: OracleAttestation,
|
|
1383
1410
|
outcome: bigint,
|
|
1384
1411
|
): Promise<FindOutcomeResponse> {
|
|
1385
|
-
const { dlcOffer } = checkTypes({ _dlcOffer });
|
|
1386
|
-
|
|
1387
1412
|
const polynomialCurve = PolynomialPayoutCurve.fromPayoutCurvePiece(
|
|
1388
1413
|
polynomialPayoutCurvePiece,
|
|
1389
1414
|
);
|
|
@@ -1400,9 +1425,9 @@ export default class BitcoinDlcProvider
|
|
|
1400
1425
|
const payout = clampBN(polynomialCurve.getPayout(outcome));
|
|
1401
1426
|
|
|
1402
1427
|
const payoutResponses = this.GetPayouts(dlcOffer);
|
|
1403
|
-
const payoutIndexOffset =
|
|
1404
|
-
contractOraclePairIndex
|
|
1405
|
-
|
|
1428
|
+
const payoutIndexOffset =
|
|
1429
|
+
this.GetIndicesFromPayouts(payoutResponses)[contractOraclePairIndex]
|
|
1430
|
+
.startingMessagesIndex;
|
|
1406
1431
|
|
|
1407
1432
|
const { payoutGroups } = payoutResponses[contractOraclePairIndex];
|
|
1408
1433
|
|
|
@@ -1457,10 +1482,10 @@ Payout Group not found',
|
|
|
1457
1482
|
|
|
1458
1483
|
async FindOutcomeIndexFromHyperbolaPayoutCurvePiece(
|
|
1459
1484
|
_dlcOffer: DlcOffer,
|
|
1460
|
-
contractDescriptor:
|
|
1485
|
+
contractDescriptor: NumericalDescriptor,
|
|
1461
1486
|
contractOraclePairIndex: number,
|
|
1462
1487
|
hyperbolaPayoutCurvePiece: HyperbolaPayoutCurvePiece,
|
|
1463
|
-
oracleAttestation:
|
|
1488
|
+
oracleAttestation: OracleAttestation,
|
|
1464
1489
|
outcome: bigint,
|
|
1465
1490
|
): Promise<FindOutcomeResponse> {
|
|
1466
1491
|
const { dlcOffer } = checkTypes({ _dlcOffer });
|
|
@@ -1478,9 +1503,9 @@ Payout Group not found',
|
|
|
1478
1503
|
const payout = clampBN(hyperbolaCurve.getPayout(outcome));
|
|
1479
1504
|
|
|
1480
1505
|
const payoutResponses = this.GetPayouts(dlcOffer);
|
|
1481
|
-
const payoutIndexOffset =
|
|
1482
|
-
contractOraclePairIndex
|
|
1483
|
-
|
|
1506
|
+
const payoutIndexOffset =
|
|
1507
|
+
this.GetIndicesFromPayouts(payoutResponses)[contractOraclePairIndex]
|
|
1508
|
+
.startingMessagesIndex;
|
|
1484
1509
|
|
|
1485
1510
|
const { payoutGroups } = payoutResponses[contractOraclePairIndex];
|
|
1486
1511
|
|
|
@@ -1541,31 +1566,52 @@ Payout Group not found',
|
|
|
1541
1566
|
}
|
|
1542
1567
|
|
|
1543
1568
|
if (groupIndex === -1) {
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1569
|
+
// Fallback to brute force search if payout-based search fails
|
|
1570
|
+
index = 0;
|
|
1571
|
+
groupLength = 0;
|
|
1572
|
+
|
|
1573
|
+
for (const [i, payoutGroup] of payoutGroups.entries()) {
|
|
1574
|
+
groupIndex = payoutGroup.groups.findIndex((group) => {
|
|
1575
|
+
return group.every((msg, j) => msg === outcomesFormatted[j]);
|
|
1576
|
+
});
|
|
1577
|
+
|
|
1578
|
+
if (groupIndex !== -1) {
|
|
1579
|
+
index += groupIndex;
|
|
1580
|
+
groupLength = payoutGroup.groups[groupIndex].length;
|
|
1581
|
+
break;
|
|
1582
|
+
} else {
|
|
1583
|
+
index += payoutGroup.groups.length;
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
|
|
1587
|
+
if (groupIndex === -1) {
|
|
1588
|
+
throw Error(
|
|
1589
|
+
'Failed to Find OutcomeIndex From HyperbolaPayoutCurvePiece. \
|
|
1590
|
+
Payout Group not found even with brute force search',
|
|
1591
|
+
);
|
|
1592
|
+
}
|
|
1548
1593
|
}
|
|
1549
1594
|
|
|
1550
1595
|
return { index: payoutIndexOffset + index, groupLength };
|
|
1551
1596
|
}
|
|
1552
1597
|
|
|
1553
1598
|
async FindOutcomeIndex(
|
|
1554
|
-
|
|
1555
|
-
oracleAttestation:
|
|
1599
|
+
dlcOffer: DlcOffer,
|
|
1600
|
+
oracleAttestation: OracleAttestation,
|
|
1556
1601
|
): Promise<FindOutcomeResponse> {
|
|
1557
|
-
const { dlcOffer } = checkTypes({ _dlcOffer });
|
|
1558
|
-
|
|
1559
1602
|
const contractOraclePairs = this.GetContractOraclePairs(
|
|
1560
1603
|
dlcOffer.contractInfo,
|
|
1561
1604
|
);
|
|
1562
|
-
|
|
1563
1605
|
const contractOraclePairIndex = contractOraclePairs.findIndex(
|
|
1564
|
-
({ oracleInfo }) =>
|
|
1565
|
-
oracleInfo.
|
|
1566
|
-
|
|
1606
|
+
({ oracleInfo }) => {
|
|
1607
|
+
if (oracleInfo.type !== MessageType.SingleOracleInfo) return false;
|
|
1608
|
+
const singleOracleInfo = oracleInfo as SingleOracleInfo;
|
|
1609
|
+
return (
|
|
1610
|
+
singleOracleInfo.announcement.oracleEvent.eventId ===
|
|
1611
|
+
oracleAttestation.eventId
|
|
1612
|
+
);
|
|
1613
|
+
},
|
|
1567
1614
|
);
|
|
1568
|
-
|
|
1569
1615
|
assert(
|
|
1570
1616
|
contractOraclePairIndex !== -1,
|
|
1571
1617
|
'OracleAttestation must be for an existing OracleEvent',
|
|
@@ -1573,39 +1619,42 @@ Payout Group not found',
|
|
|
1573
1619
|
|
|
1574
1620
|
const contractOraclePair = contractOraclePairs[contractOraclePairIndex];
|
|
1575
1621
|
|
|
1576
|
-
const {
|
|
1577
|
-
|
|
1578
|
-
oracleInfo,
|
|
1579
|
-
} = contractOraclePair;
|
|
1580
|
-
|
|
1622
|
+
const { contractDescriptor: _contractDescriptor, oracleInfo } =
|
|
1623
|
+
contractOraclePair;
|
|
1581
1624
|
assert(
|
|
1582
|
-
_contractDescriptor.
|
|
1583
|
-
|
|
1625
|
+
_contractDescriptor.contractDescriptorType ===
|
|
1626
|
+
ContractDescriptorType.NumericOutcome,
|
|
1627
|
+
'ContractDescriptor must be NumericOutcome',
|
|
1584
1628
|
);
|
|
1585
|
-
|
|
1586
|
-
const contractDescriptor = _contractDescriptor as ContractDescriptorV1;
|
|
1629
|
+
const contractDescriptor = _contractDescriptor as NumericalDescriptor;
|
|
1587
1630
|
const _payoutFunction = contractDescriptor.payoutFunction;
|
|
1588
|
-
|
|
1589
1631
|
assert(
|
|
1590
|
-
_payoutFunction.type === MessageType.
|
|
1632
|
+
_payoutFunction.type === MessageType.PayoutFunction,
|
|
1591
1633
|
'PayoutFunction must be V0',
|
|
1592
1634
|
);
|
|
1593
1635
|
|
|
1594
|
-
|
|
1595
|
-
|
|
1636
|
+
if (oracleInfo.type !== MessageType.SingleOracleInfo) {
|
|
1637
|
+
throw new Error('Only SingleOracleInfo supported in this context');
|
|
1638
|
+
}
|
|
1639
|
+
|
|
1640
|
+
const singleOracleInfo = oracleInfo as SingleOracleInfo;
|
|
1641
|
+
const eventDescriptor = singleOracleInfo.announcement.oracleEvent
|
|
1642
|
+
.eventDescriptor as DigitDecompositionEventDescriptor;
|
|
1596
1643
|
const payoutFunction = _payoutFunction as PayoutFunctionV0;
|
|
1597
1644
|
|
|
1598
1645
|
const base = eventDescriptor.base;
|
|
1599
|
-
|
|
1600
1646
|
const outcome: number = [...oracleAttestation.outcomes]
|
|
1601
1647
|
.reverse()
|
|
1602
1648
|
.reduce((acc, val, i) => acc + Number(val) * base ** i, 0);
|
|
1603
1649
|
|
|
1604
|
-
const piecesSorted = payoutFunction.
|
|
1605
|
-
(a, b) =>
|
|
1650
|
+
const piecesSorted = payoutFunction.payoutFunctionPieces.sort(
|
|
1651
|
+
(a, b) =>
|
|
1652
|
+
Number(a.endPoint.eventOutcome) - Number(b.endPoint.eventOutcome),
|
|
1606
1653
|
);
|
|
1607
1654
|
|
|
1608
|
-
const piece = piecesSorted.find(
|
|
1655
|
+
const piece = piecesSorted.find(
|
|
1656
|
+
(piece) => outcome < piece.endPoint.eventOutcome,
|
|
1657
|
+
);
|
|
1609
1658
|
|
|
1610
1659
|
switch (piece.payoutCurvePiece.type) {
|
|
1611
1660
|
case MessageType.PolynomialPayoutCurvePiece:
|
|
@@ -1641,30 +1690,34 @@ Payout Group not found',
|
|
|
1641
1690
|
}
|
|
1642
1691
|
|
|
1643
1692
|
ValidateEvent(
|
|
1644
|
-
|
|
1645
|
-
oracleAttestation:
|
|
1693
|
+
dlcOffer: DlcOffer,
|
|
1694
|
+
oracleAttestation: OracleAttestation,
|
|
1646
1695
|
): void {
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
case MessageType.ContractInfoV0: {
|
|
1653
|
-
const contractInfo = dlcOffer.contractInfo as ContractInfoV0;
|
|
1654
|
-
switch (contractInfo.contractDescriptor.type) {
|
|
1655
|
-
case MessageType.ContractDescriptorV0: {
|
|
1696
|
+
switch (dlcOffer.contractInfo.contractInfoType) {
|
|
1697
|
+
case ContractInfoType.Single: {
|
|
1698
|
+
const contractInfo = dlcOffer.contractInfo as SingleContractInfo;
|
|
1699
|
+
switch (contractInfo.contractDescriptor.contractDescriptorType) {
|
|
1700
|
+
case ContractDescriptorType.Enumerated: {
|
|
1656
1701
|
const oracleInfo = contractInfo.oracleInfo;
|
|
1702
|
+
if (oracleInfo.type !== MessageType.SingleOracleInfo) {
|
|
1703
|
+
throw Error('Only SingleOracleInfo supported in this context');
|
|
1704
|
+
}
|
|
1705
|
+
const singleOracleInfo = oracleInfo as SingleOracleInfo;
|
|
1657
1706
|
if (
|
|
1658
|
-
|
|
1707
|
+
singleOracleInfo.announcement.oracleEvent.eventId !==
|
|
1659
1708
|
oracleAttestation.eventId
|
|
1660
1709
|
)
|
|
1661
1710
|
throw Error('Incorrect Oracle Attestation. Event Id must match.');
|
|
1662
1711
|
break;
|
|
1663
1712
|
}
|
|
1664
|
-
case
|
|
1713
|
+
case ContractDescriptorType.NumericOutcome: {
|
|
1665
1714
|
const oracleInfo = contractInfo.oracleInfo;
|
|
1715
|
+
if (oracleInfo.type !== MessageType.SingleOracleInfo) {
|
|
1716
|
+
throw Error('Only SingleOracleInfo supported in this context');
|
|
1717
|
+
}
|
|
1718
|
+
const singleOracleInfo = oracleInfo as SingleOracleInfo;
|
|
1666
1719
|
if (
|
|
1667
|
-
|
|
1720
|
+
singleOracleInfo.announcement.oracleEvent.eventId !==
|
|
1668
1721
|
oracleAttestation.eventId
|
|
1669
1722
|
)
|
|
1670
1723
|
throw Error('Incorrect Oracle Attestation. Event Id must match.');
|
|
@@ -1675,12 +1728,17 @@ Payout Group not found',
|
|
|
1675
1728
|
}
|
|
1676
1729
|
break;
|
|
1677
1730
|
}
|
|
1678
|
-
case
|
|
1679
|
-
const contractInfo = dlcOffer.contractInfo as
|
|
1731
|
+
case ContractInfoType.Disjoint: {
|
|
1732
|
+
const contractInfo = dlcOffer.contractInfo as DisjointContractInfo;
|
|
1680
1733
|
const attestedOracleEvent = contractInfo.contractOraclePairs.find(
|
|
1681
|
-
({ oracleInfo }) =>
|
|
1682
|
-
oracleInfo.
|
|
1683
|
-
|
|
1734
|
+
({ oracleInfo }) => {
|
|
1735
|
+
if (oracleInfo.type !== MessageType.SingleOracleInfo) return false;
|
|
1736
|
+
const singleOracleInfo = oracleInfo as SingleOracleInfo;
|
|
1737
|
+
return (
|
|
1738
|
+
singleOracleInfo.announcement.oracleEvent.eventId ===
|
|
1739
|
+
oracleAttestation.eventId
|
|
1740
|
+
);
|
|
1741
|
+
},
|
|
1684
1742
|
);
|
|
1685
1743
|
|
|
1686
1744
|
if (!attestedOracleEvent)
|
|
@@ -1694,20 +1752,13 @@ Payout Group not found',
|
|
|
1694
1752
|
}
|
|
1695
1753
|
|
|
1696
1754
|
async FindAndSignCet(
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
oracleAttestation:
|
|
1755
|
+
dlcOffer: DlcOffer,
|
|
1756
|
+
dlcAccept: DlcAccept,
|
|
1757
|
+
dlcSign: DlcSign,
|
|
1758
|
+
dlcTxs: DlcTransactions,
|
|
1759
|
+
oracleAttestation: OracleAttestation,
|
|
1702
1760
|
isOfferer?: boolean,
|
|
1703
1761
|
): Promise<Tx> {
|
|
1704
|
-
const { dlcOffer, dlcAccept, dlcSign, dlcTxs } = checkTypes({
|
|
1705
|
-
_dlcOffer,
|
|
1706
|
-
_dlcAccept,
|
|
1707
|
-
_dlcSign,
|
|
1708
|
-
_dlcTxs,
|
|
1709
|
-
});
|
|
1710
|
-
|
|
1711
1762
|
if (isOfferer === undefined)
|
|
1712
1763
|
isOfferer = await this.isOfferer(dlcOffer, dlcAccept);
|
|
1713
1764
|
|
|
@@ -1720,14 +1771,16 @@ Payout Group not found',
|
|
|
1720
1771
|
let signCetRequest: SignCetRequest;
|
|
1721
1772
|
|
|
1722
1773
|
if (
|
|
1723
|
-
dlcOffer.contractInfo.
|
|
1724
|
-
(dlcOffer.contractInfo as
|
|
1725
|
-
|
|
1774
|
+
dlcOffer.contractInfo.contractInfoType === ContractInfoType.Single &&
|
|
1775
|
+
(dlcOffer.contractInfo as SingleContractInfo).contractDescriptor
|
|
1776
|
+
.contractDescriptorType === ContractDescriptorType.Enumerated
|
|
1726
1777
|
) {
|
|
1727
|
-
const outcomeIndex = (
|
|
1728
|
-
.
|
|
1778
|
+
const outcomeIndex = (
|
|
1779
|
+
(dlcOffer.contractInfo as SingleContractInfo)
|
|
1780
|
+
.contractDescriptor as EnumeratedDescriptor
|
|
1781
|
+
).outcomes.findIndex(
|
|
1729
1782
|
(outcome) =>
|
|
1730
|
-
outcome.outcome
|
|
1783
|
+
outcome.outcome ===
|
|
1731
1784
|
sha256(Buffer.from(oracleAttestation.outcomes[0])).toString('hex'),
|
|
1732
1785
|
);
|
|
1733
1786
|
|
|
@@ -1736,19 +1789,19 @@ Payout Group not found',
|
|
|
1736
1789
|
fundPrivkey: fundPrivateKey,
|
|
1737
1790
|
fundTxId: dlcTxs.fundTx.txId.toString(),
|
|
1738
1791
|
fundVout: dlcTxs.fundTxVout,
|
|
1739
|
-
localFundPubkey: dlcOffer.
|
|
1740
|
-
remoteFundPubkey: dlcAccept.
|
|
1792
|
+
localFundPubkey: dlcOffer.fundingPubkey.toString('hex'),
|
|
1793
|
+
remoteFundPubkey: dlcAccept.fundingPubkey.toString('hex'),
|
|
1741
1794
|
oracleSignatures: oracleAttestation.signatures.map((sig) =>
|
|
1742
1795
|
sig.toString('hex'),
|
|
1743
1796
|
),
|
|
1744
1797
|
fundInputAmount: dlcTxs.fundTx.outputs[dlcTxs.fundTxVout].value.sats,
|
|
1745
1798
|
adaptorSignature: isOfferer
|
|
1746
|
-
? dlcAccept.
|
|
1747
|
-
|
|
1748
|
-
)
|
|
1749
|
-
: dlcSign.
|
|
1750
|
-
|
|
1751
|
-
),
|
|
1799
|
+
? dlcAccept.cetAdaptorSignatures.sigs[
|
|
1800
|
+
outcomeIndex
|
|
1801
|
+
].encryptedSig.toString('hex')
|
|
1802
|
+
: dlcSign.cetAdaptorSignatures.sigs[
|
|
1803
|
+
outcomeIndex
|
|
1804
|
+
].encryptedSig.toString('hex'),
|
|
1752
1805
|
};
|
|
1753
1806
|
} else {
|
|
1754
1807
|
const { index: outcomeIndex, groupLength } = await this.FindOutcomeIndex(
|
|
@@ -1768,17 +1821,17 @@ Payout Group not found',
|
|
|
1768
1821
|
fundPrivkey: fundPrivateKey,
|
|
1769
1822
|
fundTxId: dlcTxs.fundTx.txId.toString(),
|
|
1770
1823
|
fundVout: dlcTxs.fundTxVout,
|
|
1771
|
-
localFundPubkey: dlcOffer.
|
|
1772
|
-
remoteFundPubkey: dlcAccept.
|
|
1824
|
+
localFundPubkey: dlcOffer.fundingPubkey.toString('hex'),
|
|
1825
|
+
remoteFundPubkey: dlcAccept.fundingPubkey.toString('hex'),
|
|
1773
1826
|
oracleSignatures: oracleSignatures.map((sig) => sig.toString('hex')),
|
|
1774
1827
|
fundInputAmount: dlcTxs.fundTx.outputs[dlcTxs.fundTxVout].value.sats,
|
|
1775
1828
|
adaptorSignature: isOfferer
|
|
1776
|
-
? dlcAccept.
|
|
1777
|
-
|
|
1778
|
-
)
|
|
1779
|
-
: dlcSign.
|
|
1780
|
-
|
|
1781
|
-
),
|
|
1829
|
+
? dlcAccept.cetAdaptorSignatures.sigs[
|
|
1830
|
+
outcomeIndex
|
|
1831
|
+
].encryptedSig.toString('hex')
|
|
1832
|
+
: dlcSign.cetAdaptorSignatures.sigs[
|
|
1833
|
+
outcomeIndex
|
|
1834
|
+
].encryptedSig.toString('hex'),
|
|
1782
1835
|
};
|
|
1783
1836
|
}
|
|
1784
1837
|
|
|
@@ -1788,14 +1841,14 @@ Payout Group not found',
|
|
|
1788
1841
|
}
|
|
1789
1842
|
|
|
1790
1843
|
private async GetFundAddress(
|
|
1791
|
-
dlcOffer:
|
|
1792
|
-
dlcAccept:
|
|
1844
|
+
dlcOffer: DlcOffer,
|
|
1845
|
+
dlcAccept: DlcAccept,
|
|
1793
1846
|
isOfferer: boolean,
|
|
1794
1847
|
): Promise<string> {
|
|
1795
1848
|
const network = await this.getConnectedNetwork();
|
|
1796
1849
|
|
|
1797
1850
|
const fundingSPK = Script.p2wpkhLock(
|
|
1798
|
-
hash160(isOfferer ? dlcOffer.
|
|
1851
|
+
hash160(isOfferer ? dlcOffer.fundingPubkey : dlcAccept.fundingPubkey),
|
|
1799
1852
|
)
|
|
1800
1853
|
.serialize()
|
|
1801
1854
|
.slice(1);
|
|
@@ -1809,8 +1862,8 @@ Payout Group not found',
|
|
|
1809
1862
|
}
|
|
1810
1863
|
|
|
1811
1864
|
private async GetFundKeyPair(
|
|
1812
|
-
dlcOffer:
|
|
1813
|
-
dlcAccept:
|
|
1865
|
+
dlcOffer: DlcOffer,
|
|
1866
|
+
dlcAccept: DlcAccept,
|
|
1814
1867
|
isOfferer: boolean,
|
|
1815
1868
|
): Promise<ECPairInterface> {
|
|
1816
1869
|
const fundingAddress = await this.GetFundAddress(
|
|
@@ -1819,19 +1872,17 @@ Payout Group not found',
|
|
|
1819
1872
|
isOfferer,
|
|
1820
1873
|
);
|
|
1821
1874
|
|
|
1822
|
-
const { derivationPath } =
|
|
1823
|
-
fundingAddress
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
derivationPath,
|
|
1827
|
-
);
|
|
1875
|
+
const { derivationPath } =
|
|
1876
|
+
await this.getMethod('getWalletAddress')(fundingAddress);
|
|
1877
|
+
const keyPair: ECPairInterface =
|
|
1878
|
+
await this.getMethod('keyPair')(derivationPath);
|
|
1828
1879
|
|
|
1829
1880
|
return keyPair;
|
|
1830
1881
|
}
|
|
1831
1882
|
|
|
1832
1883
|
private async GetFundPrivateKey(
|
|
1833
|
-
dlcOffer:
|
|
1834
|
-
dlcAccept:
|
|
1884
|
+
dlcOffer: DlcOffer,
|
|
1885
|
+
dlcAccept: DlcAccept,
|
|
1835
1886
|
isOfferer: boolean,
|
|
1836
1887
|
): Promise<string> {
|
|
1837
1888
|
const fundPrivateKeyPair: ECPairInterface = await this.GetFundKeyPair(
|
|
@@ -1844,28 +1895,23 @@ Payout Group not found',
|
|
|
1844
1895
|
}
|
|
1845
1896
|
|
|
1846
1897
|
async CreateCloseRawTxs(
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1898
|
+
dlcOffer: DlcOffer,
|
|
1899
|
+
dlcAccept: DlcAccept,
|
|
1900
|
+
dlcTxs: DlcTransactions,
|
|
1850
1901
|
closeInputAmount: bigint,
|
|
1851
1902
|
isOfferer: boolean,
|
|
1852
1903
|
_dlcCloses: DlcClose[] = [],
|
|
1853
1904
|
fundingInputs?: FundingInput[],
|
|
1854
1905
|
initiatorPayouts?: bigint[],
|
|
1855
1906
|
): Promise<string[]> {
|
|
1856
|
-
const { dlcOffer, dlcAccept, dlcTxs } = checkTypes({
|
|
1857
|
-
_dlcOffer,
|
|
1858
|
-
_dlcAccept,
|
|
1859
|
-
_dlcTxs,
|
|
1860
|
-
});
|
|
1861
1907
|
const network = await this.getConnectedNetwork();
|
|
1862
1908
|
|
|
1863
1909
|
let finalizer: DualClosingTxFinalizer;
|
|
1864
1910
|
if (_dlcCloses.length === 0) {
|
|
1865
1911
|
finalizer = new DualClosingTxFinalizer(
|
|
1866
1912
|
fundingInputs,
|
|
1867
|
-
dlcOffer.
|
|
1868
|
-
dlcAccept.
|
|
1913
|
+
dlcOffer.payoutSpk,
|
|
1914
|
+
dlcAccept.payoutSpk,
|
|
1869
1915
|
dlcOffer.feeRatePerVb,
|
|
1870
1916
|
);
|
|
1871
1917
|
}
|
|
@@ -1909,14 +1955,14 @@ Payout Group not found',
|
|
|
1909
1955
|
|
|
1910
1956
|
if (Number(offerPayoutValue) > 0) {
|
|
1911
1957
|
txOuts.push({
|
|
1912
|
-
address: address.fromOutputScript(dlcOffer.
|
|
1958
|
+
address: address.fromOutputScript(dlcOffer.payoutSpk, network),
|
|
1913
1959
|
amount: Number(offerPayoutValue),
|
|
1914
1960
|
});
|
|
1915
1961
|
}
|
|
1916
1962
|
|
|
1917
1963
|
if (Number(acceptPayoutValue) > 0) {
|
|
1918
1964
|
txOuts.push({
|
|
1919
|
-
address: address.fromOutputScript(dlcAccept.
|
|
1965
|
+
address: address.fromOutputScript(dlcAccept.payoutSpk, network),
|
|
1920
1966
|
amount: Number(acceptPayoutValue),
|
|
1921
1967
|
});
|
|
1922
1968
|
}
|
|
@@ -1968,9 +2014,9 @@ Payout Group not found',
|
|
|
1968
2014
|
const network = await this.getConnectedNetwork();
|
|
1969
2015
|
|
|
1970
2016
|
const fundingPubKeys =
|
|
1971
|
-
Buffer.compare(dlcOffer.
|
|
1972
|
-
? [dlcOffer.
|
|
1973
|
-
: [dlcAccept.
|
|
2017
|
+
Buffer.compare(dlcOffer.fundingPubkey, dlcAccept.fundingPubkey) === -1
|
|
2018
|
+
? [dlcOffer.fundingPubkey, dlcAccept.fundingPubkey]
|
|
2019
|
+
: [dlcAccept.fundingPubkey, dlcOffer.fundingPubkey];
|
|
1974
2020
|
|
|
1975
2021
|
const p2ms = payments.p2ms({
|
|
1976
2022
|
m: 2,
|
|
@@ -2079,9 +2125,9 @@ Payout Group not found',
|
|
|
2079
2125
|
const network = await this.getConnectedNetwork();
|
|
2080
2126
|
|
|
2081
2127
|
const fundingPubKeys =
|
|
2082
|
-
Buffer.compare(dlcOffer.
|
|
2083
|
-
? [dlcOffer.
|
|
2084
|
-
: [dlcAccept.
|
|
2128
|
+
Buffer.compare(dlcOffer.fundingPubkey, dlcAccept.fundingPubkey) === -1
|
|
2129
|
+
? [dlcOffer.fundingPubkey, dlcAccept.fundingPubkey]
|
|
2130
|
+
: [dlcAccept.fundingPubkey, dlcOffer.fundingPubkey];
|
|
2085
2131
|
|
|
2086
2132
|
const p2ms = payments.p2ms({
|
|
2087
2133
|
m: 2,
|
|
@@ -2094,7 +2140,7 @@ Payout Group not found',
|
|
|
2094
2140
|
network,
|
|
2095
2141
|
});
|
|
2096
2142
|
|
|
2097
|
-
const pubkey = isOfferer ? dlcAccept.
|
|
2143
|
+
const pubkey = isOfferer ? dlcAccept.fundingPubkey : dlcOffer.fundingPubkey;
|
|
2098
2144
|
|
|
2099
2145
|
const sigsValidity: Promise<boolean>[] = [];
|
|
2100
2146
|
|
|
@@ -2147,10 +2193,10 @@ Payout Group not found',
|
|
|
2147
2193
|
});
|
|
2148
2194
|
const network = await this.getConnectedNetwork();
|
|
2149
2195
|
|
|
2150
|
-
const offerFundingSPK = Script.p2wpkhLock(hash160(dlcOffer.
|
|
2196
|
+
const offerFundingSPK = Script.p2wpkhLock(hash160(dlcOffer.fundingPubkey))
|
|
2151
2197
|
.serialize()
|
|
2152
2198
|
.slice(1);
|
|
2153
|
-
const acceptFundingSPK = Script.p2wpkhLock(hash160(dlcAccept.
|
|
2199
|
+
const acceptFundingSPK = Script.p2wpkhLock(hash160(dlcAccept.fundingPubkey))
|
|
2154
2200
|
.serialize()
|
|
2155
2201
|
.slice(1);
|
|
2156
2202
|
|
|
@@ -2196,7 +2242,10 @@ Payout Group not found',
|
|
|
2196
2242
|
contractInfo.validate();
|
|
2197
2243
|
const network = await this.getConnectedNetwork();
|
|
2198
2244
|
|
|
2199
|
-
const dlcOffer = new
|
|
2245
|
+
const dlcOffer = new DlcOffer();
|
|
2246
|
+
|
|
2247
|
+
// Generate a random 32-byte temporary contract ID
|
|
2248
|
+
dlcOffer.temporaryContractId = crypto.randomBytes(32);
|
|
2200
2249
|
|
|
2201
2250
|
const {
|
|
2202
2251
|
fundingPubKey,
|
|
@@ -2213,13 +2262,13 @@ Payout Group not found',
|
|
|
2213
2262
|
|
|
2214
2263
|
_fundingInputs.forEach((input) =>
|
|
2215
2264
|
assert(
|
|
2216
|
-
input.type === MessageType.
|
|
2265
|
+
input.type === MessageType.FundingInput,
|
|
2217
2266
|
'FundingInput must be V0',
|
|
2218
2267
|
),
|
|
2219
2268
|
);
|
|
2220
2269
|
|
|
2221
|
-
const fundingInputs:
|
|
2222
|
-
(input) => input as
|
|
2270
|
+
const fundingInputs: FundingInput[] = _fundingInputs.map(
|
|
2271
|
+
(input) => input as FundingInput,
|
|
2223
2272
|
);
|
|
2224
2273
|
|
|
2225
2274
|
fundingInputs.sort(
|
|
@@ -2236,14 +2285,15 @@ Payout Group not found',
|
|
|
2236
2285
|
dlcOffer.contractFlags = Buffer.from('00', 'hex');
|
|
2237
2286
|
dlcOffer.chainHash = chainHashFromNetwork(network);
|
|
2238
2287
|
dlcOffer.contractInfo = contractInfo;
|
|
2239
|
-
dlcOffer.
|
|
2240
|
-
dlcOffer.
|
|
2288
|
+
dlcOffer.fundingPubkey = fundingPubKey;
|
|
2289
|
+
dlcOffer.payoutSpk = payoutSPK;
|
|
2241
2290
|
dlcOffer.payoutSerialId = payoutSerialId;
|
|
2242
|
-
dlcOffer.
|
|
2291
|
+
dlcOffer.offerCollateral = offerCollateralSatoshis;
|
|
2243
2292
|
dlcOffer.fundingInputs = fundingInputs;
|
|
2244
|
-
dlcOffer.
|
|
2293
|
+
dlcOffer.changeSpk = changeSPK;
|
|
2245
2294
|
dlcOffer.changeSerialId = changeSerialId;
|
|
2246
|
-
dlcOffer.fundOutputSerialId = dlcOffer.fundOutputSerialId =
|
|
2295
|
+
dlcOffer.fundOutputSerialId = dlcOffer.fundOutputSerialId =
|
|
2296
|
+
fundOutputSerialId;
|
|
2247
2297
|
dlcOffer.feeRatePerVb = feeRatePerVb;
|
|
2248
2298
|
dlcOffer.cetLocktime = cetLocktime;
|
|
2249
2299
|
dlcOffer.refundLocktime = refundLocktime;
|
|
@@ -2252,8 +2302,8 @@ Payout Group not found',
|
|
|
2252
2302
|
(() => {
|
|
2253
2303
|
const finalizer = new DualFundingTxFinalizer(
|
|
2254
2304
|
dlcOffer.fundingInputs,
|
|
2255
|
-
dlcOffer.
|
|
2256
|
-
dlcOffer.
|
|
2305
|
+
dlcOffer.payoutSpk,
|
|
2306
|
+
dlcOffer.changeSpk,
|
|
2257
2307
|
null,
|
|
2258
2308
|
null,
|
|
2259
2309
|
null,
|
|
@@ -2290,7 +2340,7 @@ Payout Group not found',
|
|
|
2290
2340
|
);
|
|
2291
2341
|
}
|
|
2292
2342
|
|
|
2293
|
-
const dlcOffers:
|
|
2343
|
+
const dlcOffers: DlcOffer[] = [];
|
|
2294
2344
|
|
|
2295
2345
|
for (let i = 0; i < contractInfos.length; i++) {
|
|
2296
2346
|
contractInfos[i].validate();
|
|
@@ -2307,13 +2357,13 @@ Payout Group not found',
|
|
|
2307
2357
|
|
|
2308
2358
|
_fundingInputs.forEach((input) =>
|
|
2309
2359
|
assert(
|
|
2310
|
-
input.type === MessageType.
|
|
2360
|
+
input.type === MessageType.FundingInput,
|
|
2311
2361
|
'FundingInput must be V0',
|
|
2312
2362
|
),
|
|
2313
2363
|
);
|
|
2314
2364
|
|
|
2315
|
-
const fundingInputs:
|
|
2316
|
-
(input) => input as
|
|
2365
|
+
const fundingInputs: FundingInput[] = _fundingInputs.map(
|
|
2366
|
+
(input) => input as FundingInput,
|
|
2317
2367
|
);
|
|
2318
2368
|
|
|
2319
2369
|
fundingInputs.sort(
|
|
@@ -2326,22 +2376,24 @@ Payout Group not found',
|
|
|
2326
2376
|
const contractInfo = contractInfos[i];
|
|
2327
2377
|
const offerCollateralSatoshis = offerCollaterals[i];
|
|
2328
2378
|
const fundOutputSerialId = fundOutputsSerialIds[i];
|
|
2329
|
-
const { fundingPubKey, payoutSPK, payoutSerialId } =
|
|
2330
|
-
i
|
|
2331
|
-
];
|
|
2379
|
+
const { fundingPubKey, payoutSPK, payoutSerialId } =
|
|
2380
|
+
initializeResponses[i];
|
|
2332
2381
|
const refundLocktime = refundLocktimes[i];
|
|
2333
2382
|
|
|
2334
|
-
const dlcOffer = new
|
|
2383
|
+
const dlcOffer = new DlcOffer();
|
|
2384
|
+
|
|
2385
|
+
// Generate a random 32-byte temporary contract ID
|
|
2386
|
+
dlcOffer.temporaryContractId = crypto.randomBytes(32);
|
|
2335
2387
|
|
|
2336
2388
|
dlcOffer.contractFlags = Buffer.from('00', 'hex');
|
|
2337
2389
|
dlcOffer.chainHash = chainHashFromNetwork(network);
|
|
2338
2390
|
dlcOffer.contractInfo = contractInfo;
|
|
2339
|
-
dlcOffer.
|
|
2340
|
-
dlcOffer.
|
|
2391
|
+
dlcOffer.fundingPubkey = fundingPubKey;
|
|
2392
|
+
dlcOffer.payoutSpk = payoutSPK;
|
|
2341
2393
|
dlcOffer.payoutSerialId = payoutSerialId;
|
|
2342
|
-
dlcOffer.
|
|
2394
|
+
dlcOffer.offerCollateral = offerCollateralSatoshis;
|
|
2343
2395
|
dlcOffer.fundingInputs = fundingInputs;
|
|
2344
|
-
dlcOffer.
|
|
2396
|
+
dlcOffer.changeSpk = changeSPK;
|
|
2345
2397
|
dlcOffer.changeSerialId = changeSerialId;
|
|
2346
2398
|
dlcOffer.fundOutputSerialId = fundOutputSerialId;
|
|
2347
2399
|
dlcOffer.feeRatePerVb = feeRatePerVb;
|
|
@@ -2352,8 +2404,8 @@ Payout Group not found',
|
|
|
2352
2404
|
(() => {
|
|
2353
2405
|
const finalizer = new DualFundingTxFinalizer(
|
|
2354
2406
|
dlcOffer.fundingInputs,
|
|
2355
|
-
dlcOffer.
|
|
2356
|
-
dlcOffer.
|
|
2407
|
+
dlcOffer.payoutSpk,
|
|
2408
|
+
dlcOffer.changeSpk,
|
|
2357
2409
|
null,
|
|
2358
2410
|
null,
|
|
2359
2411
|
null,
|
|
@@ -2390,12 +2442,11 @@ Payout Group not found',
|
|
|
2390
2442
|
dlcOffer.validate();
|
|
2391
2443
|
|
|
2392
2444
|
const acceptCollateralSatoshis =
|
|
2393
|
-
dlcOffer.contractInfo.totalCollateral - dlcOffer.
|
|
2445
|
+
dlcOffer.contractInfo.totalCollateral - dlcOffer.offerCollateral;
|
|
2394
2446
|
|
|
2395
2447
|
assert(
|
|
2396
2448
|
acceptCollateralSatoshis ===
|
|
2397
|
-
dlcOffer.contractInfo.totalCollateral -
|
|
2398
|
-
dlcOffer.offerCollateralSatoshis,
|
|
2449
|
+
dlcOffer.contractInfo.totalCollateral - dlcOffer.offerCollateral,
|
|
2399
2450
|
'acceptCollaterialSatoshis should equal totalCollateral - offerCollateralSatoshis',
|
|
2400
2451
|
);
|
|
2401
2452
|
|
|
@@ -2413,34 +2464,34 @@ Payout Group not found',
|
|
|
2413
2464
|
);
|
|
2414
2465
|
|
|
2415
2466
|
assert(
|
|
2416
|
-
Buffer.compare(dlcOffer.
|
|
2467
|
+
Buffer.compare(dlcOffer.fundingPubkey, fundingPubKey) !== 0,
|
|
2417
2468
|
'DlcOffer and DlcAccept FundingPubKey cannot be the same',
|
|
2418
2469
|
);
|
|
2419
2470
|
|
|
2420
2471
|
_fundingInputs.forEach((input) =>
|
|
2421
2472
|
assert(
|
|
2422
|
-
input.type === MessageType.
|
|
2473
|
+
input.type === MessageType.FundingInput,
|
|
2423
2474
|
'FundingInput must be V0',
|
|
2424
2475
|
),
|
|
2425
2476
|
);
|
|
2426
2477
|
|
|
2427
|
-
const fundingInputs:
|
|
2428
|
-
(input) => input as
|
|
2478
|
+
const fundingInputs: FundingInput[] = _fundingInputs.map(
|
|
2479
|
+
(input) => input as FundingInput,
|
|
2429
2480
|
);
|
|
2430
2481
|
|
|
2431
2482
|
fundingInputs.sort(
|
|
2432
2483
|
(a, b) => Number(a.inputSerialId) - Number(b.inputSerialId),
|
|
2433
2484
|
);
|
|
2434
2485
|
|
|
2435
|
-
const dlcAccept = new
|
|
2486
|
+
const dlcAccept = new DlcAccept();
|
|
2436
2487
|
|
|
2437
|
-
dlcAccept.
|
|
2438
|
-
dlcAccept.
|
|
2439
|
-
dlcAccept.
|
|
2440
|
-
dlcAccept.
|
|
2488
|
+
dlcAccept.temporaryContractId = sha256(dlcOffer.serialize());
|
|
2489
|
+
dlcAccept.acceptCollateral = acceptCollateralSatoshis;
|
|
2490
|
+
dlcAccept.fundingPubkey = fundingPubKey;
|
|
2491
|
+
dlcAccept.payoutSpk = payoutSPK;
|
|
2441
2492
|
dlcAccept.payoutSerialId = dlcAccept.payoutSerialId = payoutSerialId;
|
|
2442
2493
|
dlcAccept.fundingInputs = fundingInputs;
|
|
2443
|
-
dlcAccept.
|
|
2494
|
+
dlcAccept.changeSpk = changeSPK;
|
|
2444
2495
|
dlcAccept.changeSerialId = dlcAccept.changeSerialId = changeSerialId;
|
|
2445
2496
|
|
|
2446
2497
|
assert(
|
|
@@ -2471,11 +2522,11 @@ Payout Group not found',
|
|
|
2471
2522
|
(() => {
|
|
2472
2523
|
const finalizer = new DualFundingTxFinalizer(
|
|
2473
2524
|
dlcOffer.fundingInputs,
|
|
2474
|
-
dlcOffer.
|
|
2475
|
-
dlcOffer.
|
|
2525
|
+
dlcOffer.payoutSpk,
|
|
2526
|
+
dlcOffer.changeSpk,
|
|
2476
2527
|
dlcAccept.fundingInputs,
|
|
2477
|
-
dlcAccept.
|
|
2478
|
-
dlcAccept.
|
|
2528
|
+
dlcAccept.payoutSpk,
|
|
2529
|
+
dlcAccept.changeSpk,
|
|
2479
2530
|
dlcOffer.feeRatePerVb,
|
|
2480
2531
|
);
|
|
2481
2532
|
const funding = fundingInputs.reduce((total, input) => {
|
|
@@ -2492,32 +2543,25 @@ Payout Group not found',
|
|
|
2492
2543
|
dlcAccept,
|
|
2493
2544
|
);
|
|
2494
2545
|
|
|
2495
|
-
const {
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
false,
|
|
2504
|
-
);
|
|
2546
|
+
const { cetSignatures, refundSignature } =
|
|
2547
|
+
await this.CreateCetAdaptorAndRefundSigs(
|
|
2548
|
+
dlcOffer,
|
|
2549
|
+
dlcAccept,
|
|
2550
|
+
dlcTransactions,
|
|
2551
|
+
messagesList,
|
|
2552
|
+
false,
|
|
2553
|
+
);
|
|
2505
2554
|
|
|
2506
|
-
|
|
2507
|
-
dlcTransactions.type === MessageType.DlcTransactionsV0,
|
|
2508
|
-
'DlcTransactions must be V0',
|
|
2509
|
-
);
|
|
2510
|
-
const _dlcTransactions = dlcTransactions as DlcTransactionsV0;
|
|
2555
|
+
const _dlcTransactions = dlcTransactions;
|
|
2511
2556
|
|
|
2512
2557
|
const contractId = xor(
|
|
2513
2558
|
_dlcTransactions.fundTx.txId.serialize(),
|
|
2514
|
-
dlcAccept.
|
|
2559
|
+
dlcAccept.temporaryContractId,
|
|
2515
2560
|
);
|
|
2516
2561
|
_dlcTransactions.contractId = contractId;
|
|
2517
2562
|
|
|
2518
|
-
dlcAccept.
|
|
2563
|
+
dlcAccept.cetAdaptorSignatures = cetSignatures;
|
|
2519
2564
|
dlcAccept.refundSignature = refundSignature;
|
|
2520
|
-
dlcAccept.negotiationFields = new NegotiationFieldsV0();
|
|
2521
2565
|
|
|
2522
2566
|
return { dlcAccept, dlcTransactions: _dlcTransactions };
|
|
2523
2567
|
}
|
|
@@ -2534,8 +2578,7 @@ Payout Group not found',
|
|
|
2534
2578
|
|
|
2535
2579
|
const acceptCollaterals = dlcOffers.map(
|
|
2536
2580
|
(dlcOffer) =>
|
|
2537
|
-
dlcOffer.contractInfo.totalCollateral -
|
|
2538
|
-
dlcOffer.offerCollateralSatoshis,
|
|
2581
|
+
dlcOffer.contractInfo.totalCollateral - dlcOffer.offerCollateral,
|
|
2539
2582
|
);
|
|
2540
2583
|
|
|
2541
2584
|
const {
|
|
@@ -2555,7 +2598,7 @@ Payout Group not found',
|
|
|
2555
2598
|
initializeResponses.forEach((initializeResponse) => {
|
|
2556
2599
|
assert(
|
|
2557
2600
|
Buffer.compare(
|
|
2558
|
-
dlcOffer.
|
|
2601
|
+
dlcOffer.fundingPubkey,
|
|
2559
2602
|
initializeResponse.fundingPubKey,
|
|
2560
2603
|
) !== 0,
|
|
2561
2604
|
'DlcOffer and DlcAccept FundingPubKey cannot be the same',
|
|
@@ -2565,34 +2608,34 @@ Payout Group not found',
|
|
|
2565
2608
|
|
|
2566
2609
|
_fundingInputs.forEach((input) =>
|
|
2567
2610
|
assert(
|
|
2568
|
-
input.type === MessageType.
|
|
2611
|
+
input.type === MessageType.FundingInput,
|
|
2569
2612
|
'FundingInput must be V0',
|
|
2570
2613
|
),
|
|
2571
2614
|
);
|
|
2572
2615
|
|
|
2573
|
-
const fundingInputs:
|
|
2574
|
-
(input) => input as
|
|
2616
|
+
const fundingInputs: FundingInput[] = _fundingInputs.map(
|
|
2617
|
+
(input) => input as FundingInput,
|
|
2575
2618
|
);
|
|
2576
2619
|
|
|
2577
2620
|
fundingInputs.sort(
|
|
2578
2621
|
(a, b) => Number(a.inputSerialId) - Number(b.inputSerialId),
|
|
2579
2622
|
);
|
|
2580
2623
|
|
|
2581
|
-
const dlcAccepts:
|
|
2624
|
+
const dlcAccepts: DlcAccept[] = [];
|
|
2582
2625
|
|
|
2583
2626
|
initializeResponses.forEach((initializeResponse, i) => {
|
|
2584
2627
|
const dlcOffer = dlcOffers[i];
|
|
2585
|
-
const dlcAccept = new
|
|
2628
|
+
const dlcAccept = new DlcAccept();
|
|
2586
2629
|
|
|
2587
2630
|
const { fundingPubKey, payoutSPK, payoutSerialId } = initializeResponse;
|
|
2588
2631
|
|
|
2589
|
-
dlcAccept.
|
|
2590
|
-
dlcAccept.
|
|
2591
|
-
dlcAccept.
|
|
2592
|
-
dlcAccept.
|
|
2632
|
+
dlcAccept.temporaryContractId = sha256(dlcOffers[i].serialize());
|
|
2633
|
+
dlcAccept.acceptCollateral = acceptCollaterals[i];
|
|
2634
|
+
dlcAccept.fundingPubkey = fundingPubKey;
|
|
2635
|
+
dlcAccept.payoutSpk = payoutSPK;
|
|
2593
2636
|
dlcAccept.payoutSerialId = payoutSerialId;
|
|
2594
2637
|
dlcAccept.fundingInputs = fundingInputs;
|
|
2595
|
-
dlcAccept.
|
|
2638
|
+
dlcAccept.changeSpk = changeSPK;
|
|
2596
2639
|
dlcAccept.changeSerialId = changeSerialId;
|
|
2597
2640
|
|
|
2598
2641
|
assert(
|
|
@@ -2623,11 +2666,11 @@ Payout Group not found',
|
|
|
2623
2666
|
(() => {
|
|
2624
2667
|
const finalizer = new DualFundingTxFinalizer(
|
|
2625
2668
|
dlcOffer.fundingInputs,
|
|
2626
|
-
dlcOffer.
|
|
2627
|
-
dlcOffer.
|
|
2669
|
+
dlcOffer.payoutSpk,
|
|
2670
|
+
dlcOffer.changeSpk,
|
|
2628
2671
|
dlcAccept.fundingInputs,
|
|
2629
|
-
dlcAccept.
|
|
2630
|
-
dlcAccept.
|
|
2672
|
+
dlcAccept.payoutSpk,
|
|
2673
|
+
dlcAccept.changeSpk,
|
|
2631
2674
|
dlcOffer.feeRatePerVb,
|
|
2632
2675
|
);
|
|
2633
2676
|
const funding = fundingInputs.reduce((total, input) => {
|
|
@@ -2642,10 +2685,8 @@ Payout Group not found',
|
|
|
2642
2685
|
dlcAccepts.push(dlcAccept);
|
|
2643
2686
|
});
|
|
2644
2687
|
|
|
2645
|
-
const {
|
|
2646
|
-
|
|
2647
|
-
nestedMessagesList,
|
|
2648
|
-
} = await this.createBatchDlcTxs(dlcOffers, dlcAccepts);
|
|
2688
|
+
const { dlcTransactionsList, nestedMessagesList } =
|
|
2689
|
+
await this.createBatchDlcTxs(dlcOffers, dlcAccepts);
|
|
2649
2690
|
|
|
2650
2691
|
for (let i = 0; i < dlcAccepts.length; i++) {
|
|
2651
2692
|
const dlcOffer = dlcOffers[i];
|
|
@@ -2653,32 +2694,25 @@ Payout Group not found',
|
|
|
2653
2694
|
const dlcTransactions = dlcTransactionsList[i];
|
|
2654
2695
|
const messagesList = nestedMessagesList[i];
|
|
2655
2696
|
|
|
2656
|
-
const {
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
false,
|
|
2665
|
-
);
|
|
2697
|
+
const { cetSignatures, refundSignature } =
|
|
2698
|
+
await this.CreateCetAdaptorAndRefundSigs(
|
|
2699
|
+
dlcOffer,
|
|
2700
|
+
dlcAccept,
|
|
2701
|
+
dlcTransactions,
|
|
2702
|
+
messagesList,
|
|
2703
|
+
false,
|
|
2704
|
+
);
|
|
2666
2705
|
|
|
2667
|
-
|
|
2668
|
-
dlcTransactions.type === MessageType.DlcTransactionsV0,
|
|
2669
|
-
'DlcTransactions must be V0',
|
|
2670
|
-
);
|
|
2671
|
-
const _dlcTransactions = dlcTransactions as DlcTransactionsV0;
|
|
2706
|
+
const _dlcTransactions = dlcTransactions;
|
|
2672
2707
|
|
|
2673
2708
|
const contractId = xor(
|
|
2674
2709
|
_dlcTransactions.fundTx.txId.serialize(),
|
|
2675
|
-
dlcAccept.
|
|
2710
|
+
dlcAccept.temporaryContractId,
|
|
2676
2711
|
);
|
|
2677
2712
|
_dlcTransactions.contractId = contractId;
|
|
2678
2713
|
|
|
2679
|
-
dlcAccepts[i].
|
|
2714
|
+
dlcAccepts[i].cetAdaptorSignatures = cetSignatures;
|
|
2680
2715
|
dlcAccepts[i].refundSignature = refundSignature;
|
|
2681
|
-
dlcAccepts[i].negotiationFields = new NegotiationFieldsV0();
|
|
2682
2716
|
}
|
|
2683
2717
|
|
|
2684
2718
|
return { dlcAccepts, dlcTransactionsList };
|
|
@@ -2702,11 +2736,11 @@ Payout Group not found',
|
|
|
2702
2736
|
dlcAccept.validate();
|
|
2703
2737
|
|
|
2704
2738
|
assert(
|
|
2705
|
-
Buffer.compare(dlcOffer.
|
|
2739
|
+
Buffer.compare(dlcOffer.fundingPubkey, dlcAccept.fundingPubkey) !== 0,
|
|
2706
2740
|
'DlcOffer and DlcAccept FundingPubKey cannot be the same',
|
|
2707
2741
|
);
|
|
2708
2742
|
|
|
2709
|
-
const dlcSign = new
|
|
2743
|
+
const dlcSign = new DlcSign();
|
|
2710
2744
|
|
|
2711
2745
|
const { dlcTransactions, messagesList } = await this.createDlcTxs(
|
|
2712
2746
|
dlcOffer,
|
|
@@ -2722,16 +2756,14 @@ Payout Group not found',
|
|
|
2722
2756
|
true,
|
|
2723
2757
|
);
|
|
2724
2758
|
|
|
2725
|
-
const {
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
true,
|
|
2734
|
-
);
|
|
2759
|
+
const { cetSignatures, refundSignature } =
|
|
2760
|
+
await this.CreateCetAdaptorAndRefundSigs(
|
|
2761
|
+
dlcOffer,
|
|
2762
|
+
dlcAccept,
|
|
2763
|
+
dlcTransactions,
|
|
2764
|
+
messagesList,
|
|
2765
|
+
true,
|
|
2766
|
+
);
|
|
2735
2767
|
|
|
2736
2768
|
const fundingSignatures = await this.CreateFundingSigs(
|
|
2737
2769
|
dlcOffer,
|
|
@@ -2740,17 +2772,17 @@ Payout Group not found',
|
|
|
2740
2772
|
true,
|
|
2741
2773
|
);
|
|
2742
2774
|
|
|
2743
|
-
const dlcTxs = dlcTransactions
|
|
2775
|
+
const dlcTxs = dlcTransactions;
|
|
2744
2776
|
|
|
2745
2777
|
const contractId = xor(
|
|
2746
2778
|
dlcTxs.fundTx.txId.serialize(),
|
|
2747
|
-
dlcAccept.
|
|
2779
|
+
dlcAccept.temporaryContractId,
|
|
2748
2780
|
);
|
|
2749
2781
|
|
|
2750
2782
|
assert(
|
|
2751
2783
|
Buffer.compare(
|
|
2752
2784
|
contractId,
|
|
2753
|
-
xor(dlcTxs.fundTx.txId.serialize(), dlcAccept.
|
|
2785
|
+
xor(dlcTxs.fundTx.txId.serialize(), dlcAccept.temporaryContractId),
|
|
2754
2786
|
) === 0,
|
|
2755
2787
|
'contractId must be the xor of funding txid, fundingOutputIndex and the tempContractId',
|
|
2756
2788
|
);
|
|
@@ -2758,7 +2790,7 @@ Payout Group not found',
|
|
|
2758
2790
|
dlcTxs.contractId = contractId;
|
|
2759
2791
|
|
|
2760
2792
|
dlcSign.contractId = contractId;
|
|
2761
|
-
dlcSign.
|
|
2793
|
+
dlcSign.cetAdaptorSignatures = cetSignatures;
|
|
2762
2794
|
dlcSign.refundSignature = refundSignature;
|
|
2763
2795
|
dlcSign.fundingSignatures = fundingSignatures;
|
|
2764
2796
|
|
|
@@ -2781,12 +2813,10 @@ Payout Group not found',
|
|
|
2781
2813
|
return dlcAccept;
|
|
2782
2814
|
});
|
|
2783
2815
|
|
|
2784
|
-
const {
|
|
2785
|
-
|
|
2786
|
-
nestedMessagesList,
|
|
2787
|
-
} = await this.createBatchDlcTxs(dlcOffers, dlcAccepts);
|
|
2816
|
+
const { dlcTransactionsList, nestedMessagesList } =
|
|
2817
|
+
await this.createBatchDlcTxs(dlcOffers, dlcAccepts);
|
|
2788
2818
|
|
|
2789
|
-
const dlcSigns:
|
|
2819
|
+
const dlcSigns: DlcSign[] = [];
|
|
2790
2820
|
|
|
2791
2821
|
const fundingSignatures = await this.CreateFundingSigs(
|
|
2792
2822
|
dlcOffers[0],
|
|
@@ -2801,7 +2831,7 @@ Payout Group not found',
|
|
|
2801
2831
|
const dlcTransactions = dlcTransactionsList[i];
|
|
2802
2832
|
const messagesList = nestedMessagesList[i];
|
|
2803
2833
|
|
|
2804
|
-
const dlcSign = new
|
|
2834
|
+
const dlcSign = new DlcSign();
|
|
2805
2835
|
|
|
2806
2836
|
await this.VerifyCetAdaptorAndRefundSigs(
|
|
2807
2837
|
dlcOffer,
|
|
@@ -2812,28 +2842,26 @@ Payout Group not found',
|
|
|
2812
2842
|
true,
|
|
2813
2843
|
);
|
|
2814
2844
|
|
|
2815
|
-
const {
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
true,
|
|
2824
|
-
);
|
|
2845
|
+
const { cetSignatures, refundSignature } =
|
|
2846
|
+
await this.CreateCetAdaptorAndRefundSigs(
|
|
2847
|
+
dlcOffer,
|
|
2848
|
+
dlcAccept,
|
|
2849
|
+
dlcTransactions,
|
|
2850
|
+
messagesList,
|
|
2851
|
+
true,
|
|
2852
|
+
);
|
|
2825
2853
|
|
|
2826
|
-
const dlcTxs = dlcTransactions
|
|
2854
|
+
const dlcTxs = dlcTransactions;
|
|
2827
2855
|
|
|
2828
2856
|
const contractId = xor(
|
|
2829
2857
|
dlcTxs.fundTx.txId.serialize(),
|
|
2830
|
-
dlcAccept.
|
|
2858
|
+
dlcAccept.temporaryContractId,
|
|
2831
2859
|
);
|
|
2832
2860
|
|
|
2833
2861
|
dlcTxs.contractId = contractId;
|
|
2834
2862
|
|
|
2835
2863
|
dlcSign.contractId = contractId;
|
|
2836
|
-
dlcSign.
|
|
2864
|
+
dlcSign.cetAdaptorSignatures = cetSignatures;
|
|
2837
2865
|
dlcSign.refundSignature = refundSignature;
|
|
2838
2866
|
dlcSign.fundingSignatures = fundingSignatures;
|
|
2839
2867
|
|
|
@@ -2845,41 +2873,35 @@ Payout Group not found',
|
|
|
2845
2873
|
|
|
2846
2874
|
/**
|
|
2847
2875
|
* Finalize Dlc Sign
|
|
2848
|
-
* @param
|
|
2849
|
-
* @param
|
|
2850
|
-
* @param
|
|
2851
|
-
* @param
|
|
2876
|
+
* @param dlcOffer Dlc Offer Message
|
|
2877
|
+
* @param dlcAccept Dlc Accept Message
|
|
2878
|
+
* @param dlcSign Dlc Sign Message
|
|
2879
|
+
* @param dlcTxs Dlc Transactions Message
|
|
2852
2880
|
* @returns {Promise<Tx>}
|
|
2853
2881
|
*/
|
|
2854
2882
|
async finalizeDlcSign(
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2883
|
+
dlcOffer: DlcOffer,
|
|
2884
|
+
dlcAccept: DlcAccept,
|
|
2885
|
+
dlcSign: DlcSign,
|
|
2886
|
+
dlcTxs: DlcTransactions,
|
|
2859
2887
|
): Promise<Tx> {
|
|
2860
|
-
const { dlcOffer, dlcAccept, dlcSign, dlcTxs } = checkTypes({
|
|
2861
|
-
_dlcOffer,
|
|
2862
|
-
_dlcAccept,
|
|
2863
|
-
_dlcSign,
|
|
2864
|
-
_dlcTxs,
|
|
2865
|
-
});
|
|
2866
|
-
|
|
2867
2888
|
let messagesList: Messages[] = [];
|
|
2868
2889
|
|
|
2869
2890
|
if (
|
|
2870
|
-
dlcOffer.contractInfo.type === MessageType.
|
|
2871
|
-
(dlcOffer.contractInfo as
|
|
2872
|
-
MessageType.
|
|
2891
|
+
dlcOffer.contractInfo.type === MessageType.SingleContractInfo &&
|
|
2892
|
+
(dlcOffer.contractInfo as SingleContractInfo).contractDescriptor.type ===
|
|
2893
|
+
MessageType.SingleContractInfo
|
|
2873
2894
|
) {
|
|
2874
|
-
for (const outcome of (
|
|
2875
|
-
.
|
|
2876
|
-
|
|
2895
|
+
for (const outcome of (
|
|
2896
|
+
(dlcOffer.contractInfo as SingleContractInfo)
|
|
2897
|
+
.contractDescriptor as EnumeratedDescriptor
|
|
2898
|
+
).outcomes) {
|
|
2899
|
+
messagesList.push({ messages: [outcome.outcome] });
|
|
2877
2900
|
}
|
|
2878
2901
|
} else {
|
|
2879
2902
|
const payoutResponses = this.GetPayouts(dlcOffer);
|
|
2880
|
-
const { messagesList: oracleEventMessagesList } =
|
|
2881
|
-
payoutResponses
|
|
2882
|
-
);
|
|
2903
|
+
const { messagesList: oracleEventMessagesList } =
|
|
2904
|
+
this.FlattenPayouts(payoutResponses);
|
|
2883
2905
|
messagesList = oracleEventMessagesList;
|
|
2884
2906
|
}
|
|
2885
2907
|
|
|
@@ -2996,20 +3018,13 @@ Payout Group not found',
|
|
|
2996
3018
|
* @returns {Promise<Tx>}
|
|
2997
3019
|
*/
|
|
2998
3020
|
async execute(
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
oracleAttestation:
|
|
3021
|
+
dlcOffer: DlcOffer,
|
|
3022
|
+
dlcAccept: DlcAccept,
|
|
3023
|
+
dlcSign: DlcSign,
|
|
3024
|
+
dlcTxs: DlcTransactions,
|
|
3025
|
+
oracleAttestation: OracleAttestation,
|
|
3004
3026
|
isOfferer?: boolean,
|
|
3005
3027
|
): Promise<Tx> {
|
|
3006
|
-
const { dlcOffer, dlcAccept, dlcSign, dlcTxs } = checkTypes({
|
|
3007
|
-
_dlcOffer,
|
|
3008
|
-
_dlcAccept,
|
|
3009
|
-
_dlcSign,
|
|
3010
|
-
_dlcTxs,
|
|
3011
|
-
});
|
|
3012
|
-
|
|
3013
3028
|
if (isOfferer === undefined)
|
|
3014
3029
|
isOfferer = await this.isOfferer(dlcOffer, dlcAccept);
|
|
3015
3030
|
|
|
@@ -3047,7 +3062,7 @@ Payout Group not found',
|
|
|
3047
3062
|
});
|
|
3048
3063
|
|
|
3049
3064
|
const signatures =
|
|
3050
|
-
Buffer.compare(dlcOffer.
|
|
3065
|
+
Buffer.compare(dlcOffer.fundingPubkey, dlcAccept.fundingPubkey) === -1
|
|
3051
3066
|
? [
|
|
3052
3067
|
dlcSign.refundSignature.toString('hex'),
|
|
3053
3068
|
dlcAccept.refundSignature.toString('hex'),
|
|
@@ -3062,8 +3077,8 @@ Payout Group not found',
|
|
|
3062
3077
|
signatures,
|
|
3063
3078
|
fundTxId: dlcTxs.fundTx.txId.toString(),
|
|
3064
3079
|
fundVout: dlcTxs.fundTxVout,
|
|
3065
|
-
localFundPubkey: dlcOffer.
|
|
3066
|
-
remoteFundPubkey: dlcAccept.
|
|
3080
|
+
localFundPubkey: dlcOffer.fundingPubkey.toString('hex'),
|
|
3081
|
+
remoteFundPubkey: dlcAccept.fundingPubkey.toString('hex'),
|
|
3067
3082
|
};
|
|
3068
3083
|
|
|
3069
3084
|
const refundHex = (
|
|
@@ -3111,9 +3126,9 @@ Payout Group not found',
|
|
|
3111
3126
|
const psbt = new Psbt({ network });
|
|
3112
3127
|
|
|
3113
3128
|
const fundingPubKeys =
|
|
3114
|
-
Buffer.compare(dlcOffer.
|
|
3115
|
-
? [dlcOffer.
|
|
3116
|
-
: [dlcAccept.
|
|
3129
|
+
Buffer.compare(dlcOffer.fundingPubkey, dlcAccept.fundingPubkey) === -1
|
|
3130
|
+
? [dlcOffer.fundingPubkey, dlcAccept.fundingPubkey]
|
|
3131
|
+
: [dlcAccept.fundingPubkey, dlcOffer.fundingPubkey];
|
|
3117
3132
|
|
|
3118
3133
|
const p2ms = payments.p2ms({
|
|
3119
3134
|
m: 2,
|
|
@@ -3212,8 +3227,8 @@ Payout Group not found',
|
|
|
3212
3227
|
|
|
3213
3228
|
const finalizer = new DualClosingTxFinalizer(
|
|
3214
3229
|
fundingInputs,
|
|
3215
|
-
dlcOffer.
|
|
3216
|
-
dlcAccept.
|
|
3230
|
+
dlcOffer.payoutSpk,
|
|
3231
|
+
dlcAccept.payoutSpk,
|
|
3217
3232
|
dlcOffer.feeRatePerVb,
|
|
3218
3233
|
);
|
|
3219
3234
|
|
|
@@ -3238,7 +3253,7 @@ Payout Group not found',
|
|
|
3238
3253
|
psbt.addOutput({
|
|
3239
3254
|
value: Number(offerFirst ? offerPayoutValue : acceptPayoutValue),
|
|
3240
3255
|
address: address.fromOutputScript(
|
|
3241
|
-
offerFirst ? dlcOffer.
|
|
3256
|
+
offerFirst ? dlcOffer.payoutSpk : dlcAccept.payoutSpk,
|
|
3242
3257
|
network,
|
|
3243
3258
|
),
|
|
3244
3259
|
});
|
|
@@ -3246,7 +3261,7 @@ Payout Group not found',
|
|
|
3246
3261
|
psbt.addOutput({
|
|
3247
3262
|
value: Number(offerFirst ? acceptPayoutValue : offerPayoutValue),
|
|
3248
3263
|
address: address.fromOutputScript(
|
|
3249
|
-
offerFirst ? dlcAccept.
|
|
3264
|
+
offerFirst ? dlcAccept.payoutSpk : dlcOffer.payoutSpk,
|
|
3250
3265
|
network,
|
|
3251
3266
|
),
|
|
3252
3267
|
});
|
|
@@ -3298,11 +3313,11 @@ Payout Group not found',
|
|
|
3298
3313
|
pubKeyWitness.witness = inputSigs[i].pubkey;
|
|
3299
3314
|
witnessElements.push([sigWitness, pubKeyWitness]);
|
|
3300
3315
|
}
|
|
3301
|
-
const fundingSignatures = new
|
|
3316
|
+
const fundingSignatures = new FundingSignatures();
|
|
3302
3317
|
fundingSignatures.witnessElements = witnessElements;
|
|
3303
3318
|
|
|
3304
3319
|
// Create DlcClose
|
|
3305
|
-
const dlcClose = new
|
|
3320
|
+
const dlcClose = new DlcClose();
|
|
3306
3321
|
dlcClose.contractId = dlcTxs.contractId;
|
|
3307
3322
|
dlcClose.offerPayoutSatoshis = BigInt(
|
|
3308
3323
|
psbt.txOutputs[offerFirst ? 0 : 1].value,
|
|
@@ -3313,7 +3328,7 @@ Payout Group not found',
|
|
|
3313
3328
|
dlcClose.fundInputSerialId = fundingInputSerialId; // randomly generated serial id
|
|
3314
3329
|
dlcClose.closeSignature = closeSignature;
|
|
3315
3330
|
dlcClose.fundingSignatures = fundingSignatures;
|
|
3316
|
-
dlcClose.fundingInputs = fundingInputs as
|
|
3331
|
+
dlcClose.fundingInputs = fundingInputs as FundingInput[];
|
|
3317
3332
|
dlcClose.validate();
|
|
3318
3333
|
|
|
3319
3334
|
return dlcClose;
|
|
@@ -3355,8 +3370,8 @@ Payout Group not found',
|
|
|
3355
3370
|
|
|
3356
3371
|
const finalizer = new DualClosingTxFinalizer(
|
|
3357
3372
|
fundingInputs,
|
|
3358
|
-
dlcOffer.
|
|
3359
|
-
dlcAccept.
|
|
3373
|
+
dlcOffer.payoutSpk,
|
|
3374
|
+
dlcAccept.payoutSpk,
|
|
3360
3375
|
dlcOffer.feeRatePerVb,
|
|
3361
3376
|
);
|
|
3362
3377
|
|
|
@@ -3415,9 +3430,9 @@ Payout Group not found',
|
|
|
3415
3430
|
? collateralMinusPayout
|
|
3416
3431
|
: closeInputAmount + payoutMinusOfferFees;
|
|
3417
3432
|
|
|
3418
|
-
const fundingSignatures = new
|
|
3433
|
+
const fundingSignatures = new FundingSignatures();
|
|
3419
3434
|
|
|
3420
|
-
const dlcClose = new
|
|
3435
|
+
const dlcClose = new DlcClose();
|
|
3421
3436
|
dlcClose.contractId = dlcTxs.contractId;
|
|
3422
3437
|
dlcClose.offerPayoutSatoshis = offerPayoutValue;
|
|
3423
3438
|
dlcClose.acceptPayoutSatoshis = acceptPayoutValue;
|
|
@@ -3542,9 +3557,9 @@ Payout Group not found',
|
|
|
3542
3557
|
const psbt = new Psbt({ network });
|
|
3543
3558
|
|
|
3544
3559
|
const fundingPubKeys =
|
|
3545
|
-
Buffer.compare(dlcOffer.
|
|
3546
|
-
? [dlcOffer.
|
|
3547
|
-
: [dlcAccept.
|
|
3560
|
+
Buffer.compare(dlcOffer.fundingPubkey, dlcAccept.fundingPubkey) === -1
|
|
3561
|
+
? [dlcOffer.fundingPubkey, dlcAccept.fundingPubkey]
|
|
3562
|
+
: [dlcAccept.fundingPubkey, dlcOffer.fundingPubkey];
|
|
3548
3563
|
|
|
3549
3564
|
const p2ms = payments.p2ms({
|
|
3550
3565
|
m: 2,
|
|
@@ -3610,7 +3625,7 @@ Payout Group not found',
|
|
|
3610
3625
|
: dlcClose.acceptPayoutSatoshis,
|
|
3611
3626
|
),
|
|
3612
3627
|
address: address.fromOutputScript(
|
|
3613
|
-
offerFirst ? dlcOffer.
|
|
3628
|
+
offerFirst ? dlcOffer.payoutSpk : dlcAccept.payoutSpk,
|
|
3614
3629
|
network,
|
|
3615
3630
|
),
|
|
3616
3631
|
});
|
|
@@ -3622,7 +3637,7 @@ Payout Group not found',
|
|
|
3622
3637
|
: dlcClose.offerPayoutSatoshis,
|
|
3623
3638
|
),
|
|
3624
3639
|
address: address.fromOutputScript(
|
|
3625
|
-
offerFirst ? dlcAccept.
|
|
3640
|
+
offerFirst ? dlcAccept.payoutSpk : dlcOffer.payoutSpk,
|
|
3626
3641
|
network,
|
|
3627
3642
|
),
|
|
3628
3643
|
});
|
|
@@ -3644,7 +3659,7 @@ Payout Group not found',
|
|
|
3644
3659
|
|
|
3645
3660
|
const partialSig = [
|
|
3646
3661
|
{
|
|
3647
|
-
pubkey: offerer ? dlcAccept.
|
|
3662
|
+
pubkey: offerer ? dlcAccept.fundingPubkey : dlcOffer.fundingPubkey,
|
|
3648
3663
|
signature: await script.signature.encode(dlcClose.closeSignature, 1), // encode using SIGHASH_ALL
|
|
3649
3664
|
},
|
|
3650
3665
|
];
|
|
@@ -3828,12 +3843,9 @@ Payout Group not found',
|
|
|
3828
3843
|
_input: FundingInput,
|
|
3829
3844
|
findDerivationPath = true,
|
|
3830
3845
|
): Promise<Input> {
|
|
3831
|
-
assert(
|
|
3832
|
-
_input.type === MessageType.FundingInputV0,
|
|
3833
|
-
'FundingInput must be V0',
|
|
3834
|
-
);
|
|
3846
|
+
assert(_input.type === MessageType.FundingInput, 'FundingInput must be V0');
|
|
3835
3847
|
const network = await this.getConnectedNetwork();
|
|
3836
|
-
const input = _input as
|
|
3848
|
+
const input = _input as FundingInput;
|
|
3837
3849
|
const prevTx = input.prevTx;
|
|
3838
3850
|
const prevTxOut = prevTx.outputs[input.prevTxVout];
|
|
3839
3851
|
const scriptPubKey = prevTxOut.scriptPubKey.serialize().slice(1);
|
|
@@ -3867,7 +3879,7 @@ Payout Group not found',
|
|
|
3867
3879
|
}
|
|
3868
3880
|
|
|
3869
3881
|
async inputToFundingInput(input: Input): Promise<FundingInput> {
|
|
3870
|
-
const fundingInput = new
|
|
3882
|
+
const fundingInput = new FundingInput();
|
|
3871
3883
|
fundingInput.prevTxVout = input.vout;
|
|
3872
3884
|
|
|
3873
3885
|
let txRaw = '';
|
|
@@ -3973,7 +3985,7 @@ interface ISig {
|
|
|
3973
3985
|
}
|
|
3974
3986
|
|
|
3975
3987
|
export interface CreateCetAdaptorAndRefundSigsResponse {
|
|
3976
|
-
cetSignatures:
|
|
3988
|
+
cetSignatures: CetAdaptorSignatures;
|
|
3977
3989
|
refundSignature: Buffer;
|
|
3978
3990
|
}
|
|
3979
3991
|
|