@babylonlabs-io/ts-sdk 0.69.0 → 0.70.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/dist/{PeginManager-VM-jifLt.cjs → PeginManager-BpouMHkS.cjs} +2 -2
  2. package/dist/{PeginManager-VM-jifLt.cjs.map → PeginManager-BpouMHkS.cjs.map} +1 -1
  3. package/dist/{PeginManager-DSFecw-w.js → PeginManager-erlaJqpN.js} +4 -4
  4. package/dist/{PeginManager-DSFecw-w.js.map → PeginManager-erlaJqpN.js.map} +1 -1
  5. package/dist/{buildAndBroadcastRefund-DY4ZZcFL.js → buildAndBroadcastReclaim-CBPDgfj7.js} +690 -596
  6. package/dist/buildAndBroadcastReclaim-CBPDgfj7.js.map +1 -0
  7. package/dist/buildAndBroadcastReclaim-DsJ5CB_H.cjs +2 -0
  8. package/dist/buildAndBroadcastReclaim-DsJ5CB_H.cjs.map +1 -0
  9. package/dist/index.cjs +1 -1
  10. package/dist/index.js +256 -244
  11. package/dist/noPayout-CDi6f5-I.js +280 -0
  12. package/dist/noPayout-CDi6f5-I.js.map +1 -0
  13. package/dist/noPayout-Cbi9TCRz.cjs +2 -0
  14. package/dist/noPayout-Cbi9TCRz.cjs.map +1 -0
  15. package/dist/{signPsbtsWithFallback-DCZO2h6i.js → signPsbtsWithFallback-DVyK-9A-.js} +2 -2
  16. package/dist/{signPsbtsWithFallback-DCZO2h6i.js.map → signPsbtsWithFallback-DVyK-9A-.js.map} +1 -1
  17. package/dist/{signPsbtsWithFallback-C5cVgYhh.cjs → signPsbtsWithFallback-DY2jBtNB.cjs} +2 -2
  18. package/dist/{signPsbtsWithFallback-C5cVgYhh.cjs.map → signPsbtsWithFallback-DY2jBtNB.cjs.map} +1 -1
  19. package/dist/tbv/core/index.cjs +1 -1
  20. package/dist/tbv/core/index.js +255 -243
  21. package/dist/tbv/core/managers/index.cjs +1 -1
  22. package/dist/tbv/core/managers/index.js +2 -2
  23. package/dist/tbv/core/primitives/index.cjs +1 -1
  24. package/dist/tbv/core/primitives/index.d.ts +4 -0
  25. package/dist/tbv/core/primitives/index.d.ts.map +1 -1
  26. package/dist/tbv/core/primitives/index.js +52 -46
  27. package/dist/tbv/core/primitives/psbt/__tests__/depositorClaim.test.d.ts +16 -0
  28. package/dist/tbv/core/primitives/psbt/__tests__/depositorClaim.test.d.ts.map +1 -0
  29. package/dist/tbv/core/primitives/psbt/__tests__/reclaim.test.d.ts +10 -0
  30. package/dist/tbv/core/primitives/psbt/__tests__/reclaim.test.d.ts.map +1 -0
  31. package/dist/tbv/core/primitives/psbt/depositorClaim.d.ts +47 -0
  32. package/dist/tbv/core/primitives/psbt/depositorClaim.d.ts.map +1 -0
  33. package/dist/tbv/core/primitives/psbt/pegin.d.ts.map +1 -1
  34. package/dist/tbv/core/primitives/psbt/reclaim.d.ts +93 -0
  35. package/dist/tbv/core/primitives/psbt/reclaim.d.ts.map +1 -0
  36. package/dist/tbv/core/services/index.cjs +1 -1
  37. package/dist/tbv/core/services/index.d.ts +1 -0
  38. package/dist/tbv/core/services/index.d.ts.map +1 -1
  39. package/dist/tbv/core/services/index.js +50 -44
  40. package/dist/tbv/core/services/reclaim/__tests__/buildAndBroadcastReclaim.test.d.ts +9 -0
  41. package/dist/tbv/core/services/reclaim/__tests__/buildAndBroadcastReclaim.test.d.ts.map +1 -0
  42. package/dist/tbv/core/services/reclaim/buildAndBroadcastReclaim.d.ts +79 -0
  43. package/dist/tbv/core/services/reclaim/buildAndBroadcastReclaim.d.ts.map +1 -0
  44. package/dist/tbv/core/services/reclaim/errors.d.ts +22 -0
  45. package/dist/tbv/core/services/reclaim/errors.d.ts.map +1 -0
  46. package/dist/tbv/core/services/reclaim/index.d.ts +9 -0
  47. package/dist/tbv/core/services/reclaim/index.d.ts.map +1 -0
  48. package/dist/tbv/core/utils/eth/waitForTransactionReceiptSmartAware.d.ts +10 -2
  49. package/dist/tbv/core/utils/eth/waitForTransactionReceiptSmartAware.d.ts.map +1 -1
  50. package/dist/tbv/core/utils/index.cjs +1 -1
  51. package/dist/tbv/core/utils/index.js +1 -1
  52. package/dist/tbv/index.cjs +1 -1
  53. package/dist/tbv/index.js +255 -243
  54. package/dist/{toRefundInputs-DaxiTty9.cjs → toRefundInputs-Cn6z5_Ko.cjs} +2 -2
  55. package/dist/{toRefundInputs-DaxiTty9.cjs.map → toRefundInputs-Cn6z5_Ko.cjs.map} +1 -1
  56. package/dist/{toRefundInputs-C012ZXcp.js → toRefundInputs-ZkvoR5Df.js} +5 -5
  57. package/dist/{toRefundInputs-C012ZXcp.js.map → toRefundInputs-ZkvoR5Df.js.map} +1 -1
  58. package/dist/{verifyScriptPathSchnorrSignature-Dy9gF5RF.js → verifyScriptPathSchnorrSignature-B7MhJmhy.js} +143 -125
  59. package/dist/verifyScriptPathSchnorrSignature-B7MhJmhy.js.map +1 -0
  60. package/dist/verifyScriptPathSchnorrSignature-BBS9oCPO.cjs +2 -0
  61. package/dist/verifyScriptPathSchnorrSignature-BBS9oCPO.cjs.map +1 -0
  62. package/dist/{waitForTransactionReceiptSmartAware-lobLm0q0.js → waitForTransactionReceiptSmartAware-B6oYRdFO.js} +117 -100
  63. package/dist/waitForTransactionReceiptSmartAware-B6oYRdFO.js.map +1 -0
  64. package/dist/waitForTransactionReceiptSmartAware-Ct7LPwPI.cjs +2 -0
  65. package/dist/waitForTransactionReceiptSmartAware-Ct7LPwPI.cjs.map +1 -0
  66. package/package.json +1 -1
  67. package/dist/buildAndBroadcastRefund-CPPGvzXb.cjs +0 -2
  68. package/dist/buildAndBroadcastRefund-CPPGvzXb.cjs.map +0 -1
  69. package/dist/buildAndBroadcastRefund-DY4ZZcFL.js.map +0 -1
  70. package/dist/noPayout-CXn-geIS.js +0 -178
  71. package/dist/noPayout-CXn-geIS.js.map +0 -1
  72. package/dist/noPayout-Ox27Td9x.cjs +0 -2
  73. package/dist/noPayout-Ox27Td9x.cjs.map +0 -1
  74. package/dist/verifyScriptPathSchnorrSignature-Dy9gF5RF.js.map +0 -1
  75. package/dist/verifyScriptPathSchnorrSignature-la8XOAFm.cjs +0 -2
  76. package/dist/verifyScriptPathSchnorrSignature-la8XOAFm.cjs.map +0 -1
  77. package/dist/waitForTransactionReceiptSmartAware-AgZ-3WV_.cjs +0 -2
  78. package/dist/waitForTransactionReceiptSmartAware-AgZ-3WV_.cjs.map +0 -1
  79. package/dist/waitForTransactionReceiptSmartAware-lobLm0q0.js.map +0 -1
