@babylonlabs-io/ts-sdk 0.33.2 → 0.33.4
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/BTCVaultRegistry.abi-DbJ5lsFJ.js +417 -0
- package/dist/BTCVaultRegistry.abi-DbJ5lsFJ.js.map +1 -0
- package/dist/BTCVaultRegistry.abi-ZdPpION2.cjs +2 -0
- package/dist/BTCVaultRegistry.abi-ZdPpION2.cjs.map +1 -0
- package/dist/PayoutManager-C9XHKZ5j.js +200 -0
- package/dist/PayoutManager-C9XHKZ5j.js.map +1 -0
- package/dist/PayoutManager-DDnNB0mj.cjs +2 -0
- package/dist/PayoutManager-DDnNB0mj.cjs.map +1 -0
- package/dist/PeginManager-BXg2S1mH.cjs +2 -0
- package/dist/PeginManager-BXg2S1mH.cjs.map +1 -0
- package/dist/{PeginManager-BtXhdqkm.js → PeginManager-C5HaMAcw.js} +367 -480
- package/dist/PeginManager-C5HaMAcw.js.map +1 -0
- package/dist/ProtocolParams.abi-BmvHwQJV.cjs +2 -0
- package/dist/ProtocolParams.abi-BmvHwQJV.cjs.map +1 -0
- package/dist/ProtocolParams.abi-DXu8L0Fn.js +382 -0
- package/dist/ProtocolParams.abi-DXu8L0Fn.js.map +1 -0
- package/dist/{bitcoin-0_T6KJON.js → bitcoin-B0S8SHCX.js} +24 -20
- package/dist/bitcoin-B0S8SHCX.js.map +1 -0
- package/dist/bitcoin-B3aqjuMP.cjs +2 -0
- package/dist/bitcoin-B3aqjuMP.cjs.map +1 -0
- package/dist/buildAndBroadcastRefund-CIPPpchL.cjs +2 -0
- package/dist/buildAndBroadcastRefund-CIPPpchL.cjs.map +1 -0
- package/dist/buildAndBroadcastRefund-D_QlvCsw.js +777 -0
- package/dist/buildAndBroadcastRefund-D_QlvCsw.js.map +1 -0
- package/dist/challengeAssert-BzxQmdZy.js +128 -0
- package/dist/challengeAssert-BzxQmdZy.js.map +1 -0
- package/dist/challengeAssert-Yyyj-EdR.cjs +2 -0
- package/dist/challengeAssert-Yyyj-EdR.cjs.map +1 -0
- package/dist/errors-9AkghWyk.js +22 -0
- package/dist/errors-9AkghWyk.js.map +1 -0
- package/dist/errors-BP73_stm.cjs +2 -0
- package/dist/errors-BP73_stm.cjs.map +1 -0
- package/dist/errors-Bu0H-dZD.cjs +2 -0
- package/dist/errors-Bu0H-dZD.cjs.map +1 -0
- package/dist/errors-CznAK5NB.js +96 -0
- package/dist/errors-CznAK5NB.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +156 -146
- package/dist/index.js.map +1 -1
- package/dist/mempoolApi-CAIge7Nj.js +205 -0
- package/dist/mempoolApi-CAIge7Nj.js.map +1 -0
- package/dist/mempoolApi-YNkKjQCU.cjs +2 -0
- package/dist/mempoolApi-YNkKjQCU.cjs.map +1 -0
- package/dist/noPayout-BXeUw0Qq.cjs +2 -0
- package/dist/noPayout-BXeUw0Qq.cjs.map +1 -0
- package/dist/noPayout-DBX6G96_.js +141 -0
- package/dist/noPayout-DBX6G96_.js.map +1 -0
- package/dist/payout-BNFMBXS6.js +193 -0
- package/dist/payout-BNFMBXS6.js.map +1 -0
- package/dist/payout-DQ_fmJUA.cjs +2 -0
- package/dist/payout-DQ_fmJUA.cjs.map +1 -0
- package/dist/peginInput-C2QPvuhR.js +177 -0
- package/dist/peginInput-C2QPvuhR.js.map +1 -0
- package/dist/peginInput-tbw9BpZy.cjs +2 -0
- package/dist/peginInput-tbw9BpZy.cjs.map +1 -0
- package/dist/peginState-BijNNT15.cjs +2 -0
- package/dist/peginState-BijNNT15.cjs.map +1 -0
- package/dist/peginState-CBAlxgXk.js +51 -0
- package/dist/peginState-CBAlxgXk.js.map +1 -0
- package/dist/psbtInputFields-2224j2ZY.js +128 -0
- package/dist/psbtInputFields-2224j2ZY.js.map +1 -0
- package/dist/psbtInputFields-B1lrwYzH.cjs +2 -0
- package/dist/psbtInputFields-B1lrwYzH.cjs.map +1 -0
- package/dist/reservation-CHUGW0F_.js +142 -0
- package/dist/reservation-CHUGW0F_.js.map +1 -0
- package/dist/reservation-ho7mjW3X.cjs +2 -0
- package/dist/reservation-ho7mjW3X.cjs.map +1 -0
- package/dist/signing-Bnsro0hE.cjs +2 -0
- package/dist/signing-Bnsro0hE.cjs.map +1 -0
- package/dist/signing-DaLvGwQe.js +16 -0
- package/dist/signing-DaLvGwQe.js.map +1 -0
- package/dist/tbv/core/clients/index.cjs +1 -1
- package/dist/tbv/core/clients/index.js +31 -30
- package/dist/tbv/core/clients/index.js.map +1 -1
- package/dist/tbv/core/contracts/index.cjs +2 -0
- package/dist/tbv/core/contracts/index.cjs.map +1 -0
- package/dist/tbv/core/contracts/index.js +14 -0
- package/dist/tbv/core/contracts/index.js.map +1 -0
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.js +156 -146
- package/dist/tbv/core/index.js.map +1 -1
- package/dist/tbv/core/managers/PayoutManager.d.ts +8 -4
- package/dist/tbv/core/managers/PayoutManager.d.ts.map +1 -1
- package/dist/tbv/core/managers/PeginManager.d.ts +15 -1
- package/dist/tbv/core/managers/PeginManager.d.ts.map +1 -1
- package/dist/tbv/core/managers/index.cjs +2 -0
- package/dist/tbv/core/managers/index.cjs.map +1 -0
- package/dist/tbv/core/managers/index.js +7 -0
- package/dist/tbv/core/managers/index.js.map +1 -0
- package/dist/tbv/core/primitives/index.cjs +1 -1
- package/dist/tbv/core/primitives/index.js +31 -29
- package/dist/tbv/core/primitives/index.js.map +1 -1
- package/dist/tbv/core/primitives/utils/bitcoin.d.ts +6 -4
- package/dist/tbv/core/primitives/utils/bitcoin.d.ts.map +1 -1
- package/dist/tbv/core/services/index.cjs +1 -1
- package/dist/tbv/core/services/index.js +28 -27
- package/dist/tbv/core/services/index.js.map +1 -1
- package/dist/tbv/core/utils/index.cjs +1 -1
- package/dist/tbv/core/utils/index.js +21 -20
- package/dist/tbv/core/utils/index.js.map +1 -1
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +156 -146
- package/dist/tbv/index.js.map +1 -1
- package/dist/testing/index.cjs +1 -1
- package/dist/testing/index.js +1 -1
- package/dist/types-ByW6nSLj.js +318 -0
- package/dist/types-ByW6nSLj.js.map +1 -0
- package/dist/types-CfCZyfid.cjs +2 -0
- package/dist/types-CfCZyfid.cjs.map +1 -0
- package/dist/vault-registry-reader-OK2V08tk.cjs +2 -0
- package/dist/vault-registry-reader-OK2V08tk.cjs.map +1 -0
- package/dist/{vault-registry-reader-eiBfG4uQ.js → vault-registry-reader-WiNVOsnD.js} +263 -840
- package/dist/vault-registry-reader-WiNVOsnD.js.map +1 -0
- package/package.json +11 -1
- package/dist/PeginManager-BtXhdqkm.js.map +0 -1
- package/dist/PeginManager-ztgWQqza.cjs +0 -2
- package/dist/PeginManager-ztgWQqza.cjs.map +0 -1
- package/dist/bitcoin-0_T6KJON.js.map +0 -1
- package/dist/bitcoin-EYBKDtEW.cjs +0 -2
- package/dist/bitcoin-EYBKDtEW.cjs.map +0 -1
- package/dist/buildAndBroadcastRefund-Ci_pVTNu.js +0 -965
- package/dist/buildAndBroadcastRefund-Ci_pVTNu.js.map +0 -1
- package/dist/buildAndBroadcastRefund-DKr9hbDn.cjs +0 -2
- package/dist/buildAndBroadcastRefund-DKr9hbDn.cjs.map +0 -1
- package/dist/challengeAssert-06GLZtV8.cjs +0 -2
- package/dist/challengeAssert-06GLZtV8.cjs.map +0 -1
- package/dist/challengeAssert-KGVKQh0J.js +0 -298
- package/dist/challengeAssert-KGVKQh0J.js.map +0 -1
- package/dist/noPayout-BmMd4NNH.js +0 -327
- package/dist/noPayout-BmMd4NNH.js.map +0 -1
- package/dist/noPayout-Bp2TYA_X.cjs +0 -2
- package/dist/noPayout-Bp2TYA_X.cjs.map +0 -1
- package/dist/psbtInputFields-BLi7Ta-T.cjs +0 -2
- package/dist/psbtInputFields-BLi7Ta-T.cjs.map +0 -1
- package/dist/psbtInputFields-DPCFHgGd.js +0 -264
- package/dist/psbtInputFields-DPCFHgGd.js.map +0 -1
- package/dist/signing-BZigafm0.js +0 -64
- package/dist/signing-BZigafm0.js.map +0 -1
- package/dist/signing-DHSXjhLM.cjs +0 -2
- package/dist/signing-DHSXjhLM.cjs.map +0 -1
- package/dist/types-PthVHz5q.cjs +0 -2
- package/dist/types-PthVHz5q.cjs.map +0 -1
- package/dist/types-SYvSQWnc.js +0 -732
- package/dist/types-SYvSQWnc.js.map +0 -1
- package/dist/vault-registry-reader-CmDdymw4.cjs +0 -2
- package/dist/vault-registry-reader-CmDdymw4.cjs.map +0 -1
- package/dist/vault-registry-reader-eiBfG4uQ.js.map +0 -1
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
const e = [
|
|
2
|
+
{
|
|
3
|
+
type: "function",
|
|
4
|
+
name: "getVaultKeepersByVersion",
|
|
5
|
+
inputs: [
|
|
6
|
+
{
|
|
7
|
+
name: "appEntryPoint",
|
|
8
|
+
type: "address",
|
|
9
|
+
internalType: "address"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
name: "versionNumber",
|
|
13
|
+
type: "uint16",
|
|
14
|
+
internalType: "uint16"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
outputs: [
|
|
18
|
+
{
|
|
19
|
+
name: "",
|
|
20
|
+
type: "tuple[]",
|
|
21
|
+
internalType: "struct BTCVaultTypes.AddressBTCKeyPair[]",
|
|
22
|
+
components: [
|
|
23
|
+
{
|
|
24
|
+
name: "ethAddress",
|
|
25
|
+
type: "address",
|
|
26
|
+
internalType: "address"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: "btcPubKey",
|
|
30
|
+
type: "bytes32",
|
|
31
|
+
internalType: "bytes32"
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
stateMutability: "view"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
type: "function",
|
|
40
|
+
name: "getCurrentVaultKeepers",
|
|
41
|
+
inputs: [
|
|
42
|
+
{
|
|
43
|
+
name: "appEntryPoint",
|
|
44
|
+
type: "address",
|
|
45
|
+
internalType: "address"
|
|
46
|
+
}
|
|
47
|
+
],
|
|
48
|
+
outputs: [
|
|
49
|
+
{
|
|
50
|
+
name: "",
|
|
51
|
+
type: "tuple[]",
|
|
52
|
+
internalType: "struct BTCVaultTypes.AddressBTCKeyPair[]",
|
|
53
|
+
components: [
|
|
54
|
+
{
|
|
55
|
+
name: "ethAddress",
|
|
56
|
+
type: "address",
|
|
57
|
+
internalType: "address"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: "btcPubKey",
|
|
61
|
+
type: "bytes32",
|
|
62
|
+
internalType: "bytes32"
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
],
|
|
67
|
+
stateMutability: "view"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
type: "function",
|
|
71
|
+
name: "getCurrentVaultKeepersVersion",
|
|
72
|
+
inputs: [
|
|
73
|
+
{
|
|
74
|
+
name: "appEntryPoint",
|
|
75
|
+
type: "address",
|
|
76
|
+
internalType: "address"
|
|
77
|
+
}
|
|
78
|
+
],
|
|
79
|
+
outputs: [
|
|
80
|
+
{
|
|
81
|
+
name: "",
|
|
82
|
+
type: "uint16",
|
|
83
|
+
internalType: "uint16"
|
|
84
|
+
}
|
|
85
|
+
],
|
|
86
|
+
stateMutability: "view"
|
|
87
|
+
}
|
|
88
|
+
], t = [
|
|
89
|
+
{
|
|
90
|
+
type: "function",
|
|
91
|
+
name: "getTBVProtocolParams",
|
|
92
|
+
inputs: [],
|
|
93
|
+
outputs: [
|
|
94
|
+
{
|
|
95
|
+
name: "",
|
|
96
|
+
type: "tuple",
|
|
97
|
+
internalType: "struct IProtocolParams.TBVProtocolParams",
|
|
98
|
+
components: [
|
|
99
|
+
{
|
|
100
|
+
name: "minimumPegInAmount",
|
|
101
|
+
type: "uint64",
|
|
102
|
+
internalType: "uint64"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: "maxPegInAmount",
|
|
106
|
+
type: "uint64",
|
|
107
|
+
internalType: "uint64"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: "pegInAckTimeout",
|
|
111
|
+
type: "uint64",
|
|
112
|
+
internalType: "uint64"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
name: "pegInActivationTimeout",
|
|
116
|
+
type: "uint64",
|
|
117
|
+
internalType: "uint64"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: "maxHtlcOutputCount",
|
|
121
|
+
type: "uint8",
|
|
122
|
+
internalType: "uint8"
|
|
123
|
+
}
|
|
124
|
+
]
|
|
125
|
+
}
|
|
126
|
+
],
|
|
127
|
+
stateMutability: "view"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
type: "function",
|
|
131
|
+
name: "getLatestOffchainParams",
|
|
132
|
+
inputs: [],
|
|
133
|
+
outputs: [
|
|
134
|
+
{
|
|
135
|
+
name: "",
|
|
136
|
+
type: "tuple",
|
|
137
|
+
internalType: "struct IProtocolParams.VersionedOffchainParams",
|
|
138
|
+
components: [
|
|
139
|
+
{
|
|
140
|
+
name: "timelockAssert",
|
|
141
|
+
type: "uint256",
|
|
142
|
+
internalType: "uint256"
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
name: "timelockChallengeAssert",
|
|
146
|
+
type: "uint256",
|
|
147
|
+
internalType: "uint256"
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
name: "securityCouncilKeys",
|
|
151
|
+
type: "bytes32[]",
|
|
152
|
+
internalType: "bytes32[]"
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
name: "councilQuorum",
|
|
156
|
+
type: "uint8",
|
|
157
|
+
internalType: "uint8"
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
name: "feeRate",
|
|
161
|
+
type: "uint64",
|
|
162
|
+
internalType: "uint64"
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
name: "babeTotalInstances",
|
|
166
|
+
type: "uint16",
|
|
167
|
+
internalType: "uint16"
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
name: "babeInstancesToFinalize",
|
|
171
|
+
type: "uint8",
|
|
172
|
+
internalType: "uint8"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
name: "minVpCommissionBps",
|
|
176
|
+
type: "uint16",
|
|
177
|
+
internalType: "uint16"
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
name: "tRefund",
|
|
181
|
+
type: "uint32",
|
|
182
|
+
internalType: "uint32"
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
name: "tStale",
|
|
186
|
+
type: "uint32",
|
|
187
|
+
internalType: "uint32"
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
name: "minPeginFeeRate",
|
|
191
|
+
type: "uint64",
|
|
192
|
+
internalType: "uint64"
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
name: "proverProgramVersion",
|
|
196
|
+
type: "uint16",
|
|
197
|
+
internalType: "uint16"
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
name: "minPrepeginDepth",
|
|
201
|
+
type: "uint32",
|
|
202
|
+
internalType: "uint32"
|
|
203
|
+
}
|
|
204
|
+
]
|
|
205
|
+
}
|
|
206
|
+
],
|
|
207
|
+
stateMutability: "view"
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
type: "function",
|
|
211
|
+
name: "getOffchainParamsByVersion",
|
|
212
|
+
inputs: [
|
|
213
|
+
{
|
|
214
|
+
name: "versionNumber",
|
|
215
|
+
type: "uint16",
|
|
216
|
+
internalType: "uint16"
|
|
217
|
+
}
|
|
218
|
+
],
|
|
219
|
+
outputs: [
|
|
220
|
+
{
|
|
221
|
+
name: "",
|
|
222
|
+
type: "tuple",
|
|
223
|
+
internalType: "struct IProtocolParams.VersionedOffchainParams",
|
|
224
|
+
components: [
|
|
225
|
+
{
|
|
226
|
+
name: "timelockAssert",
|
|
227
|
+
type: "uint256",
|
|
228
|
+
internalType: "uint256"
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
name: "timelockChallengeAssert",
|
|
232
|
+
type: "uint256",
|
|
233
|
+
internalType: "uint256"
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
name: "securityCouncilKeys",
|
|
237
|
+
type: "bytes32[]",
|
|
238
|
+
internalType: "bytes32[]"
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
name: "councilQuorum",
|
|
242
|
+
type: "uint8",
|
|
243
|
+
internalType: "uint8"
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
name: "feeRate",
|
|
247
|
+
type: "uint64",
|
|
248
|
+
internalType: "uint64"
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
name: "babeTotalInstances",
|
|
252
|
+
type: "uint16",
|
|
253
|
+
internalType: "uint16"
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
name: "babeInstancesToFinalize",
|
|
257
|
+
type: "uint8",
|
|
258
|
+
internalType: "uint8"
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
name: "minVpCommissionBps",
|
|
262
|
+
type: "uint16",
|
|
263
|
+
internalType: "uint16"
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
name: "tRefund",
|
|
267
|
+
type: "uint32",
|
|
268
|
+
internalType: "uint32"
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
name: "tStale",
|
|
272
|
+
type: "uint32",
|
|
273
|
+
internalType: "uint32"
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
name: "minPeginFeeRate",
|
|
277
|
+
type: "uint64",
|
|
278
|
+
internalType: "uint64"
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
name: "proverProgramVersion",
|
|
282
|
+
type: "uint16",
|
|
283
|
+
internalType: "uint16"
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
name: "minPrepeginDepth",
|
|
287
|
+
type: "uint32",
|
|
288
|
+
internalType: "uint32"
|
|
289
|
+
}
|
|
290
|
+
]
|
|
291
|
+
}
|
|
292
|
+
],
|
|
293
|
+
stateMutability: "view"
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
type: "function",
|
|
297
|
+
name: "latestOffchainParamsVersion",
|
|
298
|
+
inputs: [],
|
|
299
|
+
outputs: [
|
|
300
|
+
{
|
|
301
|
+
name: "",
|
|
302
|
+
type: "uint16",
|
|
303
|
+
internalType: "uint16"
|
|
304
|
+
}
|
|
305
|
+
],
|
|
306
|
+
stateMutability: "view"
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
type: "function",
|
|
310
|
+
name: "getUniversalChallengersByVersion",
|
|
311
|
+
inputs: [
|
|
312
|
+
{
|
|
313
|
+
name: "versionNumber",
|
|
314
|
+
type: "uint16",
|
|
315
|
+
internalType: "uint16"
|
|
316
|
+
}
|
|
317
|
+
],
|
|
318
|
+
outputs: [
|
|
319
|
+
{
|
|
320
|
+
name: "",
|
|
321
|
+
type: "tuple[]",
|
|
322
|
+
internalType: "struct BTCVaultTypes.AddressBTCKeyPair[]",
|
|
323
|
+
components: [
|
|
324
|
+
{
|
|
325
|
+
name: "ethAddress",
|
|
326
|
+
type: "address",
|
|
327
|
+
internalType: "address"
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
name: "btcPubKey",
|
|
331
|
+
type: "bytes32",
|
|
332
|
+
internalType: "bytes32"
|
|
333
|
+
}
|
|
334
|
+
]
|
|
335
|
+
}
|
|
336
|
+
],
|
|
337
|
+
stateMutability: "view"
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
type: "function",
|
|
341
|
+
name: "getCurrentUniversalChallengers",
|
|
342
|
+
inputs: [],
|
|
343
|
+
outputs: [
|
|
344
|
+
{
|
|
345
|
+
name: "",
|
|
346
|
+
type: "tuple[]",
|
|
347
|
+
internalType: "struct BTCVaultTypes.AddressBTCKeyPair[]",
|
|
348
|
+
components: [
|
|
349
|
+
{
|
|
350
|
+
name: "ethAddress",
|
|
351
|
+
type: "address",
|
|
352
|
+
internalType: "address"
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
name: "btcPubKey",
|
|
356
|
+
type: "bytes32",
|
|
357
|
+
internalType: "bytes32"
|
|
358
|
+
}
|
|
359
|
+
]
|
|
360
|
+
}
|
|
361
|
+
],
|
|
362
|
+
stateMutability: "view"
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
type: "function",
|
|
366
|
+
name: "latestUniversalChallengersVersion",
|
|
367
|
+
inputs: [],
|
|
368
|
+
outputs: [
|
|
369
|
+
{
|
|
370
|
+
name: "",
|
|
371
|
+
type: "uint16",
|
|
372
|
+
internalType: "uint16"
|
|
373
|
+
}
|
|
374
|
+
],
|
|
375
|
+
stateMutability: "view"
|
|
376
|
+
}
|
|
377
|
+
];
|
|
378
|
+
export {
|
|
379
|
+
e as A,
|
|
380
|
+
t as P
|
|
381
|
+
};
|
|
382
|
+
//# sourceMappingURL=ProtocolParams.abi-DXu8L0Fn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProtocolParams.abi-DXu8L0Fn.js","sources":["../src/tbv/core/contracts/abis/ApplicationRegistry.abi.ts","../src/tbv/core/contracts/abis/ProtocolParams.abi.ts"],"sourcesContent":["/**\n * ApplicationRegistry Contract ABI\n *\n * Minimal ABI containing only the vault keeper read functions needed by the SDK.\n * Generated from vault-contracts-aave-v4 IApplicationRegistry.sol interface.\n *\n * @module contracts/abis/ApplicationRegistry\n */\n\nexport const ApplicationRegistryABI = [\n {\n type: \"function\",\n name: \"getVaultKeepersByVersion\",\n inputs: [\n {\n name: \"appEntryPoint\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"versionNumber\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n ],\n outputs: [\n {\n name: \"\",\n type: \"tuple[]\",\n internalType: \"struct BTCVaultTypes.AddressBTCKeyPair[]\",\n components: [\n {\n name: \"ethAddress\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"btcPubKey\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"getCurrentVaultKeepers\",\n inputs: [\n {\n name: \"appEntryPoint\",\n type: \"address\",\n internalType: \"address\",\n },\n ],\n outputs: [\n {\n name: \"\",\n type: \"tuple[]\",\n internalType: \"struct BTCVaultTypes.AddressBTCKeyPair[]\",\n components: [\n {\n name: \"ethAddress\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"btcPubKey\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"getCurrentVaultKeepersVersion\",\n inputs: [\n {\n name: \"appEntryPoint\",\n type: \"address\",\n internalType: \"address\",\n },\n ],\n outputs: [\n {\n name: \"\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n ],\n stateMutability: \"view\",\n },\n] as const;\n","/**\n * ProtocolParams Contract ABI\n *\n * Minimal ABI containing only the read functions needed by the SDK.\n * Generated from vault-contracts-aave-v4 IProtocolParams.sol interface.\n *\n * @module contracts/abis/ProtocolParams\n */\n\nexport const ProtocolParamsABI = [\n {\n type: \"function\",\n name: \"getTBVProtocolParams\",\n inputs: [],\n outputs: [\n {\n name: \"\",\n type: \"tuple\",\n internalType: \"struct IProtocolParams.TBVProtocolParams\",\n components: [\n {\n name: \"minimumPegInAmount\",\n type: \"uint64\",\n internalType: \"uint64\",\n },\n {\n name: \"maxPegInAmount\",\n type: \"uint64\",\n internalType: \"uint64\",\n },\n {\n name: \"pegInAckTimeout\",\n type: \"uint64\",\n internalType: \"uint64\",\n },\n {\n name: \"pegInActivationTimeout\",\n type: \"uint64\",\n internalType: \"uint64\",\n },\n {\n name: \"maxHtlcOutputCount\",\n type: \"uint8\",\n internalType: \"uint8\",\n },\n ],\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"getLatestOffchainParams\",\n inputs: [],\n outputs: [\n {\n name: \"\",\n type: \"tuple\",\n internalType: \"struct IProtocolParams.VersionedOffchainParams\",\n components: [\n {\n name: \"timelockAssert\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n {\n name: \"timelockChallengeAssert\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n {\n name: \"securityCouncilKeys\",\n type: \"bytes32[]\",\n internalType: \"bytes32[]\",\n },\n {\n name: \"councilQuorum\",\n type: \"uint8\",\n internalType: \"uint8\",\n },\n {\n name: \"feeRate\",\n type: \"uint64\",\n internalType: \"uint64\",\n },\n {\n name: \"babeTotalInstances\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"babeInstancesToFinalize\",\n type: \"uint8\",\n internalType: \"uint8\",\n },\n {\n name: \"minVpCommissionBps\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"tRefund\",\n type: \"uint32\",\n internalType: \"uint32\",\n },\n {\n name: \"tStale\",\n type: \"uint32\",\n internalType: \"uint32\",\n },\n {\n name: \"minPeginFeeRate\",\n type: \"uint64\",\n internalType: \"uint64\",\n },\n {\n name: \"proverProgramVersion\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"minPrepeginDepth\",\n type: \"uint32\",\n internalType: \"uint32\",\n },\n ],\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"getOffchainParamsByVersion\",\n inputs: [\n {\n name: \"versionNumber\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n ],\n outputs: [\n {\n name: \"\",\n type: \"tuple\",\n internalType: \"struct IProtocolParams.VersionedOffchainParams\",\n components: [\n {\n name: \"timelockAssert\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n {\n name: \"timelockChallengeAssert\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n {\n name: \"securityCouncilKeys\",\n type: \"bytes32[]\",\n internalType: \"bytes32[]\",\n },\n {\n name: \"councilQuorum\",\n type: \"uint8\",\n internalType: \"uint8\",\n },\n {\n name: \"feeRate\",\n type: \"uint64\",\n internalType: \"uint64\",\n },\n {\n name: \"babeTotalInstances\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"babeInstancesToFinalize\",\n type: \"uint8\",\n internalType: \"uint8\",\n },\n {\n name: \"minVpCommissionBps\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"tRefund\",\n type: \"uint32\",\n internalType: \"uint32\",\n },\n {\n name: \"tStale\",\n type: \"uint32\",\n internalType: \"uint32\",\n },\n {\n name: \"minPeginFeeRate\",\n type: \"uint64\",\n internalType: \"uint64\",\n },\n {\n name: \"proverProgramVersion\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"minPrepeginDepth\",\n type: \"uint32\",\n internalType: \"uint32\",\n },\n ],\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"latestOffchainParamsVersion\",\n inputs: [],\n outputs: [\n {\n name: \"\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"getUniversalChallengersByVersion\",\n inputs: [\n {\n name: \"versionNumber\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n ],\n outputs: [\n {\n name: \"\",\n type: \"tuple[]\",\n internalType: \"struct BTCVaultTypes.AddressBTCKeyPair[]\",\n components: [\n {\n name: \"ethAddress\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"btcPubKey\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"getCurrentUniversalChallengers\",\n inputs: [],\n outputs: [\n {\n name: \"\",\n type: \"tuple[]\",\n internalType: \"struct BTCVaultTypes.AddressBTCKeyPair[]\",\n components: [\n {\n name: \"ethAddress\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"btcPubKey\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"latestUniversalChallengersVersion\",\n inputs: [],\n outputs: [\n {\n name: \"\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n ],\n stateMutability: \"view\",\n },\n] as const;\n"],"names":["ApplicationRegistryABI","ProtocolParamsABI"],"mappings":"AASO,MAAMA,IAAyB;AAAA,EACpC;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,QAAQ;AAAA,MACN;AAAA,QACE,MAAM;AAAA,QACN,MAAM;AAAA,QACN,cAAc;AAAA,MAAA;AAAA,MAEhB;AAAA,QACE,MAAM;AAAA,QACN,MAAM;AAAA,QACN,cAAc;AAAA,MAAA;AAAA,IAChB;AAAA,IAEF,SAAS;AAAA,MACP;AAAA,QACE,MAAM;AAAA,QACN,MAAM;AAAA,QACN,cAAc;AAAA,QACd,YAAY;AAAA,UACV;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,cAAc;AAAA,UAAA;AAAA,UAEhB;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,cAAc;AAAA,UAAA;AAAA,QAChB;AAAA,MACF;AAAA,IACF;AAAA,IAEF,iBAAiB;AAAA,EAAA;AAAA,EAEnB;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,QAAQ;AAAA,MACN;AAAA,QACE,MAAM;AAAA,QACN,MAAM;AAAA,QACN,cAAc;AAAA,MAAA;AAAA,IAChB;AAAA,IAEF,SAAS;AAAA,MACP;AAAA,QACE,MAAM;AAAA,QACN,MAAM;AAAA,QACN,cAAc;AAAA,QACd,YAAY;AAAA,UACV;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,cAAc;AAAA,UAAA;AAAA,UAEhB;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,cAAc;AAAA,UAAA;A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A;AAAA,EAEnB;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,QAAQ;AAAA,MACN;AAAA,QACE,MAAM;AAAA,QACN,MAAM;AAAA,QACN,cAAc;AAAA,MAAA;AAAA,IAChB;AAAA,IAEF,SAAS;AAAA,MACP;AAAA,QACE,MAAM;AAAA,QACN,MAAM;AAAA,QACN,cAAc;AAAA,QACd,YAAY;AAAA,UACV;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,cAAc;AAAA,UAAA;AAAA,UAEhB;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,cAAc;AAAA,UAAA;AAAA,QAChB;AAAA,MACF;AAAA,IACF;AAAA,IAEF,iBAAiB;AAAA,EAAA;AAAA,EAEnB;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,QAAQ,CAAA;AAAA,IACR,SAAS;AAAA,MACP;AAAA,QACE,MAAM;AAAA,QACN,MAAM;AAAA,QACN,cAAc;AAAA,QACd,YAAY;AAAA,UACV;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,cAAc;AAAA,UAAA;AAAA,UAEhB;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,cAAc;AAAA,UAAA;AAAA,QAChB;AAAA,MACF;AAAA,IACF;AAAA,IAEF,iBAAiB;AAAA,EAAA;AAAA,EAEnB;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,QAAQ,CAAA;AAAA,IACR,SAAS;AAAA,MACP;AAAA,QACE,MAAM;AAAA,QACN,MAAM;AAAA,QACN,cAAc;AAAA,MAAA;AAAA,IAChB;AAAA,IAEF,iBAAiB;AAAA,EAAA;AAErB;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Buffer as l } from "buffer";
|
|
2
2
|
import { payments as u, networks as s } from "bitcoinjs-lib";
|
|
3
|
-
const
|
|
3
|
+
const x = 192, a = 64, c = 66, h = 130, _ = 128;
|
|
4
4
|
function o(t) {
|
|
5
5
|
return t.startsWith("0x") || t.startsWith("0X") ? t.slice(2) : t;
|
|
6
6
|
}
|
|
@@ -16,13 +16,13 @@ function f(t) {
|
|
|
16
16
|
n[r / 2] = parseInt(e.slice(r, r + 2), 16);
|
|
17
17
|
return n;
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function E(t) {
|
|
20
20
|
return Array.from(t).map((e) => e.toString(16).padStart(2, "0")).join("");
|
|
21
21
|
}
|
|
22
22
|
function A(t) {
|
|
23
|
-
return
|
|
23
|
+
return E(new Uint8Array(t.hash).slice().reverse());
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function b(t) {
|
|
26
26
|
return t.length === 32 ? t : t.slice(1, 33);
|
|
27
27
|
}
|
|
28
28
|
function d(t) {
|
|
@@ -39,26 +39,30 @@ function w(t) {
|
|
|
39
39
|
`Invalid public key length: ${e.length} (expected ${a}, ${c}, or ${h} hex chars)`
|
|
40
40
|
);
|
|
41
41
|
const n = f(e);
|
|
42
|
-
return
|
|
42
|
+
return E(b(n));
|
|
43
43
|
}
|
|
44
44
|
function C(t) {
|
|
45
45
|
const e = o(t);
|
|
46
46
|
return d(e);
|
|
47
47
|
}
|
|
48
48
|
function N(t, e) {
|
|
49
|
-
|
|
49
|
+
if (!e)
|
|
50
|
+
throw new Error(
|
|
51
|
+
"validateWalletPubkey requires expectedDepositorPubkey. Pass the on-chain registered depositor pubkey to avoid a self-comparison."
|
|
52
|
+
);
|
|
53
|
+
const n = w(t), r = e;
|
|
50
54
|
if (n.toLowerCase() !== r.toLowerCase())
|
|
51
55
|
throw new Error(
|
|
52
56
|
`Wallet public key does not match vault depositor. Expected: ${r}, Got: ${n}. Please connect the wallet that was used to create this vault.`
|
|
53
57
|
);
|
|
54
58
|
return { walletPubkeyRaw: t, walletPubkeyXOnly: n, depositorPubkey: r };
|
|
55
59
|
}
|
|
56
|
-
const
|
|
57
|
-
function
|
|
60
|
+
const p = 100000000n;
|
|
61
|
+
function S(t) {
|
|
58
62
|
if (t < 0n)
|
|
59
|
-
return `-${
|
|
60
|
-
const e = t /
|
|
61
|
-
let r = (t %
|
|
63
|
+
return `-${S(-t)}`;
|
|
64
|
+
const e = t / p;
|
|
65
|
+
let r = (t % p).toString().padStart(8, "0");
|
|
62
66
|
return r = r.replace(/0+$/, ""), r.length > 0 ? `${e}.${r}` : e.toString();
|
|
63
67
|
}
|
|
64
68
|
function k() {
|
|
@@ -94,7 +98,7 @@ function m(t, e) {
|
|
|
94
98
|
throw new Error("Failed to derive taproot address from public key");
|
|
95
99
|
return r;
|
|
96
100
|
}
|
|
97
|
-
function
|
|
101
|
+
function P(t, e) {
|
|
98
102
|
const n = o(t);
|
|
99
103
|
if (n.length !== 66)
|
|
100
104
|
throw new Error(
|
|
@@ -121,7 +125,7 @@ function T(t, e, n) {
|
|
|
121
125
|
r.length === c ? i.push(r) : r.length === a && i.push(`02${r}`, `03${r}`);
|
|
122
126
|
for (const g of i)
|
|
123
127
|
try {
|
|
124
|
-
if (t ===
|
|
128
|
+
if (t === P(g, n))
|
|
125
129
|
return !0;
|
|
126
130
|
} catch {
|
|
127
131
|
}
|
|
@@ -129,22 +133,22 @@ function T(t, e, n) {
|
|
|
129
133
|
}
|
|
130
134
|
export {
|
|
131
135
|
c as C,
|
|
132
|
-
|
|
133
|
-
|
|
136
|
+
_ as S,
|
|
137
|
+
x as T,
|
|
134
138
|
a as X,
|
|
135
139
|
m as a,
|
|
136
140
|
C as b,
|
|
137
141
|
A as c,
|
|
138
|
-
|
|
142
|
+
P as d,
|
|
139
143
|
H as e,
|
|
140
|
-
|
|
144
|
+
S as f,
|
|
141
145
|
y as g,
|
|
142
146
|
f as h,
|
|
143
147
|
T as i,
|
|
144
148
|
w as p,
|
|
145
149
|
o as s,
|
|
146
|
-
|
|
147
|
-
|
|
150
|
+
b as t,
|
|
151
|
+
E as u,
|
|
148
152
|
N as v
|
|
149
153
|
};
|
|
150
|
-
//# sourceMappingURL=bitcoin-
|
|
154
|
+
//# sourceMappingURL=bitcoin-B0S8SHCX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bitcoin-B0S8SHCX.js","sources":["../src/tbv/core/primitives/utils/bitcoin.ts"],"sourcesContent":["/**\n * Bitcoin Utilities\n *\n * Common pure utility functions for Bitcoin operations including:\n * - Public key conversions (x-only format)\n * - Hex string manipulation\n * - Uint8Array conversions and validation\n * - Address derivation and validation\n *\n * All functions are pure (no side effects) and work in Node.js, browsers,\n * and serverless environments.\n *\n * @module primitives/utils/bitcoin\n */\n\nimport { Buffer } from \"buffer\";\nimport { networks, payments } from \"bitcoinjs-lib\";\n\nimport type { Network } from \"@babylonlabs-io/babylon-tbv-rust-wasm\";\nimport type { Hex } from \"viem\";\n\n/**\n * BIP-341 Tapscript leaf version for script-path spends.\n * @see https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki\n * @see Rust: bitcoin::taproot::LeafVersion::TapScript\n */\nexport const TAPSCRIPT_LEAF_VERSION = 0xc0;\n\n/**\n * Hex-string length of a 32-byte BIP-340 x-only public key (taproot,\n * Schnorr). Doubles the byte count: `2 * 32 = 64`.\n */\nexport const X_ONLY_PUBKEY_HEX_LEN = 64;\n\n/**\n * Hex-string length of a 33-byte SEC1-compressed secp256k1 public key\n * (`0x02` or `0x03` prefix + 32-byte x-coordinate). `2 * 33 = 66`.\n */\nexport const COMPRESSED_PUBKEY_HEX_LEN = 66;\n\n/**\n * Hex-string length of a 65-byte SEC1-uncompressed secp256k1 public\n * key (`0x04` prefix + 32-byte x + 32-byte y). `2 * 65 = 130`.\n */\nexport const UNCOMPRESSED_PUBKEY_HEX_LEN = 130;\n\n/**\n * Hex-string length of a 64-byte BIP-340 Schnorr signature. `2 * 64 = 128`.\n */\nexport const SCHNORR_SIG_HEX_LEN = 128;\n\n/**\n * Strip \"0x\" prefix from hex string if present.\n *\n * Bitcoin expects plain hex (no \"0x\" prefix), but frontend often uses\n * Ethereum-style \"0x\"-prefixed hex.\n *\n * @param hex - Hex string with or without \"0x\" prefix\n * @returns Hex string without \"0x\" prefix\n */\nexport function stripHexPrefix(hex: string): string {\n return hex.startsWith(\"0x\") || hex.startsWith(\"0X\") ? hex.slice(2) : hex;\n}\n\n/**\n * Ensure \"0x\" prefix on a hex string, returning viem's Hex type.\n *\n * Ethereum/viem APIs expect `0x`-prefixed hex, but Bitcoin tooling\n * typically omits the prefix. This normalises either form.\n *\n * @param hex - Hex string with or without \"0x\" prefix\n * @returns `0x`-prefixed hex string typed as viem Hex\n */\nexport function ensureHexPrefix(hex: string): Hex {\n if (hex.startsWith(\"0x\")) return hex as Hex;\n if (hex.startsWith(\"0X\")) return `0x${hex.slice(2)}` as Hex;\n return `0x${hex}` as Hex;\n}\n\n/**\n * Convert hex string to Uint8Array.\n *\n * @param hex - Hex string (with or without 0x prefix)\n * @returns Uint8Array\n * @throws If hex is invalid\n */\nexport function hexToUint8Array(hex: string): Uint8Array {\n const cleanHex = stripHexPrefix(hex);\n if (!isValidHexRaw(cleanHex)) {\n throw new Error(`Invalid hex string: ${hex}`);\n }\n const bytes = new Uint8Array(cleanHex.length / 2);\n for (let i = 0; i < cleanHex.length; i += 2) {\n bytes[i / 2] = parseInt(cleanHex.slice(i, i + 2), 16);\n }\n return bytes;\n}\n\n/**\n * Convert Uint8Array to hex string (without 0x prefix).\n *\n * @param bytes - Uint8Array to convert\n * @returns Hex string without 0x prefix\n */\nexport function uint8ArrayToHex(bytes: Uint8Array): string {\n return Array.from(bytes)\n .map((b) => b.toString(16).padStart(2, \"0\"))\n .join(\"\");\n}\n\n/**\n * Read the prevout txid (big-endian hex) from a bitcoinjs-lib transaction input.\n *\n * bitcoinjs-lib stores `hash` in little-endian internal byte order; txids are\n * displayed in big-endian, so the bytes must be reversed before hex-encoding.\n *\n * @param input - Transaction input with a `hash` field (Buffer or Uint8Array)\n * @returns Prevout txid as a hex string (big-endian, no 0x prefix)\n */\nexport function inputTxidHex(input: {\n hash: Buffer | Uint8Array;\n}): string {\n return uint8ArrayToHex(new Uint8Array(input.hash).slice().reverse());\n}\n\n/**\n * Convert a 33-byte public key to 32-byte x-only format (removes first byte).\n *\n * Used for Taproot/Schnorr signatures which only need the x-coordinate.\n * If the input is already 32 bytes, returns it unchanged.\n *\n * @param pubKey - 33-byte or 32-byte public key\n * @returns 32-byte x-only public key\n */\nexport function toXOnly(pubKey: Uint8Array): Uint8Array {\n return pubKey.length === 32 ? pubKey : pubKey.slice(1, 33);\n}\n\n/**\n * Internal helper: Validate hex string format without stripping prefix\n *\n * @internal\n * @param hex - Hex string (must already have prefix stripped)\n * @returns true if valid hex string\n */\nfunction isValidHexRaw(hex: string): boolean {\n return /^[0-9a-fA-F]*$/.test(hex) && hex.length % 2 === 0;\n}\n\n/**\n * Process and convert a public key to x-only format (32 bytes hex).\n *\n * Handles:\n * - 0x prefix removal\n * - Hex character validation\n * - Length validation\n * - Conversion to x-only format\n *\n * Accepts:\n * - 64 hex chars (32 bytes) - already x-only\n * - 66 hex chars (33 bytes) - compressed pubkey\n * - 130 hex chars (65 bytes) - uncompressed pubkey\n *\n * @param publicKeyHex - Public key in hex format (with or without 0x prefix)\n * @returns X-only public key as 32 bytes hex string (without 0x prefix)\n * @throws If public key format is invalid or contains invalid hex characters\n */\nexport function processPublicKeyToXOnly(publicKeyHex: string): string {\n // Remove '0x' prefix if present\n const cleanHex = stripHexPrefix(publicKeyHex);\n\n // Validate hex characters early to prevent silent failures\n if (!isValidHexRaw(cleanHex)) {\n throw new Error(`Invalid hex characters in public key: ${publicKeyHex}`);\n }\n\n // If already 64 chars (32 bytes), it's already x-only format\n if (cleanHex.length === X_ONLY_PUBKEY_HEX_LEN) {\n return cleanHex;\n }\n\n // Validate public key length (compressed SEC1 or uncompressed SEC1)\n if (\n cleanHex.length !== COMPRESSED_PUBKEY_HEX_LEN &&\n cleanHex.length !== UNCOMPRESSED_PUBKEY_HEX_LEN\n ) {\n throw new Error(\n `Invalid public key length: ${cleanHex.length} (expected ${X_ONLY_PUBKEY_HEX_LEN}, ${COMPRESSED_PUBKEY_HEX_LEN}, or ${UNCOMPRESSED_PUBKEY_HEX_LEN} hex chars)`,\n );\n }\n\n const pubkeyBytes = hexToUint8Array(cleanHex);\n return uint8ArrayToHex(toXOnly(pubkeyBytes));\n}\n\n/**\n * Validate hex string format.\n *\n * Checks that the string contains only valid hexadecimal characters (0-9, a-f, A-F)\n * and has an even length (since each byte is represented by 2 hex characters).\n *\n * @param hex - String to validate (with or without 0x prefix)\n * @returns true if valid hex string\n */\nexport function isValidHex(hex: string): boolean {\n const cleanHex = stripHexPrefix(hex);\n return isValidHexRaw(cleanHex);\n}\n\n/**\n * Result of validating a wallet public key against an expected depositor public key.\n */\nexport interface WalletPubkeyValidationResult {\n /** Wallet's raw public key (as returned by wallet, may be compressed) */\n walletPubkeyRaw: string;\n /** Wallet's public key in x-only format (32 bytes, 64 hex chars) */\n walletPubkeyXOnly: string;\n /** The validated depositor public key (x-only format) */\n depositorPubkey: string;\n}\n\n/**\n * Validate that a wallet's public key matches the expected depositor public key.\n *\n * This function:\n * 1. Converts the wallet pubkey to x-only format\n * 2. Validates the wallet x-only pubkey matches the expected depositor pubkey\n * (case-insensitive)\n *\n * @param walletPubkeyRaw - Raw public key from wallet (may be compressed 66 chars or x-only 64 chars)\n * @param expectedDepositorPubkey - Expected depositor public key (x-only).\n * Required: omitting it would degrade this check to a self-comparison.\n * @returns Validation result with both pubkey formats\n * @throws If `expectedDepositorPubkey` is missing/empty\n * @throws If wallet pubkey doesn't match expected depositor pubkey\n */\nexport function validateWalletPubkey(\n walletPubkeyRaw: string,\n expectedDepositorPubkey: string,\n): WalletPubkeyValidationResult {\n if (!expectedDepositorPubkey) {\n throw new Error(\n \"validateWalletPubkey requires expectedDepositorPubkey. Pass the on-chain registered depositor pubkey to avoid a self-comparison.\",\n );\n }\n\n const walletPubkeyXOnly = processPublicKeyToXOnly(walletPubkeyRaw);\n const depositorPubkey = expectedDepositorPubkey;\n\n if (walletPubkeyXOnly.toLowerCase() !== depositorPubkey.toLowerCase()) {\n throw new Error(\n `Wallet public key does not match vault depositor. ` +\n `Expected: ${depositorPubkey}, Got: ${walletPubkeyXOnly}. ` +\n `Please connect the wallet that was used to create this vault.`\n );\n }\n\n return { walletPubkeyRaw, walletPubkeyXOnly, depositorPubkey };\n}\n\n// ============================================================================\n// BTC formatting\n// ============================================================================\n\nconst SATOSHIS_PER_BTC = 100_000_000n;\n\n/**\n * Format satoshis as a human-readable BTC string with trailing zeros removed.\n */\nexport function formatSatoshisToBtc(satoshis: bigint): string {\n if (satoshis < 0n) {\n return `-${formatSatoshisToBtc(-satoshis)}`;\n }\n const whole = satoshis / SATOSHIS_PER_BTC;\n const fraction = satoshis % SATOSHIS_PER_BTC;\n let fractionStr = fraction.toString().padStart(8, \"0\");\n fractionStr = fractionStr.replace(/0+$/, \"\");\n return fractionStr.length > 0 ? `${whole}.${fractionStr}` : whole.toString();\n}\n\n// ============================================================================\n// Address derivation and validation\n// ============================================================================\n\n/**\n * Assert that the ECC library has been initialized via `initEccLib(ecc)`.\n *\n * The consuming application must call `initEccLib(ecc)` from `bitcoinjs-lib`\n * once at startup before using any SDK function that involves Taproot / P2TR\n * operations. This guard provides a clear error message when that step was\n * missed, instead of letting bitcoinjs-lib throw its generic\n * \"No ECC Library provided\" error deep in a call stack.\n */\nfunction assertEccInitialized(): void {\n try {\n payments.p2tr({ internalPubkey: Buffer.alloc(32, 1) });\n } catch (e) {\n if (e instanceof Error && e.message.includes(\"No ECC Library provided\")) {\n throw new Error(\n \"ECC library not initialized. \" +\n 'You must call initEccLib(ecc) from \"bitcoinjs-lib\" before using the SDK. ' +\n \"See the ts-sdk README for setup instructions.\",\n );\n }\n // Any other error means ECC is loaded (e.g. invalid key is fine — ECC worked).\n }\n}\n\n/**\n * Map SDK network type to bitcoinjs-lib Network object.\n *\n * @param network - Network type (\"bitcoin\", \"testnet\", \"signet\", \"regtest\")\n * @returns bitcoinjs-lib Network object\n */\nexport function getNetwork(network: Network): networks.Network {\n switch (network) {\n case \"bitcoin\":\n return networks.bitcoin;\n case \"testnet\":\n case \"signet\":\n return networks.testnet;\n case \"regtest\":\n return networks.regtest;\n default:\n throw new Error(`Unknown network: ${network}`);\n }\n}\n\n/**\n * Derive a Taproot (P2TR) address from a public key.\n *\n * @param publicKeyHex - Compressed (66 hex) or x-only (64 hex) public key\n * @param network - Bitcoin network\n * @returns Taproot address (bc1p... / tb1p... / bcrt1p...)\n */\nexport function deriveTaprootAddress(\n publicKeyHex: string,\n network: Network,\n): string {\n assertEccInitialized();\n const xOnly = hexToUint8Array(processPublicKeyToXOnly(publicKeyHex));\n const { address } = payments.p2tr({\n internalPubkey: Buffer.from(xOnly),\n network: getNetwork(network),\n });\n if (!address) {\n throw new Error(\"Failed to derive taproot address from public key\");\n }\n return address;\n}\n\n/**\n * Derive a Native SegWit (P2WPKH) address from a compressed public key.\n *\n * @param publicKeyHex - Compressed public key (66 hex chars, with or without 0x prefix)\n * @param network - Bitcoin network\n * @returns Native SegWit address (bc1q... / tb1q... / bcrt1q...)\n * @throws If publicKeyHex is not a compressed public key (66 hex chars)\n */\nexport function deriveNativeSegwitAddress(\n publicKeyHex: string,\n network: Network,\n): string {\n const cleanHex = stripHexPrefix(publicKeyHex);\n if (cleanHex.length !== 66) {\n throw new Error(\n `Native SegWit requires a compressed public key (66 hex chars), got ${cleanHex.length}`,\n );\n }\n const { address } = payments.p2wpkh({\n pubkey: Buffer.from(hexToUint8Array(cleanHex)),\n network: getNetwork(network),\n });\n if (!address) {\n throw new Error(\n \"Failed to derive native segwit address from public key\",\n );\n }\n return address;\n}\n\n/**\n * Validate that a BTC address was derived from the given public key.\n *\n * Derives Taproot (P2TR) and Native SegWit (P2WPKH) addresses from the\n * public key and checks if the provided address matches any of them.\n *\n * When the input is an x-only key (64 hex chars), both possible compressed\n * keys (`02` + x and `03` + x) are tried for Native SegWit derivation,\n * since the y-parity is unknown.\n *\n * @param address - BTC address to validate\n * @param publicKeyHex - Public key from the wallet (x-only 64 or compressed 66 hex chars)\n * @param network - Bitcoin network\n * @returns true if the address matches the public key\n */\nexport function isAddressFromPublicKey(\n address: string,\n publicKeyHex: string,\n network: Network,\n): boolean {\n const cleanHex = stripHexPrefix(publicKeyHex);\n\n // P2TR — works with both x-only and compressed keys\n try {\n if (address === deriveTaprootAddress(cleanHex, network)) {\n return true;\n }\n } catch {\n // derivation failed, continue\n }\n\n // Build the list of compressed keys to try for P2WPKH\n const compressedKeys: string[] = [];\n if (cleanHex.length === COMPRESSED_PUBKEY_HEX_LEN) {\n compressedKeys.push(cleanHex);\n } else if (cleanHex.length === X_ONLY_PUBKEY_HEX_LEN) {\n // x-only key — try both even (02) and odd (03) y-parity\n compressedKeys.push(`02${cleanHex}`, `03${cleanHex}`);\n }\n\n for (const key of compressedKeys) {\n try {\n if (address === deriveNativeSegwitAddress(key, network)) {\n return true;\n }\n } catch {\n // derivation failed, continue\n }\n }\n\n return false;\n}\n"],"names":["TAPSCRIPT_LEAF_VERSION","X_ONLY_PUBKEY_HEX_LEN","COMPRESSED_PUBKEY_HEX_LEN","UNCOMPRESSED_PUBKEY_HEX_LEN","SCHNORR_SIG_HEX_LEN","stripHexPrefix","hex","ensureHexPrefix","hexToUint8Array","cleanHex","isValidHexRaw","bytes","i","uint8ArrayToHex","b","inputTxidHex","input","toXOnly","pubKey","processPublicKeyToXOnly","publicKeyHex","pubkeyBytes","isValidHex","validateWalletPubkey","walletPubkeyRaw","expectedDepositorPubkey","walletPubkeyXOnly","depositorPubkey","SATOSHIS_PER_BTC","formatSatoshisToBtc","satoshis","whole","fractionStr","assertEccInitialized","payments","Buffer","e","getNetwork","network","networks","deriveTaprootAddress","xOnly","address","deriveNativeSegwitAddress","isAddressFromPublicKey","compressedKeys","key"],"mappings":";;AA0BO,MAAMA,IAAyB,KAMzBC,IAAwB,IAMxBC,IAA4B,IAM5BC,IAA8B,KAK9BC,IAAsB;AAW5B,SAASC,EAAeC,GAAqB;AAClD,SAAOA,EAAI,WAAW,IAAI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,IAAI,KAAKA,CAAQ,EAAE;AAGtD,aAAWqC,KAAOD;AAChB,QAAI;AACF,UAAIH,MAAYC,EAA0BG,GAAKR,CAAO;AACpD,eAAO;AAAA,IAEX,QAAQ;AAAA,IAER;AAGF,SAAO;AACT;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const l=require("buffer"),i=require("bitcoinjs-lib"),b=192,s=64,c=66,y=130,k=128;function o(e){return e.startsWith("0x")||e.startsWith("0X")?e.slice(2):e}function x(e){return e.startsWith("0x")?e:e.startsWith("0X")?`0x${e.slice(2)}`:`0x${e}`}function a(e){const t=o(e);if(!d(t))throw new Error(`Invalid hex string: ${e}`);const n=new Uint8Array(t.length/2);for(let r=0;r<t.length;r+=2)n[r/2]=parseInt(t.slice(r,r+2),16);return n}function f(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}function H(e){return f(new Uint8Array(e.hash).slice().reverse())}function w(e){return e.length===32?e:e.slice(1,33)}function d(e){return/^[0-9a-fA-F]*$/.test(e)&&e.length%2===0}function E(e){const t=o(e);if(!d(t))throw new Error(`Invalid hex characters in public key: ${e}`);if(t.length===s)return t;if(t.length!==c&&t.length!==y)throw new Error(`Invalid public key length: ${t.length} (expected ${s}, ${c}, or ${y} hex chars)`);const n=a(t);return f(w(n))}function v(e){const t=o(e);return d(t)}function m(e,t){if(!t)throw new Error("validateWalletPubkey requires expectedDepositorPubkey. Pass the on-chain registered depositor pubkey to avoid a self-comparison.");const n=E(e),r=t;if(n.toLowerCase()!==r.toLowerCase())throw new Error(`Wallet public key does not match vault depositor. Expected: ${r}, Got: ${n}. Please connect the wallet that was used to create this vault.`);return{walletPubkeyRaw:e,walletPubkeyXOnly:n,depositorPubkey:r}}const p=100000000n;function g(e){if(e<0n)return`-${g(-e)}`;const t=e/p;let r=(e%p).toString().padStart(8,"0");return r=r.replace(/0+$/,""),r.length>0?`${t}.${r}`:t.toString()}function A(){try{i.payments.p2tr({internalPubkey:l.Buffer.alloc(32,1)})}catch(e){if(e instanceof Error&&e.message.includes("No ECC Library provided"))throw new Error('ECC library not initialized. You must call initEccLib(ecc) from "bitcoinjs-lib" before using the SDK. See the ts-sdk README for setup instructions.')}}function h(e){switch(e){case"bitcoin":return i.networks.bitcoin;case"testnet":case"signet":return i.networks.testnet;case"regtest":return i.networks.regtest;default:throw new Error(`Unknown network: ${e}`)}}function S(e,t){A();const n=a(E(e)),{address:r}=i.payments.p2tr({internalPubkey:l.Buffer.from(n),network:h(t)});if(!r)throw new Error("Failed to derive taproot address from public key");return r}function P(e,t){const n=o(e);if(n.length!==66)throw new Error(`Native SegWit requires a compressed public key (66 hex chars), got ${n.length}`);const{address:r}=i.payments.p2wpkh({pubkey:l.Buffer.from(a(n)),network:h(t)});if(!r)throw new Error("Failed to derive native segwit address from public key");return r}function N(e,t,n){const r=o(t);try{if(e===S(r,n))return!0}catch{}const u=[];r.length===c?u.push(r):r.length===s&&u.push(`02${r}`,`03${r}`);for(const _ of u)try{if(e===P(_,n))return!0}catch{}return!1}exports.COMPRESSED_PUBKEY_HEX_LEN=c;exports.SCHNORR_SIG_HEX_LEN=k;exports.TAPSCRIPT_LEAF_VERSION=b;exports.X_ONLY_PUBKEY_HEX_LEN=s;exports.deriveNativeSegwitAddress=P;exports.deriveTaprootAddress=S;exports.ensureHexPrefix=x;exports.formatSatoshisToBtc=g;exports.getNetwork=h;exports.hexToUint8Array=a;exports.inputTxidHex=H;exports.isAddressFromPublicKey=N;exports.isValidHex=v;exports.processPublicKeyToXOnly=E;exports.stripHexPrefix=o;exports.toXOnly=w;exports.uint8ArrayToHex=f;exports.validateWalletPubkey=m;
|
|
2
|
+
//# sourceMappingURL=bitcoin-B3aqjuMP.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bitcoin-B3aqjuMP.cjs","sources":["../src/tbv/core/primitives/utils/bitcoin.ts"],"sourcesContent":["/**\n * Bitcoin Utilities\n *\n * Common pure utility functions for Bitcoin operations including:\n * - Public key conversions (x-only format)\n * - Hex string manipulation\n * - Uint8Array conversions and validation\n * - Address derivation and validation\n *\n * All functions are pure (no side effects) and work in Node.js, browsers,\n * and serverless environments.\n *\n * @module primitives/utils/bitcoin\n */\n\nimport { Buffer } from \"buffer\";\nimport { networks, payments } from \"bitcoinjs-lib\";\n\nimport type { Network } from \"@babylonlabs-io/babylon-tbv-rust-wasm\";\nimport type { Hex } from \"viem\";\n\n/**\n * BIP-341 Tapscript leaf version for script-path spends.\n * @see https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki\n * @see Rust: bitcoin::taproot::LeafVersion::TapScript\n */\nexport const TAPSCRIPT_LEAF_VERSION = 0xc0;\n\n/**\n * Hex-string length of a 32-byte BIP-340 x-only public key (taproot,\n * Schnorr). Doubles the byte count: `2 * 32 = 64`.\n */\nexport const X_ONLY_PUBKEY_HEX_LEN = 64;\n\n/**\n * Hex-string length of a 33-byte SEC1-compressed secp256k1 public key\n * (`0x02` or `0x03` prefix + 32-byte x-coordinate). `2 * 33 = 66`.\n */\nexport const COMPRESSED_PUBKEY_HEX_LEN = 66;\n\n/**\n * Hex-string length of a 65-byte SEC1-uncompressed secp256k1 public\n * key (`0x04` prefix + 32-byte x + 32-byte y). `2 * 65 = 130`.\n */\nexport const UNCOMPRESSED_PUBKEY_HEX_LEN = 130;\n\n/**\n * Hex-string length of a 64-byte BIP-340 Schnorr signature. `2 * 64 = 128`.\n */\nexport const SCHNORR_SIG_HEX_LEN = 128;\n\n/**\n * Strip \"0x\" prefix from hex string if present.\n *\n * Bitcoin expects plain hex (no \"0x\" prefix), but frontend often uses\n * Ethereum-style \"0x\"-prefixed hex.\n *\n * @param hex - Hex string with or without \"0x\" prefix\n * @returns Hex string without \"0x\" prefix\n */\nexport function stripHexPrefix(hex: string): string {\n return hex.startsWith(\"0x\") || hex.startsWith(\"0X\") ? hex.slice(2) : hex;\n}\n\n/**\n * Ensure \"0x\" prefix on a hex string, returning viem's Hex type.\n *\n * Ethereum/viem APIs expect `0x`-prefixed hex, but Bitcoin tooling\n * typically omits the prefix. This normalises either form.\n *\n * @param hex - Hex string with or without \"0x\" prefix\n * @returns `0x`-prefixed hex string typed as viem Hex\n */\nexport function ensureHexPrefix(hex: string): Hex {\n if (hex.startsWith(\"0x\")) return hex as Hex;\n if (hex.startsWith(\"0X\")) return `0x${hex.slice(2)}` as Hex;\n return `0x${hex}` as Hex;\n}\n\n/**\n * Convert hex string to Uint8Array.\n *\n * @param hex - Hex string (with or without 0x prefix)\n * @returns Uint8Array\n * @throws If hex is invalid\n */\nexport function hexToUint8Array(hex: string): Uint8Array {\n const cleanHex = stripHexPrefix(hex);\n if (!isValidHexRaw(cleanHex)) {\n throw new Error(`Invalid hex string: ${hex}`);\n }\n const bytes = new Uint8Array(cleanHex.length / 2);\n for (let i = 0; i < cleanHex.length; i += 2) {\n bytes[i / 2] = parseInt(cleanHex.slice(i, i + 2), 16);\n }\n return bytes;\n}\n\n/**\n * Convert Uint8Array to hex string (without 0x prefix).\n *\n * @param bytes - Uint8Array to convert\n * @returns Hex string without 0x prefix\n */\nexport function uint8ArrayToHex(bytes: Uint8Array): string {\n return Array.from(bytes)\n .map((b) => b.toString(16).padStart(2, \"0\"))\n .join(\"\");\n}\n\n/**\n * Read the prevout txid (big-endian hex) from a bitcoinjs-lib transaction input.\n *\n * bitcoinjs-lib stores `hash` in little-endian internal byte order; txids are\n * displayed in big-endian, so the bytes must be reversed before hex-encoding.\n *\n * @param input - Transaction input with a `hash` field (Buffer or Uint8Array)\n * @returns Prevout txid as a hex string (big-endian, no 0x prefix)\n */\nexport function inputTxidHex(input: {\n hash: Buffer | Uint8Array;\n}): string {\n return uint8ArrayToHex(new Uint8Array(input.hash).slice().reverse());\n}\n\n/**\n * Convert a 33-byte public key to 32-byte x-only format (removes first byte).\n *\n * Used for Taproot/Schnorr signatures which only need the x-coordinate.\n * If the input is already 32 bytes, returns it unchanged.\n *\n * @param pubKey - 33-byte or 32-byte public key\n * @returns 32-byte x-only public key\n */\nexport function toXOnly(pubKey: Uint8Array): Uint8Array {\n return pubKey.length === 32 ? pubKey : pubKey.slice(1, 33);\n}\n\n/**\n * Internal helper: Validate hex string format without stripping prefix\n *\n * @internal\n * @param hex - Hex string (must already have prefix stripped)\n * @returns true if valid hex string\n */\nfunction isValidHexRaw(hex: string): boolean {\n return /^[0-9a-fA-F]*$/.test(hex) && hex.length % 2 === 0;\n}\n\n/**\n * Process and convert a public key to x-only format (32 bytes hex).\n *\n * Handles:\n * - 0x prefix removal\n * - Hex character validation\n * - Length validation\n * - Conversion to x-only format\n *\n * Accepts:\n * - 64 hex chars (32 bytes) - already x-only\n * - 66 hex chars (33 bytes) - compressed pubkey\n * - 130 hex chars (65 bytes) - uncompressed pubkey\n *\n * @param publicKeyHex - Public key in hex format (with or without 0x prefix)\n * @returns X-only public key as 32 bytes hex string (without 0x prefix)\n * @throws If public key format is invalid or contains invalid hex characters\n */\nexport function processPublicKeyToXOnly(publicKeyHex: string): string {\n // Remove '0x' prefix if present\n const cleanHex = stripHexPrefix(publicKeyHex);\n\n // Validate hex characters early to prevent silent failures\n if (!isValidHexRaw(cleanHex)) {\n throw new Error(`Invalid hex characters in public key: ${publicKeyHex}`);\n }\n\n // If already 64 chars (32 bytes), it's already x-only format\n if (cleanHex.length === X_ONLY_PUBKEY_HEX_LEN) {\n return cleanHex;\n }\n\n // Validate public key length (compressed SEC1 or uncompressed SEC1)\n if (\n cleanHex.length !== COMPRESSED_PUBKEY_HEX_LEN &&\n cleanHex.length !== UNCOMPRESSED_PUBKEY_HEX_LEN\n ) {\n throw new Error(\n `Invalid public key length: ${cleanHex.length} (expected ${X_ONLY_PUBKEY_HEX_LEN}, ${COMPRESSED_PUBKEY_HEX_LEN}, or ${UNCOMPRESSED_PUBKEY_HEX_LEN} hex chars)`,\n );\n }\n\n const pubkeyBytes = hexToUint8Array(cleanHex);\n return uint8ArrayToHex(toXOnly(pubkeyBytes));\n}\n\n/**\n * Validate hex string format.\n *\n * Checks that the string contains only valid hexadecimal characters (0-9, a-f, A-F)\n * and has an even length (since each byte is represented by 2 hex characters).\n *\n * @param hex - String to validate (with or without 0x prefix)\n * @returns true if valid hex string\n */\nexport function isValidHex(hex: string): boolean {\n const cleanHex = stripHexPrefix(hex);\n return isValidHexRaw(cleanHex);\n}\n\n/**\n * Result of validating a wallet public key against an expected depositor public key.\n */\nexport interface WalletPubkeyValidationResult {\n /** Wallet's raw public key (as returned by wallet, may be compressed) */\n walletPubkeyRaw: string;\n /** Wallet's public key in x-only format (32 bytes, 64 hex chars) */\n walletPubkeyXOnly: string;\n /** The validated depositor public key (x-only format) */\n depositorPubkey: string;\n}\n\n/**\n * Validate that a wallet's public key matches the expected depositor public key.\n *\n * This function:\n * 1. Converts the wallet pubkey to x-only format\n * 2. Validates the wallet x-only pubkey matches the expected depositor pubkey\n * (case-insensitive)\n *\n * @param walletPubkeyRaw - Raw public key from wallet (may be compressed 66 chars or x-only 64 chars)\n * @param expectedDepositorPubkey - Expected depositor public key (x-only).\n * Required: omitting it would degrade this check to a self-comparison.\n * @returns Validation result with both pubkey formats\n * @throws If `expectedDepositorPubkey` is missing/empty\n * @throws If wallet pubkey doesn't match expected depositor pubkey\n */\nexport function validateWalletPubkey(\n walletPubkeyRaw: string,\n expectedDepositorPubkey: string,\n): WalletPubkeyValidationResult {\n if (!expectedDepositorPubkey) {\n throw new Error(\n \"validateWalletPubkey requires expectedDepositorPubkey. Pass the on-chain registered depositor pubkey to avoid a self-comparison.\",\n );\n }\n\n const walletPubkeyXOnly = processPublicKeyToXOnly(walletPubkeyRaw);\n const depositorPubkey = expectedDepositorPubkey;\n\n if (walletPubkeyXOnly.toLowerCase() !== depositorPubkey.toLowerCase()) {\n throw new Error(\n `Wallet public key does not match vault depositor. ` +\n `Expected: ${depositorPubkey}, Got: ${walletPubkeyXOnly}. ` +\n `Please connect the wallet that was used to create this vault.`\n );\n }\n\n return { walletPubkeyRaw, walletPubkeyXOnly, depositorPubkey };\n}\n\n// ============================================================================\n// BTC formatting\n// ============================================================================\n\nconst SATOSHIS_PER_BTC = 100_000_000n;\n\n/**\n * Format satoshis as a human-readable BTC string with trailing zeros removed.\n */\nexport function formatSatoshisToBtc(satoshis: bigint): string {\n if (satoshis < 0n) {\n return `-${formatSatoshisToBtc(-satoshis)}`;\n }\n const whole = satoshis / SATOSHIS_PER_BTC;\n const fraction = satoshis % SATOSHIS_PER_BTC;\n let fractionStr = fraction.toString().padStart(8, \"0\");\n fractionStr = fractionStr.replace(/0+$/, \"\");\n return fractionStr.length > 0 ? `${whole}.${fractionStr}` : whole.toString();\n}\n\n// ============================================================================\n// Address derivation and validation\n// ============================================================================\n\n/**\n * Assert that the ECC library has been initialized via `initEccLib(ecc)`.\n *\n * The consuming application must call `initEccLib(ecc)` from `bitcoinjs-lib`\n * once at startup before using any SDK function that involves Taproot / P2TR\n * operations. This guard provides a clear error message when that step was\n * missed, instead of letting bitcoinjs-lib throw its generic\n * \"No ECC Library provided\" error deep in a call stack.\n */\nfunction assertEccInitialized(): void {\n try {\n payments.p2tr({ internalPubkey: Buffer.alloc(32, 1) });\n } catch (e) {\n if (e instanceof Error && e.message.includes(\"No ECC Library provided\")) {\n throw new Error(\n \"ECC library not initialized. \" +\n 'You must call initEccLib(ecc) from \"bitcoinjs-lib\" before using the SDK. ' +\n \"See the ts-sdk README for setup instructions.\",\n );\n }\n // Any other error means ECC is loaded (e.g. invalid key is fine — ECC worked).\n }\n}\n\n/**\n * Map SDK network type to bitcoinjs-lib Network object.\n *\n * @param network - Network type (\"bitcoin\", \"testnet\", \"signet\", \"regtest\")\n * @returns bitcoinjs-lib Network object\n */\nexport function getNetwork(network: Network): networks.Network {\n switch (network) {\n case \"bitcoin\":\n return networks.bitcoin;\n case \"testnet\":\n case \"signet\":\n return networks.testnet;\n case \"regtest\":\n return networks.regtest;\n default:\n throw new Error(`Unknown network: ${network}`);\n }\n}\n\n/**\n * Derive a Taproot (P2TR) address from a public key.\n *\n * @param publicKeyHex - Compressed (66 hex) or x-only (64 hex) public key\n * @param network - Bitcoin network\n * @returns Taproot address (bc1p... / tb1p... / bcrt1p...)\n */\nexport function deriveTaprootAddress(\n publicKeyHex: string,\n network: Network,\n): string {\n assertEccInitialized();\n const xOnly = hexToUint8Array(processPublicKeyToXOnly(publicKeyHex));\n const { address } = payments.p2tr({\n internalPubkey: Buffer.from(xOnly),\n network: getNetwork(network),\n });\n if (!address) {\n throw new Error(\"Failed to derive taproot address from public key\");\n }\n return address;\n}\n\n/**\n * Derive a Native SegWit (P2WPKH) address from a compressed public key.\n *\n * @param publicKeyHex - Compressed public key (66 hex chars, with or without 0x prefix)\n * @param network - Bitcoin network\n * @returns Native SegWit address (bc1q... / tb1q... / bcrt1q...)\n * @throws If publicKeyHex is not a compressed public key (66 hex chars)\n */\nexport function deriveNativeSegwitAddress(\n publicKeyHex: string,\n network: Network,\n): string {\n const cleanHex = stripHexPrefix(publicKeyHex);\n if (cleanHex.length !== 66) {\n throw new Error(\n `Native SegWit requires a compressed public key (66 hex chars), got ${cleanHex.length}`,\n );\n }\n const { address } = payments.p2wpkh({\n pubkey: Buffer.from(hexToUint8Array(cleanHex)),\n network: getNetwork(network),\n });\n if (!address) {\n throw new Error(\n \"Failed to derive native segwit address from public key\",\n );\n }\n return address;\n}\n\n/**\n * Validate that a BTC address was derived from the given public key.\n *\n * Derives Taproot (P2TR) and Native SegWit (P2WPKH) addresses from the\n * public key and checks if the provided address matches any of them.\n *\n * When the input is an x-only key (64 hex chars), both possible compressed\n * keys (`02` + x and `03` + x) are tried for Native SegWit derivation,\n * since the y-parity is unknown.\n *\n * @param address - BTC address to validate\n * @param publicKeyHex - Public key from the wallet (x-only 64 or compressed 66 hex chars)\n * @param network - Bitcoin network\n * @returns true if the address matches the public key\n */\nexport function isAddressFromPublicKey(\n address: string,\n publicKeyHex: string,\n network: Network,\n): boolean {\n const cleanHex = stripHexPrefix(publicKeyHex);\n\n // P2TR — works with both x-only and compressed keys\n try {\n if (address === deriveTaprootAddress(cleanHex, network)) {\n return true;\n }\n } catch {\n // derivation failed, continue\n }\n\n // Build the list of compressed keys to try for P2WPKH\n const compressedKeys: string[] = [];\n if (cleanHex.length === COMPRESSED_PUBKEY_HEX_LEN) {\n compressedKeys.push(cleanHex);\n } else if (cleanHex.length === X_ONLY_PUBKEY_HEX_LEN) {\n // x-only key — try both even (02) and odd (03) y-parity\n compressedKeys.push(`02${cleanHex}`, `03${cleanHex}`);\n }\n\n for (const key of compressedKeys) {\n try {\n if (address === deriveNativeSegwitAddress(key, network)) {\n return true;\n }\n } catch {\n // derivation failed, continue\n }\n }\n\n return false;\n}\n"],"names":["TAPSCRIPT_LEAF_VERSION","X_ONLY_PUBKEY_HEX_LEN","COMPRESSED_PUBKEY_HEX_LEN","UNCOMPRESSED_PUBKEY_HEX_LEN","SCHNORR_SIG_HEX_LEN","stripHexPrefix","hex","ensureHexPrefix","hexToUint8Array","cleanHex","isValidHexRaw","bytes","i","uint8ArrayToHex","b","inputTxidHex","input","toXOnly","pubKey","processPublicKeyToXOnly","publicKeyHex","pubkeyBytes","isValidHex","validateWalletPubkey","walletPubkeyRaw","expectedDepositorPubkey","walletPubkeyXOnly","depositorPubkey","SATOSHIS_PER_BTC","formatSatoshisToBtc","satoshis","whole","fractionStr","assertEccInitialized","payments","Buffer","getNetwork","network","networks","deriveTaprootAddress","xOnly","address","deriveNativeSegwitAddress","isAddressFromPublicKey","compressedKeys","key"],"mappings":"kEA0BaA,EAAyB,IAMzBC,EAAwB,GAMxBC,EAA4B,GAM5BC,EAA8B,IAK9BC,EAAsB,IAW5B,SAASC,EAAeC,EAAqB,CAClD,OAAOA,EAAI,WAAW,IAAI,GAAKA,EAAI,WAAW,IAAI,EAAIA,EAAI,MAAM,CAAC,EAAIA,CACvE,CAWO,SAASC,EAAgBD,EAAkB,CAChD,OAAIA,EAAI,WAAW,IAAI,EAAUA,EAC7BA,EAAI,WAAW,IAAI,EAAU,KAAKA,EAAI,MAAM,CAAC,CAAC,GAC3C,KAAKA,CAAG,E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