@babylonlabs-io/ts-sdk 0.69.1 → 0.70.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/dist/{PeginManager-BI3pacy0.js → PeginManager-BNtg6jgY.js} +5 -5
- package/dist/{PeginManager-BI3pacy0.js.map → PeginManager-BNtg6jgY.js.map} +1 -1
- package/dist/{PeginManager-DZE2nnjt.cjs → PeginManager-CvI99Uhd.cjs} +2 -2
- package/dist/{PeginManager-DZE2nnjt.cjs.map → PeginManager-CvI99Uhd.cjs.map} +1 -1
- package/dist/{batchPoll-Bc_UKaTz.js → batchPoll-BM4iQ9jT.js} +3 -3
- package/dist/{batchPoll-Bc_UKaTz.js.map → batchPoll-BM4iQ9jT.js.map} +1 -1
- package/dist/{batchPoll-C9cZ5usJ.cjs → batchPoll-cqpEfBjr.cjs} +2 -2
- package/dist/{batchPoll-C9cZ5usJ.cjs.map → batchPoll-cqpEfBjr.cjs.map} +1 -1
- package/dist/buildAndBroadcastReclaim-iNJfx0ZG.cjs +2 -0
- package/dist/buildAndBroadcastReclaim-iNJfx0ZG.cjs.map +1 -0
- package/dist/{buildAndBroadcastRefund-DY4ZZcFL.js → buildAndBroadcastReclaim-kBHwOL02.js} +692 -598
- package/dist/buildAndBroadcastReclaim-kBHwOL02.js.map +1 -0
- package/dist/constants-BCdDRd_Y.cjs +2 -0
- package/dist/constants-BCdDRd_Y.cjs.map +1 -0
- package/dist/constants-DRiWbItj.js +24 -0
- package/dist/constants-DRiWbItj.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +256 -244
- package/dist/{mempoolApi-71R_CNZa.js → mempoolApi-CfOFmov6.js} +2 -2
- package/dist/{mempoolApi-71R_CNZa.js.map → mempoolApi-CfOFmov6.js.map} +1 -1
- package/dist/{mempoolApi-BJN9fGEd.cjs → mempoolApi-Q90mz17e.cjs} +2 -2
- package/dist/{mempoolApi-BJN9fGEd.cjs.map → mempoolApi-Q90mz17e.cjs.map} +1 -1
- package/dist/noPayout-BKP3mRu3.cjs +2 -0
- package/dist/noPayout-BKP3mRu3.cjs.map +1 -0
- package/dist/noPayout-BdATUPjF.js +280 -0
- package/dist/noPayout-BdATUPjF.js.map +1 -0
- package/dist/signPsbtsWithFallback-Bo1PJX90.cjs +2 -0
- package/dist/signPsbtsWithFallback-Bo1PJX90.cjs.map +1 -0
- package/dist/{signPsbtsWithFallback-DCZO2h6i.js → signPsbtsWithFallback-X6ivsbh7.js} +56 -47
- package/dist/signPsbtsWithFallback-X6ivsbh7.js.map +1 -0
- package/dist/tbv/core/clients/index.cjs +1 -1
- package/dist/tbv/core/clients/index.js +2 -2
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.js +255 -243
- package/dist/tbv/core/managers/PayoutManager.d.ts.map +1 -1
- package/dist/tbv/core/managers/index.cjs +1 -1
- package/dist/tbv/core/managers/index.js +2 -2
- package/dist/tbv/core/primitives/index.cjs +1 -1
- package/dist/tbv/core/primitives/index.d.ts +4 -0
- package/dist/tbv/core/primitives/index.d.ts.map +1 -1
- package/dist/tbv/core/primitives/index.js +52 -46
- package/dist/tbv/core/primitives/psbt/__tests__/depositorClaim.test.d.ts +16 -0
- package/dist/tbv/core/primitives/psbt/__tests__/depositorClaim.test.d.ts.map +1 -0
- package/dist/tbv/core/primitives/psbt/__tests__/reclaim.test.d.ts +10 -0
- package/dist/tbv/core/primitives/psbt/__tests__/reclaim.test.d.ts.map +1 -0
- package/dist/tbv/core/primitives/psbt/constants.d.ts +7 -0
- package/dist/tbv/core/primitives/psbt/constants.d.ts.map +1 -1
- package/dist/tbv/core/primitives/psbt/depositorClaim.d.ts +47 -0
- package/dist/tbv/core/primitives/psbt/depositorClaim.d.ts.map +1 -0
- package/dist/tbv/core/primitives/psbt/pegin.d.ts.map +1 -1
- package/dist/tbv/core/primitives/psbt/reclaim.d.ts +93 -0
- package/dist/tbv/core/primitives/psbt/reclaim.d.ts.map +1 -0
- package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts.map +1 -1
- package/dist/tbv/core/services/index.cjs +1 -1
- package/dist/tbv/core/services/index.d.ts +1 -0
- package/dist/tbv/core/services/index.d.ts.map +1 -1
- package/dist/tbv/core/services/index.js +50 -44
- package/dist/tbv/core/services/reclaim/__tests__/buildAndBroadcastReclaim.test.d.ts +9 -0
- package/dist/tbv/core/services/reclaim/__tests__/buildAndBroadcastReclaim.test.d.ts.map +1 -0
- package/dist/tbv/core/services/reclaim/buildAndBroadcastReclaim.d.ts +79 -0
- package/dist/tbv/core/services/reclaim/buildAndBroadcastReclaim.d.ts.map +1 -0
- package/dist/tbv/core/services/reclaim/errors.d.ts +22 -0
- package/dist/tbv/core/services/reclaim/errors.d.ts.map +1 -0
- package/dist/tbv/core/services/reclaim/index.d.ts +9 -0
- package/dist/tbv/core/services/reclaim/index.d.ts.map +1 -0
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +255 -243
- package/dist/{toRefundInputs-B62WZ9co.cjs → toRefundInputs-BJojfg3k.cjs} +2 -2
- package/dist/{toRefundInputs-B62WZ9co.cjs.map → toRefundInputs-BJojfg3k.cjs.map} +1 -1
- package/dist/{toRefundInputs-amYZu79x.js → toRefundInputs-DPNYBFkP.js} +4 -4
- package/dist/{toRefundInputs-amYZu79x.js.map → toRefundInputs-DPNYBFkP.js.map} +1 -1
- package/dist/{verifyScriptPathSchnorrSignature-Dy9gF5RF.js → verifyScriptPathSchnorrSignature-CQYucnJA.js} +143 -125
- package/dist/verifyScriptPathSchnorrSignature-CQYucnJA.js.map +1 -0
- package/dist/verifyScriptPathSchnorrSignature-D-ppKNjT.cjs +2 -0
- package/dist/verifyScriptPathSchnorrSignature-D-ppKNjT.cjs.map +1 -0
- package/package.json +1 -1
- package/dist/buildAndBroadcastRefund-CPPGvzXb.cjs +0 -2
- package/dist/buildAndBroadcastRefund-CPPGvzXb.cjs.map +0 -1
- package/dist/buildAndBroadcastRefund-DY4ZZcFL.js.map +0 -1
- package/dist/constants-DU5CGcqO.cjs +0 -2
- package/dist/constants-DU5CGcqO.cjs.map +0 -1
- package/dist/constants-GjWXdaqV.js +0 -23
- package/dist/constants-GjWXdaqV.js.map +0 -1
- package/dist/noPayout-CXn-geIS.js +0 -178
- package/dist/noPayout-CXn-geIS.js.map +0 -1
- package/dist/noPayout-Ox27Td9x.cjs +0 -2
- package/dist/noPayout-Ox27Td9x.cjs.map +0 -1
- package/dist/signPsbtsWithFallback-C5cVgYhh.cjs +0 -2
- package/dist/signPsbtsWithFallback-C5cVgYhh.cjs.map +0 -1
- package/dist/signPsbtsWithFallback-DCZO2h6i.js.map +0 -1
- package/dist/verifyScriptPathSchnorrSignature-Dy9gF5RF.js.map +0 -1
- package/dist/verifyScriptPathSchnorrSignature-la8XOAFm.cjs +0 -2
- package/dist/verifyScriptPathSchnorrSignature-la8XOAFm.cjs.map +0 -1
|
@@ -1,49 +1,55 @@
|
|
|
1
|
-
import { P as s,
|
|
2
|
-
import { a as
|
|
3
|
-
import { computeMinClaimValue as
|
|
4
|
-
import { a as
|
|
5
|
-
import { a as
|
|
6
|
-
import { b as
|
|
7
|
-
import { c as
|
|
1
|
+
import { P as s, h as t, i as r, j as i, f as o, b as u, a as n, c as P, k as l, d, e as b, g as c } from "../../../verifyScriptPathSchnorrSignature-CQYucnJA.js";
|
|
2
|
+
import { a as g } from "../../../constants-DRiWbItj.js";
|
|
3
|
+
import { computeMinClaimValue as x, computeMinPeginFee as y, deriveVaultId as S, peginP2aAnchorOutput as f, supportedTxGraphVersions as h, validatePeginP2aAnchor as v } from "@babylonlabs-io/babylon-tbv-rust-wasm";
|
|
4
|
+
import { a as A, c as V, b as C, e as I, f as O } from "../../../verifyKeyPathSchnorrSignature-C6Cmk0R1.js";
|
|
5
|
+
import { c as F, a as H, b as R, e as k, r as D } from "../../../noPayout-BdATUPjF.js";
|
|
6
|
+
import { b as N } from "../../../challengeAssert-BNQ8sToz.js";
|
|
7
|
+
import { c as B, d as E, a as U, b as X, e as _, f as j, g as G, h as L, i as w, j as W, p as q, s as J, t as Q, u as Y, v as Z } from "../../../bitcoin-Ch_jxnDa.js";
|
|
8
8
|
export {
|
|
9
|
-
s as
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
u as
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
9
|
+
s as PEGIN_DEPOSITOR_CLAIM_VOUT,
|
|
10
|
+
t as PsbtSubstitutionError,
|
|
11
|
+
A as assertKeyPathSchnorrSignature,
|
|
12
|
+
r as assertPsbtUnsignedTxMatches,
|
|
13
|
+
V as assertReturnedKeyPathSignatures,
|
|
14
|
+
i as assertScriptPathSchnorrSignature,
|
|
15
|
+
g as assertValidVaultCoreVersion,
|
|
16
|
+
N as buildChallengeAssertPsbt,
|
|
17
|
+
F as buildNoPayoutPsbt,
|
|
18
|
+
o as buildPayoutPsbt,
|
|
19
|
+
C as buildPeginInputPsbt,
|
|
20
|
+
u as buildPeginTxFromFundedPrePegin,
|
|
21
|
+
n as buildPrePeginPsbt,
|
|
22
|
+
H as buildReclaimPsbt,
|
|
23
|
+
R as buildRefundPsbt,
|
|
24
|
+
B as canonicalizeBtcPubkey,
|
|
25
|
+
x as computeMinClaimValue,
|
|
26
|
+
y as computeMinPeginFee,
|
|
27
|
+
P as computeNumLocalChallengers,
|
|
28
|
+
l as createPayoutScript,
|
|
29
|
+
E as deriveBip86ScriptPubKeyHex,
|
|
30
|
+
d as deriveDepositorClaimDescriptor,
|
|
31
|
+
b as deriveDepositorClaimScriptPubKey,
|
|
32
|
+
U as deriveNativeSegwitAddress,
|
|
33
|
+
X as deriveTaprootAddress,
|
|
34
|
+
S as deriveVaultId,
|
|
35
|
+
_ as ensureHexPrefix,
|
|
36
|
+
k as estimateReclaimFeeSats,
|
|
37
|
+
c as extractPayoutSignature,
|
|
38
|
+
I as extractPeginInputSignature,
|
|
39
|
+
O as finalizePeginInputPsbt,
|
|
40
|
+
j as formatSatoshisToBtc,
|
|
41
|
+
G as getSortedXOnlyPubkeys,
|
|
42
|
+
L as hexToUint8Array,
|
|
43
|
+
w as isAddressFromPublicKey,
|
|
44
|
+
W as isValidHex,
|
|
45
|
+
f as peginP2aAnchorOutput,
|
|
46
|
+
q as processPublicKeyToXOnly,
|
|
47
|
+
D as reclaimVsize,
|
|
48
|
+
J as stripHexPrefix,
|
|
49
|
+
h as supportedTxGraphVersions,
|
|
50
|
+
Q as toXOnly,
|
|
51
|
+
Y as uint8ArrayToHex,
|
|
52
|
+
v as validatePeginP2aAnchor,
|
|
53
|
+
Z as validateWalletPubkey
|
|
48
54
|
};
|
|
49
55
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Depositor-claim descriptor tests.
|
|
3
|
+
*
|
|
4
|
+
* CLAUDE.md critical path #9: this derivation mints the script a real Bitcoin
|
|
5
|
+
* transaction is signed against, and it has no Rust counterpart to compare
|
|
6
|
+
* with — btc-vault's `SingleKeyConnector` is not exposed through WASM. So the
|
|
7
|
+
* differential oracle here is a second, independent JS implementation: the
|
|
8
|
+
* hand-rolled BIP-341 construction below, which mirrors the Ledger firmware
|
|
9
|
+
* test's `p2trFromSingleLeaf` (test_sign_psbt_validate.py:188) and shares no
|
|
10
|
+
* code with `payments.p2tr`.
|
|
11
|
+
*
|
|
12
|
+
* The differential runs over pinned golden vectors *and* randomised keys — a
|
|
13
|
+
* single hardcoded vector pins one input, not the function.
|
|
14
|
+
*/
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=depositorClaim.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"depositorClaim.test.d.ts","sourceRoot":"","sources":["../../../../../../src/tbv/core/primitives/psbt/__tests__/depositorClaim.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reclaim PSBT builder tests.
|
|
3
|
+
*
|
|
4
|
+
* The builder signs away a real UTXO, so every assertion it makes gets a
|
|
5
|
+
* rejection test here: one per bind, plus value conservation and the dust
|
|
6
|
+
* floor. The vsize model is measured against a real transaction rather than
|
|
7
|
+
* asserted against the arithmetic that produced it.
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=reclaim.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reclaim.test.d.ts","sourceRoot":"","sources":["../../../../../../src/tbv/core/primitives/psbt/__tests__/reclaim.test.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
|
|
@@ -15,6 +15,13 @@
|
|
|
15
15
|
* Input 0: PegIn:0 (signed). Input 1: Assert:0 (in sighash, not signed).
|
|
16
16
|
*/
|
|
17
17
|
export declare const DEPOSITOR_PAYOUT_INPUT_COUNT = 2;
|
|
18
|
+
/**
|
|
19
|
+
* Inputs the depositor signs per Payout / NoPayout PSBT: input 0 only. The
|
|
20
|
+
* other inputs are in the SIGHASH_DEFAULT sighash but carry no depositor
|
|
21
|
+
* signature — the Ledger host expects exactly this many yields, so a drift
|
|
22
|
+
* here re-arms an input the device never signs.
|
|
23
|
+
*/
|
|
24
|
+
export declare const DEPOSITOR_SIGNED_INPUT_COUNT = 1;
|
|
18
25
|
/** PegIn vault output index spent by the depositor's Payout input 0. */
|
|
19
26
|
export declare const PEGIN_VAULT_OUTPUT_INDEX = 0;
|
|
20
27
|
/** Assert output index spent by the depositor's Payout input 1 (NOT signed). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/primitives/psbt/constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;;GAGG;AACH,eAAO,MAAM,4BAA4B,IAAI,CAAC;AAE9C,wEAAwE;AACxE,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAE1C,gFAAgF;AAChF,eAAO,MAAM,0BAA0B,IAAI,CAAC;AAE5C;;;GAGG;AACH,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,IAAI,CAAC;AACnC,eAAO,MAAM,kBAAkB,IAAI,CAAC;AAEpC,sFAAsF;AACtF,eAAO,MAAM,8BAA8B,IAAI,CAAC;AAEhD,+EAA+E;AAC/E,eAAO,MAAM,kCAAkC,IAAI,CAAC;AAEpD;;;;;;GAMG;AACH,eAAO,MAAM,0CAA0C,IAAI,CAAC;AAE5D;;;;;GAKG;AACH,eAAO,MAAM,+BAA+B,QAAS,CAAC;AAEtD;;;;;GAKG;AACH,eAAO,MAAM,eAAe,QAAS,CAAC;AAEtC;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,MAAM,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/primitives/psbt/constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;;GAGG;AACH,eAAO,MAAM,4BAA4B,IAAI,CAAC;AAE9C;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,IAAI,CAAC;AAE9C,wEAAwE;AACxE,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAE1C,gFAAgF;AAChF,eAAO,MAAM,0BAA0B,IAAI,CAAC;AAE5C;;;GAGG;AACH,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,IAAI,CAAC;AACnC,eAAO,MAAM,kBAAkB,IAAI,CAAC;AAEpC,sFAAsF;AACtF,eAAO,MAAM,8BAA8B,IAAI,CAAC;AAEhD,+EAA+E;AAC/E,eAAO,MAAM,kCAAkC,IAAI,CAAC;AAEpD;;;;;;GAMG;AACH,eAAO,MAAM,0CAA0C,IAAI,CAAC;AAE5D;;;;;GAKG;AACH,eAAO,MAAM,+BAA+B,QAAS,CAAC;AAEtD;;;;;GAKG;AACH,eAAO,MAAM,eAAe,QAAS,CAAC;AAEtC;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,MAAM,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Buffer } from 'buffer';
|
|
2
|
+
/**
|
|
3
|
+
* Vout of the depositor-claim output in every PegIn version (btc-vault: vault
|
|
4
|
+
* at 0, depositor claim at 1, optional P2A anchor appended after).
|
|
5
|
+
*
|
|
6
|
+
* Version-invariant: the graph version dispatches only the trailing P2A anchor
|
|
7
|
+
* (absent in v1, 240 sats at vout 2 in v2/v3). Nothing touches vout 1.
|
|
8
|
+
*/
|
|
9
|
+
export declare const PEGIN_DEPOSITOR_CLAIM_VOUT = 1;
|
|
10
|
+
/** The single-leaf taptree's spend material for one depositor key. */
|
|
11
|
+
export interface DepositorClaimDescriptor {
|
|
12
|
+
/** P2TR scriptPubKey the PegIn pays at {@link PEGIN_DEPOSITOR_CLAIM_VOUT}. */
|
|
13
|
+
scriptPubKey: Buffer;
|
|
14
|
+
/** The one tapleaf: `<depositor> OP_CHECKSIG`, 34 bytes. */
|
|
15
|
+
leafScript: Buffer;
|
|
16
|
+
/**
|
|
17
|
+
* Control block for that leaf: `[leafVersion | outputKeyParity] || NUMS`,
|
|
18
|
+
* 33 bytes. The tree has a single leaf at depth 0, so it carries no sibling
|
|
19
|
+
* hashes.
|
|
20
|
+
*/
|
|
21
|
+
controlBlock: Buffer;
|
|
22
|
+
/**
|
|
23
|
+
* The NUMS internal key the taptree commits to — the PSBT's `tapInternalKey`.
|
|
24
|
+
* Carried here so an input's internal key and control block provably come
|
|
25
|
+
* from the same derivation.
|
|
26
|
+
*/
|
|
27
|
+
internalKey: Buffer;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Derive the depositor-claim output's spend material in JS, independently of
|
|
31
|
+
* WASM — the Rust `SingleKeyConnector` has no WASM wrapper, so this is the
|
|
32
|
+
* only derivation available on the JS side.
|
|
33
|
+
*
|
|
34
|
+
* Takes no graph version: the connector is identical across v1/v2/v3. A future
|
|
35
|
+
* `VAULT_WASM_COMMIT` bump that changed it would break `assertPeginTxShape` at
|
|
36
|
+
* peg-in build time, which is where that regression should surface.
|
|
37
|
+
*
|
|
38
|
+
* @param depositorPubkey - x-only depositor pubkey, 64-char hex (no 0x prefix)
|
|
39
|
+
* @throws If bitcoinjs cannot derive the P2TR output or its control block
|
|
40
|
+
*/
|
|
41
|
+
export declare function deriveDepositorClaimDescriptor(depositorPubkey: string): DepositorClaimDescriptor;
|
|
42
|
+
/**
|
|
43
|
+
* The depositor-claim output's scriptPubKey alone — the peg-in validation path,
|
|
44
|
+
* which has no need of the spend material.
|
|
45
|
+
*/
|
|
46
|
+
export declare function deriveDepositorClaimScriptPubKey(depositorPubkey: string): Buffer;
|
|
47
|
+
//# sourceMappingURL=depositorClaim.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"depositorClaim.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/primitives/psbt/depositorClaim.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAShC;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,IAAI,CAAC;AAE5C,sEAAsE;AACtE,MAAM,WAAW,wBAAwB;IACvC,8EAA8E;IAC9E,YAAY,EAAE,MAAM,CAAC;IACrB,4DAA4D;IAC5D,UAAU,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,8BAA8B,CAC5C,eAAe,EAAE,MAAM,GACtB,wBAAwB,CA2C1B;AAED;;;GAGG;AACH,wBAAgB,gCAAgC,CAC9C,eAAe,EAAE,MAAM,GACtB,MAAM,CAER"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pegin.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/primitives/psbt/pegin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"pegin.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/primitives/psbt/pegin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAML,KAAK,OAAO,EACb,MAAM,uCAAuC,CAAC;AAe/C;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB,yEAAyE;IACzE,eAAe,EAAE,MAAM,CAAC;IACxB,4DAA4D;IAC5D,mBAAmB,EAAE,MAAM,CAAC;IAC5B,kEAAkE;IAClE,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAC7B,0EAA0E;IAC1E,0BAA0B,EAAE,MAAM,EAAE,CAAC;IACrC,+DAA+D;IAC/D,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7B,sDAAsD;IACtD,cAAc,EAAE,MAAM,CAAC;IACvB,oDAAoD;IACpD,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,iGAAiG;IACjG,OAAO,EAAE,MAAM,CAAC;IAChB,6FAA6F;IAC7F,eAAe,EAAE,MAAM,CAAC;IACxB,yDAAyD;IACzD,m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iBAAiB,CACrC,MAAM,EAAE,cAAc,GACrB,OAAO,CAAC,kBAAkB,CAAC,CA+D7B;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,MAAM,GAAG,SAAS,GACxB,MAAM,GAAG,SAAS,CAapB;AAED;;;;;;;;;GASG;AACH,wBAAsB,8BAA8B,CAClD,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,aAAa,CAAC,CAwCxB"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reclaim PSBT Builder Primitive
|
|
3
|
+
*
|
|
4
|
+
* Builds an unsigned PSBT that sweeps the depositor-claim reserve — PegIn
|
|
5
|
+
* vout 1 — back to the depositor's own BIP-86 address.
|
|
6
|
+
*
|
|
7
|
+
* The reserve funds the depositor's `claim_tx`, their recourse if the vault
|
|
8
|
+
* provider fails during peg-out. When the vault provider claims instead and
|
|
9
|
+
* the depositor withdraws normally, nothing ever spends it. This primitive is
|
|
10
|
+
* the only thing in the repository that can.
|
|
11
|
+
*
|
|
12
|
+
* Spend path: the single `<depositor> OP_CHECKSIG` tapleaf (see
|
|
13
|
+
* ./depositorClaim). No timelock, no counterparty signature — the depositor's
|
|
14
|
+
* Schnorr signature alone. That is also why the *caller* must gate: this
|
|
15
|
+
* builder will happily sweep a reserve whose vault is still live, which would
|
|
16
|
+
* permanently void the depositor's pre-signed recourse graph. Eligibility is
|
|
17
|
+
* enforced upstream, in the service.
|
|
18
|
+
*
|
|
19
|
+
* @module primitives/psbt/reclaim
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Virtual size of an N-in/1-out reclaim transaction.
|
|
23
|
+
*
|
|
24
|
+
* `REFUND_VSIZE = 160` does not generalise to N inputs, and
|
|
25
|
+
* `computePeginBaseFeeSats` is wrong for this shape entirely — its
|
|
26
|
+
* `P2TR_INPUT_SIZE = 58` is a *key-path* input and under-fees a script-path
|
|
27
|
+
* spend by roughly a quarter.
|
|
28
|
+
*
|
|
29
|
+
* N=1 → 129 vB; each additional input adds 75 vB.
|
|
30
|
+
*/
|
|
31
|
+
export declare function reclaimVsize(numInputs: number): number;
|
|
32
|
+
/** Absolute fee in satoshis for an N-in/1-out reclaim at a given rate. */
|
|
33
|
+
export declare function estimateReclaimFeeSats(feeRateSatsVb: number, numInputs: number): bigint;
|
|
34
|
+
/** One depositor-claim reserve to sweep, with the material to bind it. */
|
|
35
|
+
export interface ReclaimReserve {
|
|
36
|
+
/**
|
|
37
|
+
* The contract's own copy of the depositor-signed PegIn transaction
|
|
38
|
+
* (`VaultProtocolInfo.depositorSignedPeginTx`). Authoritative: its SegWit
|
|
39
|
+
* txid equals the broadcast PegIn's, and its `outs[1]` carries the reserve's
|
|
40
|
+
* script and value at no extra RPC cost.
|
|
41
|
+
*/
|
|
42
|
+
depositorSignedPeginTxHex: string;
|
|
43
|
+
/** Independent chain observation of `peginTxid:1` (esplora UTXO lookup). */
|
|
44
|
+
observed: {
|
|
45
|
+
/** scriptPubKey hex, with or without `0x` prefix. */
|
|
46
|
+
scriptPubKey: string;
|
|
47
|
+
/** Output value in satoshis. */
|
|
48
|
+
value: bigint;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* The reserve value recomputed from this vault's protocol parameters via
|
|
52
|
+
* `computeMinClaimValue`. Bound so a doctored PegIn that agrees with itself
|
|
53
|
+
* and with a compromised indexer still fails.
|
|
54
|
+
*/
|
|
55
|
+
expectedValue: bigint;
|
|
56
|
+
}
|
|
57
|
+
export interface BuildReclaimPsbtParams {
|
|
58
|
+
/**
|
|
59
|
+
* The **connected wallet's live** x-only pubkey, 64-char hex. Never the
|
|
60
|
+
* indexer's `depositorBtcPubkey`: re-deriving from the live key is what
|
|
61
|
+
* proves the wallet about to sign is the wallet that can spend, and rejects
|
|
62
|
+
* the wrong-wallet case with an error instead of an unspendable broadcast.
|
|
63
|
+
*/
|
|
64
|
+
depositorPubkey: string;
|
|
65
|
+
/**
|
|
66
|
+
* Reserves to sweep. An array so batching several vaults into one
|
|
67
|
+
* transaction is a later change rather than a rewrite; today the app passes
|
|
68
|
+
* exactly one.
|
|
69
|
+
*/
|
|
70
|
+
inputs: ReclaimReserve[];
|
|
71
|
+
/** Absolute fee in satoshis. The caller sizes it; see `reclaimVsize`. */
|
|
72
|
+
feeSats: bigint;
|
|
73
|
+
}
|
|
74
|
+
export interface BuildReclaimPsbtResult {
|
|
75
|
+
/** PSBT hex ready for depositor signing. */
|
|
76
|
+
psbtHex: string;
|
|
77
|
+
/** Value of the single output — what the depositor actually receives. */
|
|
78
|
+
outputValue: bigint;
|
|
79
|
+
/** Sum of the swept reserves, before fee. */
|
|
80
|
+
totalInputValue: bigint;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Build the N-in/1-out reclaim PSBT.
|
|
84
|
+
*
|
|
85
|
+
* Every input is bound three ways before it reaches the PSBT: the contract's
|
|
86
|
+
* PegIn bytes, the chain observation, and a JS re-derivation from the live
|
|
87
|
+
* wallet key must agree on both script and value. Any disagreement throws.
|
|
88
|
+
*
|
|
89
|
+
* @throws If `inputs` is empty, the fee is non-positive, any input fails its
|
|
90
|
+
* script or value bind, or the resulting output would be at or below dust.
|
|
91
|
+
*/
|
|
92
|
+
export declare function buildReclaimPsbt(params: BuildReclaimPsbtParams): BuildReclaimPsbtResult;
|
|
93
|
+
//# sourceMappingURL=reclaim.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reclaim.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/primitives/psbt/reclaim.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAqDH;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAWtD;AAED,0EAA0E;AAC1E,wBAAgB,sBAAsB,CACpC,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,MAAM,GAChB,MAAM,CAOR;AAED,0EAA0E;AAC1E,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,yBAAyB,EAAE,MAAM,CAAC;IAClC,4EAA4E;IAC5E,QAAQ,EAAE;QACR,qDAAqD;QACrD,YAAY,EAAE,MAAM,CAAC;QACrB,gCAAgC;QAChC,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF;;;;OAIG;IACH,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,sBAAsB;IACrC;;;;;OAKG;IACH,eAAe,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,yEAAyE;IACzE,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,sBAAsB;IACrC,4CAA4C;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,yEAAyE;IACzE,WAAW,EAAE,MAAM,CAAC;IACpB,6CAA6C;IAC7C,eAAe,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,sBAAsB,GAC7B,sBAAsB,CA4IxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signDepositorGraph.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/services/deposit/signDepositorGraph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,uCAAuC,CAAC;AAGrE,OAAO,KAAK,EACV,aAAa,EAEd,MAAM,uCAAuC,CAAC;AAC/C,OAAO,KAAK,EACV,+BAA+B,EAC/B,0BAA0B,EAG3B,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"signDepositorGraph.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/services/deposit/signDepositorGraph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,uCAA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AuC1C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../../signPsbtsWithFallback-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../../signPsbtsWithFallback-Bo1PJX90.cjs"),t=require("../../../buildAndBroadcastReclaim-iNJfx0ZG.cjs"),i=require("../../../peginState-eaQ4IO_R.cjs");exports.computeHashlock=e.computeHashlock;exports.validateSecretAgainstHashlock=e.validateSecretAgainstHashlock;exports.BIP68NotMatureError=t.BIP68NotMatureError;exports.ClaimerPegoutStatusValue=t.ClaimerPegoutStatusValue;exports.PEGIN_ETH_CONFIRMATIONS=t.PEGIN_ETH_CONFIRMATIONS;exports.ParticipantKeyDriftError=t.ParticipantKeyDriftError;exports.PeginRegistrationMissingError=t.PeginRegistrationMissingError;exports.PeginRegistrationNotFinalError=t.PeginRegistrationNotFinalError;exports.RECLAIM_MAX_FEE_FRACTION_DENOMINATOR=t.RECLAIM_MAX_FEE_FRACTION_DENOMINATOR;exports.RECLAIM_MAX_FEE_FRACTION_NUMERATOR=t.RECLAIM_MAX_FEE_FRACTION_NUMERATOR;exports.RECLAIM_MAX_FEE_RATE_SATS_VB=t.RECLAIM_MAX_FEE_RATE_SATS_VB;exports.RECLAIM_WARN_FEE_FRACTION_NUMERATOR=t.RECLAIM_WARN_FEE_FRACTION_NUMERATOR;exports.REFUND_MAX_FEE_FRACTION_DENOMINATOR=t.REFUND_MAX_FEE_FRACTION_DENOMINATOR;exports.REFUND_MAX_FEE_FRACTION_NUMERATOR=t.REFUND_MAX_FEE_FRACTION_NUMERATOR;exports.REFUND_MAX_FEE_RATE_SATS_VB=t.REFUND_MAX_FEE_RATE_SATS_VB;exports.REFUND_VSIZE=t.REFUND_VSIZE;exports.ReclaimUneconomicalError=t.ReclaimUneconomicalError;exports.RegisteredVaultVersionMismatchError=t.RegisteredVaultVersionMismatchError;exports.activateVault=t.activateVault;exports.activateVaultAndRedeem=t.activateVaultAndRedeem;exports.assertVaultProviderHintAccepted=t.assertVaultProviderHintAccepted;exports.buildAndBroadcastReclaim=t.buildAndBroadcastReclaim;exports.buildAndBroadcastRefund=t.buildAndBroadcastRefund;exports.estimateRefundFeeSats=t.estimateRefundFeeSats;exports.isDepositAmountValid=t.isDepositAmountValid;exports.isHintAccepted=t.isHintAccepted;exports.isParticipantKeyDriftError=t.isParticipantKeyDriftError;exports.isPeginRegistrationMissingError=t.isPeginRegistrationMissingError;exports.isPeginRegistrationNotFinalError=t.isPeginRegistrationNotFinalError;exports.isPegoutTerminalStatus=t.isPegoutTerminalStatus;exports.isRecognizedPegoutStatus=t.isRecognizedPegoutStatus;exports.isRegisteredVaultVersionMismatchError=t.isRegisteredVaultVersionMismatchError;exports.matchKeyHint=t.matchKeyHint;exports.matchKeySetHint=t.matchKeySetHint;exports.resolveCurrentParticipantKeys=t.resolveCurrentParticipantKeys;exports.resolveParticipantKeysAtEpochs=t.resolveParticipantKeysAtEpochs;exports.runDepositorPresignFlow=t.runDepositorPresignFlow;exports.signDepositorGraph=t.signDepositorGraph;exports.submitWotsPublicKey=t.submitWotsPublicKey;exports.validateDepositAmount=t.validateDepositAmount;exports.validateMultiVaultDepositInputs=t.validateMultiVaultDepositInputs;exports.validateOnChainParticipantKeys=t.validateOnChainParticipantKeys;exports.validateProviderSelection=t.validateProviderSelection;exports.validateRemainingCapacity=t.validateRemainingCapacity;exports.validateVaultAmounts=t.validateVaultAmounts;exports.validateVaultProviderPubkey=t.validateVaultProviderPubkey;exports.verifyRegisteredParticipantKeys=t.verifyRegisteredParticipantKeys;exports.verifyRegisteredVaultVersions=t.verifyRegisteredVaultVersions;exports.waitForPeginRegistrationDepth=t.waitForPeginRegistrationDepth;exports.waitForPeginStatus=t.waitForPeginStatus;exports.ContractStatus=i.ContractStatus;exports.PeginAction=i.PeginAction;exports.canPerformAction=i.canPerformAction;exports.getPeginProtocolState=i.getPeginProtocolState;exports.isActivationDeadlinePassedOnChain=i.isActivationDeadlinePassedOnChain;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/tbv/core/services/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/tbv/core/services/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC"}
|
|
@@ -1,55 +1,61 @@
|
|
|
1
|
-
import { c as s, v as i } from "../../../signPsbtsWithFallback-
|
|
2
|
-
import { H as r, E as o, P as n, o as c, c as l,
|
|
3
|
-
import { C as
|
|
1
|
+
import { c as s, v as i } from "../../../signPsbtsWithFallback-X6ivsbh7.js";
|
|
2
|
+
import { H as r, E as o, P as n, o as E, c as R, d as c, S as A, T as l, U as u, V as _, K as d, L as g, M as P, N as F, O as N, R as p, a as M, b as m, y as v, Q as C, I, J as T, g as V, z as O, p as S, i as D, e as y, G as h, F as f, t as K, A as U, B as H, C as b, D as B, r as X, s as L, f as k, h as w, j as x, v as G, k as z, l as W, m as j, n as q, q as J, u as Q, w as Z, x as Y } from "../../../buildAndBroadcastReclaim-kBHwOL02.js";
|
|
3
|
+
import { C as aa, P as ta, c as sa, g as ia, i as ea } from "../../../peginState-CxDiaKuk.js";
|
|
4
4
|
export {
|
|
5
5
|
r as BIP68NotMatureError,
|
|
6
6
|
o as ClaimerPegoutStatusValue,
|
|
7
|
-
|
|
7
|
+
aa as ContractStatus,
|
|
8
8
|
n as PEGIN_ETH_CONFIRMATIONS,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
E as ParticipantKeyDriftError,
|
|
10
|
+
ta as PeginAction,
|
|
11
|
+
R as PeginRegistrationMissingError,
|
|
12
|
+
c as PeginRegistrationNotFinalError,
|
|
13
|
+
A as RECLAIM_MAX_FEE_FRACTION_DENOMINATOR,
|
|
14
|
+
l as RECLAIM_MAX_FEE_FRACTION_NUMERATOR,
|
|
15
|
+
u as RECLAIM_MAX_FEE_RATE_SATS_VB,
|
|
16
|
+
_ as RECLAIM_WARN_FEE_FRACTION_NUMERATOR,
|
|
17
|
+
d as REFUND_MAX_FEE_FRACTION_DENOMINATOR,
|
|
18
|
+
g as REFUND_MAX_FEE_FRACTION_NUMERATOR,
|
|
19
|
+
P as REFUND_MAX_FEE_RATE_SATS_VB,
|
|
20
|
+
F as REFUND_VSIZE,
|
|
21
|
+
N as ReclaimUneconomicalError,
|
|
22
|
+
p as RegisteredVaultVersionMismatchError,
|
|
23
|
+
M as activateVault,
|
|
24
|
+
m as activateVaultAndRedeem,
|
|
20
25
|
v as assertVaultProviderHintAccepted,
|
|
21
|
-
|
|
22
|
-
|
|
26
|
+
C as buildAndBroadcastReclaim,
|
|
27
|
+
I as buildAndBroadcastRefund,
|
|
28
|
+
sa as canPerformAction,
|
|
23
29
|
s as computeHashlock,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
T as estimateRefundFeeSats,
|
|
31
|
+
ia as getPeginProtocolState,
|
|
32
|
+
ea as isActivationDeadlinePassedOnChain,
|
|
33
|
+
V as isDepositAmountValid,
|
|
34
|
+
O as isHintAccepted,
|
|
35
|
+
S as isParticipantKeyDriftError,
|
|
30
36
|
D as isPeginRegistrationMissingError,
|
|
31
37
|
y as isPeginRegistrationNotFinalError,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
38
|
+
h as isPegoutTerminalStatus,
|
|
39
|
+
f as isRecognizedPegoutStatus,
|
|
40
|
+
K as isRegisteredVaultVersionMismatchError,
|
|
41
|
+
U as matchKeyHint,
|
|
42
|
+
H as matchKeySetHint,
|
|
43
|
+
b as resolveCurrentParticipantKeys,
|
|
44
|
+
B as resolveParticipantKeysAtEpochs,
|
|
45
|
+
X as runDepositorPresignFlow,
|
|
46
|
+
L as signDepositorGraph,
|
|
47
|
+
k as submitWotsPublicKey,
|
|
48
|
+
w as validateDepositAmount,
|
|
49
|
+
x as validateMultiVaultDepositInputs,
|
|
50
|
+
G as validateOnChainParticipantKeys,
|
|
51
|
+
z as validateProviderSelection,
|
|
52
|
+
W as validateRemainingCapacity,
|
|
47
53
|
i as validateSecretAgainstHashlock,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
+
j as validateVaultAmounts,
|
|
55
|
+
q as validateVaultProviderPubkey,
|
|
56
|
+
J as verifyRegisteredParticipantKeys,
|
|
57
|
+
Q as verifyRegisteredVaultVersions,
|
|
58
|
+
Z as waitForPeginRegistrationDepth,
|
|
59
|
+
Y as waitForPeginStatus
|
|
54
60
|
};
|
|
55
61
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reclaim orchestration tests.
|
|
3
|
+
*
|
|
4
|
+
* The PSBT builder and its binds have their own suite; here the contract under
|
|
5
|
+
* test is the orchestration — fee caps, call order, per-input signature
|
|
6
|
+
* verification, and abort handling.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=buildAndBroadcastReclaim.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildAndBroadcastReclaim.test.d.ts","sourceRoot":"","sources":["../../../../../../src/tbv/core/services/reclaim/__tests__/buildAndBroadcastReclaim.test.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Hex } from 'viem';
|
|
2
|
+
import { SignPsbtOptions } from '../../../../shared/wallets/interfaces/BitcoinWallet';
|
|
3
|
+
import { BtcBroadcastResult, BtcBroadcaster } from '../refund/buildAndBroadcastRefund';
|
|
4
|
+
/**
|
|
5
|
+
* Hard upper bound on the per-vbyte fee rate the SDK will sign a reclaim at.
|
|
6
|
+
* Same reasoning and value as the refund's cap: a compromised mempool endpoint
|
|
7
|
+
* can legally return up to 10,000 sat/vB, and 2000 leaves margin over the
|
|
8
|
+
* worst historical `halfHourFee` while still blocking that by 5×.
|
|
9
|
+
*/
|
|
10
|
+
export declare const RECLAIM_MAX_FEE_RATE_SATS_VB = 2000;
|
|
11
|
+
/**
|
|
12
|
+
* Hard upper bound on the absolute fee as a fraction of the **swept total**.
|
|
13
|
+
*
|
|
14
|
+
* > ⚠️ The basis here is deliberately different from the refund's. There the
|
|
15
|
+
* > basis is `vault.amount` and the swept amount is far larger, so a 10% cap is
|
|
16
|
+
* > generous. Here the basis *is* the swept amount — roughly 33k sats — and a
|
|
17
|
+
* > 10% cap would block every reclaim above about 25 sat/vB. Do not "fix" this
|
|
18
|
+
* > into symmetry with `REFUND_MAX_FEE_FRACTION_*`; it would silently change
|
|
19
|
+
* > behaviour. The matching comment lives at the UI cap site.
|
|
20
|
+
*/
|
|
21
|
+
export declare const RECLAIM_MAX_FEE_FRACTION_NUMERATOR = 25n;
|
|
22
|
+
export declare const RECLAIM_MAX_FEE_FRACTION_DENOMINATOR = 100n;
|
|
23
|
+
/**
|
|
24
|
+
* Fraction of the swept total above which the UI warns but still allows the
|
|
25
|
+
* reclaim. Exported so the review screen derives its threshold from the same
|
|
26
|
+
* constant the SDK enforces against, rather than restating it.
|
|
27
|
+
*/
|
|
28
|
+
export declare const RECLAIM_WARN_FEE_FRACTION_NUMERATOR = 10n;
|
|
29
|
+
export type ReclaimPsbtSigner = (psbtHex: string, opts: SignPsbtOptions) => Promise<string>;
|
|
30
|
+
/** One reserve to sweep, as the caller resolves it. */
|
|
31
|
+
export interface ReclaimVaultData {
|
|
32
|
+
/**
|
|
33
|
+
* The contract's own copy of the depositor-signed PegIn transaction
|
|
34
|
+
* (`VaultProtocolInfo.depositorSignedPeginTx`). Must come from the chain —
|
|
35
|
+
* never the indexer. Its `outs[1]` is one leg of the three-way bind.
|
|
36
|
+
*/
|
|
37
|
+
depositorSignedPeginTxHex: string;
|
|
38
|
+
/** Independent chain observation of `peginTxid:1`. */
|
|
39
|
+
observed: {
|
|
40
|
+
scriptPubKey: string;
|
|
41
|
+
value: bigint;
|
|
42
|
+
};
|
|
43
|
+
/** This vault's reserve value, recomputed via `computeMinClaimValue`. */
|
|
44
|
+
expectedClaimValue: bigint;
|
|
45
|
+
}
|
|
46
|
+
export interface ReclaimInput<R extends BtcBroadcastResult = BtcBroadcastResult> {
|
|
47
|
+
vaultIds: Hex[];
|
|
48
|
+
/**
|
|
49
|
+
* The **connected wallet's live** BTC pubkey — compressed sec1 or x-only.
|
|
50
|
+
* Never the indexer's `depositorBtcPubkey`: re-deriving the claim script
|
|
51
|
+
* from the live key is what proves the wallet about to sign is the wallet
|
|
52
|
+
* that can spend.
|
|
53
|
+
*/
|
|
54
|
+
depositorBtcPubkey: string;
|
|
55
|
+
/**
|
|
56
|
+
* Resolve the reserves to sweep, in the same order as `vaultIds`. The SDK
|
|
57
|
+
* passes no arguments — the caller closes over whatever context it needs.
|
|
58
|
+
*/
|
|
59
|
+
readVaults: () => Promise<ReclaimVaultData[]>;
|
|
60
|
+
/** Mempool-derived sat/vB fee rate. Caller fetches it before invoking. */
|
|
61
|
+
feeRate: number;
|
|
62
|
+
/** BTC wallet signer; receives a PSBT hex + taproot script-path options. */
|
|
63
|
+
signPsbt: ReclaimPsbtSigner;
|
|
64
|
+
/** Broadcast callback — returns whatever shape the caller needs. */
|
|
65
|
+
broadcastTx: BtcBroadcaster<R>;
|
|
66
|
+
/** Checked at every async boundary. */
|
|
67
|
+
signal?: AbortSignal;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Build, sign, and broadcast a reclaim transaction sweeping one or more
|
|
71
|
+
* depositor-claim reserves back to the depositor's BIP-86 address.
|
|
72
|
+
*
|
|
73
|
+
* @returns whatever the injected `broadcastTx` returns (generic pass-through)
|
|
74
|
+
* @throws {@link ReclaimUneconomicalError} if the fee breaches either cap
|
|
75
|
+
* @throws `Error` if any validation or script/value bind fails
|
|
76
|
+
* @throws anything `readVaults`, `signPsbt`, or `broadcastTx` throws
|
|
77
|
+
*/
|
|
78
|
+
export declare function buildAndBroadcastReclaim<R extends BtcBroadcastResult = BtcBroadcastResult>(input: ReclaimInput<R>): Promise<R>;
|
|
79
|
+
//# sourceMappingURL=buildAndBroadcastReclaim.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildAndBroadcastReclaim.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/services/reclaim/buildAndBroadcastReclaim.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEhC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qDAAqD,CAAC;AAc3F,OAAO,KAAK,EACV,kBAAkB,EAClB,cAAc,EACf,MAAM,mCAAmC,CAAC;AAI3C;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,OAAO,CAAC;AAEjD;;;;;;;;;GAS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|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Thrown when the fee would consume too much of the swept reserve — either the
|
|
8
|
+
* per-vbyte rate exceeds the safety ceiling, or the absolute fee exceeds the
|
|
9
|
+
* fraction cap.
|
|
10
|
+
*
|
|
11
|
+
* Distinct from a generic error because the caller's response differs: nothing
|
|
12
|
+
* is at risk and nothing expires. The reserve simply stays where it is until
|
|
13
|
+
* fee rates fall, and the UI should say so rather than presenting a failure.
|
|
14
|
+
*/
|
|
15
|
+
export declare class ReclaimUneconomicalError extends Error {
|
|
16
|
+
/** Fee the reclaim would have paid, in satoshis. */
|
|
17
|
+
readonly feeSats: bigint;
|
|
18
|
+
/** Sum of the reserves the reclaim would have swept, in satoshis. */
|
|
19
|
+
readonly sweptTotalSats: bigint;
|
|
20
|
+
constructor(message: string, feeSats: bigint, sweptTotalSats: bigint);
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/services/reclaim/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;GAQG;AACH,qBAAa,wBAAyB,SAAQ,KAAK;IACjD,oDAAoD;IACpD,SAAgB,OAAO,EAAE,MAAM,CAAC;IAChC,qEAAqE;IACrE,SAAgB,cAAc,EAAE,MAAM,CAAC;gBAE3B,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;CAMrE"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vault reclaim service — sweep the depositor-claim reserve (PegIn vout 1)
|
|
3
|
+
* back to the depositor after their vault has terminally settled.
|
|
4
|
+
*
|
|
5
|
+
* @module services/reclaim
|
|
6
|
+
*/
|
|
7
|
+
export { ReclaimUneconomicalError } from './errors';
|
|
8
|
+
export { buildAndBroadcastReclaim, RECLAIM_MAX_FEE_FRACTION_DENOMINATOR, RECLAIM_MAX_FEE_FRACTION_NUMERATOR, RECLAIM_MAX_FEE_RATE_SATS_VB, RECLAIM_WARN_FEE_FRACTION_NUMERATOR, type ReclaimInput, type ReclaimPsbtSigner, type ReclaimVaultData, } from './buildAndBroadcastReclaim';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/services/reclaim/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EACL,wBAAwB,EACxB,oCAAoC,EACpC,kCAAkC,EAClC,4BAA4B,EAC5B,mCAAmC,EACnC,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,GACtB,MAAM,4BAA4B,CAAC"}
|