@@ -1,49 +1,55 @@
1
- import { P as s, f as t, g as r, d as i, b as o, a as u, c as n, h as P, e as d } from "../../../verifyScriptPathSchnorrSignature-Dy9gF5RF.js";
2
- import { a as b } from "../../../constants-GjWXdaqV.js";
3
- import { computeMinClaimValue as c, computeMinPeginFee as g, deriveVaultId as x, peginP2aAnchorOutput as y, supportedTxGraphVersions as f, validatePeginP2aAnchor as h } from "@babylonlabs-io/babylon-tbv-rust-wasm";
4
- import { a as S, c as v, b as A, e as T, f as V } from "../../../verifyKeyPathSchnorrSignature-C6Cmk0R1.js";
5
- import { a as K, b as C } from "../../../noPayout-CXn-geIS.js";
6
- import { b as I } from "../../../challengeAssert-BNQ8sToz.js";
7
- import { c as k, d as B, a as M, b as N, e as X, f as z, g as R, h as U, i as j, j as w, p as E, s as G, t as L, u as W, v as q } from "../../../bitcoin-Ch_jxnDa.js";
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-B7MhJmhy.js";
2
+ import { a as g } from "../../../constants-GjWXdaqV.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-CDi6f5-I.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 PsbtSubstitutionError,
10
- S as assertKeyPathSchnorrSignature,
11
- t as assertPsbtUnsignedTxMatches,
12
- v as assertReturnedKeyPathSignatures,
13
- r as assertScriptPathSchnorrSignature,
14
- b as assertValidVaultCoreVersion,
15
- I as buildChallengeAssertPsbt,
16
- K as buildNoPayoutPsbt,
17
- i as buildPayoutPsbt,
18
- A as buildPeginInputPsbt,
19
- o as buildPeginTxFromFundedPrePegin,
20
- u as buildPrePeginPsbt,
21
- C as buildRefundPsbt,
22
- k as canonicalizeBtcPubkey,
23
- c as computeMinClaimValue,
24
- g as computeMinPeginFee,
25
- n as computeNumLocalChallengers,
26
- P as createPayoutScript,
27
- B as deriveBip86ScriptPubKeyHex,
28
- M as deriveNativeSegwitAddress,
29
- N as deriveTaprootAddress,
30
- x as deriveVaultId,
31
- X as ensureHexPrefix,
32
- d as extractPayoutSignature,
33
- T as extractPeginInputSignature,
34
- V as finalizePeginInputPsbt,
35
- z as formatSatoshisToBtc,
36
- R as getSortedXOnlyPubkeys,
37
- U as hexToUint8Array,
38
- j as isAddressFromPublicKey,
39
- w as isValidHex,
40
- y as peginP2aAnchorOutput,
41
- E as processPublicKeyToXOnly,
42
- G as stripHexPrefix,
43
- f as supportedTxGraphVersions,
44
- L as toXOnly,
45
- W as uint8ArrayToHex,
46
- h as validatePeginP2aAnchor,
47
- q as validateWalletPubkey
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"}
@@ -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;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jD,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,sEAAsE;IACtE,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;;;OAIG;IACH,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,mEAAmE;IACnE,cAAc,EAAE,cAAc,CAAC;IAC/B,wDAAwD;IACxD,aAAa,EAAE,MAAM,CAAC;IACtB,+CAA+C;IAC/C,mBAAmB,EAAE,MAAM,CAAC;IAC5B,wCAAwC;IACxC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,2BAA2B;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,8CAA8C;IAC9C,iBAAiB,EAAE,MAAM,CAAC;IAC1B,qCAAqC;IACrC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,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,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../../signPsbtsWithFallback-C5cVgYhh.cjs"),t=require("../../../buildAndBroadcastRefund-CPPGvzXb.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.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.RegisteredVaultVersionMismatchError=t.RegisteredVaultVersionMismatchError;exports.activateVault=t.activateVault;exports.activateVaultAndRedeem=t.activateVaultAndRedeem;exports.assertVaultProviderHintAccepted=t.assertVaultProviderHintAccepted;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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../../signPsbtsWithFallback-DY2jBtNB.cjs"),t=require("../../../buildAndBroadcastReclaim-DsJ5CB_H.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
@@ -10,4 +10,5 @@ export * from './htlc';
10
10
  export * from './participants';
