@babylonlabs-io/ts-sdk 2.0.0 → 2.0.2
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/{PayoutManager-CpfQjtL0.cjs → PayoutManager-B6GFbG3X.cjs} +2 -2
- package/dist/{PayoutManager-CpfQjtL0.cjs.map → PayoutManager-B6GFbG3X.cjs.map} +1 -1
- package/dist/{PayoutManager-CHTOwj0E.js → PayoutManager-BSwbUQeF.js} +2 -2
- package/dist/{PayoutManager-CHTOwj0E.js.map → PayoutManager-BSwbUQeF.js.map} +1 -1
- package/dist/{PeginManager-DEldv_Ro.js → PeginManager-CKf7Bjmj.js} +6 -6
- package/dist/{PeginManager-DEldv_Ro.js.map → PeginManager-CKf7Bjmj.js.map} +1 -1
- package/dist/{PeginManager-6tjlGd0t.cjs → PeginManager-Dt2Z5ljw.cjs} +2 -2
- package/dist/{PeginManager-6tjlGd0t.cjs.map → PeginManager-Dt2Z5ljw.cjs.map} +1 -1
- package/dist/{bip322Verify-DSco3Yhl.js → bip322Verify-BXYrHBh8.js} +2 -2
- package/dist/{bip322Verify-DSco3Yhl.js.map → bip322Verify-BXYrHBh8.js.map} +1 -1
- package/dist/{bip322Verify-B7_gIhRk.cjs → bip322Verify-DLxJR9CQ.cjs} +2 -2
- package/dist/{bip322Verify-B7_gIhRk.cjs.map → bip322Verify-DLxJR9CQ.cjs.map} +1 -1
- package/dist/{buildAndBroadcastReclaim-CqO2DoP8.js → buildAndBroadcastReclaim-B19cyK69.js} +952 -724
- package/dist/buildAndBroadcastReclaim-B19cyK69.js.map +1 -0
- package/dist/buildAndBroadcastReclaim-DcbsjJdf.cjs +2 -0
- package/dist/buildAndBroadcastReclaim-DcbsjJdf.cjs.map +1 -0
- package/dist/{deriveVaultRoot-BwbXmN0x.js → deriveVaultRoot-BcvmER1E.js} +2 -2
- package/dist/{deriveVaultRoot-BwbXmN0x.js.map → deriveVaultRoot-BcvmER1E.js.map} +1 -1
- package/dist/{deriveVaultRoot-DvhkHzNb.cjs → deriveVaultRoot-C3uqnJto.cjs} +2 -2
- package/dist/{deriveVaultRoot-DvhkHzNb.cjs.map → deriveVaultRoot-C3uqnJto.cjs.map} +1 -1
- package/dist/{index-DQ5bfoT3.js → index-Bnavi_r3.js} +115 -99
- package/dist/index-Bnavi_r3.js.map +1 -0
- package/dist/index-CcdCNFLM.cjs +2 -0
- package/dist/index-CcdCNFLM.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +159 -154
- package/dist/{json-rpc-client-DuUARJvV.js → json-rpc-client-CQLbpuKK.js} +31 -30
- package/dist/json-rpc-client-CQLbpuKK.js.map +1 -0
- package/dist/json-rpc-client-DbpFfa_o.cjs +2 -0
- package/dist/json-rpc-client-DbpFfa_o.cjs.map +1 -0
- package/dist/{onChainBtcPubkey-BXry_CM4.cjs → onChainBtcPubkey-BlzxYImF.cjs} +2 -2
- package/dist/{onChainBtcPubkey-BXry_CM4.cjs.map → onChainBtcPubkey-BlzxYImF.cjs.map} +1 -1
- package/dist/{onChainBtcPubkey-C1WqyxPM.js → onChainBtcPubkey-CCTdl53s.js} +2 -2
- package/dist/{onChainBtcPubkey-C1WqyxPM.js.map → onChainBtcPubkey-CCTdl53s.js.map} +1 -1
- package/dist/{pegin-registration-client-BNV44jzw.cjs → pegin-registration-client-BdJ6c7si.cjs} +2 -2
- package/dist/{pegin-registration-client-BNV44jzw.cjs.map → pegin-registration-client-BdJ6c7si.cjs.map} +1 -1
- package/dist/{pegin-registration-client-1sZ-74UC.js → pegin-registration-client-C5Hktrja.js} +3 -3
- package/dist/{pegin-registration-client-1sZ-74UC.js.map → pegin-registration-client-C5Hktrja.js.map} +1 -1
- package/dist/peginState-BU2ONFXF.js +68 -0
- package/dist/{peginState-CxDiaKuk.js.map → peginState-BU2ONFXF.js.map} +1 -1
- package/dist/peginState-DUv10EJR.cjs +2 -0
- package/dist/{peginState-eaQ4IO_R.cjs.map → peginState-DUv10EJR.cjs.map} +1 -1
- package/dist/{primeVpAuth-BOGKniTl.cjs → primeVpAuth-D21PXgg2.cjs} +2 -2
- package/dist/{primeVpAuth-BOGKniTl.cjs.map → primeVpAuth-D21PXgg2.cjs.map} +1 -1
- package/dist/{primeVpAuth-DdfHSC53.js → primeVpAuth-PiUJksAq.js} +5 -5
- package/dist/{primeVpAuth-DdfHSC53.js.map → primeVpAuth-PiUJksAq.js.map} +1 -1
- package/dist/{reservation-Cj9F0rP9.js → reservation-DOAHVT3B.js} +2 -2
- package/dist/{reservation-Cj9F0rP9.js.map → reservation-DOAHVT3B.js.map} +1 -1
- package/dist/{reservation-Dr2HLCxx.cjs → reservation-ECxjZi5t.cjs} +2 -2
- package/dist/{reservation-Dr2HLCxx.cjs.map → reservation-ECxjZi5t.cjs.map} +1 -1
- package/dist/sha2-Ce6KewYx.cjs +2 -0
- package/dist/{sha2-DI0-0SHr.cjs.map → sha2-Ce6KewYx.cjs.map} +1 -1
- package/dist/{sha2-CLpQd0Rd.js → sha2-YqVHJiFj.js} +91 -77
- package/dist/{sha2-CLpQd0Rd.js.map → sha2-YqVHJiFj.js.map} +1 -1
- package/dist/tbv/core/clients/eth/index.cjs +1 -1
- package/dist/tbv/core/clients/eth/index.js +3 -3
- package/dist/tbv/core/clients/index.cjs +1 -1
- package/dist/tbv/core/clients/index.js +27 -26
- package/dist/tbv/core/clients/vault-provider/index.d.ts +1 -1
- package/dist/tbv/core/clients/vault-provider/index.d.ts.map +1 -1
- package/dist/tbv/core/clients/vault-provider/status/index.cjs +1 -1
- package/dist/tbv/core/clients/vault-provider/status/index.d.ts +1 -1
- package/dist/tbv/core/clients/vault-provider/status/index.d.ts.map +1 -1
- package/dist/tbv/core/clients/vault-provider/status/index.js +10 -9
- package/dist/tbv/core/clients/vault-provider/types.d.ts +7 -3
- package/dist/tbv/core/clients/vault-provider/types.d.ts.map +1 -1
- package/dist/tbv/core/clients/vault-provider/validators.d.ts +8 -0
- package/dist/tbv/core/clients/vault-provider/validators.d.ts.map +1 -1
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.js +158 -153
- package/dist/tbv/core/managers/index.cjs +1 -1
- package/dist/tbv/core/managers/index.js +2 -2
- package/dist/tbv/core/primitives/psbt/peginInput.d.ts.map +1 -1
- package/dist/tbv/core/services/deposit/__tests__/graphFingerprint.test.d.ts +2 -0
- package/dist/tbv/core/services/deposit/__tests__/graphFingerprint.test.d.ts.map +1 -0
- package/dist/tbv/core/services/deposit/graphFingerprint.d.ts +115 -0
- package/dist/tbv/core/services/deposit/graphFingerprint.d.ts.map +1 -0
- package/dist/tbv/core/services/deposit/index.d.ts +2 -1
- package/dist/tbv/core/services/deposit/index.d.ts.map +1 -1
- package/dist/tbv/core/services/deposit/peginState.d.ts +23 -0
- package/dist/tbv/core/services/deposit/peginState.d.ts.map +1 -1
- package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts +11 -0
- package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts.map +1 -1
- package/dist/tbv/core/services/index.cjs +1 -1
- package/dist/tbv/core/services/index.js +66 -62
- package/dist/tbv/core/utils/index.cjs +1 -1
- package/dist/tbv/core/utils/index.js +1 -1
- package/dist/tbv/core/vault-secrets/index.cjs +1 -1
- package/dist/tbv/core/vault-secrets/index.js +1 -1
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +158 -153
- package/dist/testing/index.cjs +1 -1
- package/dist/testing/index.js +1 -1
- package/dist/{toRefundInputs-BaN9XluU.cjs → toRefundInputs-B_GlIXjk.cjs} +2 -2
- package/dist/{toRefundInputs-BaN9XluU.cjs.map → toRefundInputs-B_GlIXjk.cjs.map} +1 -1
- package/dist/{toRefundInputs-mtuuYezp.js → toRefundInputs-DIIdhjvu.js} +5 -5
- package/dist/{toRefundInputs-mtuuYezp.js.map → toRefundInputs-DIIdhjvu.js.map} +1 -1
- package/dist/{types-BuxreSq4.cjs → types-DJxOEU3P.cjs} +2 -2
- package/dist/{types-BuxreSq4.cjs.map → types-DJxOEU3P.cjs.map} +1 -1
- package/dist/{types-BdCEoANP.js → types-Dz1kVqn6.js} +2 -2
- package/dist/{types-BdCEoANP.js.map → types-Dz1kVqn6.js.map} +1 -1
- package/dist/verifyKeyPathSchnorrSignature-BQHNhRj6.js.map +1 -1
- package/dist/verifyKeyPathSchnorrSignature-Gm9EmZkx.cjs.map +1 -1
- package/package.json +2 -1
- package/dist/buildAndBroadcastReclaim-BwT6Jxp5.cjs +0 -2
- package/dist/buildAndBroadcastReclaim-BwT6Jxp5.cjs.map +0 -1
- package/dist/buildAndBroadcastReclaim-CqO2DoP8.js.map +0 -1
- package/dist/index-CK1Xvq4K.cjs +0 -2
- package/dist/index-CK1Xvq4K.cjs.map +0 -1
- package/dist/index-DQ5bfoT3.js.map +0 -1
- package/dist/json-rpc-client-BiAmg_ho.cjs +0 -2
- package/dist/json-rpc-client-BiAmg_ho.cjs.map +0 -1
- package/dist/json-rpc-client-DuUARJvV.js.map +0 -1
- package/dist/peginState-CxDiaKuk.js +0 -63
- package/dist/peginState-eaQ4IO_R.cjs +0 -2
- package/dist/sha2-DI0-0SHr.cjs +0 -2
|
@@ -1,48 +1,52 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var V = (s, e, t) =>
|
|
4
|
-
import { D as O, a as
|
|
1
|
+
var N = Object.defineProperty;
|
|
2
|
+
var H = (s, e, t) => e in s ? N(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
|
+
var V = (s, e, t) => H(s, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { D as O, a as I, e as U } from "./json-rpc-client-CQLbpuKK.js";
|
|
5
5
|
import { C as A } from "./constants-D5vORbQE.js";
|
|
6
|
-
import { H as
|
|
7
|
-
const
|
|
6
|
+
import { H as X, X as R, C as k } from "./validation-OSC0xTHB.js";
|
|
7
|
+
const D = new Set(Object.values(O)), M = 200;
|
|
8
8
|
function a(s) {
|
|
9
9
|
var e;
|
|
10
|
-
return ((e = JSON.stringify(s)) == null ? void 0 : e.slice(0,
|
|
10
|
+
return ((e = JSON.stringify(s)) == null ? void 0 : e.slice(0, M)) ?? "undefined";
|
|
11
11
|
}
|
|
12
|
-
const
|
|
12
|
+
const C = "VP response validation failed: unrecognized status";
|
|
13
|
+
function _e(s) {
|
|
14
|
+
return s.startsWith(C);
|
|
15
|
+
}
|
|
16
|
+
const q = "The vault provider returned an unexpected response. Please try again or contact support.";
|
|
13
17
|
class n extends Error {
|
|
14
18
|
constructor(t) {
|
|
15
|
-
super(
|
|
19
|
+
super(q);
|
|
16
20
|
V(this, "detail");
|
|
17
21
|
this.name = "VpResponseValidationError", this.detail = t;
|
|
18
22
|
}
|
|
19
23
|
}
|
|
20
|
-
const
|
|
24
|
+
const y = 64, T = 64;
|
|
21
25
|
function f(s) {
|
|
22
|
-
return typeof s == "string" && s.length > 0 &&
|
|
26
|
+
return typeof s == "string" && s.length > 0 && X.test(s);
|
|
23
27
|
}
|
|
24
|
-
function
|
|
28
|
+
function L(s) {
|
|
25
29
|
return typeof s == "string" && s.length > 0;
|
|
26
30
|
}
|
|
27
|
-
function
|
|
31
|
+
function z(s, e) {
|
|
28
32
|
if (!f(s))
|
|
29
33
|
throw new n(
|
|
30
34
|
`VP response validation failed: "${e}" must be a non-empty hex string, got ${a(s)}`
|
|
31
35
|
);
|
|
32
36
|
}
|
|
33
37
|
function u(s, e) {
|
|
34
|
-
if (!
|
|
38
|
+
if (!L(s))
|
|
35
39
|
throw new n(
|
|
36
40
|
`VP response validation failed: "${e}" must be a non-empty string, got ${a(s)}`
|
|
37
41
|
);
|
|
38
42
|
}
|
|
39
|
-
function
|
|
40
|
-
if (!f(s) || s.length !==
|
|
43
|
+
function E(s, e) {
|
|
44
|
+
if (!f(s) || s.length !== R && s.length !== k)
|
|
41
45
|
throw new n(
|
|
42
|
-
`VP response validation failed: "${e}" must be a ${
|
|
46
|
+
`VP response validation failed: "${e}" must be a ${R} or ${k}-char hex string (BTC pubkey), got ${a(s)}`
|
|
43
47
|
);
|
|
44
48
|
}
|
|
45
|
-
function
|
|
49
|
+
function F(s) {
|
|
46
50
|
const e = s.presigning;
|
|
47
51
|
if (e == null) return;
|
|
48
52
|
if (typeof e != "object" || Array.isArray(e))
|
|
@@ -69,23 +73,23 @@ function B(s) {
|
|
|
69
73
|
"VP response validation failed: getPeginStatus response is not an object"
|
|
70
74
|
);
|
|
71
75
|
const e = s;
|
|
72
|
-
if (!f(e.pegin_txid) || e.pegin_txid.length !==
|
|
76
|
+
if (!f(e.pegin_txid) || e.pegin_txid.length !== y)
|
|
73
77
|
throw new n(
|
|
74
|
-
`VP response validation failed: "pegin_txid" must be a ${
|
|
78
|
+
`VP response validation failed: "pegin_txid" must be a ${y}-char hex string (txid), got ${a(e.pegin_txid)}`
|
|
75
79
|
);
|
|
76
80
|
if (typeof e.status != "string")
|
|
77
81
|
throw new n(
|
|
78
82
|
'VP response validation failed: "status" must be a string'
|
|
79
83
|
);
|
|
80
|
-
if (!
|
|
84
|
+
if (!D.has(e.status))
|
|
81
85
|
throw new n(
|
|
82
|
-
|
|
86
|
+
`${C} ${a(e.status)}. Expected one of: ${[...D].join(", ")}`
|
|
83
87
|
);
|
|
84
88
|
if (e.progress === null || typeof e.progress != "object" || Array.isArray(e.progress))
|
|
85
89
|
throw new n(
|
|
86
90
|
'VP response validation failed: "progress" must be an object'
|
|
87
91
|
);
|
|
88
|
-
if (
|
|
92
|
+
if (F(e.progress), typeof e.health_info != "string")
|
|
89
93
|
throw new n(
|
|
90
94
|
'VP response validation failed: "health_info" must be a string'
|
|
91
95
|
);
|
|
@@ -94,7 +98,7 @@ function B(s) {
|
|
|
94
98
|
`VP response validation failed: "last_error" must be a string if present, got ${a(e.last_error)}`
|
|
95
99
|
);
|
|
96
100
|
}
|
|
97
|
-
function
|
|
101
|
+
function W(s) {
|
|
98
102
|
if (s === null || typeof s != "object")
|
|
99
103
|
throw new n(
|
|
100
104
|
"VP response validation failed: requestDepositorPresignTransactions response is not an object"
|
|
@@ -105,31 +109,31 @@ function z(s) {
|
|
|
105
109
|
'VP response validation failed: "txs" must be an array'
|
|
106
110
|
);
|
|
107
111
|
for (let t = 0; t < e.txs.length; t++)
|
|
108
|
-
|
|
112
|
+
K(e.txs[t], `txs[${t}]`);
|
|
109
113
|
if (e.depositor_graph === null || typeof e.depositor_graph != "object")
|
|
110
114
|
throw new n(
|
|
111
115
|
'VP response validation failed: "depositor_graph" must be an object'
|
|
112
116
|
);
|
|
113
|
-
|
|
117
|
+
re(
|
|
114
118
|
e.depositor_graph
|
|
115
119
|
);
|
|
116
120
|
}
|
|
117
|
-
function
|
|
121
|
+
function h(s, e) {
|
|
118
122
|
if (s === null || typeof s != "object")
|
|
119
123
|
throw new n(
|
|
120
124
|
`VP response validation failed: "${e}" must be an object`
|
|
121
125
|
);
|
|
122
|
-
|
|
126
|
+
z(s.tx_hex, `${e}.tx_hex`);
|
|
123
127
|
}
|
|
124
|
-
function
|
|
128
|
+
function K(s, e) {
|
|
125
129
|
if (s === null || typeof s != "object")
|
|
126
130
|
throw new n(
|
|
127
131
|
`VP response validation failed: "${e}" must be an object`
|
|
128
132
|
);
|
|
129
133
|
const t = s;
|
|
130
|
-
|
|
134
|
+
E(t.claimer_pubkey, `${e}.claimer_pubkey`), h(t.claim_tx, `${e}.claim_tx`), h(t.assert_tx, `${e}.assert_tx`), h(t.payout_tx, `${e}.payout_tx`), u(t.payout_psbt, `${e}.payout_psbt`);
|
|
131
135
|
}
|
|
132
|
-
function
|
|
136
|
+
function Y(s, e) {
|
|
133
137
|
if (s === null || typeof s != "object")
|
|
134
138
|
throw new n(
|
|
135
139
|
`VP response validation failed: "${e}" must be an object`
|
|
@@ -137,19 +141,19 @@ function K(s, e) {
|
|
|
137
141
|
const t = s;
|
|
138
142
|
u(t.wots_pks_json, `${e}.wots_pks_json`), u(t.gc_wots_keys_json, `${e}.gc_wots_keys_json`);
|
|
139
143
|
}
|
|
140
|
-
function
|
|
144
|
+
function J(s, e) {
|
|
141
145
|
if (s === null || typeof s != "object")
|
|
142
146
|
throw new n(
|
|
143
147
|
`VP response validation failed: "${e}" must be an object`
|
|
144
148
|
);
|
|
145
149
|
const t = s;
|
|
146
|
-
if (
|
|
150
|
+
if (E(t.challenger_pubkey, `${e}.challenger_pubkey`), h(
|
|
147
151
|
t.challenge_assert_x_tx,
|
|
148
152
|
`${e}.challenge_assert_x_tx`
|
|
149
|
-
),
|
|
153
|
+
), h(
|
|
150
154
|
t.challenge_assert_y_tx,
|
|
151
155
|
`${e}.challenge_assert_y_tx`
|
|
152
|
-
),
|
|
156
|
+
), h(t.nopayout_tx, `${e}.nopayout_tx`), u(t.nopayout_psbt, `${e}.nopayout_psbt`), !Array.isArray(t.challenge_assert_connectors))
|
|
153
157
|
throw new n(
|
|
154
158
|
`VP response validation failed: "${e}.challenge_assert_connectors" must be an array`
|
|
155
159
|
);
|
|
@@ -158,7 +162,7 @@ function W(s, e) {
|
|
|
158
162
|
`VP response validation failed: "${e}.challenge_assert_connectors" must have exactly ${A} entries, got ${t.challenge_assert_connectors.length}`
|
|
159
163
|
);
|
|
160
164
|
for (let r = 0; r < t.challenge_assert_connectors.length; r++)
|
|
161
|
-
|
|
165
|
+
Y(
|
|
162
166
|
t.challenge_assert_connectors[r],
|
|
163
167
|
`${e}.challenge_assert_connectors[${r}]`
|
|
164
168
|
);
|
|
@@ -166,19 +170,21 @@ function W(s, e) {
|
|
|
166
170
|
throw new n(
|
|
167
171
|
`VP response validation failed: "${e}.output_label_hashes" must be an array`
|
|
168
172
|
);
|
|
169
|
-
for (let r = 0; r < t.output_label_hashes.length; r++)
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
173
|
+
for (let r = 0; r < t.output_label_hashes.length; r++) {
|
|
174
|
+
const o = t.output_label_hashes[r];
|
|
175
|
+
if (!f(o) || o.length !== T)
|
|
176
|
+
throw new n(
|
|
177
|
+
`VP response validation failed: "${e}.output_label_hashes[${r}]" must be a ${T}-char hex string, got ${a(o)}`
|
|
178
|
+
);
|
|
179
|
+
}
|
|
174
180
|
}
|
|
175
|
-
function
|
|
181
|
+
function Z(s) {
|
|
176
182
|
if (s === null || typeof s != "object")
|
|
177
183
|
throw new n(
|
|
178
184
|
"VP response validation failed: requestDepositorClaimerArtifacts response is not an object"
|
|
179
185
|
);
|
|
180
186
|
const e = s;
|
|
181
|
-
if (!
|
|
187
|
+
if (!L(e.tx_graph_json))
|
|
182
188
|
throw new n(
|
|
183
189
|
`VP response validation failed: "tx_graph_json" must be a non-empty string, got ${a(e.tx_graph_json)}`
|
|
184
190
|
);
|
|
@@ -198,7 +204,7 @@ function Y(s) {
|
|
|
198
204
|
'VP response validation failed: "babe_sessions" must contain at least one challenger entry'
|
|
199
205
|
);
|
|
200
206
|
for (const [r, o] of t) {
|
|
201
|
-
if (
|
|
207
|
+
if (E(r, `babe_sessions["${r}"]`), o === null || typeof o != "object")
|
|
202
208
|
throw new n(
|
|
203
209
|
`VP response validation failed: "babe_sessions.${r}" must be an object`
|
|
204
210
|
);
|
|
@@ -209,15 +215,15 @@ function Y(s) {
|
|
|
209
215
|
);
|
|
210
216
|
}
|
|
211
217
|
}
|
|
212
|
-
function
|
|
218
|
+
function Q(s) {
|
|
213
219
|
if (s === null || typeof s != "object")
|
|
214
220
|
throw new n(
|
|
215
221
|
"VP response validation failed: pegout status payload is not an object"
|
|
216
222
|
);
|
|
217
223
|
const e = s;
|
|
218
|
-
if (!f(e.pegin_txid) || e.pegin_txid.length !==
|
|
224
|
+
if (!f(e.pegin_txid) || e.pegin_txid.length !== y)
|
|
219
225
|
throw new n(
|
|
220
|
-
`VP response validation failed: "pegin_txid" must be a ${
|
|
226
|
+
`VP response validation failed: "pegin_txid" must be a ${y}-char hex string (txid), got ${a(e.pegin_txid)}`
|
|
221
227
|
);
|
|
222
228
|
if (typeof e.found != "boolean")
|
|
223
229
|
throw new n(
|
|
@@ -228,16 +234,16 @@ function J(s) {
|
|
|
228
234
|
throw new n(
|
|
229
235
|
`VP response validation failed: "claimer" must be an object or null, got ${a(e.claimer)}`
|
|
230
236
|
);
|
|
231
|
-
|
|
237
|
+
ee(e.claimer);
|
|
232
238
|
}
|
|
233
239
|
if (!Array.isArray(e.challengers))
|
|
234
240
|
throw new n(
|
|
235
241
|
`VP response validation failed: "challengers" must be an array, got ${a(e.challengers)}`
|
|
236
242
|
);
|
|
237
243
|
for (let t = 0; t < e.challengers.length; t++)
|
|
238
|
-
|
|
244
|
+
te(e.challengers[t], t);
|
|
239
245
|
}
|
|
240
|
-
function
|
|
246
|
+
function ee(s) {
|
|
241
247
|
if (u(s.status, "claimer.status"), typeof s.failed != "boolean")
|
|
242
248
|
throw new n(
|
|
243
249
|
`VP response validation failed: "claimer.failed" must be a boolean, got ${a(s.failed)}`
|
|
@@ -251,7 +257,7 @@ function Z(s) {
|
|
|
251
257
|
`VP response validation failed: "claimer.updated_at" must be a number, got ${a(s.updated_at)}`
|
|
252
258
|
);
|
|
253
259
|
}
|
|
254
|
-
function
|
|
260
|
+
function te(s, e) {
|
|
255
261
|
if (s === null || typeof s != "object")
|
|
256
262
|
throw new n(
|
|
257
263
|
`VP response validation failed: "challengers[${e}]" must be an object, got ${a(s)}`
|
|
@@ -278,17 +284,17 @@ function $(s, e) {
|
|
|
278
284
|
`VP response validation failed: "${e}" must be a string or null, got ${a(s)}`
|
|
279
285
|
);
|
|
280
286
|
}
|
|
281
|
-
function
|
|
282
|
-
|
|
287
|
+
function se(s) {
|
|
288
|
+
G(s, "batchGetPeginStatus", (e) => {
|
|
283
289
|
e.result !== null && B(e.result);
|
|
284
290
|
});
|
|
285
291
|
}
|
|
286
|
-
function
|
|
287
|
-
|
|
288
|
-
e.result !== null &&
|
|
292
|
+
function ne(s) {
|
|
293
|
+
G(s, "batchGetPegoutStatus", (e) => {
|
|
294
|
+
e.result !== null && Q(e.result);
|
|
289
295
|
});
|
|
290
296
|
}
|
|
291
|
-
function
|
|
297
|
+
function G(s, e, t) {
|
|
292
298
|
if (s === null || typeof s != "object")
|
|
293
299
|
throw new n(
|
|
294
300
|
`VP response validation failed: ${e} response is not an object`
|
|
@@ -305,9 +311,9 @@ function L(s, e, t) {
|
|
|
305
311
|
`VP response validation failed: "${e}.results[${o}]" must be an object, got ${a(c)}`
|
|
306
312
|
);
|
|
307
313
|
const i = c;
|
|
308
|
-
if (!f(i.pegin_txid) || i.pegin_txid.length !==
|
|
314
|
+
if (!f(i.pegin_txid) || i.pegin_txid.length !== y)
|
|
309
315
|
throw new n(
|
|
310
|
-
`VP response validation failed: "${e}.results[${o}].pegin_txid" must be a ${
|
|
316
|
+
`VP response validation failed: "${e}.results[${o}].pegin_txid" must be a ${y}-char hex string, got ${a(i.pegin_txid)}`
|
|
311
317
|
);
|
|
312
318
|
if (i.error !== null && typeof i.error != "string")
|
|
313
319
|
throw new n(
|
|
@@ -321,16 +327,25 @@ function L(s, e, t) {
|
|
|
321
327
|
throw new n(
|
|
322
328
|
`VP response validation failed: "${e}.results[${o}]" has both "result" and "error" populated`
|
|
323
329
|
);
|
|
324
|
-
|
|
330
|
+
try {
|
|
331
|
+
t(i, o);
|
|
332
|
+
} catch (d) {
|
|
333
|
+
if (!(d instanceof n)) throw d;
|
|
334
|
+
r.results[o] = {
|
|
335
|
+
pegin_txid: i.pegin_txid,
|
|
336
|
+
result: null,
|
|
337
|
+
error: d.detail
|
|
338
|
+
};
|
|
339
|
+
}
|
|
325
340
|
}
|
|
326
341
|
}
|
|
327
|
-
function
|
|
328
|
-
if (
|
|
342
|
+
function re(s) {
|
|
343
|
+
if (h(s.claim_tx, "depositor_graph.claim_tx"), h(s.assert_tx, "depositor_graph.assert_tx"), h(s.payout_tx, "depositor_graph.payout_tx"), u(s.payout_psbt, "depositor_graph.payout_psbt"), !Array.isArray(s.challenger_presign_data))
|
|
329
344
|
throw new n(
|
|
330
345
|
'VP response validation failed: "depositor_graph.challenger_presign_data" must be an array'
|
|
331
346
|
);
|
|
332
347
|
for (let e = 0; e < s.challenger_presign_data.length; e++)
|
|
333
|
-
|
|
348
|
+
J(
|
|
334
349
|
s.challenger_presign_data[e],
|
|
335
350
|
`depositor_graph.challenger_presign_data[${e}]`
|
|
336
351
|
);
|
|
@@ -339,13 +354,13 @@ function se(s) {
|
|
|
339
354
|
'VP response validation failed: "depositor_graph.offchain_params_version" must be a number'
|
|
340
355
|
);
|
|
341
356
|
}
|
|
342
|
-
const
|
|
343
|
-
class
|
|
357
|
+
const ae = 6e4;
|
|
358
|
+
class pe {
|
|
344
359
|
constructor(e, t) {
|
|
345
360
|
V(this, "client");
|
|
346
361
|
const r = {
|
|
347
362
|
baseUrl: e,
|
|
348
|
-
timeout: (t == null ? void 0 : t.timeout) ??
|
|
363
|
+
timeout: (t == null ? void 0 : t.timeout) ?? ae,
|
|
349
364
|
retries: t == null ? void 0 : t.retries,
|
|
350
365
|
retryDelay: t == null ? void 0 : t.retryDelay,
|
|
351
366
|
retryableFor: t == null ? void 0 : t.retryableFor,
|
|
@@ -353,7 +368,7 @@ class ce {
|
|
|
353
368
|
tokenProvider: t == null ? void 0 : t.tokenProvider,
|
|
354
369
|
maxResponseBytes: t == null ? void 0 : t.maxResponseBytes
|
|
355
370
|
};
|
|
356
|
-
this.client = new
|
|
371
|
+
this.client = new I(r);
|
|
357
372
|
}
|
|
358
373
|
/**
|
|
359
374
|
* Request the payout/claim/assert transactions that the depositor
|
|
@@ -361,7 +376,7 @@ class ce {
|
|
|
361
376
|
*/
|
|
362
377
|
async requestDepositorPresignTransactions(e, t) {
|
|
363
378
|
const r = await this.client.call("vaultProvider_requestDepositorPresignTransactions", e, t);
|
|
364
|
-
return
|
|
379
|
+
return W(r), r;
|
|
365
380
|
}
|
|
366
381
|
/**
|
|
367
382
|
* Submit the depositor's pre-signatures for the payout transactions
|
|
@@ -392,7 +407,7 @@ class ce {
|
|
|
392
407
|
*/
|
|
393
408
|
async requestDepositorClaimerArtifacts(e, t) {
|
|
394
409
|
const r = await this.client.call("vaultProvider_requestDepositorClaimerArtifacts", e, t);
|
|
395
|
-
return
|
|
410
|
+
return Z(r), r;
|
|
396
411
|
}
|
|
397
412
|
/** Get the current pegin status from the vault provider daemon. */
|
|
398
413
|
async getPeginStatus(e, t) {
|
|
@@ -410,7 +425,7 @@ class ce {
|
|
|
410
425
|
*/
|
|
411
426
|
async batchGetPeginStatus(e, t) {
|
|
412
427
|
const r = await this.client.call("vaultProvider_batchGetPeginStatus", e, t);
|
|
413
|
-
return
|
|
428
|
+
return se(r), r;
|
|
414
429
|
}
|
|
415
430
|
/**
|
|
416
431
|
* Get pegout status for many txids in one round trip. Same per-result
|
|
@@ -418,32 +433,32 @@ class ce {
|
|
|
418
433
|
*/
|
|
419
434
|
async batchGetPegoutStatus(e, t) {
|
|
420
435
|
const r = await this.client.call("vaultProvider_batchGetPegoutStatus", e, t);
|
|
421
|
-
return
|
|
436
|
+
return ne(r), r;
|
|
422
437
|
}
|
|
423
438
|
}
|
|
424
|
-
function
|
|
439
|
+
function oe(s, e) {
|
|
425
440
|
const t = /* @__PURE__ */ new Set();
|
|
426
441
|
for (const p of s)
|
|
427
442
|
t.add(p.toLowerCase());
|
|
428
443
|
const r = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set(), c = [], i = [];
|
|
429
444
|
for (const p of e) {
|
|
430
|
-
const
|
|
431
|
-
if (!t.has(
|
|
432
|
-
i.push(
|
|
445
|
+
const g = p.pegin_txid.toLowerCase();
|
|
446
|
+
if (!t.has(g)) {
|
|
447
|
+
i.push(g);
|
|
433
448
|
continue;
|
|
434
449
|
}
|
|
435
|
-
if (o.has(
|
|
436
|
-
c.push(
|
|
450
|
+
if (o.has(g)) {
|
|
451
|
+
c.push(g);
|
|
437
452
|
continue;
|
|
438
453
|
}
|
|
439
|
-
o.add(
|
|
454
|
+
o.add(g), r.set(g, { result: p.result, error: p.error });
|
|
440
455
|
}
|
|
441
|
-
const
|
|
456
|
+
const d = [];
|
|
442
457
|
for (const p of t)
|
|
443
|
-
o.has(p) ||
|
|
444
|
-
return { byTxid: r, missing:
|
|
458
|
+
o.has(p) || d.push(p);
|
|
459
|
+
return { byTxid: r, missing: d, unexpected: i, duplicate: c };
|
|
445
460
|
}
|
|
446
|
-
async function
|
|
461
|
+
async function de(s) {
|
|
447
462
|
const {
|
|
448
463
|
items: e,
|
|
449
464
|
getTxid: t,
|
|
@@ -451,41 +466,41 @@ async function ue(s) {
|
|
|
451
466
|
onItem: o,
|
|
452
467
|
onMissing: c,
|
|
453
468
|
onDuplicate: i,
|
|
454
|
-
onDuplicateBatch:
|
|
469
|
+
onDuplicateBatch: d,
|
|
455
470
|
onWholeBatchError: p,
|
|
456
|
-
onUnexpected:
|
|
457
|
-
batchSize: w =
|
|
471
|
+
onUnexpected: g,
|
|
472
|
+
batchSize: w = U
|
|
458
473
|
} = s;
|
|
459
474
|
if (!Number.isInteger(w) || w <= 0)
|
|
460
475
|
throw new Error(
|
|
461
476
|
`batchPollByProvider: batchSize must be a positive integer, got ${w}`
|
|
462
477
|
);
|
|
463
478
|
for (let m = 0; m < e.length; m += w) {
|
|
464
|
-
const
|
|
465
|
-
for (const l of
|
|
479
|
+
const j = e.slice(m, m + w), P = /* @__PURE__ */ new Map(), v = [];
|
|
480
|
+
for (const l of j) {
|
|
466
481
|
const _ = t(l).toLowerCase();
|
|
467
482
|
P.set(_, l), v.push(_);
|
|
468
483
|
}
|
|
469
|
-
let
|
|
484
|
+
let b;
|
|
470
485
|
try {
|
|
471
486
|
const l = await r(v);
|
|
472
|
-
|
|
487
|
+
b = oe(v, l.results);
|
|
473
488
|
} catch (l) {
|
|
474
|
-
p(
|
|
489
|
+
p(j, l);
|
|
475
490
|
continue;
|
|
476
491
|
}
|
|
477
|
-
|
|
478
|
-
const x = new Set(
|
|
492
|
+
g && b.unexpected.length > 0 && g(b.unexpected);
|
|
493
|
+
const x = new Set(b.duplicate);
|
|
479
494
|
for (const l of x) {
|
|
480
495
|
const _ = P.get(l);
|
|
481
496
|
_ && i(_);
|
|
482
497
|
}
|
|
483
|
-
|
|
484
|
-
for (const l of
|
|
498
|
+
d && x.size > 0 && d(x.size);
|
|
499
|
+
for (const l of b.missing) {
|
|
485
500
|
const _ = P.get(l);
|
|
486
501
|
_ && c(_);
|
|
487
502
|
}
|
|
488
|
-
for (const [l, _] of
|
|
503
|
+
for (const [l, _] of b.byTxid) {
|
|
489
504
|
if (x.has(l)) continue;
|
|
490
505
|
const S = P.get(l);
|
|
491
506
|
S && o(S, {
|
|
@@ -497,9 +512,10 @@ async function ue(s) {
|
|
|
497
512
|
}
|
|
498
513
|
}
|
|
499
514
|
export {
|
|
500
|
-
|
|
515
|
+
pe as V,
|
|
501
516
|
n as a,
|
|
502
|
-
|
|
503
|
-
|
|
517
|
+
de as b,
|
|
518
|
+
_e as i,
|
|
519
|
+
Z as v
|
|
504
520
|
};
|
|
505
|
-
//# sourceMappingURL=index-
|
|
521
|
+
//# sourceMappingURL=index-Bnavi_r3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-Bnavi_r3.js","sources":["../src/tbv/core/clients/vault-provider/validators.ts","../src/tbv/core/clients/vault-provider/api.ts","../src/tbv/core/clients/vault-provider/batchAttribution.ts","../src/tbv/core/clients/vault-provider/batchPoll.ts"],"sourcesContent":["/**\n * Runtime validation for vault provider RPC responses.\n *\n * All VP RPC methods return untyped JSON that TypeScript generics cast without\n * inspection. These validators check the critical top-level fields and\n * security-relevant values (status, txids, pubkeys). Optional progress\n * sub-fields (gc_data, ack_collection, claimer_graphs) are NOT validated\n * since they are informational and not used for signing or transaction\n * construction. Only `progress.presigning` sub-fields are checked.\n */\n\nimport { CHALLENGE_ASSERT_CONNECTORS_PER_CHALLENGER } from \"../../primitives/psbt/constants\";\nimport {\n COMPRESSED_PUBKEY_HEX_LEN,\n HEX_RE,\n X_ONLY_PUBKEY_HEX_LEN,\n} from \"../../utils/validation\";\n\nimport type {\n BatchGetPeginStatusResponse,\n BatchGetPegoutStatusResponse,\n GetPeginStatusResponse,\n GetPegoutStatusResponse,\n RequestDepositorClaimerArtifactsResponse,\n RequestDepositorPresignTransactionsResponse,\n} from \"./types\";\nimport { DaemonStatus } from \"./types\";\n\nconst DAEMON_STATUS_VALUES = new Set<string>(Object.values(DaemonStatus));\n\nconst VP_ERROR_PREVIEW_MAX_LEN = 200;\n\nfunction preview(value: unknown): string {\n return (\n JSON.stringify(value)?.slice(0, VP_ERROR_PREVIEW_MAX_LEN) ?? \"undefined\"\n );\n}\n\nconst UNRECOGNIZED_STATUS_ERROR_PREFIX =\n \"VP response validation failed: unrecognized status\";\n\n/**\n * Whether a batch status entry's `error` reports a pegin status outside\n * {@link DaemonStatus}. The batch validator moves such an entry to its\n * `error` slot, so one unknown status does not fail the whole reply.\n */\nexport function isUnrecognizedDaemonStatusError(error: string): boolean {\n return error.startsWith(UNRECOGNIZED_STATUS_ERROR_PREFIX);\n}\n\nconst VP_VALIDATION_USER_MESSAGE =\n \"The vault provider returned an unexpected response. Please try again or contact support.\";\n\n/**\n * Thrown when a VP RPC response fails runtime validation.\n *\n * `.message` is a user-facing string safe to display in the UI.\n * `.detail` contains the technical reason, suitable for logging.\n */\nexport class VpResponseValidationError extends Error {\n readonly detail: string;\n\n constructor(detail: string) {\n super(VP_VALIDATION_USER_MESSAGE);\n this.name = \"VpResponseValidationError\";\n this.detail = detail;\n }\n}\n\n/** Expected length (in hex chars) of a Bitcoin transaction ID (32 bytes). */\nconst TXID_HEX_LEN = 64;\n\n/** Expected length (in hex chars) of a GC output label hash (SHA-256). */\nconst LABEL_HASH_HEX_LEN = 64;\n\nfunction isNonEmptyHex(value: unknown): value is string {\n return typeof value === \"string\" && value.length > 0 && HEX_RE.test(value);\n}\n\nfunction isNonEmptyString(value: unknown): value is string {\n return typeof value === \"string\" && value.length > 0;\n}\n\nfunction assertNonEmptyHex(value: unknown, field: string): void {\n if (!isNonEmptyHex(value)) {\n throw new VpResponseValidationError(\n `VP response validation failed: \"${field}\" must be a non-empty hex string, got ${preview(value)}`,\n );\n }\n}\n\nfunction assertNonEmptyString(value: unknown, field: string): void {\n if (!isNonEmptyString(value)) {\n throw new VpResponseValidationError(\n `VP response validation failed: \"${field}\" must be a non-empty string, got ${preview(value)}`,\n );\n }\n}\n\n/**\n * Accept both x-only (64-char) and compressed (66-char) pubkeys from VP responses.\n * The signing code normalizes to x-only via processPublicKeyToXOnly().\n */\nfunction assertBtcPubkey(value: unknown, field: string): void {\n if (\n !isNonEmptyHex(value) ||\n (value.length !== X_ONLY_PUBKEY_HEX_LEN &&\n value.length !== COMPRESSED_PUBKEY_HEX_LEN)\n ) {\n throw new VpResponseValidationError(\n `VP response validation failed: \"${field}\" must be a ${X_ONLY_PUBKEY_HEX_LEN} or ${COMPRESSED_PUBKEY_HEX_LEN}-char hex string (BTC pubkey), got ${preview(value)}`,\n );\n }\n}\n\n/**\n * Validate the optional presigning progress fields returned inside PeginProgressDetails.\n */\nfunction validatePresigningProgressFields(\n progress: Record<string, unknown>,\n): void {\n const presigning = progress.presigning;\n if (presigning === undefined || presigning === null) return;\n if (typeof presigning !== \"object\" || Array.isArray(presigning)) {\n throw new VpResponseValidationError(\n `VP response validation failed: \"progress.presigning\" must be an object if present`,\n );\n }\n\n const p = presigning as Record<string, unknown>;\n\n if (\n p.depositor_graph_created !== undefined &&\n typeof p.depositor_graph_created !== \"boolean\"\n ) {\n throw new VpResponseValidationError(\n `VP response validation failed: \"progress.presigning.depositor_graph_created\" must be a boolean if present, got ${preview(p.depositor_graph_created)}`,\n );\n }\n\n if (\n p.vk_challenger_presigning_completed !== undefined &&\n typeof p.vk_challenger_presigning_completed !== \"number\"\n ) {\n throw new VpResponseValidationError(\n `VP response validation failed: \"progress.presigning.vk_challenger_presigning_completed\" must be a number if present, got ${preview(p.vk_challenger_presigning_completed)}`,\n );\n }\n\n if (\n p.vk_challenger_presigning_total !== undefined &&\n typeof p.vk_challenger_presigning_total !== \"number\"\n ) {\n throw new VpResponseValidationError(\n `VP response validation failed: \"progress.presigning.vk_challenger_presigning_total\" must be a number if present, got ${preview(p.vk_challenger_presigning_total)}`,\n );\n }\n}\n\n/**\n * Validate a getPeginStatus response.\n *\n * Throws if the status field is not a recognized DaemonStatus value.\n */\nexport function validateGetPeginStatusResponse(\n response: unknown,\n): asserts response is GetPeginStatusResponse {\n if (response === null || typeof response !== \"object\") {\n throw new VpResponseValidationError(\n `VP response validation failed: getPeginStatus response is not an object`,\n );\n }\n\n const r = response as Record<string, unknown>;\n\n if (!isNonEmptyHex(r.pegin_txid) || r.pegin_txid.length !== TXID_HEX_LEN) {\n throw new VpResponseValidationError(\n `VP response validation failed: \"pegin_txid\" must be a ${TXID_HEX_LEN}-char hex string (txid), got ${preview(r.pegin_txid)}`,\n );\n }\n\n if (typeof r.status !== \"string\") {\n throw new VpResponseValidationError(\n `VP response validation failed: \"status\" must be a string`,\n );\n }\n\n if (!DAEMON_STATUS_VALUES.has(r.status)) {\n throw new VpResponseValidationError(\n `${UNRECOGNIZED_STATUS_ERROR_PREFIX} ${preview(r.status)}. Expected one of: ${[...DAEMON_STATUS_VALUES].join(\", \")}`,\n );\n }\n\n if (\n r.progress === null ||\n typeof r.progress !== \"object\" ||\n Array.isArray(r.progress)\n ) {\n throw new VpResponseValidationError(\n `VP response validation failed: \"progress\" must be an object`,\n );\n }\n\n validatePresigningProgressFields(r.progress as Record<string, unknown>);\n\n if (typeof r.health_info !== \"string\") {\n throw new VpResponseValidationError(\n `VP response validation failed: \"health_info\" must be a string`,\n );\n }\n\n if (r.last_error !== undefined && typeof r.last_error !== \"string\") {\n throw new VpResponseValidationError(\n `VP response validation failed: \"last_error\" must be a string if present, got ${preview(r.last_error)}`,\n );\n }\n}\n\n/**\n * Validate a requestDepositorPresignTransactions response.\n */\nexport function validateRequestDepositorPresignTransactionsResponse(\n response: unknown,\n): asserts response is RequestDepositorPresignTransactionsResponse {\n if (response === null || typeof response !== \"object\") {\n throw new VpResponseValidationError(\n `VP response validation failed: requestDepositorPresignTransactions response is not an object`,\n );\n }\n\n const r = response as Record<string, unknown>;\n\n if (!Array.isArray(r.txs)) {\n throw new VpResponseValidationError(\n `VP response validation failed: \"txs\" must be an array`,\n );\n }\n\n for (let i = 0; i < r.txs.length; i++) {\n validateClaimerTransactions(r.txs[i], `txs[${i}]`);\n }\n\n if (r.depositor_graph === null || typeof r.depositor_graph !== \"object\") {\n throw new VpResponseValidationError(\n `VP response validation failed: \"depositor_graph\" must be an object`,\n );\n }\n\n validateDepositorGraphTransactions(\n r.depositor_graph as Record<string, unknown>,\n );\n}\n\nfunction validateTransactionData(value: unknown, field: string): void {\n if (value === null || typeof value !== \"object\") {\n throw new VpResponseValidationError(\n `VP response validation failed: \"${field}\" must be an object`,\n );\n }\n const tx = value as Record<string, unknown>;\n assertNonEmptyHex(tx.tx_hex, `${field}.tx_hex`);\n}\n\nfunction validateClaimerTransactions(value: unknown, field: string): void {\n if (value === null || typeof value !== \"object\") {\n throw new VpResponseValidationError(\n `VP response validation failed: \"${field}\" must be an object`,\n );\n }\n\n const tx = value as Record<string, unknown>;\n\n assertBtcPubkey(tx.claimer_pubkey, `${field}.claimer_pubkey`);\n validateTransactionData(tx.claim_tx, `${field}.claim_tx`);\n validateTransactionData(tx.assert_tx, `${field}.assert_tx`);\n validateTransactionData(tx.payout_tx, `${field}.payout_tx`);\n assertNonEmptyString(tx.payout_psbt, `${field}.payout_psbt`);\n}\n\nfunction validateChallengeAssertConnectorData(\n value: unknown,\n field: string,\n): void {\n if (value === null || typeof value !== \"object\") {\n throw new VpResponseValidationError(\n `VP response validation failed: \"${field}\" must be an object`,\n );\n }\n\n const c = value as Record<string, unknown>;\n assertNonEmptyString(c.wots_pks_json, `${field}.wots_pks_json`);\n assertNonEmptyString(c.gc_wots_keys_json, `${field}.gc_wots_keys_json`);\n}\n\nfunction validatePresignDataPerChallenger(value: unknown, field: string): void {\n if (value === null || typeof value !== \"object\") {\n throw new VpResponseValidationError(\n `VP response validation failed: \"${field}\" must be an object`,\n );\n }\n\n const d = value as Record<string, unknown>;\n\n assertBtcPubkey(d.challenger_pubkey, `${field}.challenger_pubkey`);\n validateTransactionData(\n d.challenge_assert_x_tx,\n `${field}.challenge_assert_x_tx`,\n );\n validateTransactionData(\n d.challenge_assert_y_tx,\n `${field}.challenge_assert_y_tx`,\n );\n validateTransactionData(d.nopayout_tx, `${field}.nopayout_tx`);\n assertNonEmptyString(d.nopayout_psbt, `${field}.nopayout_psbt`);\n\n if (!Array.isArray(d.challenge_assert_connectors)) {\n throw new VpResponseValidationError(\n `VP response validation failed: \"${field}.challenge_assert_connectors\" must be an array`,\n );\n }\n\n if (\n d.challenge_assert_connectors.length !==\n CHALLENGE_ASSERT_CONNECTORS_PER_CHALLENGER\n ) {\n throw new VpResponseValidationError(\n `VP response validation failed: \"${field}.challenge_assert_connectors\" must have exactly ${CHALLENGE_ASSERT_CONNECTORS_PER_CHALLENGER} entries, got ${d.challenge_assert_connectors.length}`,\n );\n }\n\n for (let i = 0; i < d.challenge_assert_connectors.length; i++) {\n validateChallengeAssertConnectorData(\n d.challenge_assert_connectors[i],\n `${field}.challenge_assert_connectors[${i}]`,\n );\n }\n\n if (!Array.isArray(d.output_label_hashes)) {\n throw new VpResponseValidationError(\n `VP response validation failed: \"${field}.output_label_hashes\" must be an array`,\n );\n }\n\n // Each entry is a SHA-256 digest. The presign fingerprint hashes these\n // unframed, so a wrong length must fail here, before any signing prompt.\n for (let i = 0; i < d.output_label_hashes.length; i++) {\n const hash: unknown = d.output_label_hashes[i];\n if (!isNonEmptyHex(hash) || hash.length !== LABEL_HASH_HEX_LEN) {\n throw new VpResponseValidationError(\n `VP response validation failed: \"${field}.output_label_hashes[${i}]\" must be a ${LABEL_HASH_HEX_LEN}-char hex string, got ${preview(hash)}`,\n );\n }\n }\n}\n\n/**\n * Validate a requestDepositorClaimerArtifacts response.\n */\nexport function validateRequestDepositorClaimerArtifactsResponse(\n response: unknown,\n): asserts response is RequestDepositorClaimerArtifactsResponse {\n if (response === null || typeof response !== \"object\") {\n throw new VpResponseValidationError(\n `VP response validation failed: requestDepositorClaimerArtifacts response is not an object`,\n );\n }\n\n const r = response as Record<string, unknown>;\n\n if (!isNonEmptyString(r.tx_graph_json)) {\n throw new VpResponseValidationError(\n `VP response validation failed: \"tx_graph_json\" must be a non-empty string, got ${preview(r.tx_graph_json)}`,\n );\n }\n\n if (!isNonEmptyHex(r.verifying_key_hex)) {\n throw new VpResponseValidationError(\n `VP response validation failed: \"verifying_key_hex\" must be a non-empty hex string, got ${preview(r.verifying_key_hex)}`,\n );\n }\n\n if (\n r.babe_sessions === null ||\n typeof r.babe_sessions !== \"object\" ||\n Array.isArray(r.babe_sessions)\n ) {\n throw new VpResponseValidationError(\n `VP response validation failed: \"babe_sessions\" must be an object`,\n );\n }\n\n const sessionEntries = Object.entries(\n r.babe_sessions as Record<string, unknown>,\n );\n if (sessionEntries.length === 0) {\n throw new VpResponseValidationError(\n `VP response validation failed: \"babe_sessions\" must contain at least one challenger entry`,\n );\n }\n\n for (const [key, session] of sessionEntries) {\n assertBtcPubkey(key, `babe_sessions[\"${key}\"]`);\n if (session === null || typeof session !== \"object\") {\n throw new VpResponseValidationError(\n `VP response validation failed: \"babe_sessions.${key}\" must be an object`,\n );\n }\n const s = session as Record<string, unknown>;\n if (!isNonEmptyHex(s.decryptor_artifacts_hex)) {\n throw new VpResponseValidationError(\n `VP response validation failed: \"babe_sessions.${key}.decryptor_artifacts_hex\" must be a non-empty hex string, got ${preview(s.decryptor_artifacts_hex)}`,\n );\n }\n }\n}\n\n/**\n * Validate a single pegout status payload. Embedded by\n * `validateBatchGetPegoutStatusResponse`. Mirrors btc-vault\n * `crates/vaultd/src/rpc/server/pegout_status.rs::GetPegoutStatusResponse`.\n */\nexport function validateGetPegoutStatusResponse(\n response: unknown,\n): asserts response is GetPegoutStatusResponse {\n if (response === null || typeof response !== \"object\") {\n throw new VpResponseValidationError(\n `VP response validation failed: pegout status payload is not an object`,\n );\n }\n\n const r = response as Record<string, unknown>;\n\n if (!isNonEmptyHex(r.pegin_txid) || r.pegin_txid.length !== TXID_HEX_LEN) {\n throw new VpResponseValidationError(\n `VP response validation failed: \"pegin_txid\" must be a ${TXID_HEX_LEN}-char hex string (txid), got ${preview(r.pegin_txid)}`,\n );\n }\n\n if (typeof r.found !== \"boolean\") {\n throw new VpResponseValidationError(\n `VP response validation failed: \"found\" must be a boolean, got ${preview(r.found)}`,\n );\n }\n\n // `claimer` is `Option<ClaimerPegoutStatus>` server-side; null when absent.\n if (r.claimer !== null) {\n if (typeof r.claimer !== \"object\") {\n throw new VpResponseValidationError(\n `VP response validation failed: \"claimer\" must be an object or null, got ${preview(r.claimer)}`,\n );\n }\n validateClaimerPegoutStatus(r.claimer as Record<string, unknown>);\n }\n\n // `challengers: Vec<ChallengerStatus>` server-side; always present (possibly empty).\n if (!Array.isArray(r.challengers)) {\n throw new VpResponseValidationError(\n `VP response validation failed: \"challengers\" must be an array, got ${preview(r.challengers)}`,\n );\n }\n for (let i = 0; i < r.challengers.length; i++) {\n validateChallengerStatus(r.challengers[i], i);\n }\n}\n\nfunction validateClaimerPegoutStatus(value: Record<string, unknown>): void {\n assertNonEmptyString(value.status, \"claimer.status\");\n if (typeof value.failed !== \"boolean\") {\n throw new VpResponseValidationError(\n `VP response validation failed: \"claimer.failed\" must be a boolean, got ${preview(value.failed)}`,\n );\n }\n assertNonEmptyString(value.claim_txid, \"claimer.claim_txid\");\n assertNonEmptyString(value.claimer_pubkey, \"claimer.claimer_pubkey\");\n assertNonEmptyString(value.assert_txid, \"claimer.assert_txid\");\n if (typeof value.created_at !== \"number\") {\n throw new VpResponseValidationError(\n `VP response validation failed: \"claimer.created_at\" must be a number, got ${preview(value.created_at)}`,\n );\n }\n if (typeof value.updated_at !== \"number\") {\n throw new VpResponseValidationError(\n `VP response validation failed: \"claimer.updated_at\" must be a number, got ${preview(value.updated_at)}`,\n );\n }\n}\n\nfunction validateChallengerStatus(value: unknown, index: number): void {\n if (value === null || typeof value !== \"object\") {\n throw new VpResponseValidationError(\n `VP response validation failed: \"challengers[${index}]\" must be an object, got ${preview(value)}`,\n );\n }\n const c = value as Record<string, unknown>;\n assertNonEmptyString(c.status, `challengers[${index}].status`);\n assertNonEmptyString(c.claim_txid, `challengers[${index}].claim_txid`);\n assertNonEmptyString(c.claimer_pubkey, `challengers[${index}].claimer_pubkey`);\n assertNullableString(c.assert_txid, `challengers[${index}].assert_txid`);\n assertNullableString(\n c.challenge_assert_x_txid,\n `challengers[${index}].challenge_assert_x_txid`,\n );\n assertNullableString(\n c.challenge_assert_y_txid,\n `challengers[${index}].challenge_assert_y_txid`,\n );\n assertNullableString(c.nopayout_txid, `challengers[${index}].nopayout_txid`);\n if (typeof c.created_at !== \"number\") {\n throw new VpResponseValidationError(\n `VP response validation failed: \"challengers[${index}].created_at\" must be a number, got ${preview(c.created_at)}`,\n );\n }\n if (typeof c.updated_at !== \"number\") {\n throw new VpResponseValidationError(\n `VP response validation failed: \"challengers[${index}].updated_at\" must be a number, got ${preview(c.updated_at)}`,\n );\n }\n}\n\nfunction assertNullableString(value: unknown, field: string): void {\n if (value !== null && typeof value !== \"string\") {\n throw new VpResponseValidationError(\n `VP response validation failed: \"${field}\" must be a string or null, got ${preview(value)}`,\n );\n }\n}\n\n/**\n * Validate a `batchGetPeginStatus` response. Per-result envelope shape:\n * `{ pegin_txid, result: GetPeginStatusResponse | null, error: string | null }`.\n * The inner result (when non-null) is validated via the single-item validator.\n * An entry whose inner result fails validation is replaced by an error entry;\n * the other entries are kept.\n */\nexport function validateBatchGetPeginStatusResponse(\n response: unknown,\n): asserts response is BatchGetPeginStatusResponse {\n validateBatchEnvelope(response, \"batchGetPeginStatus\", (entry) => {\n if (entry.result !== null) {\n validateGetPeginStatusResponse(entry.result);\n }\n });\n}\n\n/** Validate a `batchGetPegoutStatus` response. Same envelope as peginStatus. */\nexport function validateBatchGetPegoutStatusResponse(\n response: unknown,\n): asserts response is BatchGetPegoutStatusResponse {\n validateBatchEnvelope(response, \"batchGetPegoutStatus\", (entry) => {\n if (entry.result !== null) {\n validateGetPegoutStatusResponse(entry.result);\n }\n });\n}\n\ninterface BatchResultEnvelope {\n pegin_txid: string;\n result: unknown;\n error: string | null;\n}\n\nfunction validateBatchEnvelope(\n response: unknown,\n rpcName: string,\n validateInnerResult: (entry: BatchResultEnvelope, index: number) => void,\n): void {\n if (response === null || typeof response !== \"object\") {\n throw new VpResponseValidationError(\n `VP response validation failed: ${rpcName} response is not an object`,\n );\n }\n const r = response as Record<string, unknown>;\n if (!Array.isArray(r.results)) {\n throw new VpResponseValidationError(\n `VP response validation failed: \"${rpcName}.results\" must be an array, got ${preview(r.results)}`,\n );\n }\n for (let i = 0; i < r.results.length; i++) {\n const entry = r.results[i];\n if (entry === null || typeof entry !== \"object\") {\n throw new VpResponseValidationError(\n `VP response validation failed: \"${rpcName}.results[${i}]\" must be an object, got ${preview(entry)}`,\n );\n }\n const e = entry as Record<string, unknown>;\n if (\n !isNonEmptyHex(e.pegin_txid) ||\n e.pegin_txid.length !== TXID_HEX_LEN\n ) {\n throw new VpResponseValidationError(\n `VP response validation failed: \"${rpcName}.results[${i}].pegin_txid\" must be a ${TXID_HEX_LEN}-char hex string, got ${preview(e.pegin_txid)}`,\n );\n }\n if (e.error !== null && typeof e.error !== \"string\") {\n throw new VpResponseValidationError(\n `VP response validation failed: \"${rpcName}.results[${i}].error\" must be a string or null, got ${preview(e.error)}`,\n );\n }\n // Exactly one of `result` / `error` must be populated. The server only\n // ever sets one per item; treating both-null as a protocol violation\n // surfaces server bugs early instead of letting them silently degrade.\n if (e.result === null && e.error === null) {\n throw new VpResponseValidationError(\n `VP response validation failed: \"${rpcName}.results[${i}]\" has neither \"result\" nor \"error\" populated`,\n );\n }\n if (e.result !== null && e.error !== null) {\n throw new VpResponseValidationError(\n `VP response validation failed: \"${rpcName}.results[${i}]\" has both \"result\" and \"error\" populated`,\n );\n }\n // Isolate a bad inner result to its own entry, so one malformed or\n // unknown-status entry does not void the status of its siblings.\n try {\n validateInnerResult(e as unknown as BatchResultEnvelope, i);\n } catch (error) {\n if (!(error instanceof VpResponseValidationError)) throw error;\n r.results[i] = {\n pegin_txid: e.pegin_txid,\n result: null,\n error: error.detail,\n };\n }\n }\n}\n\nfunction validateDepositorGraphTransactions(\n graph: Record<string, unknown>,\n): void {\n validateTransactionData(graph.claim_tx, \"depositor_graph.claim_tx\");\n validateTransactionData(graph.assert_tx, \"depositor_graph.assert_tx\");\n validateTransactionData(graph.payout_tx, \"depositor_graph.payout_tx\");\n assertNonEmptyString(graph.payout_psbt, \"depositor_graph.payout_psbt\");\n\n if (!Array.isArray(graph.challenger_presign_data)) {\n throw new VpResponseValidationError(\n `VP response validation failed: \"depositor_graph.challenger_presign_data\" must be an array`,\n );\n }\n\n for (let i = 0; i < graph.challenger_presign_data.length; i++) {\n validatePresignDataPerChallenger(\n graph.challenger_presign_data[i],\n `depositor_graph.challenger_presign_data[${i}]`,\n );\n }\n\n if (typeof graph.offchain_params_version !== \"number\") {\n throw new VpResponseValidationError(\n `VP response validation failed: \"depositor_graph.offchain_params_version\" must be a number`,\n );\n }\n}\n","/**\n * JSON-RPC client for the Vault Provider API.\n *\n * Wraps {@link JsonRpcClient} with typed methods matching the\n * `vaultProvider_*` RPC namespace defined in the btc-vault pegin spec.\n *\n * Implements the narrow service interfaces (PeginStatusReader, WotsKeySubmitter,\n * PresignClient, ClaimerArtifactsReader) so it can be passed directly to\n * any deposit protocol service function.\n *\n * @see https://github.com/babylonlabs-io/btc-vault/blob/main/docs/pegin.md\n */\n\nimport type { PeginStatusReader, WotsKeySubmitter, PresignClient, ClaimerArtifactsReader } from \"../../services/deposit/interfaces\";\n\nimport {\n type BearerTokenProvider,\n JsonRpcClient,\n type JsonRpcClientConfig,\n} from \"./json-rpc-client\";\nimport type {\n BatchGetPeginStatusParams,\n BatchGetPeginStatusResponse,\n BatchGetPegoutStatusParams,\n BatchGetPegoutStatusResponse,\n GetPeginStatusParams,\n GetPeginStatusResponse,\n RequestDepositorClaimerArtifactsParams,\n RequestDepositorClaimerArtifactsResponse,\n RequestDepositorPresignTransactionsParams,\n RequestDepositorPresignTransactionsResponse,\n SubmitDepositorPresignaturesParams,\n SubmitDepositorWotsKeyParams,\n} from \"./types\";\nimport {\n validateBatchGetPeginStatusResponse,\n validateBatchGetPegoutStatusResponse,\n validateGetPeginStatusResponse,\n validateRequestDepositorClaimerArtifactsResponse,\n validateRequestDepositorPresignTransactionsResponse,\n} from \"./validators\";\n\nexport interface VaultProviderRpcClientOptions {\n /** Timeout in milliseconds per request (default: 60000) */\n timeout?: number;\n /** Number of retry attempts for safe methods (default: 3) */\n retries?: number;\n /** Initial retry delay in milliseconds (default: 1000) */\n retryDelay?: number;\n /**\n * Custom retry predicate. Default retries only the idempotent read\n * methods: `getPeginStatus`, `batchGetPeginStatus`, `batchGetPegoutStatus`,\n * `requestDepositorPresignTransactions`.\n */\n retryableFor?: (method: string) => boolean;\n /** Custom headers. */\n headers?: Record<string, string>;\n /**\n * Per-request bearer-token source. A non-null return attaches\n * `Authorization: Bearer <token>`; `null` skips auth. Wire a\n * {@link VpTokenProvider} for depositor-gated methods.\n */\n tokenProvider?: BearerTokenProvider;\n /** Maximum response body size, in bytes, for typed JSON-RPC calls */\n maxResponseBytes?: number;\n}\n\nconst DEFAULT_TIMEOUT_MS = 60_000;\n\n/**\n * Concrete VP RPC client implementing all service interfaces.\n *\n * Usage:\n * ```ts\n * const client = new VaultProviderRpcClient(\"https://vp.example.com/rpc\");\n * const status = await client.getPeginStatus({ pegin_txid: \"abc...\" });\n * ```\n */\nexport class VaultProviderRpcClient\n implements PeginStatusReader, WotsKeySubmitter, PresignClient, ClaimerArtifactsReader\n{\n private client: JsonRpcClient;\n\n constructor(baseUrl: string, options?: VaultProviderRpcClientOptions) {\n const config: JsonRpcClientConfig = {\n baseUrl,\n timeout: options?.timeout ?? DEFAULT_TIMEOUT_MS,\n retries: options?.retries,\n retryDelay: options?.retryDelay,\n retryableFor: options?.retryableFor,\n headers: options?.headers,\n tokenProvider: options?.tokenProvider,\n maxResponseBytes: options?.maxResponseBytes,\n };\n this.client = new JsonRpcClient(config);\n }\n\n /**\n * Request the payout/claim/assert transactions that the depositor\n * needs to pre-sign before the vault can be activated on Bitcoin.\n */\n async requestDepositorPresignTransactions(\n params: RequestDepositorPresignTransactionsParams,\n signal?: AbortSignal,\n ): Promise<RequestDepositorPresignTransactionsResponse> {\n const response = await this.client.call<\n RequestDepositorPresignTransactionsParams,\n unknown\n >(\"vaultProvider_requestDepositorPresignTransactions\", params, signal);\n validateRequestDepositorPresignTransactionsResponse(response);\n return response;\n }\n\n /**\n * Submit the depositor's pre-signatures for the payout transactions\n * and the depositor-as-claimer graph.\n */\n async submitDepositorPresignatures(\n params: SubmitDepositorPresignaturesParams,\n signal?: AbortSignal,\n ): Promise<void> {\n return this.client.call<SubmitDepositorPresignaturesParams, void>(\n \"vaultProvider_submitDepositorPresignatures\",\n params,\n signal,\n );\n }\n\n /**\n * Submit the depositor's WOTS public key to the vault provider.\n * Called after the pegin is finalized on Ethereum, when the VP is in\n * `PendingDepositorWotsPK` status.\n */\n async submitDepositorWotsKey(\n params: SubmitDepositorWotsKeyParams,\n signal?: AbortSignal,\n ): Promise<void> {\n return this.client.call<SubmitDepositorWotsKeyParams, void>(\n \"vaultProvider_submitDepositorWotsKey\",\n params,\n signal,\n );\n }\n\n /**\n * Request the BaBe DecryptorArtifacts needed for the depositor to\n * independently evaluate garbled circuits during a challenge.\n */\n async requestDepositorClaimerArtifacts(\n params: RequestDepositorClaimerArtifactsParams,\n signal?: AbortSignal,\n ): Promise<RequestDepositorClaimerArtifactsResponse> {\n const response = await this.client.call<\n RequestDepositorClaimerArtifactsParams,\n unknown\n >(\"vaultProvider_requestDepositorClaimerArtifacts\", params, signal);\n validateRequestDepositorClaimerArtifactsResponse(response);\n return response;\n }\n\n /** Get the current pegin status from the vault provider daemon. */\n async getPeginStatus(\n params: GetPeginStatusParams,\n signal?: AbortSignal,\n ): Promise<GetPeginStatusResponse> {\n const response = await this.client.call<GetPeginStatusParams, unknown>(\n \"vaultProvider_getPeginStatus\",\n params,\n signal,\n );\n validateGetPeginStatusResponse(response);\n return response;\n }\n\n /**\n * Get pegin status for many txids in one round trip. Per-result envelope\n * isolates per-pegin failures from the overall RPC. Caller must chunk\n * inputs at `VP_BATCH_MAX_SIZE`.\n */\n async batchGetPeginStatus(\n params: BatchGetPeginStatusParams,\n signal?: AbortSignal,\n ): Promise<BatchGetPeginStatusResponse> {\n const response = await this.client.call<\n BatchGetPeginStatusParams,\n unknown\n >(\"vaultProvider_batchGetPeginStatus\", params, signal);\n validateBatchGetPeginStatusResponse(response);\n return response;\n }\n\n /**\n * Get pegout status for many txids in one round trip. Same per-result\n * envelope semantics as `batchGetPeginStatus`.\n */\n async batchGetPegoutStatus(\n params: BatchGetPegoutStatusParams,\n signal?: AbortSignal,\n ): Promise<BatchGetPegoutStatusResponse> {\n const response = await this.client.call<\n BatchGetPegoutStatusParams,\n unknown\n >(\"vaultProvider_batchGetPegoutStatus\", params, signal);\n validateBatchGetPegoutStatusResponse(response);\n return response;\n }\n}\n","/**\n * Defensive helper for attributing per-item results in a VP batch RPC\n * response back to the requested txids. The server promises 1:1 ordered\n * results, but we don't trust that promise — a server bug could duplicate,\n * skip, or scramble items, and silent attribution-by-array-index would\n * mask the bug.\n *\n * Lowercases all txids on both sides to absorb case mismatch (the FE\n * strips `0x` but doesn't otherwise normalize).\n *\n * @module tbv/core/clients/vault-provider/batchAttribution\n */\n\n/** Per-item entry in a VP batch response. */\nexport interface BatchResultEntry<T> {\n pegin_txid: string;\n result: T | null;\n error: string | null;\n}\n\n/** Output of {@link attributeBatchResults}. */\nexport interface BatchAttributionResult<T> {\n /** Lowercase requested txid -> per-item envelope. */\n byTxid: Map<string, { result: T | null; error: string | null }>;\n /** Requested txids that did not appear in the response. */\n missing: string[];\n /** Echoed txids that were not in the request — logged + dropped. */\n unexpected: string[];\n /** Echoed txids that appeared more than once — first kept, rest dropped. */\n duplicate: string[];\n}\n\n/**\n * Attribute batch results to requested txids defensively.\n *\n * Both `requestedTxids` and the echoed `pegin_txid` field on each result\n * are lowercased before lookup. Duplicates and unexpected echoes are\n * surfaced so callers can flag the affected items as errored rather than\n * silently overwriting state.\n *\n * `requestedTxids` may contain duplicates; they are de-duplicated for the\n * purposes of map keys (each unique txid becomes a single map entry).\n */\nexport function attributeBatchResults<T>(\n requestedTxids: string[],\n results: ReadonlyArray<BatchResultEntry<T>>,\n): BatchAttributionResult<T> {\n const requestedSet = new Set<string>();\n for (const txid of requestedTxids) {\n requestedSet.add(txid.toLowerCase());\n }\n\n const byTxid = new Map<\n string,\n { result: T | null; error: string | null }\n >();\n const seen = new Set<string>();\n const duplicate: string[] = [];\n const unexpected: string[] = [];\n\n for (const entry of results) {\n const lower = entry.pegin_txid.toLowerCase();\n if (!requestedSet.has(lower)) {\n unexpected.push(lower);\n continue;\n }\n if (seen.has(lower)) {\n duplicate.push(lower);\n continue;\n }\n seen.add(lower);\n byTxid.set(lower, { result: entry.result, error: entry.error });\n }\n\n const missing: string[] = [];\n for (const txid of requestedSet) {\n if (!seen.has(txid)) missing.push(txid);\n }\n\n return { byTxid, missing, unexpected, duplicate };\n}\n","/**\n * Generic chunk + attribute + dispatch loop for VP batch RPCs.\n *\n * Wraps {@link attributeBatchResults} with chunking and per-callback\n * dispatch so the FE polling hooks (and any future SDK consumer) only\n * have to declare per-item handlers — chunking by `VP_BATCH_MAX_SIZE`,\n * lowercase txid normalization, missing/duplicate/unexpected\n * surfacing, and the duplicate-skip invariant in the byTxid loop are\n * all owned here.\n *\n * @module tbv/core/clients/vault-provider/batchPoll\n */\n\nimport {\n attributeBatchResults,\n type BatchResultEntry,\n} from \"./batchAttribution\";\nimport { VP_BATCH_MAX_SIZE } from \"./types\";\n\nexport interface BatchPollByProviderOptions<TItem, TResult> {\n /** Items to poll for this provider, e.g. `DepositToPoll[]`. */\n items: TItem[];\n /** Extract the canonical txid for each item. Helper lowercases it. */\n getTxid: (item: TItem) => string;\n /**\n * Per-chunk RPC call. Receives lowercased txids; returns the batch\n * envelope. Caller wraps `rpcClient.batchGet*Status({ pegin_txids })`.\n */\n batchCall: (\n txids: string[],\n ) => Promise<{ results: ReadonlyArray<BatchResultEntry<TResult>> }>;\n /**\n * Handle a per-item envelope. Exactly one of `result` / `error` is\n * populated (validator invariant). Caller decides UI state, logging,\n * etc. Not invoked for txids surfaced via {@link onDuplicate}.\n *\n * Note: `envelope.pegin_txid` is the lowercased txid the helper\n * sent in the request, not whatever case/encoding the server echoed.\n */\n onItem: (item: TItem, envelope: BatchResultEntry<TResult>) => void;\n /** Server omitted this item from the response. */\n onMissing: (item: TItem) => void;\n /** Server returned this item more than once. Caller picks UI state. */\n onDuplicate: (item: TItem) => void;\n /**\n * Optional aggregate signal for an entire chunk where the server\n * returned duplicates. Fires once per chunk (only if `count > 0`)\n * AFTER all per-item `onDuplicate` dispatches. Caller typically logs\n * the count alongside the provider name.\n */\n onDuplicateBatch?: (count: number) => void;\n /**\n * The whole chunk's RPC call failed (transport or response\n * validation). Receives the chunk and the error. Caller decides how\n * to project that onto per-item state.\n */\n onWholeBatchError: (chunk: TItem[], error: unknown) => void;\n /**\n * Server returned txids that were not in the request. Caller\n * typically logs the count for observability — there's no recovery\n * action since the original request items are unaffected. Optional;\n * defaults to no-op.\n */\n onUnexpected?: (echoedTxids: string[]) => void;\n /**\n * Maximum items per RPC call. Defaults to {@link VP_BATCH_MAX_SIZE}.\n * Exposed for tests so chunking can be exercised without 50+\n * fixtures.\n */\n batchSize?: number;\n}\n\nexport async function batchPollByProvider<TItem, TResult>(\n options: BatchPollByProviderOptions<TItem, TResult>,\n): Promise<void> {\n const {\n items,\n getTxid,\n batchCall,\n onItem,\n onMissing,\n onDuplicate,\n onDuplicateBatch,\n onWholeBatchError,\n onUnexpected,\n batchSize = VP_BATCH_MAX_SIZE,\n } = options;\n\n if (!Number.isInteger(batchSize) || batchSize <= 0) {\n throw new Error(\n `batchPollByProvider: batchSize must be a positive integer, got ${batchSize}`,\n );\n }\n\n for (let i = 0; i < items.length; i += batchSize) {\n const chunk = items.slice(i, i + batchSize);\n const txidToItem = new Map<string, TItem>();\n const txids: string[] = [];\n for (const item of chunk) {\n const lowerTxid = getTxid(item).toLowerCase();\n txidToItem.set(lowerTxid, item);\n txids.push(lowerTxid);\n }\n\n // Both the RPC call and attribution sit inside the same try/catch\n // so a malformed-batch validator throw is routed through\n // `onWholeBatchError` rather than aborting the polling pass.\n let attribution;\n try {\n const response = await batchCall(txids);\n attribution = attributeBatchResults<TResult>(txids, response.results);\n } catch (error) {\n onWholeBatchError(chunk, error);\n continue;\n }\n\n if (onUnexpected && attribution.unexpected.length > 0) {\n onUnexpected(attribution.unexpected);\n }\n\n const duplicateTxids = new Set(attribution.duplicate);\n for (const txid of duplicateTxids) {\n const item = txidToItem.get(txid);\n if (item) onDuplicate(item);\n }\n if (onDuplicateBatch && duplicateTxids.size > 0) {\n onDuplicateBatch(duplicateTxids.size);\n }\n for (const txid of attribution.missing) {\n const item = txidToItem.get(txid);\n if (item) onMissing(item);\n }\n for (const [txid, envelope] of attribution.byTxid) {\n // Skip duplicates — already dispatched via onDuplicate above.\n if (duplicateTxids.has(txid)) continue;\n const item = txidToItem.get(txid);\n if (!item) continue;\n onItem(item, {\n pegin_txid: txid,\n result: envelope.result,\n error: envelope.error,\n });\n }\n }\n}\n"],"names":["DAEMON_STATUS_VALUES","DaemonStatus","VP_ERROR_PREVIEW_MAX_LEN","preview","value","_a","UNRECOGNIZED_STATUS_ERROR_PREFIX","isUnrecognizedDaemonStatusError","error","VP_VALIDATION_USER_MESSAGE","VpResponseValidationError","detail","__publicField","TXID_HEX_LEN","LABEL_HASH_HEX_LEN","isNonEmptyHex","HEX_RE","isNonEmptyString","assertNonEmptyHex","field","assertNonEmptyString","assertBtcPubkey","X_ONLY_PUBKEY_HEX_LEN","COMPRESSED_PUBKEY_HEX_LEN","validatePresigningProgressFields","progress","presigning","p","validateGetPeginStatusResponse","response","r","validateRequestDepositorPresignTransactionsResponse","i","validateClaimerTransactions","validateDepositorGraphTransactions","validateTransactionData","tx","validateChallengeAssertConnectorData","c","validatePresignDataPerChallenger","d","CHALLENGE_ASSERT_CONNECTORS_PER_CHALLENGER","hash","validateRequestDepositorClaimerArtifactsResponse","sessionEntries","key","session","s","validateGetPegoutStatusResponse","validateClaimerPegoutStatus","validateChallengerStatus","index","assertNullableString","validateBatchGetPeginStatusResponse","validateBatchEnvelope","entry","validateBatchGetPegoutStatusResponse","rpcName","validateInnerResult","e","graph","DEFAULT_TIMEOUT_MS","VaultProviderRpcClient","baseUrl","options","config","JsonRpcClient","params","signal","attributeBatchResults","requestedTxids","results","requestedSet","txid","byTxid","seen","duplicate","unexpected","lower","missing","batchPollByProvider","items","getTxid","batchCall","onItem","onMissing","onDuplicate","onDuplicateBatch","onWholeBatchError","onUnexpected","batchSize","VP_BATCH_MAX_SIZE","chunk","txidToItem","txids","item","lowerTxid","attribution","duplicateTxids","envelope"],"mappings":";;;;;;AA4BA,MAAMA,IAAuB,IAAI,IAAY,OAAO,OAAOC,CAAY,CAAC,GAElEC,IAA2B;AAEjC,SAASC,EAAQC,GAAwB;;AACvC,WACEC,IAAA,KAAK,UAAUD,CAAK,MAApB,gBAAAC,EAAuB,MAAM,GAAGH,OAA6B;AAEjE;AAEA,MAAMI,IACJ;AAOK,SAASC,GAAgCC,GAAwB;AACtE,SAAOA,EAAM,WAAWF,CAAgC;AAC1D;AAEA,MAAMG,IACJ;AAQK,MAAMC,UAAkC,MAAM;AAAA,EAGnD,YAAYC,GAAgB;AAC1B,UAAMF,CAA0B;AAHzB,IAAAG,EAAA;AAIP,SAAK,OAAO,6BACZ,KAAK,SAASD;AAAA,EAChB;AACF;AAGA,MAAME,IAAe,IAGfC,IAAqB;AAE3B,SAASC,EAAcX,GAAiC;AACtD,SAAO,OAAOA,KAAU,YAAYA,EAAM,SAAS,KAAKY,EAAO,KAAKZ,CAAK;AAC3E;AAEA,SAASa,EAAiBb,GAAiC;AACzD,SAAO,OAAOA,KAAU,YAAYA,EAAM,SAAS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