@atomicfinance/bitcoin-wallet-provider 3.6.1 → 4.0.1
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/.turbo/turbo-lint.log +1 -0
- package/.yalc/@node-dlc/core/.nyc_output/687a3c14-9765-45fd-a1fe-f7db3d56fee4.json +1 -0
- package/.yalc/@node-dlc/core/.nyc_output/processinfo/687a3c14-9765-45fd-a1fe-f7db3d56fee4.json +1 -0
- package/.yalc/@node-dlc/core/.nyc_output/processinfo/index.json +1 -0
- package/.yalc/@node-dlc/core/README.md +11 -0
- package/.yalc/@node-dlc/core/__tests__/core.spec.ts +7 -0
- package/.yalc/@node-dlc/core/__tests__/dlc/CETCalculator.spec.ts +1029 -0
- package/.yalc/@node-dlc/core/__tests__/dlc/CoinSelect.spec.ts +179 -0
- package/.yalc/@node-dlc/core/__tests__/dlc/PolynomialPayoutCurve.spec.ts +345 -0
- package/.yalc/@node-dlc/core/__tests__/dlc/TxBuilder.spec.ts +424 -0
- package/.yalc/@node-dlc/core/__tests__/dlc/finance/Builder.spec.ts +492 -0
- package/.yalc/@node-dlc/core/__tests__/dlc/finance/CoveredCall.spec.ts +112 -0
- package/.yalc/@node-dlc/core/__tests__/dlc/finance/CsoInfo.spec.ts +1124 -0
- package/.yalc/@node-dlc/core/__tests__/dlc/finance/LongCall.spec.ts +55 -0
- package/.yalc/@node-dlc/core/__tests__/dlc/finance/LongPut.spec.ts +55 -0
- package/.yalc/@node-dlc/core/__tests__/dlc/finance/OptionInfo.spec.ts +226 -0
- package/.yalc/@node-dlc/core/__tests__/dlc/finance/ShortPut.spec.ts +62 -0
- package/.yalc/@node-dlc/core/__tests__/tsconfig.json +8 -0
- package/.yalc/@node-dlc/core/__tests__/utils/precision.spec.ts +40 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/base.css +224 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/block-navigation.js +79 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/favicon.png +0 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/index.html +171 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/AsyncProcessingQueue.ts.html +269 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/Base32.ts.html +86 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/BigIntUtils.ts.html +86 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/BitField.ts.html +86 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/ChannelId.ts.html +86 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/LinkedList.ts.html +413 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/LinkedListNode.ts.html +122 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/Queue.ts.html +188 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/ShortChannelId.ts.html +86 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/ShortChannelIdUtils.ts.html +107 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/CETCalculator.ts.html +1430 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/CoinSelect.ts.html +431 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/HyperbolaPayoutCurve.ts.html +644 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/PolynomialPayoutCurve.ts.html +878 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/TxBuilder.ts.html +1088 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/TxFinalizer.ts.html +731 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/Builder.ts.html +2270 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/CoveredCall.ts.html +410 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/CsoInfo.ts.html +1574 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/LinearPayout.ts.html +362 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/LongCall.ts.html +302 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/LongPut.ts.html +302 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/OptionInfo.ts.html +626 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/ShortPut.ts.html +305 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/index.html +216 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/index.html +186 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/index.html +261 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/index.ts.html +278 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/ChannelId.ts.html +242 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/ChannelKeys.ts.html +407 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/CommitmentNumber.ts.html +362 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/CommitmentSecret.ts.html +203 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/CommitmentSecretStore.ts.html +332 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/Htlc.ts.html +236 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/HtlcDirection.ts.html +131 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/ScriptFactory.ts.html +530 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/TxFactory.ts.html +1094 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/index.html +231 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/utils/BigIntUtils.ts.html +272 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/utils/Precision.ts.html +149 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/utils/index.html +126 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/prettify.css +1 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/prettify.js +2 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/sorter.js +170 -0
- package/.yalc/@node-dlc/core/coverage/lcov.info +2426 -0
- package/.yalc/@node-dlc/core/dist/AsyncProcessingQueue.d.ts +22 -0
- package/.yalc/@node-dlc/core/dist/AsyncProcessingQueue.js +55 -0
- package/.yalc/@node-dlc/core/dist/AsyncProcessingQueue.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/Base32.d.ts +1 -0
- package/.yalc/@node-dlc/core/dist/Base32.js +7 -0
- package/.yalc/@node-dlc/core/dist/Base32.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/BigIntUtils.d.ts +1 -0
- package/.yalc/@node-dlc/core/dist/BigIntUtils.js +8 -0
- package/.yalc/@node-dlc/core/dist/BigIntUtils.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/BitField.d.ts +1 -0
- package/.yalc/@node-dlc/core/dist/BitField.js +7 -0
- package/.yalc/@node-dlc/core/dist/BitField.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/ChannelId.d.ts +1 -0
- package/.yalc/@node-dlc/core/dist/ChannelId.js +7 -0
- package/.yalc/@node-dlc/core/dist/ChannelId.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/LinkedList.d.ts +30 -0
- package/.yalc/@node-dlc/core/dist/LinkedList.js +104 -0
- package/.yalc/@node-dlc/core/dist/LinkedList.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/LinkedListNode.d.ts +9 -0
- package/.yalc/@node-dlc/core/dist/LinkedListNode.js +15 -0
- package/.yalc/@node-dlc/core/dist/LinkedListNode.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/Queue.d.ts +22 -0
- package/.yalc/@node-dlc/core/dist/Queue.js +38 -0
- package/.yalc/@node-dlc/core/dist/Queue.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/ShortChannelId.d.ts +1 -0
- package/.yalc/@node-dlc/core/dist/ShortChannelId.js +7 -0
- package/.yalc/@node-dlc/core/dist/ShortChannelId.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/ShortChannelIdUtils.d.ts +1 -0
- package/.yalc/@node-dlc/core/dist/ShortChannelIdUtils.js +12 -0
- package/.yalc/@node-dlc/core/dist/ShortChannelIdUtils.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/dlc/CETCalculator.d.ts +50 -0
- package/.yalc/@node-dlc/core/dist/dlc/CETCalculator.js +332 -0
- package/.yalc/@node-dlc/core/dist/dlc/CETCalculator.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/dlc/CoinSelect.d.ts +23 -0
- package/.yalc/@node-dlc/core/dist/dlc/CoinSelect.js +77 -0
- package/.yalc/@node-dlc/core/dist/dlc/CoinSelect.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/dlc/HyperbolaPayoutCurve.d.ts +20 -0
- package/.yalc/@node-dlc/core/dist/dlc/HyperbolaPayoutCurve.js +117 -0
- package/.yalc/@node-dlc/core/dist/dlc/HyperbolaPayoutCurve.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/dlc/PayoutCurve.d.ts +5 -0
- package/.yalc/@node-dlc/core/dist/dlc/PayoutCurve.js +3 -0
- package/.yalc/@node-dlc/core/dist/dlc/PayoutCurve.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/dlc/PolynomialPayoutCurve.d.ts +52 -0
- package/.yalc/@node-dlc/core/dist/dlc/PolynomialPayoutCurve.js +173 -0
- package/.yalc/@node-dlc/core/dist/dlc/PolynomialPayoutCurve.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/dlc/TxBuilder.d.ts +55 -0
- package/.yalc/@node-dlc/core/dist/dlc/TxBuilder.js +217 -0
- package/.yalc/@node-dlc/core/dist/dlc/TxBuilder.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/dlc/TxFinalizer.d.ts +40 -0
- package/.yalc/@node-dlc/core/dist/dlc/TxFinalizer.js +146 -0
- package/.yalc/@node-dlc/core/dist/dlc/TxFinalizer.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/Builder.d.ts +193 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/Builder.js +422 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/Builder.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/CoveredCall.d.ts +13 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/CoveredCall.js +67 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/CoveredCall.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/CsoInfo.d.ts +114 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/CsoInfo.js +290 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/CsoInfo.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/LinearPayout.d.ts +6 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/LinearPayout.js +79 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/LinearPayout.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/LongCall.d.ts +13 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/LongCall.js +47 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/LongCall.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/LongPut.d.ts +13 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/LongPut.js +47 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/LongPut.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/OptionInfo.d.ts +20 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/OptionInfo.js +101 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/OptionInfo.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/ShortPut.d.ts +12 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/ShortPut.js +46 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/ShortPut.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/index.d.ts +39 -0
- package/.yalc/@node-dlc/core/dist/index.js +78 -0
- package/.yalc/@node-dlc/core/dist/index.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/lightning/ChannelId.d.ts +31 -0
- package/.yalc/@node-dlc/core/dist/lightning/ChannelId.js +52 -0
- package/.yalc/@node-dlc/core/dist/lightning/ChannelId.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/lightning/ChannelKeys.d.ts +55 -0
- package/.yalc/@node-dlc/core/dist/lightning/ChannelKeys.js +105 -0
- package/.yalc/@node-dlc/core/dist/lightning/ChannelKeys.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/lightning/CommitmentNumber.d.ts +55 -0
- package/.yalc/@node-dlc/core/dist/lightning/CommitmentNumber.js +76 -0
- package/.yalc/@node-dlc/core/dist/lightning/CommitmentNumber.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/lightning/CommitmentSecret.d.ts +26 -0
- package/.yalc/@node-dlc/core/dist/lightning/CommitmentSecret.js +44 -0
- package/.yalc/@node-dlc/core/dist/lightning/CommitmentSecret.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/lightning/CommitmentSecretStore.d.ts +41 -0
- package/.yalc/@node-dlc/core/dist/lightning/CommitmentSecretStore.js +79 -0
- package/.yalc/@node-dlc/core/dist/lightning/CommitmentSecretStore.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/lightning/Htlc.d.ts +46 -0
- package/.yalc/@node-dlc/core/dist/lightning/Htlc.js +46 -0
- package/.yalc/@node-dlc/core/dist/lightning/Htlc.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/lightning/HtlcDirection.d.ts +16 -0
- package/.yalc/@node-dlc/core/dist/lightning/HtlcDirection.js +21 -0
- package/.yalc/@node-dlc/core/dist/lightning/HtlcDirection.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/lightning/ScriptFactory.d.ts +76 -0
- package/.yalc/@node-dlc/core/dist/lightning/ScriptFactory.js +102 -0
- package/.yalc/@node-dlc/core/dist/lightning/ScriptFactory.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/lightning/TxFactory.d.ts +83 -0
- package/.yalc/@node-dlc/core/dist/lightning/TxFactory.js +222 -0
- package/.yalc/@node-dlc/core/dist/lightning/TxFactory.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/utils/BigIntUtils.d.ts +9 -0
- package/.yalc/@node-dlc/core/dist/utils/BigIntUtils.js +59 -0
- package/.yalc/@node-dlc/core/dist/utils/BigIntUtils.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/utils/Precision.d.ts +13 -0
- package/.yalc/@node-dlc/core/dist/utils/Precision.js +28 -0
- package/.yalc/@node-dlc/core/dist/utils/Precision.js.map +1 -0
- package/.yalc/@node-dlc/core/lib/AsyncProcessingQueue.ts +63 -0
- package/.yalc/@node-dlc/core/lib/Base32.ts +2 -0
- package/.yalc/@node-dlc/core/lib/BigIntUtils.ts +2 -0
- package/.yalc/@node-dlc/core/lib/BitField.ts +2 -0
- package/.yalc/@node-dlc/core/lib/ChannelId.ts +2 -0
- package/.yalc/@node-dlc/core/lib/LinkedList.ts +111 -0
- package/.yalc/@node-dlc/core/lib/LinkedListNode.ts +14 -0
- package/.yalc/@node-dlc/core/lib/Queue.ts +36 -0
- package/.yalc/@node-dlc/core/lib/ShortChannelId.ts +2 -0
- package/.yalc/@node-dlc/core/lib/ShortChannelIdUtils.ts +9 -0
- package/.yalc/@node-dlc/core/lib/dlc/CETCalculator.ts +450 -0
- package/.yalc/@node-dlc/core/lib/dlc/CoinSelect.ts +117 -0
- package/.yalc/@node-dlc/core/lib/dlc/HyperbolaPayoutCurve.ts +188 -0
- package/.yalc/@node-dlc/core/lib/dlc/PayoutCurve.ts +6 -0
- package/.yalc/@node-dlc/core/lib/dlc/PolynomialPayoutCurve.ts +266 -0
- package/.yalc/@node-dlc/core/lib/dlc/TxBuilder.ts +336 -0
- package/.yalc/@node-dlc/core/lib/dlc/TxFinalizer.ts +217 -0
- package/.yalc/@node-dlc/core/lib/dlc/finance/Builder.ts +730 -0
- package/.yalc/@node-dlc/core/lib/dlc/finance/CoveredCall.ts +110 -0
- package/.yalc/@node-dlc/core/lib/dlc/finance/CsoInfo.ts +498 -0
- package/.yalc/@node-dlc/core/lib/dlc/finance/LinearPayout.ts +94 -0
- package/.yalc/@node-dlc/core/lib/dlc/finance/LongCall.ts +74 -0
- package/.yalc/@node-dlc/core/lib/dlc/finance/LongPut.ts +74 -0
- package/.yalc/@node-dlc/core/lib/dlc/finance/OptionInfo.ts +182 -0
- package/.yalc/@node-dlc/core/lib/dlc/finance/ShortPut.ts +75 -0
- package/.yalc/@node-dlc/core/lib/index.ts +66 -0
- package/.yalc/@node-dlc/core/lib/lightning/ChannelId.ts +54 -0
- package/.yalc/@node-dlc/core/lib/lightning/ChannelKeys.ts +109 -0
- package/.yalc/@node-dlc/core/lib/lightning/CommitmentNumber.ts +94 -0
- package/.yalc/@node-dlc/core/lib/lightning/CommitmentSecret.ts +41 -0
- package/.yalc/@node-dlc/core/lib/lightning/CommitmentSecretStore.ts +84 -0
- package/.yalc/@node-dlc/core/lib/lightning/Htlc.ts +52 -0
- package/.yalc/@node-dlc/core/lib/lightning/HtlcDirection.ts +17 -0
- package/.yalc/@node-dlc/core/lib/lightning/ScriptFactory.ts +150 -0
- package/.yalc/@node-dlc/core/lib/lightning/TxFactory.ts +338 -0
- package/.yalc/@node-dlc/core/lib/utils/BigIntUtils.ts +64 -0
- package/.yalc/@node-dlc/core/lib/utils/Precision.ts +23 -0
- package/.yalc/@node-dlc/core/package.json +38 -0
- package/.yalc/@node-dlc/core/tsconfig.json +8 -0
- package/.yalc/@node-dlc/core/yalc.sig +1 -0
- package/CHANGELOG.md +112 -0
- package/dist/BitcoinWalletProvider.d.ts +4 -2
- package/dist/BitcoinWalletProvider.js +1 -0
- package/dist/BitcoinWalletProvider.js.map +1 -1
- package/lib/BitcoinWalletProvider.ts +13 -4
- package/package.json +5 -5
- package/yalc.lock +10 -0
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
import {
|
|
2
|
+
HashValue,
|
|
3
|
+
LockTime,
|
|
4
|
+
OutPoint,
|
|
5
|
+
Script,
|
|
6
|
+
Sequence,
|
|
7
|
+
TxBuilder,
|
|
8
|
+
TxOut,
|
|
9
|
+
Value,
|
|
10
|
+
} from '@node-dlc/bitcoin';
|
|
11
|
+
|
|
12
|
+
import { CommitmentNumber } from './CommitmentNumber';
|
|
13
|
+
import { Htlc } from './Htlc';
|
|
14
|
+
import { HtlcDirection } from './HtlcDirection';
|
|
15
|
+
import { ScriptFactory } from './ScriptFactory';
|
|
16
|
+
|
|
17
|
+
export class TxFactory {
|
|
18
|
+
/**
|
|
19
|
+
* Creates a TxOut to attach to a funding transaction. This includes
|
|
20
|
+
* the P2WSH-P2MS script that uses 2-2MS. The open and accept funding
|
|
21
|
+
* pubkeys are sorted lexicographcially to create the script.
|
|
22
|
+
* @param builder
|
|
23
|
+
*/
|
|
24
|
+
public static createFundingOutput(
|
|
25
|
+
value: Value,
|
|
26
|
+
openPubKey: Buffer,
|
|
27
|
+
acceptPubKey: Buffer,
|
|
28
|
+
): TxOut {
|
|
29
|
+
const script = Script.p2wshLock(
|
|
30
|
+
ScriptFactory.fundingScript(openPubKey, acceptPubKey),
|
|
31
|
+
);
|
|
32
|
+
return new TxOut(value, script);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Constructs an unsigned commitment transaction according to BOLT3.
|
|
37
|
+
* This method is a low level commitment transaction builder, meaning
|
|
38
|
+
* it accepts primatives and constructs a commitment transaction
|
|
39
|
+
* accordingly. The proper inputs are determiend
|
|
40
|
+
*
|
|
41
|
+
* @param isFunderLocal True when the funding node is local. This
|
|
42
|
+
* is used to determine which output pays fees (to_local/to_remote).
|
|
43
|
+
* @param commitmentNumber The commitment number of the transaction
|
|
44
|
+
* which is used to generate the obscurred commitment number.
|
|
45
|
+
* @param openPaymentBasePoint The basepoint sent in open_channel
|
|
46
|
+
* which is used to generate the obscurred commitment number.
|
|
47
|
+
* @param acceptPaymentBasePoint The basepoitn sent in accept_channel
|
|
48
|
+
* which is used to generate the obscurred commitment number.
|
|
49
|
+
* @param fundingOutPoint The outpoint of the funding transaction
|
|
50
|
+
* which was established in funding_created.
|
|
51
|
+
* @param dustLimitSatoshi The dust limit in sats after which outputs
|
|
52
|
+
* will be prune
|
|
53
|
+
* @param feePerKw The fee rate per kiloweight which will be deducted
|
|
54
|
+
* from the funding node's output
|
|
55
|
+
* @param localDelay The delay applied to the to_local output
|
|
56
|
+
* @param localValue Value paid to the to_local RSMC output
|
|
57
|
+
* @param remoteValue Value paid to the to_emote P2WPKH output
|
|
58
|
+
* @param revocationPubKey The revocation public key used to in the
|
|
59
|
+
* to_local and HTLC outputs
|
|
60
|
+
* @param delayedPubKey The delayed public key used to spend the
|
|
61
|
+
* to_local output
|
|
62
|
+
* @param remotePubKey The public key used to spend the to_remote
|
|
63
|
+
* output
|
|
64
|
+
* @param reverseHtlcs True when the HTLC direction needs to be
|
|
65
|
+
* inverted because the holder of this commitment transaction is
|
|
66
|
+
* our counterparty.
|
|
67
|
+
* @param localHtlcPubKey The public key used to spend HTLC outputs
|
|
68
|
+
* by the commitment holder.
|
|
69
|
+
* @param remoteHtlcPubKey The public key used to spend HTLC outputs
|
|
70
|
+
* by the commitment counterparty.
|
|
71
|
+
* @param htlcs A full list of HTLCs that will be selectively
|
|
72
|
+
* included in the commitment transaction based on the feePerKw.
|
|
73
|
+
*/
|
|
74
|
+
public static createCommitment(
|
|
75
|
+
isFunderLocal: boolean,
|
|
76
|
+
commitmentNumber: number,
|
|
77
|
+
openPaymentBasePoint: Buffer,
|
|
78
|
+
acceptPaymentBasePoint: Buffer,
|
|
79
|
+
fundingOutPoint: OutPoint,
|
|
80
|
+
dustLimitSatoshi: Value,
|
|
81
|
+
feePerKw: bigint,
|
|
82
|
+
localDelay: number,
|
|
83
|
+
localValue: Value,
|
|
84
|
+
remoteValue: Value,
|
|
85
|
+
revocationPubKey: Buffer,
|
|
86
|
+
delayedPubKey: Buffer,
|
|
87
|
+
remotePubKey: Buffer,
|
|
88
|
+
reverseHtlcs: boolean,
|
|
89
|
+
localHtlcPubKey?: Buffer,
|
|
90
|
+
remoteHtlcPubKey?: Buffer,
|
|
91
|
+
htlcs: Htlc[] = [],
|
|
92
|
+
): [TxBuilder, Htlc[]] {
|
|
93
|
+
const obscuredCommitmentNumber = CommitmentNumber.obscure(
|
|
94
|
+
commitmentNumber,
|
|
95
|
+
openPaymentBasePoint,
|
|
96
|
+
acceptPaymentBasePoint,
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
// 1. add the input as the funding outpoint and set the nSequence
|
|
100
|
+
const tx = new TxBuilder();
|
|
101
|
+
tx.version = 2;
|
|
102
|
+
tx.addInput(
|
|
103
|
+
fundingOutPoint,
|
|
104
|
+
CommitmentNumber.getSequence(obscuredCommitmentNumber),
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
// 2. set the locktime to the obscurred commitment number
|
|
108
|
+
tx.locktime = CommitmentNumber.getLockTime(obscuredCommitmentNumber);
|
|
109
|
+
|
|
110
|
+
// 3. find unpruned outputs
|
|
111
|
+
const unprunedHtlcs: Htlc[] = [];
|
|
112
|
+
for (const htlc of htlcs) {
|
|
113
|
+
const valueInSats = htlc.value.sats;
|
|
114
|
+
let feeWeight: bigint;
|
|
115
|
+
|
|
116
|
+
// HtlcDirection refers to the local nodes perception of the HTLC.
|
|
117
|
+
// When isLocal, offered uses the HTLC-Timeout weight of 663. When
|
|
118
|
+
// remote, the commitment is for the remote counterparty and an
|
|
119
|
+
// offered HTLC is received and will be spent by the remote
|
|
120
|
+
// counterparty using the HTLC-Success transaction with a weight of 703
|
|
121
|
+
if (reverseHtlcs) {
|
|
122
|
+
feeWeight =
|
|
123
|
+
htlc.direction === HtlcDirection.Offered ? BigInt(703) : BigInt(663);
|
|
124
|
+
} else {
|
|
125
|
+
feeWeight =
|
|
126
|
+
htlc.direction === HtlcDirection.Offered ? BigInt(663) : BigInt(703);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Calculate the HTLC less fees
|
|
130
|
+
const feeInSats = (feeWeight * feePerKw) / BigInt(1000);
|
|
131
|
+
const satsLessFee = valueInSats - feeInSats;
|
|
132
|
+
|
|
133
|
+
// Only keep HTLCs greater than the dustLimitSatoshi for the tx
|
|
134
|
+
if (satsLessFee >= dustLimitSatoshi.sats) {
|
|
135
|
+
unprunedHtlcs.push(htlc);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// 4. calculate base fee
|
|
140
|
+
const weight = 724 + unprunedHtlcs.length * 172;
|
|
141
|
+
const baseFee = (BigInt(weight) * feePerKw) / BigInt(1000);
|
|
142
|
+
|
|
143
|
+
// 5. substract base fee from funding node
|
|
144
|
+
if (isFunderLocal) {
|
|
145
|
+
const newValue = localValue.sats - baseFee;
|
|
146
|
+
if (newValue > BigInt(0)) {
|
|
147
|
+
localValue = Value.fromSats(newValue);
|
|
148
|
+
} else {
|
|
149
|
+
localValue = Value.zero();
|
|
150
|
+
}
|
|
151
|
+
} else {
|
|
152
|
+
const newValue = remoteValue.sats - baseFee;
|
|
153
|
+
if (newValue > BigInt(0)) {
|
|
154
|
+
remoteValue = Value.fromSats(newValue);
|
|
155
|
+
} else {
|
|
156
|
+
remoteValue = Value.zero();
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// 6/7. add unpruned offered/received HTLCs
|
|
161
|
+
const txouts: Array<[TxOut, Htlc?]> = [];
|
|
162
|
+
for (const htlc of unprunedHtlcs) {
|
|
163
|
+
const witnessScript: Script =
|
|
164
|
+
(!reverseHtlcs && htlc.direction === HtlcDirection.Offered) ||
|
|
165
|
+
(reverseHtlcs && htlc.direction === HtlcDirection.Accepted)
|
|
166
|
+
? ScriptFactory.offeredHtlcScript(
|
|
167
|
+
htlc.paymentHash,
|
|
168
|
+
revocationPubKey,
|
|
169
|
+
localHtlcPubKey,
|
|
170
|
+
remoteHtlcPubKey,
|
|
171
|
+
)
|
|
172
|
+
: ScriptFactory.receivedHtlcScript(
|
|
173
|
+
htlc.paymentHash,
|
|
174
|
+
htlc.cltvExpiry,
|
|
175
|
+
revocationPubKey,
|
|
176
|
+
localHtlcPubKey,
|
|
177
|
+
remoteHtlcPubKey,
|
|
178
|
+
);
|
|
179
|
+
const txout = new TxOut(htlc.value, Script.p2wshLock(witnessScript));
|
|
180
|
+
txouts.push([txout, htlc]);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// 8. add local if unpruned
|
|
184
|
+
if (localValue.sats >= dustLimitSatoshi.sats) {
|
|
185
|
+
txouts.push([
|
|
186
|
+
new TxOut(
|
|
187
|
+
localValue,
|
|
188
|
+
Script.p2wshLock(
|
|
189
|
+
ScriptFactory.toLocalScript(
|
|
190
|
+
revocationPubKey,
|
|
191
|
+
delayedPubKey,
|
|
192
|
+
localDelay,
|
|
193
|
+
),
|
|
194
|
+
),
|
|
195
|
+
),
|
|
196
|
+
]);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// 9. add remote if unpruned
|
|
200
|
+
if (remoteValue.sats >= dustLimitSatoshi.sats) {
|
|
201
|
+
txouts.push([new TxOut(remoteValue, Script.p2wpkhLock(remotePubKey))]);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// 10. sort outputs using bip69 and using cltv for htlc tiebreaks
|
|
205
|
+
txouts.sort((a, b) => {
|
|
206
|
+
// compare on value
|
|
207
|
+
const value = Number(a[0].value.sats - b[0].value.sats);
|
|
208
|
+
if (value !== 0) return value;
|
|
209
|
+
|
|
210
|
+
// compare on script
|
|
211
|
+
const scriptCompare = a[0].scriptPubKey
|
|
212
|
+
.serializeCmds()
|
|
213
|
+
.compare(b[0].scriptPubKey.serializeCmds());
|
|
214
|
+
if (scriptCompare !== 0) return scriptCompare;
|
|
215
|
+
|
|
216
|
+
// tie-break on htlcs
|
|
217
|
+
return b[1].cltvExpiry - a[1].cltvExpiry;
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
// add hte outputs in sorted order
|
|
221
|
+
const sortedHtlcs: Htlc[] = [];
|
|
222
|
+
for (const [txout, htlc] of txouts) {
|
|
223
|
+
tx.addOutput(txout);
|
|
224
|
+
sortedHtlcs.push(htlc);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// return the tuple with the sorted htlcs
|
|
228
|
+
return [tx, sortedHtlcs];
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Constructs an HTLC-Timeout transaction as defined in BOLT3. This
|
|
233
|
+
* transaction spends an offered HTLC from the commitment transaction
|
|
234
|
+
* and outputs the HTLC value less the fee. The output is spendable
|
|
235
|
+
* via an RSMC that is sequence locked for the received by the
|
|
236
|
+
* transaction owner. Finally this transaction has an absolute
|
|
237
|
+
* locktime of the HTLC's cltv expiry.
|
|
238
|
+
* @param commitmentTx
|
|
239
|
+
* @param outputIndex
|
|
240
|
+
* @param localDelay
|
|
241
|
+
* @param revocationPubKey
|
|
242
|
+
* @param delayedPubKey
|
|
243
|
+
* @param feePerKw
|
|
244
|
+
* @param htlc
|
|
245
|
+
*/
|
|
246
|
+
public static createHtlcTimeout(
|
|
247
|
+
commitmentTx: HashValue,
|
|
248
|
+
outputIndex: number,
|
|
249
|
+
localDelay: number,
|
|
250
|
+
revocationPubKey: Buffer,
|
|
251
|
+
delayedPubKey: Buffer,
|
|
252
|
+
feePerKw: bigint,
|
|
253
|
+
htlc: Htlc,
|
|
254
|
+
): TxBuilder {
|
|
255
|
+
const tx = new TxBuilder();
|
|
256
|
+
|
|
257
|
+
// Input points to the commmitment transaction and the BIP69
|
|
258
|
+
// sorted index of the HTLC. nSequence is set to zero.
|
|
259
|
+
tx.addInput(new OutPoint(commitmentTx, outputIndex), Sequence.zero());
|
|
260
|
+
|
|
261
|
+
// calc value less fees for this transaction
|
|
262
|
+
const weight = BigInt(663);
|
|
263
|
+
const fees = (weight * feePerKw) / BigInt(1000);
|
|
264
|
+
const sats = fees > htlc.value.sats ? 0 : htlc.value.sats - fees;
|
|
265
|
+
|
|
266
|
+
// Spends a P2WSH RSMC
|
|
267
|
+
tx.addOutput(
|
|
268
|
+
Value.fromSats(sats),
|
|
269
|
+
Script.p2wshLock(
|
|
270
|
+
ScriptFactory.toLocalScript(
|
|
271
|
+
revocationPubKey,
|
|
272
|
+
delayedPubKey,
|
|
273
|
+
localDelay,
|
|
274
|
+
),
|
|
275
|
+
),
|
|
276
|
+
);
|
|
277
|
+
|
|
278
|
+
// nLocktime is set to the cltvExpiry of the HTLC. This prevents
|
|
279
|
+
// the HTLC-Timeout from being broadcast until after the expiry
|
|
280
|
+
// has been reached.
|
|
281
|
+
tx.locktime = new LockTime(htlc.cltvExpiry);
|
|
282
|
+
|
|
283
|
+
return tx;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Constructs an HTLC-Success transaction as defined in BOLT3. This
|
|
288
|
+
* transaction spends a received HTLC form the commitment transaction
|
|
289
|
+
* and outputs the HTLC value less the fee. The output is spendable
|
|
290
|
+
* via an RSMC that is sequence locked for the received by the
|
|
291
|
+
* transaction owner.
|
|
292
|
+
* @param commitmentTx
|
|
293
|
+
* @param outputIndex
|
|
294
|
+
* @param localDelay
|
|
295
|
+
* @param revocationPubKey
|
|
296
|
+
* @param delayedPubKey
|
|
297
|
+
* @param feePerKw
|
|
298
|
+
* @param htlc
|
|
299
|
+
*/
|
|
300
|
+
public static createHtlcSuccess(
|
|
301
|
+
commitmentTx: HashValue,
|
|
302
|
+
outputIndex: number,
|
|
303
|
+
localDelay: number,
|
|
304
|
+
revocationPubKey: Buffer,
|
|
305
|
+
delayedPubKey: Buffer,
|
|
306
|
+
feePerKw: bigint,
|
|
307
|
+
htlc: Htlc,
|
|
308
|
+
): TxBuilder {
|
|
309
|
+
const tx = new TxBuilder();
|
|
310
|
+
|
|
311
|
+
// Input points to the commmitment transaction and the BIP69
|
|
312
|
+
// sorted index of the HTLC. nSequence is set to zero.
|
|
313
|
+
tx.addInput(new OutPoint(commitmentTx, outputIndex), Sequence.zero());
|
|
314
|
+
|
|
315
|
+
// calc value less fees for this transaction
|
|
316
|
+
const weight = BigInt(703);
|
|
317
|
+
const fees = (weight * feePerKw) / BigInt(1000);
|
|
318
|
+
const sats = fees > htlc.value.sats ? 0 : htlc.value.sats - fees;
|
|
319
|
+
|
|
320
|
+
// Spends a P2WSH RSMC
|
|
321
|
+
tx.addOutput(
|
|
322
|
+
Value.fromSats(sats),
|
|
323
|
+
Script.p2wshLock(
|
|
324
|
+
ScriptFactory.toLocalScript(
|
|
325
|
+
revocationPubKey,
|
|
326
|
+
delayedPubKey,
|
|
327
|
+
localDelay,
|
|
328
|
+
),
|
|
329
|
+
),
|
|
330
|
+
);
|
|
331
|
+
|
|
332
|
+
// nLockTime is zero since the tx owner can immediately spend
|
|
333
|
+
// this transaction if they have the preimage
|
|
334
|
+
tx.locktime = LockTime.zero();
|
|
335
|
+
|
|
336
|
+
return tx;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import BigNumber from 'bignumber.js';
|
|
2
|
+
|
|
3
|
+
export class BigIntMath {
|
|
4
|
+
static max(...values: bigint[]): bigint {
|
|
5
|
+
if (values.length === 0) {
|
|
6
|
+
return null;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
if (values.length === 1) {
|
|
10
|
+
return values[0];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
let max = values[0];
|
|
14
|
+
for (let i = 1; i < values.length; i++) {
|
|
15
|
+
if (values[i] > max) {
|
|
16
|
+
max = values[i];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return max;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
static min(...values: bigint[]): bigint {
|
|
23
|
+
if (values.length === 0) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (values.length === 1) {
|
|
28
|
+
return values[0];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
let min = values[0];
|
|
32
|
+
for (let i = 1; i < values.length; i++) {
|
|
33
|
+
if (values[i] < min) {
|
|
34
|
+
min = values[i];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return min;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static sign(value: bigint): bigint {
|
|
41
|
+
if (value > BigInt(0)) {
|
|
42
|
+
return BigInt(1);
|
|
43
|
+
}
|
|
44
|
+
if (value < BigInt(0)) {
|
|
45
|
+
return BigInt(-1);
|
|
46
|
+
}
|
|
47
|
+
return BigInt(0);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
static abs(value: bigint): bigint {
|
|
51
|
+
if (this.sign(value) === BigInt(-1)) {
|
|
52
|
+
return -value;
|
|
53
|
+
}
|
|
54
|
+
return value;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static clamp(min: bigint, val: bigint, max: bigint): bigint {
|
|
58
|
+
return this.max(min, this.min(val, max));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function toBigInt(num: BigNumber): bigint {
|
|
63
|
+
return BigInt(num.integerValue().toString());
|
|
64
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import BigNumber from 'bignumber.js';
|
|
2
|
+
|
|
3
|
+
// Precision refers to the number of digits after the decimal point.
|
|
4
|
+
// Refer to https://github.com/discreetlogcontracts/dlcspecs/blob/master/PayoutCurve.md#version-0-payout_function
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Extract the precision of a number
|
|
8
|
+
* @param num
|
|
9
|
+
* @returns The precision of the number
|
|
10
|
+
*/
|
|
11
|
+
export const getPrecision = (num: BigNumber): number =>
|
|
12
|
+
num.decimalPlaces(16).abs().modulo(1).shiftedBy(16).toNumber();
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Creates a precise number from a precision
|
|
16
|
+
* @param precision
|
|
17
|
+
* @returns The number with the given precision
|
|
18
|
+
*/
|
|
19
|
+
export const fromPrecision = (precision: number): BigNumber => {
|
|
20
|
+
if (precision.toString().length > 16)
|
|
21
|
+
throw new Error('Precision is too large');
|
|
22
|
+
return new BigNumber(precision).shiftedBy(-16);
|
|
23
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@node-dlc/core",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "DLC Core",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"start": "npm run build && node dist/index.js",
|
|
7
|
+
"test": "../../node_modules/.bin/nyc --reporter=lcov --reporter=text --extension=.ts ../../node_modules/.bin/mocha --require ts-node/register --recursive \"__tests__/**/*.spec.*\"",
|
|
8
|
+
"lint": "../../node_modules/.bin/eslint --ignore-path ../../.eslintignore -c ../../.eslintrc.js .",
|
|
9
|
+
"lint:fix": "../../node_modules/.bin/eslint --fix --ignore-path ../../.eslintignore -c ../../.eslintrc.js .",
|
|
10
|
+
"build": "../../node_modules/.bin/tsc --project tsconfig.json"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"dlc",
|
|
14
|
+
"core"
|
|
15
|
+
],
|
|
16
|
+
"author": "Atomic Finance <info@atomic.finance>",
|
|
17
|
+
"homepage": "https://github.com/atomicfinance/node-dlc/tree/master/packages/daemon",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"main": "dist/index.js",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/atomicfinance/node-dlc.git"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@node-dlc/bitcoin": "^1.0.1",
|
|
26
|
+
"@node-dlc/bufio": "^1.0.1",
|
|
27
|
+
"@node-dlc/common": "^1.0.1",
|
|
28
|
+
"@node-dlc/crypto": "^1.0.1",
|
|
29
|
+
"@node-dlc/messaging": "^1.0.1",
|
|
30
|
+
"bignumber.js": "^9.0.1",
|
|
31
|
+
"bitcoin-networks": "^1.0.0",
|
|
32
|
+
"decimal.js": "10.4.3"
|
|
33
|
+
},
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
},
|
|
37
|
+
"yalcSig": "d6b67fd54b29f78ffbe9737666f9467e"
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
d6b67fd54b29f78ffbe9737666f9467e
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,117 @@
|
|
|
1
1
|
# @atomicfinance/bitcoin-wallet-provider
|
|
2
2
|
|
|
3
|
+
## 4.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 03c6974: Add DLC input splicing support
|
|
8
|
+
|
|
9
|
+
This release introduces DLC (Discreet Log Contract) input splicing functionality, enabling more flexible contract funding and management.
|
|
10
|
+
|
|
11
|
+
## Key Features
|
|
12
|
+
- **Core Types**: Added new types and interfaces for DLC input splicing operations
|
|
13
|
+
- **Provider Integration**: Implemented splicing support in BitcoinDlcProvider with proper input handling
|
|
14
|
+
- **Comprehensive Testing**: Added integration tests to validate splicing functionality
|
|
15
|
+
- **Dependency Updates**: Upgraded @node-dlc to v1.1.0 for enhanced splicing capabilities
|
|
16
|
+
|
|
17
|
+
## What's New
|
|
18
|
+
- DLC contracts can now be funded using spliced inputs
|
|
19
|
+
- Enhanced input selection and handling for splicing operations
|
|
20
|
+
- Improved test coverage for edge cases in DLC splicing scenarios
|
|
21
|
+
|
|
22
|
+
This feature enables more efficient Bitcoin transaction management when working with DLC contracts by allowing existing UTXOs to be split and used as contract inputs.
|
|
23
|
+
|
|
24
|
+
- d94fbbf: Fix TypeScript ESLint compatibility and improve type safety
|
|
25
|
+
- Upgrade @typescript-eslint dependencies to v6.21.0 for TypeScript 4.9.5 support
|
|
26
|
+
|
|
27
|
+
- b83e3a8: Add single-funded DLC support and update to node-dlc v1.0.1
|
|
28
|
+
- Add comprehensive single-funded DLC support to BitcoinDlcProvider
|
|
29
|
+
- Update @node-dlc dependencies to v1.0.1 with single-funded support
|
|
30
|
+
- Update cfd-dlc-js to v0.0.52
|
|
31
|
+
- Implement single-funded DLC detection and validation logic
|
|
32
|
+
- Handle acceptDlcOffer with 0 collateral scenarios (no funding)
|
|
33
|
+
- Fix fundTxVout calculation for parties with collateral only
|
|
34
|
+
- Add getFundOutputValueSats helper with proper error handling
|
|
35
|
+
- Add markAsSingleFunded() calls for proper DLC type identification
|
|
36
|
+
- Skip funding validation when accept collateral is 0
|
|
37
|
+
- Generate addresses/keys without requiring funding inputs
|
|
38
|
+
|
|
39
|
+
Enables single-funded DLCs where one party provides all collateral
|
|
40
|
+
while the other party participates without funding inputs.
|
|
41
|
+
|
|
42
|
+
- Updated dependencies [03c6974]
|
|
43
|
+
- Updated dependencies [d94fbbf]
|
|
44
|
+
- Updated dependencies [b83e3a8]
|
|
45
|
+
- @atomicfinance/types@4.0.1
|
|
46
|
+
- @atomicfinance/bitcoin-utils@4.0.1
|
|
47
|
+
- @atomicfinance/provider@4.0.1
|
|
48
|
+
|
|
49
|
+
## 4.0.0
|
|
50
|
+
|
|
51
|
+
### Major Changes
|
|
52
|
+
|
|
53
|
+
- 8989c75: Upgrade to @node-dlc v1.0.0
|
|
54
|
+
|
|
55
|
+
## Breaking Changes
|
|
56
|
+
|
|
57
|
+
This release upgrades to @node-dlc v1.0.0 with significant breaking changes:
|
|
58
|
+
|
|
59
|
+
### Dependencies
|
|
60
|
+
- Upgraded @node-dlc packages from 0.24.0 to ^1.0.0
|
|
61
|
+
- Minimum Node.js version now 18.18.2
|
|
62
|
+
- Added decimal.js dependency for F64 type support
|
|
63
|
+
|
|
64
|
+
### API Changes
|
|
65
|
+
- **Message Types**: Removed versioned suffixes (DlcOfferV0 → DlcOffer)
|
|
66
|
+
- **Property Names**:
|
|
67
|
+
- `fundingPubKey` → `fundingPubkey`
|
|
68
|
+
- `payoutSPK` → `payoutSpk`
|
|
69
|
+
- `changeSPK` → `changeSpk`
|
|
70
|
+
- `cetSignatures` → `cetAdaptorSignatures`
|
|
71
|
+
- `tempContractId` → `temporaryContractId`
|
|
72
|
+
|
|
73
|
+
### Type System
|
|
74
|
+
- **Contract Descriptors**: V0/V1 types replaced with Enumerated/Numerical descriptors
|
|
75
|
+
- **Oracle Types**: OracleInfoV0 → SingleOracleInfo/MultiOracleInfo
|
|
76
|
+
- **Message Validation**: Switched from type-based to property-based checking
|
|
77
|
+
- **Enum Outcomes**: Migrated from Buffer to string format
|
|
78
|
+
|
|
79
|
+
### New Features
|
|
80
|
+
- Enhanced oracle event descriptor handling
|
|
81
|
+
- Improved decimal precision with F64 types
|
|
82
|
+
- Fallback outcome index search algorithm
|
|
83
|
+
- Auto-generation of temporary contract IDs
|
|
84
|
+
|
|
85
|
+
## Migration Guide
|
|
86
|
+
|
|
87
|
+
### Code Updates Required
|
|
88
|
+
|
|
89
|
+
```javascript
|
|
90
|
+
// Before
|
|
91
|
+
const dlcOffer = new DlcOfferV0();
|
|
92
|
+
dlcOffer.fundingPubKey = pubkey;
|
|
93
|
+
dlcOffer.payoutSPK = spk;
|
|
94
|
+
|
|
95
|
+
// After
|
|
96
|
+
const dlcOffer = new DlcOffer();
|
|
97
|
+
dlcOffer.fundingPubkey = pubkey;
|
|
98
|
+
dlcOffer.payoutSpk = spk;
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Environment
|
|
102
|
+
- Update Node.js to 18.18.2+
|
|
103
|
+
- Run `yarn install` to update dependencies
|
|
104
|
+
- Review custom DLC implementations for compatibility
|
|
105
|
+
|
|
106
|
+
This is a **major breaking change** requiring code updates in consuming applications.
|
|
107
|
+
|
|
108
|
+
### Patch Changes
|
|
109
|
+
|
|
110
|
+
- Updated dependencies [8989c75]
|
|
111
|
+
- @atomicfinance/types@4.0.0
|
|
112
|
+
- @atomicfinance/bitcoin-utils@4.0.0
|
|
113
|
+
- @atomicfinance/provider@4.0.0
|
|
114
|
+
|
|
3
115
|
## 3.6.1
|
|
4
116
|
|
|
5
117
|
### Patch Changes
|
|
@@ -40,7 +40,9 @@ declare const _default: <T extends Constructor<Provider>>(superclass: T) => (abs
|
|
|
40
40
|
{
|
|
41
41
|
inputTxHex: string;
|
|
42
42
|
index: number;
|
|
43
|
-
vout:
|
|
43
|
+
vout: {
|
|
44
|
+
vSat: number;
|
|
45
|
+
};
|
|
44
46
|
outputScript: Buffer;
|
|
45
47
|
}
|
|
46
48
|
], addresses: string, tx: any, lockTime?: number, segwit?: boolean): Promise<Buffer[]>;
|
|
@@ -104,7 +106,7 @@ declare const _default: <T extends Constructor<Provider>>(superclass: T) => (abs
|
|
|
104
106
|
*/
|
|
105
107
|
findAddress(addresses: string[], change?: boolean | null): Promise<Address>;
|
|
106
108
|
getUsedAddresses(numAddressPerCall?: number): Promise<any[]>;
|
|
107
|
-
withCachedUtxos(func: () =>
|
|
109
|
+
withCachedUtxos(func: () => unknown): Promise<any>;
|
|
108
110
|
getTotalFee(opts: SendOptions, max: boolean): Promise<number>;
|
|
109
111
|
getTotalFees(transactions: SendOptions[], max: boolean): Promise<any>;
|
|
110
112
|
getInputsForAmount(_targets: bT.OutputTarget[], feePerByte?: number, fixedInputs?: bT.Input[], numAddressPerCall?: number, sweep?: boolean): Promise<{
|
|
@@ -46,6 +46,7 @@ var AddressSearchType;
|
|
|
46
46
|
})(AddressSearchType = exports.AddressSearchType || (exports.AddressSearchType = {}));
|
|
47
47
|
exports.default = (superclass) => {
|
|
48
48
|
class BitcoinWalletProvider extends superclass {
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
49
50
|
constructor(...args) {
|
|
50
51
|
const options = args[0];
|
|
51
52
|
const { network, baseDerivationPath, addressType = types_1.bitcoin.AddressType.BECH32, addressIndex = 0, changeAddressIndex = 0, } = options;
|