11
11
  export * from './pegout';
12
12
  export * from './refund';
13
+ export * from './reclaim';
13
14
  //# sourceMappingURL=index.d.ts.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-DCZO2h6i.js";
2
- import { H as r, E as o, P as n, o as c, c as l, d as u, K as g, L as P, M as d, N as E, R, a as p, b as A, y as v, I as m, J as F, g as N, z as V, p as _, i as D, e as y, G as S, F as M, t as h, A as f, B as C, C as I, D as K, r as O, s as T, f as H, h as b, j as U, v as k, k as w, l as x, m as B, n as G, q as X, u as z, w as j, x as q } from "../../../buildAndBroadcastRefund-DY4ZZcFL.js";
3
- import { C as L, P as W, c as Z, g as Q, i as Y } from "../../../peginState-CxDiaKuk.js";
1
+ import { c as s, v as i } from "../../../signPsbtsWithFallback-DVyK-9A-.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-CBPDgfj7.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
- L as ContractStatus,
7
+ aa as ContractStatus,
8
8
  n as PEGIN_ETH_CONFIRMATIONS,
9
- c as ParticipantKeyDriftError,
10
- W as PeginAction,
11
- l as PeginRegistrationMissingError,
12
- u as PeginRegistrationNotFinalError,
13
- g as REFUND_MAX_FEE_FRACTION_DENOMINATOR,
14
- P as REFUND_MAX_FEE_FRACTION_NUMERATOR,
15
- d as REFUND_MAX_FEE_RATE_SATS_VB,
16
- E as REFUND_VSIZE,
17
- R as RegisteredVaultVersionMismatchError,
18
- p as activateVault,
19
- A as activateVaultAndRedeem,
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
- m as buildAndBroadcastRefund,
22
- Z as canPerformAction,
26
+ C as buildAndBroadcastReclaim,
27
+ I as buildAndBroadcastRefund,
28
+ sa as canPerformAction,
23
29
  s as computeHashlock,
