@atomicfinance/bitcoin-wallet-provider 4.2.6 → 4.2.8
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/.turbo/turbo-build.log +4 -5
- package/CHANGELOG.md +24 -0
- package/package.json +7 -7
- package/.turbo/turbo-lint$colon$fix.log +0 -4
- package/.turbo/turbo-lint.log +0 -5
- package/.turbo/turbo-test.log +0 -0
- package/.yalc/@node-dlc/core/.nyc_output/687a3c14-9765-45fd-a1fe-f7db3d56fee4.json +0 -1
- package/.yalc/@node-dlc/core/.nyc_output/processinfo/687a3c14-9765-45fd-a1fe-f7db3d56fee4.json +0 -1
- package/.yalc/@node-dlc/core/.nyc_output/processinfo/index.json +0 -1
- package/.yalc/@node-dlc/core/README.md +0 -11
- package/.yalc/@node-dlc/core/__tests__/core.spec.ts +0 -7
- package/.yalc/@node-dlc/core/__tests__/dlc/CETCalculator.spec.ts +0 -1029
- package/.yalc/@node-dlc/core/__tests__/dlc/CoinSelect.spec.ts +0 -179
- package/.yalc/@node-dlc/core/__tests__/dlc/PolynomialPayoutCurve.spec.ts +0 -345
- package/.yalc/@node-dlc/core/__tests__/dlc/TxBuilder.spec.ts +0 -424
- package/.yalc/@node-dlc/core/__tests__/dlc/finance/Builder.spec.ts +0 -492
- package/.yalc/@node-dlc/core/__tests__/dlc/finance/CoveredCall.spec.ts +0 -112
- package/.yalc/@node-dlc/core/__tests__/dlc/finance/CsoInfo.spec.ts +0 -1124
- package/.yalc/@node-dlc/core/__tests__/dlc/finance/LongCall.spec.ts +0 -55
- package/.yalc/@node-dlc/core/__tests__/dlc/finance/LongPut.spec.ts +0 -55
- package/.yalc/@node-dlc/core/__tests__/dlc/finance/OptionInfo.spec.ts +0 -226
- package/.yalc/@node-dlc/core/__tests__/dlc/finance/ShortPut.spec.ts +0 -62
- package/.yalc/@node-dlc/core/__tests__/tsconfig.json +0 -8
- package/.yalc/@node-dlc/core/__tests__/utils/precision.spec.ts +0 -40
- package/.yalc/@node-dlc/core/coverage/lcov-report/base.css +0 -224
- package/.yalc/@node-dlc/core/coverage/lcov-report/block-navigation.js +0 -79
- package/.yalc/@node-dlc/core/coverage/lcov-report/favicon.png +0 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/index.html +0 -171
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/AsyncProcessingQueue.ts.html +0 -269
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/Base32.ts.html +0 -86
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/BigIntUtils.ts.html +0 -86
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/BitField.ts.html +0 -86
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/ChannelId.ts.html +0 -86
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/LinkedList.ts.html +0 -413
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/LinkedListNode.ts.html +0 -122
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/Queue.ts.html +0 -188
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/ShortChannelId.ts.html +0 -86
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/ShortChannelIdUtils.ts.html +0 -107
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/CETCalculator.ts.html +0 -1430
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/CoinSelect.ts.html +0 -431
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/HyperbolaPayoutCurve.ts.html +0 -644
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/PolynomialPayoutCurve.ts.html +0 -878
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/TxBuilder.ts.html +0 -1088
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/TxFinalizer.ts.html +0 -731
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/Builder.ts.html +0 -2270
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/CoveredCall.ts.html +0 -410
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/CsoInfo.ts.html +0 -1574
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/LinearPayout.ts.html +0 -362
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/LongCall.ts.html +0 -302
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/LongPut.ts.html +0 -302
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/OptionInfo.ts.html +0 -626
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/ShortPut.ts.html +0 -305
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/index.html +0 -216
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/index.html +0 -186
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/index.html +0 -261
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/index.ts.html +0 -278
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/ChannelId.ts.html +0 -242
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/ChannelKeys.ts.html +0 -407
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/CommitmentNumber.ts.html +0 -362
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/CommitmentSecret.ts.html +0 -203
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/CommitmentSecretStore.ts.html +0 -332
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/Htlc.ts.html +0 -236
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/HtlcDirection.ts.html +0 -131
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/ScriptFactory.ts.html +0 -530
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/TxFactory.ts.html +0 -1094
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/index.html +0 -231
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/utils/BigIntUtils.ts.html +0 -272
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/utils/Precision.ts.html +0 -149
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/utils/index.html +0 -126
- package/.yalc/@node-dlc/core/coverage/lcov-report/prettify.css +0 -1
- package/.yalc/@node-dlc/core/coverage/lcov-report/prettify.js +0 -2
- package/.yalc/@node-dlc/core/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/sorter.js +0 -170
- package/.yalc/@node-dlc/core/coverage/lcov.info +0 -2426
- package/.yalc/@node-dlc/core/dist/AsyncProcessingQueue.d.ts +0 -22
- package/.yalc/@node-dlc/core/dist/AsyncProcessingQueue.js +0 -55
- package/.yalc/@node-dlc/core/dist/AsyncProcessingQueue.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/Base32.d.ts +0 -1
- package/.yalc/@node-dlc/core/dist/Base32.js +0 -7
- package/.yalc/@node-dlc/core/dist/Base32.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/BigIntUtils.d.ts +0 -1
- package/.yalc/@node-dlc/core/dist/BigIntUtils.js +0 -8
- package/.yalc/@node-dlc/core/dist/BigIntUtils.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/BitField.d.ts +0 -1
- package/.yalc/@node-dlc/core/dist/BitField.js +0 -7
- package/.yalc/@node-dlc/core/dist/BitField.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/ChannelId.d.ts +0 -1
- package/.yalc/@node-dlc/core/dist/ChannelId.js +0 -7
- package/.yalc/@node-dlc/core/dist/ChannelId.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/LinkedList.d.ts +0 -30
- package/.yalc/@node-dlc/core/dist/LinkedList.js +0 -104
- package/.yalc/@node-dlc/core/dist/LinkedList.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/LinkedListNode.d.ts +0 -9
- package/.yalc/@node-dlc/core/dist/LinkedListNode.js +0 -15
- package/.yalc/@node-dlc/core/dist/LinkedListNode.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/Queue.d.ts +0 -22
- package/.yalc/@node-dlc/core/dist/Queue.js +0 -38
- package/.yalc/@node-dlc/core/dist/Queue.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/ShortChannelId.d.ts +0 -1
- package/.yalc/@node-dlc/core/dist/ShortChannelId.js +0 -7
- package/.yalc/@node-dlc/core/dist/ShortChannelId.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/ShortChannelIdUtils.d.ts +0 -1
- package/.yalc/@node-dlc/core/dist/ShortChannelIdUtils.js +0 -12
- package/.yalc/@node-dlc/core/dist/ShortChannelIdUtils.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/dlc/CETCalculator.d.ts +0 -50
- package/.yalc/@node-dlc/core/dist/dlc/CETCalculator.js +0 -332
- package/.yalc/@node-dlc/core/dist/dlc/CETCalculator.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/dlc/CoinSelect.d.ts +0 -23
- package/.yalc/@node-dlc/core/dist/dlc/CoinSelect.js +0 -77
- package/.yalc/@node-dlc/core/dist/dlc/CoinSelect.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/dlc/HyperbolaPayoutCurve.d.ts +0 -20
- package/.yalc/@node-dlc/core/dist/dlc/HyperbolaPayoutCurve.js +0 -117
- package/.yalc/@node-dlc/core/dist/dlc/HyperbolaPayoutCurve.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/dlc/PayoutCurve.d.ts +0 -5
- package/.yalc/@node-dlc/core/dist/dlc/PayoutCurve.js +0 -3
- package/.yalc/@node-dlc/core/dist/dlc/PayoutCurve.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/dlc/PolynomialPayoutCurve.d.ts +0 -52
- package/.yalc/@node-dlc/core/dist/dlc/PolynomialPayoutCurve.js +0 -173
- package/.yalc/@node-dlc/core/dist/dlc/PolynomialPayoutCurve.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/dlc/TxBuilder.d.ts +0 -55
- package/.yalc/@node-dlc/core/dist/dlc/TxBuilder.js +0 -217
- package/.yalc/@node-dlc/core/dist/dlc/TxBuilder.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/dlc/TxFinalizer.d.ts +0 -40
- package/.yalc/@node-dlc/core/dist/dlc/TxFinalizer.js +0 -146
- package/.yalc/@node-dlc/core/dist/dlc/TxFinalizer.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/dlc/finance/Builder.d.ts +0 -193
- package/.yalc/@node-dlc/core/dist/dlc/finance/Builder.js +0 -422
- package/.yalc/@node-dlc/core/dist/dlc/finance/Builder.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/dlc/finance/CoveredCall.d.ts +0 -13
- package/.yalc/@node-dlc/core/dist/dlc/finance/CoveredCall.js +0 -67
- package/.yalc/@node-dlc/core/dist/dlc/finance/CoveredCall.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/dlc/finance/CsoInfo.d.ts +0 -114
- package/.yalc/@node-dlc/core/dist/dlc/finance/CsoInfo.js +0 -290
- package/.yalc/@node-dlc/core/dist/dlc/finance/CsoInfo.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/dlc/finance/LinearPayout.d.ts +0 -6
- package/.yalc/@node-dlc/core/dist/dlc/finance/LinearPayout.js +0 -79
- package/.yalc/@node-dlc/core/dist/dlc/finance/LinearPayout.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/dlc/finance/LongCall.d.ts +0 -13
- package/.yalc/@node-dlc/core/dist/dlc/finance/LongCall.js +0 -47
- package/.yalc/@node-dlc/core/dist/dlc/finance/LongCall.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/dlc/finance/LongPut.d.ts +0 -13
- package/.yalc/@node-dlc/core/dist/dlc/finance/LongPut.js +0 -47
- package/.yalc/@node-dlc/core/dist/dlc/finance/LongPut.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/dlc/finance/OptionInfo.d.ts +0 -20
- package/.yalc/@node-dlc/core/dist/dlc/finance/OptionInfo.js +0 -101
- package/.yalc/@node-dlc/core/dist/dlc/finance/OptionInfo.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/dlc/finance/ShortPut.d.ts +0 -12
- package/.yalc/@node-dlc/core/dist/dlc/finance/ShortPut.js +0 -46
- package/.yalc/@node-dlc/core/dist/dlc/finance/ShortPut.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/index.d.ts +0 -39
- package/.yalc/@node-dlc/core/dist/index.js +0 -78
- package/.yalc/@node-dlc/core/dist/index.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/lightning/ChannelId.d.ts +0 -31
- package/.yalc/@node-dlc/core/dist/lightning/ChannelId.js +0 -52
- package/.yalc/@node-dlc/core/dist/lightning/ChannelId.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/lightning/ChannelKeys.d.ts +0 -55
- package/.yalc/@node-dlc/core/dist/lightning/ChannelKeys.js +0 -105
- package/.yalc/@node-dlc/core/dist/lightning/ChannelKeys.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/lightning/CommitmentNumber.d.ts +0 -55
- package/.yalc/@node-dlc/core/dist/lightning/CommitmentNumber.js +0 -76
- package/.yalc/@node-dlc/core/dist/lightning/CommitmentNumber.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/lightning/CommitmentSecret.d.ts +0 -26
- package/.yalc/@node-dlc/core/dist/lightning/CommitmentSecret.js +0 -44
- package/.yalc/@node-dlc/core/dist/lightning/CommitmentSecret.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/lightning/CommitmentSecretStore.d.ts +0 -41
- package/.yalc/@node-dlc/core/dist/lightning/CommitmentSecretStore.js +0 -79
- package/.yalc/@node-dlc/core/dist/lightning/CommitmentSecretStore.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/lightning/Htlc.d.ts +0 -46
- package/.yalc/@node-dlc/core/dist/lightning/Htlc.js +0 -46
- package/.yalc/@node-dlc/core/dist/lightning/Htlc.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/lightning/HtlcDirection.d.ts +0 -16
- package/.yalc/@node-dlc/core/dist/lightning/HtlcDirection.js +0 -21
- package/.yalc/@node-dlc/core/dist/lightning/HtlcDirection.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/lightning/ScriptFactory.d.ts +0 -76
- package/.yalc/@node-dlc/core/dist/lightning/ScriptFactory.js +0 -102
- package/.yalc/@node-dlc/core/dist/lightning/ScriptFactory.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/lightning/TxFactory.d.ts +0 -83
- package/.yalc/@node-dlc/core/dist/lightning/TxFactory.js +0 -222
- package/.yalc/@node-dlc/core/dist/lightning/TxFactory.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/utils/BigIntUtils.d.ts +0 -9
- package/.yalc/@node-dlc/core/dist/utils/BigIntUtils.js +0 -59
- package/.yalc/@node-dlc/core/dist/utils/BigIntUtils.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/utils/Precision.d.ts +0 -13
- package/.yalc/@node-dlc/core/dist/utils/Precision.js +0 -28
- package/.yalc/@node-dlc/core/dist/utils/Precision.js.map +0 -1
- package/.yalc/@node-dlc/core/lib/AsyncProcessingQueue.ts +0 -63
- package/.yalc/@node-dlc/core/lib/Base32.ts +0 -2
- package/.yalc/@node-dlc/core/lib/BigIntUtils.ts +0 -2
- package/.yalc/@node-dlc/core/lib/BitField.ts +0 -2
- package/.yalc/@node-dlc/core/lib/ChannelId.ts +0 -2
- package/.yalc/@node-dlc/core/lib/LinkedList.ts +0 -111
- package/.yalc/@node-dlc/core/lib/LinkedListNode.ts +0 -14
- package/.yalc/@node-dlc/core/lib/Queue.ts +0 -36
- package/.yalc/@node-dlc/core/lib/ShortChannelId.ts +0 -2
- package/.yalc/@node-dlc/core/lib/ShortChannelIdUtils.ts +0 -9
- package/.yalc/@node-dlc/core/lib/dlc/CETCalculator.ts +0 -450
- package/.yalc/@node-dlc/core/lib/dlc/CoinSelect.ts +0 -117
- package/.yalc/@node-dlc/core/lib/dlc/HyperbolaPayoutCurve.ts +0 -188
- package/.yalc/@node-dlc/core/lib/dlc/PayoutCurve.ts +0 -6
- package/.yalc/@node-dlc/core/lib/dlc/PolynomialPayoutCurve.ts +0 -266
- package/.yalc/@node-dlc/core/lib/dlc/TxBuilder.ts +0 -336
- package/.yalc/@node-dlc/core/lib/dlc/TxFinalizer.ts +0 -217
- package/.yalc/@node-dlc/core/lib/dlc/finance/Builder.ts +0 -730
- package/.yalc/@node-dlc/core/lib/dlc/finance/CoveredCall.ts +0 -110
- package/.yalc/@node-dlc/core/lib/dlc/finance/CsoInfo.ts +0 -498
- package/.yalc/@node-dlc/core/lib/dlc/finance/LinearPayout.ts +0 -94
- package/.yalc/@node-dlc/core/lib/dlc/finance/LongCall.ts +0 -74
- package/.yalc/@node-dlc/core/lib/dlc/finance/LongPut.ts +0 -74
- package/.yalc/@node-dlc/core/lib/dlc/finance/OptionInfo.ts +0 -182
- package/.yalc/@node-dlc/core/lib/dlc/finance/ShortPut.ts +0 -75
- package/.yalc/@node-dlc/core/lib/index.ts +0 -66
- package/.yalc/@node-dlc/core/lib/lightning/ChannelId.ts +0 -54
- package/.yalc/@node-dlc/core/lib/lightning/ChannelKeys.ts +0 -109
- package/.yalc/@node-dlc/core/lib/lightning/CommitmentNumber.ts +0 -94
- package/.yalc/@node-dlc/core/lib/lightning/CommitmentSecret.ts +0 -41
- package/.yalc/@node-dlc/core/lib/lightning/CommitmentSecretStore.ts +0 -84
- package/.yalc/@node-dlc/core/lib/lightning/Htlc.ts +0 -52
- package/.yalc/@node-dlc/core/lib/lightning/HtlcDirection.ts +0 -17
- package/.yalc/@node-dlc/core/lib/lightning/ScriptFactory.ts +0 -150
- package/.yalc/@node-dlc/core/lib/lightning/TxFactory.ts +0 -338
- package/.yalc/@node-dlc/core/lib/utils/BigIntUtils.ts +0 -64
- package/.yalc/@node-dlc/core/lib/utils/Precision.ts +0 -23
- package/.yalc/@node-dlc/core/package.json +0 -38
- package/.yalc/@node-dlc/core/tsconfig.json +0 -8
- package/.yalc/@node-dlc/core/yalc.sig +0 -1
- package/yalc.lock +0 -10
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { PayoutFunction, PolynomialPayoutCurvePiece, RoundingIntervals } from '@node-dlc/messaging';
|
|
2
|
-
import BigNumber from 'bignumber.js';
|
|
3
|
-
import { CETPayout } from './CETCalculator';
|
|
4
|
-
interface DlcPoint {
|
|
5
|
-
outcome: BigNumber;
|
|
6
|
-
payout: BigNumber;
|
|
7
|
-
}
|
|
8
|
-
export declare class PolynomialPayoutCurve {
|
|
9
|
-
private readonly points;
|
|
10
|
-
private readonly slope;
|
|
11
|
-
private readonly left;
|
|
12
|
-
private readonly right;
|
|
13
|
-
constructor(points: DlcPoint[]);
|
|
14
|
-
/**
|
|
15
|
-
* Get the payout for a given outcome
|
|
16
|
-
* @param outcome The outcome to get the payout for
|
|
17
|
-
* @returns The payout for the outcome
|
|
18
|
-
*/
|
|
19
|
-
getPayout(outcome: bigint): BigNumber;
|
|
20
|
-
/**
|
|
21
|
-
* Get the outcome for a given payout
|
|
22
|
-
* @param payout The payout to get the outcome for
|
|
23
|
-
* @returns The outcome for the payout
|
|
24
|
-
*/
|
|
25
|
-
getOutcomeForPayout(payout: BigNumber): bigint;
|
|
26
|
-
/**
|
|
27
|
-
* Serializes PolynomialPayoutCurve to a PolynomialPayoutCurvePiece (for transport)
|
|
28
|
-
* @returns A PolynomialPayoutCurvePiece
|
|
29
|
-
*/
|
|
30
|
-
toPayoutCurvePiece(): PolynomialPayoutCurvePiece;
|
|
31
|
-
/**
|
|
32
|
-
* Determine if the payout curve is equal to another
|
|
33
|
-
* @param curve A PolynomialPayoutCurve
|
|
34
|
-
* @returns True if the curves are the same
|
|
35
|
-
*/
|
|
36
|
-
equals(curve: PolynomialPayoutCurve): boolean;
|
|
37
|
-
/**
|
|
38
|
-
* Creates a PolynomialPayoutCurve from a PolynomialPayoutCurvePiece
|
|
39
|
-
* @param piece
|
|
40
|
-
* @returns A PolynomialPayoutCurve
|
|
41
|
-
*/
|
|
42
|
-
static fromPayoutCurvePiece(piece: PolynomialPayoutCurvePiece): PolynomialPayoutCurve;
|
|
43
|
-
/**
|
|
44
|
-
* Computes all CETs for a given payout curve
|
|
45
|
-
* @param payoutFunction The payout function
|
|
46
|
-
* @param totalCollateral The total collateral
|
|
47
|
-
* @param roundingIntervals The rounding intervals
|
|
48
|
-
* @returns A list of CETs
|
|
49
|
-
*/
|
|
50
|
-
static computePayouts(payoutFunction: PayoutFunction, totalCollateral: bigint, roundingIntervals: RoundingIntervals): CETPayout[];
|
|
51
|
-
}
|
|
52
|
-
export {};
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.PolynomialPayoutCurve = void 0;
|
|
7
|
-
const messaging_1 = require("@node-dlc/messaging");
|
|
8
|
-
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
9
|
-
const Precision_1 = require("../utils/Precision");
|
|
10
|
-
const CETCalculator_1 = require("./CETCalculator");
|
|
11
|
-
class PolynomialPayoutCurve {
|
|
12
|
-
constructor(points) {
|
|
13
|
-
if (points.length !== 2)
|
|
14
|
-
throw new Error('Must have two points');
|
|
15
|
-
this.points = points;
|
|
16
|
-
this.left = points[0];
|
|
17
|
-
this.right = points[points.length - 1];
|
|
18
|
-
// m = (y2 - y1) / (x2 - x1)
|
|
19
|
-
this.slope = this.right.payout
|
|
20
|
-
.minus(this.left.payout)
|
|
21
|
-
.dividedBy(this.right.outcome.minus(this.left.outcome));
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Get the payout for a given outcome
|
|
25
|
-
* @param outcome The outcome to get the payout for
|
|
26
|
-
* @returns The payout for the outcome
|
|
27
|
-
*/
|
|
28
|
-
getPayout(outcome) {
|
|
29
|
-
const { left, slope } = this;
|
|
30
|
-
const x = new bignumber_js_1.default(Number(outcome));
|
|
31
|
-
// y = mx + b
|
|
32
|
-
const payout = slope.times(x.minus(left.outcome)).plus(left.payout);
|
|
33
|
-
return payout;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Get the outcome for a given payout
|
|
37
|
-
* @param payout The payout to get the outcome for
|
|
38
|
-
* @returns The outcome for the payout
|
|
39
|
-
*/
|
|
40
|
-
getOutcomeForPayout(payout) {
|
|
41
|
-
const { left, right, slope } = this;
|
|
42
|
-
const y = new bignumber_js_1.default(Number(payout));
|
|
43
|
-
// Handle constant payout curve (slope = 0)
|
|
44
|
-
if (slope.isZero()) {
|
|
45
|
-
// For constant curves, if the payout matches, return any outcome in the range
|
|
46
|
-
// If it doesn't match, this is an invalid request
|
|
47
|
-
if (y.eq(left.payout)) {
|
|
48
|
-
return BigInt(left.outcome.toString());
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
// For constant curves, if payout doesn't match, return left outcome
|
|
52
|
-
// This prevents Infinity errors in calculations
|
|
53
|
-
return BigInt(left.outcome.toString());
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
// Find the x value for the given y
|
|
57
|
-
// slope = (y2 - y1) / (x2 - x1)
|
|
58
|
-
// x1 = (y2 - y1) / slope + x2
|
|
59
|
-
const outcome = y
|
|
60
|
-
.minus(left.payout)
|
|
61
|
-
.dividedBy(slope)
|
|
62
|
-
.plus(left.outcome)
|
|
63
|
-
.integerValue();
|
|
64
|
-
// Clamp the outcome to the valid range
|
|
65
|
-
const clampedOutcome = bignumber_js_1.default.max(left.outcome, bignumber_js_1.default.min(outcome, right.outcome));
|
|
66
|
-
return BigInt(clampedOutcome.toString());
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Serializes PolynomialPayoutCurve to a PolynomialPayoutCurvePiece (for transport)
|
|
70
|
-
* @returns A PolynomialPayoutCurvePiece
|
|
71
|
-
*/
|
|
72
|
-
toPayoutCurvePiece() {
|
|
73
|
-
const { points } = this;
|
|
74
|
-
const piece = new messaging_1.PolynomialPayoutCurvePiece();
|
|
75
|
-
piece.points = points.map((point) => {
|
|
76
|
-
const eventOutcome = BigInt(point.outcome.toString());
|
|
77
|
-
const outcomePayout = BigInt(point.payout.toString());
|
|
78
|
-
const extraPrecision = (0, Precision_1.getPrecision)(point.payout);
|
|
79
|
-
return { eventOutcome, outcomePayout, extraPrecision };
|
|
80
|
-
});
|
|
81
|
-
return piece;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Determine if the payout curve is equal to another
|
|
85
|
-
* @param curve A PolynomialPayoutCurve
|
|
86
|
-
* @returns True if the curves are the same
|
|
87
|
-
*/
|
|
88
|
-
equals(curve) {
|
|
89
|
-
return this.points.every((point, i) => {
|
|
90
|
-
const otherPoint = curve.points[i];
|
|
91
|
-
return (point.outcome.eq(otherPoint.outcome) &&
|
|
92
|
-
point.payout.eq(otherPoint.payout));
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Creates a PolynomialPayoutCurve from a PolynomialPayoutCurvePiece
|
|
97
|
-
* @param piece
|
|
98
|
-
* @returns A PolynomialPayoutCurve
|
|
99
|
-
*/
|
|
100
|
-
static fromPayoutCurvePiece(piece) {
|
|
101
|
-
const points = piece.points.map((point) => {
|
|
102
|
-
const outcome = new bignumber_js_1.default(point.eventOutcome.toString());
|
|
103
|
-
const payout = new bignumber_js_1.default(point.outcomePayout.toString()).plus((0, Precision_1.fromPrecision)(point.extraPrecision));
|
|
104
|
-
return { outcome, payout };
|
|
105
|
-
});
|
|
106
|
-
return new PolynomialPayoutCurve(points);
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Computes all CETs for a given payout curve
|
|
110
|
-
* @param payoutFunction The payout function
|
|
111
|
-
* @param totalCollateral The total collateral
|
|
112
|
-
* @param roundingIntervals The rounding intervals
|
|
113
|
-
* @returns A list of CETs
|
|
114
|
-
*/
|
|
115
|
-
static computePayouts(payoutFunction, totalCollateral, roundingIntervals) {
|
|
116
|
-
if (payoutFunction.payoutFunctionPieces.length < 1)
|
|
117
|
-
throw new Error('Must have at least one piece');
|
|
118
|
-
payoutFunction.payoutFunctionPieces.forEach((piece) => {
|
|
119
|
-
if (piece.payoutCurvePiece.payoutCurvePieceType !==
|
|
120
|
-
messaging_1.PayoutCurvePieceType.Polynomial &&
|
|
121
|
-
piece.payoutCurvePiece.type !== messaging_1.MessageType.PolynomialPayoutCurvePiece)
|
|
122
|
-
throw new Error('Payout curve piece must be a polynomial');
|
|
123
|
-
});
|
|
124
|
-
const CETS = [];
|
|
125
|
-
// 1. Add the first piece to the list
|
|
126
|
-
const { payoutCurvePiece } = payoutFunction.payoutFunctionPieces[0];
|
|
127
|
-
const curve = this.fromPayoutCurvePiece(payoutCurvePiece);
|
|
128
|
-
// For the first piece, start from 0 and go to the first endpoint
|
|
129
|
-
const firstPiece = payoutFunction.payoutFunctionPieces[0];
|
|
130
|
-
// Calculate the start payout by evaluating the curve at outcome 0
|
|
131
|
-
const startPayout = curve.getPayout(BigInt(0));
|
|
132
|
-
const startPayoutBigInt = BigInt(startPayout.integerValue().toString());
|
|
133
|
-
// Only add ranges if there's actually a range to cover
|
|
134
|
-
if (firstPiece.endPoint.eventOutcome > 0) {
|
|
135
|
-
CETS.push(...(0, CETCalculator_1.splitIntoRanges)(BigInt(0), // Start from 0
|
|
136
|
-
firstPiece.endPoint.eventOutcome, startPayoutBigInt, // Start payout calculated from curve
|
|
137
|
-
firstPiece.endPoint.outcomePayout, // End payout from endpoint
|
|
138
|
-
totalCollateral, curve, roundingIntervals.intervals));
|
|
139
|
-
}
|
|
140
|
-
// 2. If there are subsequent pieces, add them to the list
|
|
141
|
-
for (let i = 1; i < payoutFunction.payoutFunctionPieces.length; i++) {
|
|
142
|
-
const { payoutCurvePiece } = payoutFunction.payoutFunctionPieces[i];
|
|
143
|
-
const curve = this.fromPayoutCurvePiece(payoutCurvePiece);
|
|
144
|
-
CETS.push(...(0, CETCalculator_1.splitIntoRanges)(payoutFunction.payoutFunctionPieces[i - 1].endPoint.eventOutcome, payoutFunction.payoutFunctionPieces[i].endPoint.eventOutcome, payoutFunction.payoutFunctionPieces[i - 1].endPoint.outcomePayout, payoutFunction.payoutFunctionPieces[i].endPoint.outcomePayout, totalCollateral, curve, roundingIntervals.intervals));
|
|
145
|
-
}
|
|
146
|
-
// 3. Handle the final range from the last piece to lastEndpoint if it exists
|
|
147
|
-
if (payoutFunction.lastEndpoint &&
|
|
148
|
-
payoutFunction.payoutFunctionPieces.length > 0) {
|
|
149
|
-
const lastPieceIndex = payoutFunction.payoutFunctionPieces.length - 1;
|
|
150
|
-
const lastPiece = payoutFunction.payoutFunctionPieces[lastPieceIndex];
|
|
151
|
-
// Check if there's a range to cover
|
|
152
|
-
if (payoutFunction.lastEndpoint.eventOutcome >
|
|
153
|
-
lastPiece.endPoint.eventOutcome) {
|
|
154
|
-
// For the final range, we'll assume a constant payout from the last piece endpoint to lastEndpoint
|
|
155
|
-
// This is a common pattern for DLC payout functions
|
|
156
|
-
const finalCurve = new PolynomialPayoutCurve([
|
|
157
|
-
{
|
|
158
|
-
outcome: new bignumber_js_1.default(lastPiece.endPoint.eventOutcome.toString()),
|
|
159
|
-
payout: new bignumber_js_1.default(lastPiece.endPoint.outcomePayout.toString()),
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
outcome: new bignumber_js_1.default(payoutFunction.lastEndpoint.eventOutcome.toString()),
|
|
163
|
-
payout: new bignumber_js_1.default(payoutFunction.lastEndpoint.outcomePayout.toString()),
|
|
164
|
-
},
|
|
165
|
-
]);
|
|
166
|
-
CETS.push(...(0, CETCalculator_1.splitIntoRanges)(lastPiece.endPoint.eventOutcome, payoutFunction.lastEndpoint.eventOutcome, lastPiece.endPoint.outcomePayout, payoutFunction.lastEndpoint.outcomePayout, totalCollateral, finalCurve, roundingIntervals.intervals));
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
return (0, CETCalculator_1.mergePayouts)(CETS);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
exports.PolynomialPayoutCurve = PolynomialPayoutCurve;
|
|
173
|
-
//# sourceMappingURL=PolynomialPayoutCurve.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PolynomialPayoutCurve.js","sourceRoot":"","sources":["../../lib/dlc/PolynomialPayoutCurve.ts"],"names":[],"mappings":";;;;;;AAAA,mDAM6B;AAC7B,gEAAqC;AAErC,kDAAiE;AACjE,mDAA2E;AAO3E,MAAa,qBAAqB;IAMhC,YAAY,MAAkB;QAC5B,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;QACjE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QACtB,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAEvC,4BAA4B;QAC5B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM;aAC3B,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;aACvB,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IAC5D,CAAC;IAED;;;;OAIG;IACH,SAAS,CAAC,OAAe;QACvB,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;QAE7B,MAAM,CAAC,GAAG,IAAI,sBAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;QAEzC,aAAa;QACb,MAAM,MAAM,GAAG,KAAK,CAAC,KA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AAC,YAAY,CAAC,YAAY;gBACxC,SAAS,CAAC,QAAQ,CAAC,YAAY,EAC/B;gBACA,mGAAmG;gBACnG,oDAAoD;gBACpD,MAAM,UAAU,GAAG,IAAI,qBAAqB,CAAC;oBAC3C;wBACE,OAAO,EAAE,IAAI,sBAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC;wBAClE,MAAM,EAAE,IAAI,sBAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC;qBACnE;oBACD;wBACE,OAAO,EAAE,IAAI,sBAAS,CACpB,cAAc,CAAC,YAAY,CAAC,YAAY,CAAC,QAAQ,EAAE,CACpD;wBACD,MAAM,EAAE,IAAI,sBAAS,CACnB,cAAc,CAAC,YAAY,CAAC,aAAa,CAAC,QAAQ,EAAE,CACrD;qBACF;iBACF,CAAC,CAAC;gBAEH,IAAI,CAAC,IAAI,CACP,GAAG,IAAA,+BAAe,EAChB,SAAS,CAAC,QAAQ,CAAC,YAAY,EAC/B,cAAc,CAAC,YAAY,CAAC,YAAY,EACxC,SAAS,CAAC,QAAQ,CAAC,aAAa,EAChC,cAAc,CAAC,YAAY,CAAC,aAAa,EACzC,eAAe,EACf,UAAU,EACV,iBAAiB,CAAC,SAAS,CAC5B,CACF,CAAC;aACH;SACF;QAED,OAAO,IAAA,4BAAY,EAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;CACF;AAxPD,sDAwPC"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DLC Transaction Builder with support for "exact amount" DLC scenarios.
|
|
3
|
-
*
|
|
4
|
-
* Key improvements:
|
|
5
|
-
* - Dust filtering: Only creates change outputs above DUST_LIMIT (1000 sats)
|
|
6
|
-
* - No-change support: Enables splicing with exact UTXO amounts
|
|
7
|
-
* - Max collateral calculation: Helper for determining exact amounts
|
|
8
|
-
*
|
|
9
|
-
* This matches the C++ layer behavior and fixes issues with DLC splicing
|
|
10
|
-
* where users want to use exact UTXO amounts without change outputs.
|
|
11
|
-
*/
|
|
12
|
-
import { Tx } from '@node-dlc/bitcoin';
|
|
13
|
-
import { DlcAcceptWithoutSigs, DlcOffer, FundingInput } from '@node-dlc/messaging';
|
|
14
|
-
export declare const DUST_LIMIT: bigint;
|
|
15
|
-
export declare class DlcTxBuilder {
|
|
16
|
-
readonly dlcOffer: DlcOffer;
|
|
17
|
-
readonly dlcAccept: DlcAcceptWithoutSigs;
|
|
18
|
-
constructor(dlcOffer: DlcOffer, dlcAccept: DlcAcceptWithoutSigs);
|
|
19
|
-
buildFundingTransaction(): Tx;
|
|
20
|
-
}
|
|
21
|
-
export declare class BatchDlcTxBuilder {
|
|
22
|
-
readonly dlcOffers: DlcOffer[];
|
|
23
|
-
readonly dlcAccepts: DlcAcceptWithoutSigs[];
|
|
24
|
-
constructor(dlcOffers: DlcOffer[], dlcAccepts: DlcAcceptWithoutSigs[]);
|
|
25
|
-
/**
|
|
26
|
-
* Calculates the maximum collateral that can be used given a set of funding inputs
|
|
27
|
-
* for exact-amount DLC scenarios (no change outputs).
|
|
28
|
-
*
|
|
29
|
-
* @param fundingInputs The inputs to be used for funding
|
|
30
|
-
* @param feeRatePerVb Fee rate in satoshis per virtual byte
|
|
31
|
-
* @param numContracts Number of DLC contracts being created (default: 1)
|
|
32
|
-
* @returns Maximum collateral amount in satoshis
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* ```typescript
|
|
36
|
-
* // Calculate max collateral for DLC splicing scenario
|
|
37
|
-
* const dlcFundingInput = getDlcFundingInput(); // 970,332 sats
|
|
38
|
-
* const additionalInput = getAdditionalInput(); // 100,000 sats
|
|
39
|
-
* const inputs = [dlcFundingInput, additionalInput];
|
|
40
|
-
*
|
|
41
|
-
* const maxCollateral = BatchDlcTxBuilder.calculateMaxCollateral(
|
|
42
|
-
* inputs,
|
|
43
|
-
* BigInt(1), // 1 sat/vB fee rate
|
|
44
|
-
* 1 // Single DLC contract
|
|
45
|
-
* );
|
|
46
|
-
*
|
|
47
|
-
* // Use maxCollateral in DLC offer to ensure exact amount with no change
|
|
48
|
-
* const dlcOffer = createDlcOffer(contractInfo, maxCollateral, ...);
|
|
49
|
-
* ```
|
|
50
|
-
*/
|
|
51
|
-
static calculateMaxCollateral(fundingInputs: FundingInput[], feeRatePerVb: bigint, numContracts?: number): bigint;
|
|
52
|
-
buildFundingTransaction(): Tx;
|
|
53
|
-
private ensureSameFundingInputs;
|
|
54
|
-
private arraysEqual;
|
|
55
|
-
}
|
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* DLC Transaction Builder with support for "exact amount" DLC scenarios.
|
|
4
|
-
*
|
|
5
|
-
* Key improvements:
|
|
6
|
-
* - Dust filtering: Only creates change outputs above DUST_LIMIT (1000 sats)
|
|
7
|
-
* - No-change support: Enables splicing with exact UTXO amounts
|
|
8
|
-
* - Max collateral calculation: Helper for determining exact amounts
|
|
9
|
-
*
|
|
10
|
-
* This matches the C++ layer behavior and fixes issues with DLC splicing
|
|
11
|
-
* where users want to use exact UTXO amounts without change outputs.
|
|
12
|
-
*/
|
|
13
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.BatchDlcTxBuilder = exports.DlcTxBuilder = exports.DUST_LIMIT = void 0;
|
|
18
|
-
const bitcoin_1 = require("@node-dlc/bitcoin");
|
|
19
|
-
const messaging_1 = require("@node-dlc/messaging");
|
|
20
|
-
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
21
|
-
const TxFinalizer_1 = require("./TxFinalizer");
|
|
22
|
-
// Dust limit matching C++ implementation (1000 satoshis)
|
|
23
|
-
exports.DUST_LIMIT = BigInt(1000);
|
|
24
|
-
class DlcTxBuilder {
|
|
25
|
-
constructor(dlcOffer, dlcAccept) {
|
|
26
|
-
this.dlcOffer = dlcOffer;
|
|
27
|
-
this.dlcAccept = dlcAccept;
|
|
28
|
-
}
|
|
29
|
-
buildFundingTransaction() {
|
|
30
|
-
const txBuilder = new BatchDlcTxBuilder([this.dlcOffer], [this.dlcAccept]);
|
|
31
|
-
return txBuilder.buildFundingTransaction();
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
exports.DlcTxBuilder = DlcTxBuilder;
|
|
35
|
-
class BatchDlcTxBuilder {
|
|
36
|
-
constructor(dlcOffers, dlcAccepts) {
|
|
37
|
-
this.dlcOffers = dlcOffers;
|
|
38
|
-
this.dlcAccepts = dlcAccepts;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Calculates the maximum collateral that can be used given a set of funding inputs
|
|
42
|
-
* for exact-amount DLC scenarios (no change outputs).
|
|
43
|
-
*
|
|
44
|
-
* @param fundingInputs The inputs to be used for funding
|
|
45
|
-
* @param feeRatePerVb Fee rate in satoshis per virtual byte
|
|
46
|
-
* @param numContracts Number of DLC contracts being created (default: 1)
|
|
47
|
-
* @returns Maximum collateral amount in satoshis
|
|
48
|
-
*
|
|
49
|
-
* @example
|
|
50
|
-
* ```typescript
|
|
51
|
-
* // Calculate max collateral for DLC splicing scenario
|
|
52
|
-
* const dlcFundingInput = getDlcFundingInput(); // 970,332 sats
|
|
53
|
-
* const additionalInput = getAdditionalInput(); // 100,000 sats
|
|
54
|
-
* const inputs = [dlcFundingInput, additionalInput];
|
|
55
|
-
*
|
|
56
|
-
* const maxCollateral = BatchDlcTxBuilder.calculateMaxCollateral(
|
|
57
|
-
* inputs,
|
|
58
|
-
* BigInt(1), // 1 sat/vB fee rate
|
|
59
|
-
* 1 // Single DLC contract
|
|
60
|
-
* );
|
|
61
|
-
*
|
|
62
|
-
* // Use maxCollateral in DLC offer to ensure exact amount with no change
|
|
63
|
-
* const dlcOffer = createDlcOffer(contractInfo, maxCollateral, ...);
|
|
64
|
-
* ```
|
|
65
|
-
*/
|
|
66
|
-
static calculateMaxCollateral(fundingInputs, feeRatePerVb, numContracts = 1) {
|
|
67
|
-
// Calculate total input value
|
|
68
|
-
const totalInputValue = fundingInputs.reduce((total, input) => {
|
|
69
|
-
return total + input.prevTx.outputs[input.prevTxVout].value.sats;
|
|
70
|
-
}, BigInt(0));
|
|
71
|
-
// Create a temporary finalizer to calculate fees
|
|
72
|
-
const fakeSPK = Buffer.from('0014663117d27e78eb432505180654e603acb30e8a4a', 'hex');
|
|
73
|
-
const finalizer = new TxFinalizer_1.DualFundingTxFinalizer(fundingInputs, fakeSPK, fakeSPK, [], // No accepter inputs for single-funded scenario
|
|
74
|
-
fakeSPK, fakeSPK, feeRatePerVb, numContracts);
|
|
75
|
-
// For exact-amount scenarios, we need to account for:
|
|
76
|
-
// 1. Future fees (for CET/refund transactions)
|
|
77
|
-
// 2. Funding transaction fees
|
|
78
|
-
const futureFee = finalizer.offerFutureFee;
|
|
79
|
-
const fundingFee = finalizer.offerFundingFee;
|
|
80
|
-
// Maximum collateral is input value minus all fees
|
|
81
|
-
const maxCollateral = totalInputValue - futureFee - fundingFee;
|
|
82
|
-
// Ensure we don't return negative values
|
|
83
|
-
return maxCollateral > BigInt(0) ? maxCollateral : BigInt(0);
|
|
84
|
-
}
|
|
85
|
-
buildFundingTransaction() {
|
|
86
|
-
const tx = new bitcoin_1.TxBuilder();
|
|
87
|
-
tx.version = 2;
|
|
88
|
-
tx.locktime = bitcoin_1.LockTime.zero();
|
|
89
|
-
if (this.dlcOffers.length !== this.dlcAccepts.length)
|
|
90
|
-
throw Error('DlcOffers and DlcAccepts must be the same length');
|
|
91
|
-
if (this.dlcOffers.length === 0)
|
|
92
|
-
throw Error('DlcOffers must not be empty');
|
|
93
|
-
if (this.dlcAccepts.length === 0)
|
|
94
|
-
throw Error('DlcAccepts must not be empty');
|
|
95
|
-
// Ensure all DLC offers and accepts have the same funding inputs
|
|
96
|
-
this.ensureSameFundingInputs();
|
|
97
|
-
const multisigScripts = [];
|
|
98
|
-
for (let i = 0; i < this.dlcOffers.length; i++) {
|
|
99
|
-
const offer = this.dlcOffers[i];
|
|
100
|
-
const accept = this.dlcAccepts[i];
|
|
101
|
-
multisigScripts.push(Buffer.compare(offer.fundingPubkey, accept.fundingPubkey) === -1
|
|
102
|
-
? bitcoin_1.Script.p2msLock(2, offer.fundingPubkey, accept.fundingPubkey)
|
|
103
|
-
: bitcoin_1.Script.p2msLock(2, accept.fundingPubkey, offer.fundingPubkey));
|
|
104
|
-
}
|
|
105
|
-
const witScripts = multisigScripts.map((multisigScript) => bitcoin_1.Script.p2wshLock(multisigScript));
|
|
106
|
-
const finalizer = new TxFinalizer_1.DualFundingTxFinalizer(this.dlcOffers[0].fundingInputs, this.dlcOffers[0].payoutSpk, this.dlcOffers[0].changeSpk, this.dlcAccepts[0].fundingInputs, this.dlcAccepts[0].payoutSpk, this.dlcAccepts[0].changeSpk, this.dlcOffers[0].feeRatePerVb, this.dlcOffers.length);
|
|
107
|
-
this.dlcOffers[0].fundingInputs.forEach((input) => {
|
|
108
|
-
if (input.type !== messaging_1.MessageType.FundingInput)
|
|
109
|
-
throw new Error('Input is not a funding input');
|
|
110
|
-
});
|
|
111
|
-
const offerFundingInputs = this.dlcOffers[0].fundingInputs.map((input) => input);
|
|
112
|
-
const offerTotalFunding = offerFundingInputs.reduce((total, input) => {
|
|
113
|
-
return total + input.prevTx.outputs[input.prevTxVout].value.sats;
|
|
114
|
-
}, BigInt(0));
|
|
115
|
-
const acceptTotalFunding = this.dlcAccepts[0].fundingInputs.reduce((total, input) => {
|
|
116
|
-
return total + input.prevTx.outputs[input.prevTxVout].value.sats;
|
|
117
|
-
}, BigInt(0));
|
|
118
|
-
const fundingInputs = [
|
|
119
|
-
...offerFundingInputs,
|
|
120
|
-
...this.dlcAccepts[0].fundingInputs,
|
|
121
|
-
];
|
|
122
|
-
fundingInputs.sort((a, b) => Number(a.inputSerialId) - Number(b.inputSerialId));
|
|
123
|
-
fundingInputs.forEach((input) => {
|
|
124
|
-
tx.addInput(bitcoin_1.OutPoint.fromString(`${input.prevTx.txId.toString()}:${input.prevTxVout}`));
|
|
125
|
-
});
|
|
126
|
-
const offerInput = this.dlcOffers.reduce((total, offer) => total + offer.offerCollateral, BigInt(0));
|
|
127
|
-
const acceptInput = this.dlcAccepts.reduce((total, accept) => total + accept.acceptCollateral, BigInt(0));
|
|
128
|
-
const totalInputs = this.dlcOffers.map((offer, i) => {
|
|
129
|
-
const offerInput = offer.offerCollateral;
|
|
130
|
-
const acceptInput = this.dlcAccepts[i].acceptCollateral;
|
|
131
|
-
return offerInput + acceptInput;
|
|
132
|
-
});
|
|
133
|
-
const fundingValues = totalInputs.map((totalInput) => {
|
|
134
|
-
const offerFutureFeePerOffer = new decimal_js_1.default(finalizer.offerFutureFee.toString())
|
|
135
|
-
.div(this.dlcOffers.length)
|
|
136
|
-
.ceil()
|
|
137
|
-
.toNumber();
|
|
138
|
-
const acceptFutureFeePerAccept = new decimal_js_1.default(finalizer.acceptFutureFee.toString())
|
|
139
|
-
.div(this.dlcAccepts.length)
|
|
140
|
-
.ceil()
|
|
141
|
-
.toNumber();
|
|
142
|
-
return (totalInput +
|
|
143
|
-
bitcoin_1.Value.fromSats(offerFutureFeePerOffer).sats +
|
|
144
|
-
bitcoin_1.Value.fromSats(acceptFutureFeePerAccept).sats);
|
|
145
|
-
});
|
|
146
|
-
const offerChangeValue = offerTotalFunding - offerInput - finalizer.offerFees;
|
|
147
|
-
const acceptChangeValue = acceptTotalFunding - acceptInput - finalizer.acceptFees;
|
|
148
|
-
// Validate that we have sufficient funds
|
|
149
|
-
if (offerChangeValue < BigInt(0)) {
|
|
150
|
-
throw new Error(`Insufficient funds for offerer: need ${offerInput + finalizer.offerFees} sats, have ${offerTotalFunding} sats`);
|
|
151
|
-
}
|
|
152
|
-
// In single-funded DLCs, if accepter has no inputs, they don't pay fees
|
|
153
|
-
// This matches the C++ layer behavior where parties with no inputs have zero fees
|
|
154
|
-
if (acceptChangeValue < BigInt(0) && acceptTotalFunding > BigInt(0)) {
|
|
155
|
-
throw new Error(`Insufficient funds for accepter: need ${acceptInput + finalizer.acceptFees} sats, have ${acceptTotalFunding} sats`);
|
|
156
|
-
}
|
|
157
|
-
const outputs = [];
|
|
158
|
-
witScripts.forEach((witScript, i) => {
|
|
159
|
-
outputs.push({
|
|
160
|
-
value: bitcoin_1.Value.fromSats(Number(fundingValues[i])),
|
|
161
|
-
script: witScript,
|
|
162
|
-
serialId: this.dlcOffers[i].fundOutputSerialId,
|
|
163
|
-
});
|
|
164
|
-
});
|
|
165
|
-
// Dust filtering: Only create change outputs if they're above dust threshold
|
|
166
|
-
// This matches the C++ implementation and enables "exact amount" DLC scenarios
|
|
167
|
-
// where all input value goes into the DLC funding output with no change
|
|
168
|
-
if (offerChangeValue >= exports.DUST_LIMIT) {
|
|
169
|
-
outputs.push({
|
|
170
|
-
value: bitcoin_1.Value.fromSats(Number(offerChangeValue)),
|
|
171
|
-
script: bitcoin_1.Script.p2wpkhLock(this.dlcOffers[0].changeSpk.slice(2)),
|
|
172
|
-
serialId: this.dlcOffers[0].changeSerialId,
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
if (acceptChangeValue >= exports.DUST_LIMIT) {
|
|
176
|
-
outputs.push({
|
|
177
|
-
value: bitcoin_1.Value.fromSats(Number(acceptChangeValue)),
|
|
178
|
-
script: bitcoin_1.Script.p2wpkhLock(this.dlcAccepts[0].changeSpk.slice(2)),
|
|
179
|
-
serialId: this.dlcAccepts[0].changeSerialId,
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
outputs.sort((a, b) => Number(a.serialId) - Number(b.serialId));
|
|
183
|
-
outputs.forEach((output) => {
|
|
184
|
-
tx.addOutput(output.value, output.script);
|
|
185
|
-
});
|
|
186
|
-
return tx.toTx();
|
|
187
|
-
}
|
|
188
|
-
ensureSameFundingInputs() {
|
|
189
|
-
// Check for offers
|
|
190
|
-
const referenceOfferInputs = this.dlcOffers[0].fundingInputs.map((input) => input.serialize().toString('hex'));
|
|
191
|
-
for (let i = 1; i < this.dlcOffers.length; i++) {
|
|
192
|
-
const currentInputs = this.dlcOffers[i].fundingInputs.map((input) => input.serialize().toString('hex'));
|
|
193
|
-
if (!this.arraysEqual(referenceOfferInputs, currentInputs)) {
|
|
194
|
-
throw new Error(`Funding inputs for offer ${i} do not match the first offer's funding inputs.`);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
// Check for accepts
|
|
198
|
-
const referenceAcceptInputs = this.dlcAccepts[0].fundingInputs.map((input) => input.serialize().toString('hex'));
|
|
199
|
-
for (let i = 1; i < this.dlcAccepts.length; i++) {
|
|
200
|
-
const currentInputs = this.dlcAccepts[i].fundingInputs.map((input) => input.serialize().toString('hex'));
|
|
201
|
-
if (!this.arraysEqual(referenceAcceptInputs, currentInputs)) {
|
|
202
|
-
throw new Error(`Funding inputs for accept ${i} do not match the first accept's funding inputs.`);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
arraysEqual(arr1, arr2) {
|
|
207
|
-
if (arr1.length !== arr2.length)
|
|
208
|
-
return false;
|
|
209
|
-
for (let i = 0; i < arr1.length; i++) {
|
|
210
|
-
if (arr1[i] !== arr2[i])
|
|
211
|
-
return false;
|
|
212
|
-
}
|
|
213
|
-
return true;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
exports.BatchDlcTxBuilder = BatchDlcTxBuilder;
|
|
217
|
-
//# sourceMappingURL=TxBuilder.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TxBuilder.js","sourceRoot":"","sources":["../../lib/dlc/TxBuilder.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;;;;AAEH,+CAO2B;AAC3B,mDAK6B;AAC7B,4DAAiC;AAEjC,+CAAuD;AAEvD,yDAAyD;AAC5C,QAAA,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;AAEvC,MAAa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|
|
4
|
-
readonly offerInputs: FundingInput[];
|
|
5
|
-
readonly offerPayoutSPK: Buffer;
|
|
6
|
-
readonly offerChangeSPK: Buffer;
|
|
7
|
-
readonly acceptInputs: FundingInput[];
|
|
8
|
-
readonly acceptPayoutSPK: Buffer;
|
|
9
|
-
readonly acceptChangeSPK: Buffer;
|
|
10
|
-
readonly feeRate: bigint;
|
|
11
|
-
readonly numContracts: number;
|
|
12
|
-
constructor(offerInputs: FundingInput[], offerPayoutSPK: Buffer, offerChangeSPK: Buffer, acceptInputs: FundingInput[], acceptPayoutSPK: Buffer, acceptChangeSPK: Buffer, feeRate: bigint, numContracts?: number);
|
|
13
|
-
private computeFees;
|
|
14
|
-
private getOfferFees;
|
|
15
|
-
private getAcceptFees;
|
|
16
|
-
get offerFees(): bigint;
|
|
17
|
-
get offerFutureFee(): bigint;
|
|
18
|
-
get offerFundingFee(): bigint;
|
|
19
|
-
get acceptFees(): bigint;
|
|
20
|
-
get acceptFutureFee(): bigint;
|
|
21
|
-
get acceptFundingFee(): bigint;
|
|
22
|
-
}
|
|
23
|
-
export declare class DualClosingTxFinalizer {
|
|
24
|
-
readonly initiatorInputs: FundingInput[];
|
|
25
|
-
readonly offerPayoutSPK: Buffer;
|
|
26
|
-
readonly acceptPayoutSPK: Buffer;
|
|
27
|
-
readonly feeRate: bigint;
|
|
28
|
-
constructor(initiatorInputs: FundingInput[], offerPayoutSPK: Buffer, acceptPayoutSPK: Buffer, feeRate: bigint);
|
|
29
|
-
private computeFees;
|
|
30
|
-
private getOfferInitiatorFees;
|
|
31
|
-
private getOfferReciprocatorFees;
|
|
32
|
-
private getAcceptInitiatorFees;
|
|
33
|
-
private getAcceptReciprocatorFees;
|
|
34
|
-
get offerInitiatorFees(): bigint;
|
|
35
|
-
get offerReciprocatorFees(): bigint;
|
|
36
|
-
get acceptInitiatorFees(): bigint;
|
|
37
|
-
get acceptReciprocatorFees(): bigint;
|
|
38
|
-
}
|
|
39
|
-
export declare const getFinalizer: (feeRate: bigint, offerInputs?: FundingInput[], acceptInputs?: FundingInput[], numContracts?: number) => DualFundingTxFinalizer;
|
|
40
|
-
export declare const getFinalizerByCount: (feeRate: bigint, numOfferInputs: number, numAcceptInputs: number, numContracts: number) => DualFundingTxFinalizer;
|