24
- F as estimateRefundFeeSats,
25
- Q as getPeginProtocolState,
26
- Y as isActivationDeadlinePassedOnChain,
27
- N as isDepositAmountValid,
28
- V as isHintAccepted,
29
- _ as isParticipantKeyDriftError,
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
- S as isPegoutTerminalStatus,
33
- M as isRecognizedPegoutStatus,
34
- h as isRegisteredVaultVersionMismatchError,
35
- f as matchKeyHint,
36
- C as matchKeySetHint,
37
- I as resolveCurrentParticipantKeys,
38
- K as resolveParticipantKeysAtEpochs,
39
- O as runDepositorPresignFlow,
40
- T as signDepositorGraph,
41
- H as submitWotsPublicKey,
42
- b as validateDepositAmount,
43
- U as validateMultiVaultDepositInputs,
44
- k as validateOnChainParticipantKeys,
45
- w as validateProviderSelection,
46
- x as validateRemainingCapacity,
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
- B as validateVaultAmounts,
49
- G as validateVaultProviderPubkey,
50
- X as verifyRegisteredParticipantKeys,
51
- z as verifyRegisteredVaultVersions,
52
- j as waitForPeginRegistrationDepth,
53
- q as waitForPeginStatus
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;;;;;;;;;GASG;AACH,eAAO,MAAM,kCAAkC,MAAM,CAAC;AACtD,eAAO,MAAM,oCAAoC,OAAO,CAAC;AAEzD;;;;GAIG;AACH,eAAO,MAAM,mCAAmC,MAAM,CAAC;AAEvD,MAAM,MAAM,iBAAiB,GAAG,CAC9B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,eAAe,KAClB,OAAO,CAAC,MAAM,CAAC,CAAC;AAErB,uDAAuD;AACvD,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,yBAAyB,EAAE,MAAM,CAAC;IAClC,sDAAsD;IACtD,QAAQ,EAAE;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAClD,yEAAyE;IACzE,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,YAAY,CAC3B,CAAC,SAAS,kBAAkB,GAAG,kBAAkB;IAEjD,QAAQ,EAAE,GAAG,EAAE,CAAC;IAChB;;;;;OAKG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,UAAU,EAAE,MAAM,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAC9C,0EAA0E;IAC1E,OAAO,EAAE,MAAM,CAAC;IAChB,4EAA4E;IAC5E,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,oEAAoE;IACpE,WAAW,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;IAC/B,uCAAuC;IACvC,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAiBD;;;;;;;;GAQG;AACH,wBAAsB,wBAAwB,CAC5C,CAAC,SAAS,kBAAkB,GAAG,kBAAkB,EACjD,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAgHpC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Domain errors thrown by the reclaim service.
3
+ *
4
+ * @module services/reclaim/errors
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"}
@@ -16,8 +16,16 @@ export interface WaitForTransactionReceiptSmartAwareParams {
16
16
  */
17
17
  confirmations?: number;
18
18
  /**
19
- * Forwarded to viem on the EOA (externally owned account) path.
20
- * Ignored on the smart-account path — see safePollTimeoutMs.
19
+ * Forwarded to viem on the EOA (externally owned account) path, and on the
20
+ * fallback where a supposed smart account turns out to submit its own
21
+ * transactions — that is the EOA case too, however we arrived at it.
22
+ *
23
+ * Ignored only while waiting on a genuine Safe proposal, whose budget is
24
+ * safePollTimeoutMs. It is not forwarded to the receipt wait that follows a
25
+ * proposal's execution either: viem's own default applies there (180s as of
26
+ * viem 2.38.2), so that wait is bounded too — a sufficiently slow node still
27
+ * raises WaitForTransactionReceiptTimeoutError, just on viem's uniform bound
28
+ * rather than on a caller's shorter one.
21
29
  */
22
30
  timeout?: number;
23
31
  /** Total budget for waiting on Safe quorum + execution. Default 4h. */
@@ -1 +1 @@
1
- {"version":3,"file":"waitForTransactionReceiptSmartAware.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/utils/eth/waitForTransactionReceiptSmartAware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EACV,OAAO,EACP,IAAI,EACJ,YAAY,EACZ,kBAAkB,EACnB,MAAM,MAAM,CAAC;AAed,MAAM,WAAW,yCAAyC;IACxD,YAAY,EAAE,YAAY,CAAC;IAC3B,aAAa,EAAE,OAAO,CAAC;IACvB,IAAI,EAAE,IAAI,CAAC;IACX;;;;;;;;;;OAUG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uEAAuE;IACvE,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,qEAAqE;IACrE,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,wBAAsB,mCAAmC,CACvD,MAAM,EAAE,yCAAyC,GAChD,OAAO,CAAC,kBAAkB,CAAC,CAkC7B"}
1
+ {"version":3,"file":"waitForTransactionReceiptSmartAware.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/utils/eth/waitForTransactionReceiptSmartAware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAC;AAkD5E,MAAM,WAAW,yCAAyC;IACxD,YAAY,EAAE,YAAY,CAAC;IAC3B,aAAa,EAAE,OAAO,CAAC;IACvB,IAAI,EAAE,IAAI,CAAC;IACX;;;;;;;;;;OAUG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uEAAuE;IACvE,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,qEAAqE;IACrE,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,wBAAsB,mCAAmC,CACvD,MAAM,EAAE,yCAAyC,GAChD,OAAO,CAAC,kBAAkB,CAAC,CAiD7B"}