@talken/talkenkit 2.3.6 → 2.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/dist/components/ChainIndicator/ChainIndicator.css.d.ts +4 -0
  2. package/dist/components/ChainIndicator/ChainIndicator.d.ts +53 -0
  3. package/dist/components/ChainIndicator/index.d.ts +2 -0
  4. package/dist/components/ChainSelector/ChainSelector.css.d.ts +5 -0
  5. package/dist/components/ChainSelector/ChainSelector.d.ts +38 -0
  6. package/dist/components/ChainSelector/index.d.ts +2 -0
  7. package/dist/components/ConnectButton/ConnectButtonRenderer.d.ts +9 -0
  8. package/dist/components/ConnectOptions/DesktopOptions.d.ts +5 -1
  9. package/dist/components/ConnectOptions/MultiChainConnectOptions.d.ts +31 -0
  10. package/dist/components/ConnectOptions/index.d.ts +3 -0
  11. package/dist/components/ModalSelection/ModalSelection.d.ts +2 -1
  12. package/dist/components/ProfileDetails/ProfileDetails.d.ts +1 -2
  13. package/dist/components/RainbowKitProvider/RainbowKitProvider.d.ts +8 -1
  14. package/dist/components/SolanaWalletList/SolanaWalletList.css.d.ts +7 -0
  15. package/dist/components/SolanaWalletList/SolanaWalletList.d.ts +32 -0
  16. package/dist/components/SolanaWalletList/index.d.ts +2 -0
  17. package/dist/contexts/MultiChainContext.d.ts +68 -0
  18. package/dist/contexts/index.d.ts +7 -0
  19. package/dist/index.css +105 -0
  20. package/dist/index.d.ts +12 -0
  21. package/dist/index.js +1432 -834
  22. package/dist/solana/SolanaWalletProvider.d.ts +38 -0
  23. package/dist/solana/config.d.ts +57 -0
  24. package/dist/solana/index.d.ts +11 -0
  25. package/dist/solana/utils/detection.d.ts +27 -0
  26. package/dist/solana/wallets/backpackWallet.d.ts +19 -0
  27. package/dist/solana/wallets/index.d.ts +8 -0
  28. package/dist/solana/wallets/phantomSolanaWallet.d.ts +17 -0
  29. package/dist/solana/wallets/solflareWallet.d.ts +17 -0
  30. package/dist/types/solana.d.ts +97 -0
  31. package/dist/wallets/recentSolanaWalletIds.d.ts +16 -0
  32. package/dist/wallets/walletConnectors/abcWallet/api/index.js +4 -4
  33. package/dist/wallets/walletConnectors/abcWallet/index.js +2 -2
  34. package/dist/wallets/walletConnectors/chunk-3SVPZCA6.js +71 -0
  35. package/dist/wallets/walletConnectors/chunk-5QEUEPNY.js +94 -0
  36. package/dist/wallets/walletConnectors/chunk-B6JLYR3I.js +66 -0
  37. package/dist/wallets/walletConnectors/chunk-HKWBR5B7.js +102 -0
  38. package/dist/wallets/walletConnectors/chunk-K4APJ4PE.js +96 -0
  39. package/dist/wallets/walletConnectors/chunk-LJ2B47VF.js +108 -0
  40. package/dist/wallets/walletConnectors/chunk-LXINMUQC.js +186 -0
  41. package/dist/wallets/walletConnectors/chunk-MORUEOYX.js +76 -0
  42. package/dist/wallets/walletConnectors/chunk-MQTXA63X.js +27 -0
  43. package/dist/wallets/walletConnectors/chunk-PMZJGS7X.js +73 -0
  44. package/dist/wallets/walletConnectors/chunk-WZZVA3LW.js +101 -0
  45. package/dist/wallets/walletConnectors/chunk-XEIKWKH7.js +63 -0
  46. package/dist/wallets/walletConnectors/chunk-XOQNQKZE.js +98 -0
  47. package/dist/wallets/walletConnectors/chunk-ZAGAF6PO.js +63 -0
  48. package/dist/wallets/walletConnectors/chunk-ZJ6OFFD5.js +95 -0
  49. package/dist/wallets/walletConnectors/index.js +9 -9
  50. package/package.json +6 -1
  51. package/dist/wallets/walletConnectors/chunk-2J66VMY5.js +0 -152
  52. package/dist/wallets/walletConnectors/chunk-2J6LHJAF.js +0 -228
  53. package/dist/wallets/walletConnectors/chunk-2ZPGPZCP.js +0 -228
  54. package/dist/wallets/walletConnectors/chunk-3DPCIDW6.js +0 -1730
  55. package/dist/wallets/walletConnectors/chunk-4HKJ53H3.js +0 -1742
  56. package/dist/wallets/walletConnectors/chunk-5EARL7FN.js +0 -39
  57. package/dist/wallets/walletConnectors/chunk-6JKWIEGA.js +0 -228
  58. package/dist/wallets/walletConnectors/chunk-7L33BY4P.js +0 -44
  59. package/dist/wallets/walletConnectors/chunk-7SXCH5TL.js +0 -1752
  60. package/dist/wallets/walletConnectors/chunk-7UZBDZZZ.js +0 -599
  61. package/dist/wallets/walletConnectors/chunk-BRM4ZVXZ.js +0 -44
  62. package/dist/wallets/walletConnectors/chunk-BUDWZAL7.js +0 -44
  63. package/dist/wallets/walletConnectors/chunk-CSWWNAYR.js +0 -44
  64. package/dist/wallets/walletConnectors/chunk-E4N7SPPU.js +0 -39
  65. package/dist/wallets/walletConnectors/chunk-ENU7XLF5.js +0 -44
  66. package/dist/wallets/walletConnectors/chunk-ESRU5KCF.js +0 -151
  67. package/dist/wallets/walletConnectors/chunk-FF7ZIXKD.js +0 -39
  68. package/dist/wallets/walletConnectors/chunk-FJCL2YPU.js +0 -1737
  69. package/dist/wallets/walletConnectors/chunk-FSU3WBH3.js +0 -63
  70. package/dist/wallets/walletConnectors/chunk-G2IHR6PW.js +0 -63
  71. package/dist/wallets/walletConnectors/chunk-HD6YCICR.js +0 -228
  72. package/dist/wallets/walletConnectors/chunk-HDYBRMYW.js +0 -194
  73. package/dist/wallets/walletConnectors/chunk-HIZCIW5L.js +0 -228
  74. package/dist/wallets/walletConnectors/chunk-JRNBDHFL.js +0 -44
  75. package/dist/wallets/walletConnectors/chunk-KIQDE4N6.js +0 -39
  76. package/dist/wallets/walletConnectors/chunk-KOT7JYJR.js +0 -39
  77. package/dist/wallets/walletConnectors/chunk-KRAIITU7.js +0 -39
  78. package/dist/wallets/walletConnectors/chunk-KZOSE2PI.js +0 -228
  79. package/dist/wallets/walletConnectors/chunk-L7I5I4CZ.js +0 -44
  80. package/dist/wallets/walletConnectors/chunk-LNZJLKFB.js +0 -39
  81. package/dist/wallets/walletConnectors/chunk-LV765WZL.js +0 -1748
  82. package/dist/wallets/walletConnectors/chunk-MSI2BPP5.js +0 -1722
  83. package/dist/wallets/walletConnectors/chunk-MX2IY5CD.js +0 -44
  84. package/dist/wallets/walletConnectors/chunk-NLX2EV7O.js +0 -44
  85. package/dist/wallets/walletConnectors/chunk-NVAZ3B3V.js +0 -228
  86. package/dist/wallets/walletConnectors/chunk-OEWU3ZMN.js +0 -39
  87. package/dist/wallets/walletConnectors/chunk-P2MTINFI.js +0 -280
  88. package/dist/wallets/walletConnectors/chunk-PNMSIVVT.js +0 -44
  89. package/dist/wallets/walletConnectors/chunk-PZNYT2HC.js +0 -1722
  90. package/dist/wallets/walletConnectors/chunk-QPAE4SDS.js +0 -39
  91. package/dist/wallets/walletConnectors/chunk-QZRNNI3E.js +0 -39
  92. package/dist/wallets/walletConnectors/chunk-R4UYVU5X.js +0 -1721
  93. package/dist/wallets/walletConnectors/chunk-R6JCHV55.js +0 -39
  94. package/dist/wallets/walletConnectors/chunk-RLBGBBIO.js +0 -309
  95. package/dist/wallets/walletConnectors/chunk-RWIZ25FJ.js +0 -1684
  96. package/dist/wallets/walletConnectors/chunk-TUUNSVKZ.js +0 -345
  97. package/dist/wallets/walletConnectors/chunk-U2CUEL35.js +0 -240
  98. package/dist/wallets/walletConnectors/chunk-V6NRLREB.js +0 -44
  99. package/dist/wallets/walletConnectors/chunk-VM7AEC7H.js +0 -39
  100. package/dist/wallets/walletConnectors/chunk-VPNKJ7PB.js +0 -1674
  101. package/dist/wallets/walletConnectors/chunk-W2VDZD74.js +0 -478
  102. package/dist/wallets/walletConnectors/chunk-WAO3KL5U.js +0 -285
  103. package/dist/wallets/walletConnectors/chunk-WPHTIILX.js +0 -228
  104. package/dist/wallets/walletConnectors/chunk-WR7HSVMH.js +0 -228
  105. package/dist/wallets/walletConnectors/chunk-WSCJY2QD.js +0 -228
  106. package/dist/wallets/walletConnectors/chunk-X3JQB5QL.js +0 -44
  107. package/dist/wallets/walletConnectors/chunk-X4CDP7L7.js +0 -228
  108. package/dist/wallets/walletConnectors/chunk-XETOVXYM.js +0 -228
  109. package/dist/wallets/walletConnectors/chunk-XYPR4BAF.js +0 -436
  110. package/dist/wallets/walletConnectors/chunk-YZBFKVTX.js +0 -1675
  111. package/dist/wallets/walletConnectors/chunk-Z2ZRPTPX.js +0 -1726
  112. package/dist/wallets/walletConnectors/{chunk-47TQ23J4.js → chunk-6TLWAEJV.js} +8 -8
  113. package/dist/wallets/walletConnectors/{chunk-LTBQU2GW.js → chunk-74ALNZG4.js} +3 -3
  114. package/dist/wallets/walletConnectors/{chunk-66SCJ77O.js → chunk-CM5OGUJV.js} +6 -6
  115. package/dist/wallets/walletConnectors/{chunk-VCBVYFLJ.js → chunk-NLKL4KD2.js} +8 -8
@@ -1,599 +0,0 @@
1
- "use client";
2
- import {
3
- BaseApiClient
4
- } from "./chunk-WAO3KL5U.js";
5
- import {
6
- createAbcError
7
- } from "./chunk-W2VDZD74.js";
8
- import {
9
- DEFAULT_HEADERS
10
- } from "./chunk-VETRBBA2.js";
11
-
12
- // src/wallets/walletConnectors/abcWallet/api/BitcoinApi.ts
13
- var BitcoinApi = class extends BaseApiClient {
14
- /**
15
- * Generate Bitcoin wallet
16
- * Uses V3 API with secp256k1 curve (same as EVM but compressed public key)
17
- *
18
- * @param pin - Hashed PIN (SHA-256)
19
- * @param network - Bitcoin network (mainnet or testnet)
20
- * @param addressType - Bitcoin address type (bech32 recommended)
21
- * @returns Bitcoin wallet information
22
- */
23
- async generateBitcoinWallet(pin, network = "bitcoin", addressType = "bech32") {
24
- console.log("[BitcoinApi] \u{1F527} Generating Bitcoin wallet...", {
25
- network,
26
- addressType
27
- });
28
- const response = await this.request("/v3/wallet/generate", {
29
- method: "POST",
30
- contentType: "json",
31
- body: {
32
- curve: "secp256k1",
33
- // Same as EVM but compressed public key
34
- password: pin,
35
- network
36
- }
37
- });
38
- if (response.status !== "success" || !response.result) {
39
- console.error("[BitcoinApi] \u274C Generation failed:", response);
40
- throw createAbcError(
41
- "WALLET_NOT_FOUND" /* WALLET_NOT_FOUND */,
42
- "Failed to generate Bitcoin wallet",
43
- response
44
- );
45
- }
46
- const result = response.result;
47
- const addressResult = await this.getBitcoinAddress(
48
- result.public_key,
49
- network,
50
- addressType
51
- );
52
- console.log("[BitcoinApi] \u2705 Bitcoin wallet generated:", addressResult);
53
- return {
54
- uid: result.uid || "",
55
- sessionId: result.share_id,
56
- shareId: result.share_id,
57
- publicKey: result.public_key,
58
- // Compressed (33 bytes, 0x02 or 0x03 prefix)
59
- address: addressResult,
60
- addressType,
61
- keyId: result.key_id || result.share_id,
62
- encryptedShare: result.encrypted_share || "",
63
- network
64
- };
65
- }
66
- /**
67
- * Recover Bitcoin wallet
68
- * Uses V3 API wallet recovery endpoint
69
- *
70
- * @param pin - Hashed PIN (SHA-256)
71
- * @param network - Bitcoin network
72
- * @param addressType - Bitcoin address type
73
- * @returns Recovered Bitcoin wallet information
74
- */
75
- async recoverBitcoinWallet(pin, network = "bitcoin", addressType = "bech32") {
76
- console.log("[BitcoinApi] \u{1F527} Recovering Bitcoin wallet...", {
77
- network,
78
- addressType
79
- });
80
- const response = await this.request("/v3/wallet/recover", {
81
- method: "POST",
82
- contentType: "json",
83
- body: {
84
- curve: "secp256k1",
85
- password: pin,
86
- network
87
- }
88
- });
89
- if (response.status !== "success" || !response.result) {
90
- console.error("[BitcoinApi] \u274C Recovery failed:", response);
91
- throw createAbcError(
92
- "WALLET_NOT_FOUND" /* WALLET_NOT_FOUND */,
93
- "Failed to recover Bitcoin wallet",
94
- response
95
- );
96
- }
97
- const result = response.result;
98
- const addressResult = await this.getBitcoinAddress(
99
- result.public_key,
100
- network,
101
- addressType
102
- );
103
- console.log("[BitcoinApi] \u2705 Bitcoin wallet recovered:", addressResult);
104
- return {
105
- uid: result.uid || "",
106
- sessionId: result.share_id,
107
- shareId: result.share_id,
108
- publicKey: result.public_key,
109
- address: addressResult,
110
- addressType,
111
- keyId: result.key_id || result.share_id,
112
- encryptedShare: result.encrypted_share || "",
113
- network
114
- };
115
- }
116
- /**
117
- * Get Bitcoin address from compressed public key
118
- * Converts compressed public key to Bitcoin address based on address type
119
- *
120
- * @param publicKey - Compressed public key (33 bytes, hex)
121
- * @param network - Bitcoin network
122
- * @param addressType - Address format type (currently not used by API)
123
- * @returns Bitcoin address
124
- */
125
- async getBitcoinAddress(publicKey, network, _addressType = "bech32") {
126
- const url = `${this.baseURL}/wapi/v2/btc/address`;
127
- const params = new URLSearchParams({
128
- pubkey: publicKey,
129
- network
130
- });
131
- const response = await fetch(`${url}?${params}`, {
132
- method: "GET",
133
- headers: {
134
- ...this.accessToken ? { Authorization: `Bearer ${this.accessToken}` } : {}
135
- }
136
- });
137
- const data = await response.json();
138
- if (!response.ok) {
139
- throw createAbcError(
140
- "NETWORK_ERROR" /* NETWORK_ERROR */,
141
- "Failed to get Bitcoin address",
142
- data
143
- );
144
- }
145
- return data.address;
146
- }
147
- /**
148
- * Get UTXOs (Unspent Transaction Outputs) for address
149
- * Bitcoin uses UTXO model unlike EVM/Solana account model
150
- *
151
- * @param address - Bitcoin address
152
- * @param network - Bitcoin network
153
- * @returns Array of UTXOs
154
- */
155
- async getUtxos(address, network) {
156
- const url = `${this.baseURL}/wapi/v2/bitcoin/utxo/list`;
157
- const params = new URLSearchParams({ network, address });
158
- console.log("[BitcoinApi] \u{1F50D} Fetching UTXOs for:", address);
159
- const response = await fetch(`${url}?${params}`, {
160
- method: "GET",
161
- headers: {
162
- ...DEFAULT_HEADERS,
163
- ...this.accessToken ? { Authorization: `Bearer ${this.accessToken}` } : {}
164
- }
165
- });
166
- const data = await response.json();
167
- if (!response.ok || data.status !== "success") {
168
- throw createAbcError(
169
- "NETWORK_ERROR" /* NETWORK_ERROR */,
170
- "Failed to get UTXOs",
171
- data
172
- );
173
- }
174
- const utxos = data.result?.utxos || [];
175
- console.log(`[BitcoinApi] \u2705 Found ${utxos.length} UTXOs`);
176
- return utxos;
177
- }
178
- /**
179
- * Sign Bitcoin transaction (PSBT-based)
180
- * Bitcoin transactions are signed using PSBT (BIP-174) format
181
- * Each input requires individual signature
182
- *
183
- * @param params - Transaction signing parameters
184
- * @returns Signed PSBT with multiple input signatures
185
- */
186
- async signBitcoinTransaction(params) {
187
- const url = `${this.baseURL}/v3/wallet/sign`;
188
- console.log("[BitcoinApi] \u{1F510} Signing Bitcoin transaction (PSBT)...");
189
- const response = await fetch(url, {
190
- method: "POST",
191
- headers: {
192
- ...DEFAULT_HEADERS,
193
- ...this.accessToken ? { Authorization: `Bearer ${this.accessToken}` } : {}
194
- },
195
- body: JSON.stringify({
196
- uid: params.uid,
197
- share_id: params.shareId,
198
- message: params.psbt,
199
- // PSBT in base64
200
- password: params.pin,
201
- network: params.network
202
- })
203
- });
204
- const data = await response.json();
205
- if (!response.ok || data.status !== "success") {
206
- console.error("[BitcoinApi] \u274C Transaction signing failed:", data);
207
- throw createAbcError(
208
- "SIGNATURE_FAILED" /* SIGNATURE_FAILED */,
209
- "Failed to sign Bitcoin transaction",
210
- data
211
- );
212
- }
213
- console.log("[BitcoinApi] \u2705 Transaction signed successfully");
214
- return {
215
- signedPsbt: data.result?.signedPsbt,
216
- signatures: data.result?.signatures || []
217
- };
218
- }
219
- /**
220
- * Sign Bitcoin message (BIP-322)
221
- * Bitcoin message signing using BIP-322 standard
222
- * Supports both legacy and modern address types
223
- *
224
- * @param params - Message signing parameters
225
- * @returns BIP-322 signature
226
- */
227
- async signBitcoinMessage(params) {
228
- const url = `${this.baseURL}/v3/wallet/sign`;
229
- console.log("[BitcoinApi] \u{1F510} Signing Bitcoin message (BIP-322)...");
230
- const response = await fetch(url, {
231
- method: "POST",
232
- headers: {
233
- ...DEFAULT_HEADERS,
234
- ...this.accessToken ? { Authorization: `Bearer ${this.accessToken}` } : {}
235
- },
236
- body: JSON.stringify({
237
- uid: params.uid,
238
- share_id: params.shareId,
239
- message: params.message,
240
- // Hex-encoded message
241
- password: params.pin,
242
- messageType: params.messageType || "bip322",
243
- network: params.network
244
- })
245
- });
246
- const data = await response.json();
247
- if (!response.ok || data.status !== "success") {
248
- console.error("[BitcoinApi] \u274C Message signing failed:", data);
249
- throw createAbcError(
250
- "SIGNATURE_FAILED" /* SIGNATURE_FAILED */,
251
- "Failed to sign Bitcoin message",
252
- data
253
- );
254
- }
255
- console.log("[BitcoinApi] \u2705 Message signed successfully");
256
- return {
257
- signature: data.result?.signature,
258
- messageHash: data.result?.messageHash,
259
- address: data.result?.address,
260
- network: params.network
261
- };
262
- }
263
- /**
264
- * Send Bitcoin transaction
265
- * Broadcasts signed transaction to Bitcoin network
266
- *
267
- * @param params - Transaction broadcast parameters
268
- * @returns Transaction hash
269
- */
270
- async sendBitcoinTransaction(params) {
271
- const url = `${this.baseURL}/wapi/v2/bitcoin/tx/sendTransaction`;
272
- console.log("[BitcoinApi] \u{1F4E1} Broadcasting Bitcoin transaction...");
273
- const response = await fetch(url, {
274
- method: "POST",
275
- headers: {
276
- ...DEFAULT_HEADERS,
277
- ...this.accessToken ? { Authorization: `Bearer ${this.accessToken}` } : {}
278
- },
279
- body: JSON.stringify({
280
- network: params.network,
281
- rawTransaction: params.rawTransaction,
282
- ...params.psbt && { psbt: params.psbt }
283
- })
284
- });
285
- const data = await response.json();
286
- if (!response.ok || data.status !== "success") {
287
- console.error("[BitcoinApi] \u274C Transaction broadcast failed:", data);
288
- throw createAbcError(
289
- "NETWORK_ERROR" /* NETWORK_ERROR */,
290
- "Failed to send Bitcoin transaction",
291
- data
292
- );
293
- }
294
- const txHash = data.result?.data;
295
- console.log("[BitcoinApi] \u2705 Transaction broadcasted:", txHash);
296
- return {
297
- txHash
298
- };
299
- }
300
- /**
301
- * Generate Bitcoin transaction (Step 1 of 3)
302
- * Creates PSBT and returns hashes to sign
303
- *
304
- * @param params - Transaction parameters
305
- * @returns Transaction data with hashes to sign
306
- */
307
- async generateTransaction(params) {
308
- const url = `${this.baseURL}/wapi/v2/btc/transaction/generate`;
309
- console.log("[BitcoinApi] \u{1F527} Generating transaction...", params);
310
- const response = await fetch(url, {
311
- method: "POST",
312
- headers: {
313
- "Content-Type": "application/json",
314
- ...this.accessToken ? { Authorization: `Bearer ${this.accessToken}` } : {}
315
- },
316
- body: JSON.stringify(params)
317
- });
318
- const data = await response.json();
319
- if (!response.ok || !data.hashes) {
320
- const errorMsg = typeof data.error === "string" ? data.error : JSON.stringify(data.error || data);
321
- console.error("[BitcoinApi] \u274C Generate failed:", errorMsg);
322
- throw createAbcError(
323
- "NETWORK_ERROR" /* NETWORK_ERROR */,
324
- `Failed to generate transaction: ${errorMsg}`,
325
- data
326
- );
327
- }
328
- console.log(
329
- `[BitcoinApi] \u2705 Generated ${data.hashes.length} hashes to sign`
330
- );
331
- return data;
332
- }
333
- /**
334
- * Sign transaction hash (Step 2 of 3)
335
- * Uses Secure Channel encryption for signing
336
- * Based on tg-wallet-frontend reference implementation
337
- *
338
- * @param hash - Transaction hash to sign
339
- * @param wallet - Full wallet object with Bitcoin signing fields
340
- * @param pinHash - Hashed PIN for device password
341
- * @param secureService - Secure service instance for encryption
342
- * @returns Signature hex string (r + s without 0x prefix on s)
343
- */
344
- async signHash(hash, wallet, pinHash, secureService) {
345
- console.log("[BitcoinApi] \u{1F510} Signing hash:", `${hash.substring(0, 20)}...`);
346
- if (!wallet.wid || !wallet.pvencstr) {
347
- console.error("[BitcoinApi] \u274C Missing Bitcoin signing fields:", {
348
- hasWid: !!wallet.wid,
349
- hasPvencstr: !!wallet.pvencstr,
350
- hasSid: !!wallet.sid,
351
- hasUid: !!wallet.uid
352
- });
353
- throw createAbcError(
354
- "WALLET_NOT_FOUND" /* WALLET_NOT_FOUND */,
355
- "Wallet missing required fields for Bitcoin signing (wid, pvencstr)",
356
- { hasWid: !!wallet.wid, hasPvencstr: !!wallet.pvencstr }
357
- );
358
- }
359
- console.log("[BitcoinApi] \u2705 Wallet fields validated for Bitcoin signing");
360
- console.log("[BitcoinApi] \u{1F4CB} Wallet PLAINTEXT values:", {
361
- hasWid: !!wallet.wid,
362
- widLength: wallet.wid?.length,
363
- hasPvencstr: !!wallet.pvencstr,
364
- pvencstrLength: wallet.pvencstr?.length,
365
- hasEncryptDevicePassword: !!wallet.encryptDevicePassword,
366
- encryptDevicePasswordLength: wallet.encryptDevicePassword?.length
367
- });
368
- const encryptDevicePassword = await secureService.getEncryptPlain(
369
- wallet.encryptDevicePassword || pinHash
370
- );
371
- const pvencstr = await secureService.getEncryptPlain(wallet.pvencstr);
372
- const wid = await secureService.getEncryptPlain(wallet.wid);
373
- const secureChannelId = await secureService.getSecureChannelId();
374
- console.log("[BitcoinApi] \u{1F510} Encrypted values:", {
375
- encryptDevicePasswordLength: encryptDevicePassword.length,
376
- pvencstrLength: pvencstr.length,
377
- widLength: wid.length,
378
- secureChannelId
379
- });
380
- const params = new URLSearchParams({
381
- uid: wallet.uid,
382
- sid: wallet.sid || "",
383
- // Handle optional sid
384
- hash,
385
- pvencstr,
386
- wid,
387
- encryptDevicePassword
388
- });
389
- console.log("[BitcoinApi] \u{1F4E4} Request params:", {
390
- uid: wallet.uid,
391
- sid: wallet.sid || "",
392
- hashLength: hash.length,
393
- bodyLength: params.toString().length
394
- });
395
- const url = `${this.baseURL}/wapi/v2/sign/hash`;
396
- const response = await fetch(url, {
397
- method: "POST",
398
- headers: {
399
- "Content-Type": "application/x-www-form-urlencoded",
400
- "Secure-Channel": secureChannelId,
401
- ...this.accessToken ? { Authorization: `Bearer ${this.accessToken}` } : {}
402
- },
403
- body: params.toString()
404
- });
405
- const responseText = await response.text();
406
- console.log("[BitcoinApi] \u{1F4E5} Raw response:", {
407
- status: response.status,
408
- statusText: response.statusText,
409
- text: responseText.substring(0, 200)
410
- });
411
- if (!responseText) {
412
- throw createAbcError(
413
- "NETWORK_ERROR" /* NETWORK_ERROR */,
414
- "Empty response from sign hash API",
415
- { status: response.status }
416
- );
417
- }
418
- let data;
419
- try {
420
- data = JSON.parse(responseText);
421
- } catch (parseError) {
422
- console.error("[BitcoinApi] \u274C JSON parse error:", parseError);
423
- throw createAbcError(
424
- "NETWORK_ERROR" /* NETWORK_ERROR */,
425
- "Invalid JSON response from sign hash API",
426
- { responseText, parseError }
427
- );
428
- }
429
- if (!response.ok || data.iserr === true || !data.signstr) {
430
- const errorDetails = data.errmsg || data.errors?.[0] || data.message || data;
431
- console.error("[BitcoinApi] \u274C Sign failed:", errorDetails);
432
- throw createAbcError(
433
- "SIGNATURE_FAILED" /* SIGNATURE_FAILED */,
434
- `Failed to sign hash: ${JSON.stringify(errorDetails)}`,
435
- data
436
- );
437
- }
438
- console.log("[BitcoinApi] \u2705 Sign successful, parsing signature...");
439
- const signstr = JSON.parse(data.signstr);
440
- const sig_list = signstr.sig_list;
441
- const signatures = [];
442
- for (const sig of sig_list) {
443
- const r = sig.r;
444
- const s = sig.s.startsWith("0x") ? sig.s.substring(2) : sig.s;
445
- const combinedSig = r + s;
446
- signatures.push(combinedSig);
447
- }
448
- console.log(
449
- "[BitcoinApi] \u2705 Signature generated:",
450
- `${signatures[0].substring(0, 32)}...`
451
- );
452
- return signatures[0];
453
- }
454
- /**
455
- * Finalize and broadcast transaction (Step 3 of 3)
456
- * Broadcasts signed transaction to Bitcoin network
457
- *
458
- * @param params - Transaction parameters with signatures
459
- * @returns Transaction hash
460
- */
461
- async finalizeTransaction(params) {
462
- const url = `${this.baseURL}/wapi/v2/btc/transaction/finalize`;
463
- console.log("[BitcoinApi] \u{1F4E1} Broadcasting transaction...");
464
- console.log("[BitcoinApi] \u{1F4E4} Finalize params:", {
465
- signatureCount: params.signatureHex.length,
466
- amount: params.amount,
467
- to: params.to,
468
- pubkey: `${params.pubkey.substring(0, 20)}...`
469
- });
470
- const response = await fetch(url, {
471
- method: "POST",
472
- headers: {
473
- "Content-Type": "application/json",
474
- ...this.accessToken ? { Authorization: `Bearer ${this.accessToken}` } : {}
475
- },
476
- body: JSON.stringify(params)
477
- });
478
- const responseText = await response.text();
479
- console.log("[BitcoinApi] \u{1F4E5} Finalize raw response:", {
480
- status: response.status,
481
- statusText: response.statusText,
482
- text: responseText.substring(0, 200)
483
- });
484
- if (!responseText) {
485
- throw createAbcError(
486
- "NETWORK_ERROR" /* NETWORK_ERROR */,
487
- "Empty response from finalize API",
488
- { status: response.status }
489
- );
490
- }
491
- let data;
492
- try {
493
- data = JSON.parse(responseText);
494
- } catch (parseError) {
495
- console.error("[BitcoinApi] \u274C JSON parse error:", parseError);
496
- throw createAbcError(
497
- "NETWORK_ERROR" /* NETWORK_ERROR */,
498
- "Invalid JSON response from finalize API",
499
- { responseText, parseError }
500
- );
501
- }
502
- console.log("[BitcoinApi] \u{1F4CB} Finalize parsed data:", data);
503
- if (!response.ok) {
504
- const errorMsg = data.error || data.message || data.errmsg || "Unknown error";
505
- console.error("[BitcoinApi] \u274C Finalize failed:", errorMsg);
506
- throw createAbcError(
507
- "NETWORK_ERROR" /* NETWORK_ERROR */,
508
- `Failed to finalize transaction: ${errorMsg}`,
509
- data
510
- );
511
- }
512
- const txHash = data.result?.tx_hash || data.tx_hash || data.result?.txHash || data.txHash;
513
- if (!txHash) {
514
- console.error("[BitcoinApi] \u274C No tx_hash in response:", data);
515
- throw createAbcError(
516
- "NETWORK_ERROR" /* NETWORK_ERROR */,
517
- "Transaction hash not found in response",
518
- data
519
- );
520
- }
521
- console.log("[BitcoinApi] \u2705 Transaction sent:", txHash);
522
- return txHash;
523
- }
524
- /**
525
- * Send Bitcoin transaction (Complete flow: generate → sign → finalize)
526
- * High-level API that handles all 3 steps
527
- *
528
- * @param params - Transaction parameters
529
- * @param wallet - EVM wallet credentials
530
- * @param pinHash - Hashed PIN
531
- * @param secureService - Secure service instance
532
- * @returns Transaction hash
533
- */
534
- async sendTransaction(params, wallet, pinHash, secureService) {
535
- console.log("[BitcoinApi] \u{1F4B8} Starting Bitcoin transaction flow...");
536
- const generateData = await this.generateTransaction({
537
- amount: params.amount,
538
- pubkey: params.pubkey,
539
- to: params.to,
540
- feeRate: "2"
541
- // Default fee rate
542
- });
543
- const { hashes, fee_rate } = generateData;
544
- const signatureHex = [];
545
- for (let i = 0; i < hashes.length; i++) {
546
- const signature = await this.signHash(
547
- hashes[i],
548
- wallet,
549
- pinHash,
550
- secureService
551
- );
552
- signatureHex.push(signature);
553
- }
554
- const txHash = await this.finalizeTransaction({
555
- network: params.network,
556
- signatureHex,
557
- feeRate: fee_rate,
558
- amount: params.amount,
559
- pubkey: params.pubkey,
560
- to: params.to
561
- });
562
- console.log("[BitcoinApi] \u2705 Transaction complete:", txHash);
563
- return txHash;
564
- }
565
- /**
566
- * Estimate Bitcoin transaction fee
567
- * Gets recommended fee rate (satoshis per byte) for target confirmation blocks
568
- *
569
- * @param network - Bitcoin network
570
- * @param targetBlocks - Target confirmation blocks (default: 6)
571
- * @returns Fee rate in satoshis per byte
572
- */
573
- async estimateFee(network, targetBlocks = 6) {
574
- const url = `${this.baseURL}/wapi/v2/bitcoin/fee/estimate`;
575
- const params = new URLSearchParams({
576
- network,
577
- targetBlocks: targetBlocks.toString()
578
- });
579
- const response = await fetch(`${url}?${params}`, {
580
- method: "GET",
581
- headers: {
582
- ...DEFAULT_HEADERS,
583
- ...this.accessToken ? { Authorization: `Bearer ${this.accessToken}` } : {}
584
- }
585
- });
586
- const data = await response.json();
587
- if (!response.ok || data.status !== "success") {
588
- console.warn("[BitcoinApi] \u26A0\uFE0F Fee estimation failed, using fallback");
589
- return 1;
590
- }
591
- const feeRate = data.result?.feeRate || 1;
592
- console.log(`[BitcoinApi] \u26FD Estimated fee rate: ${feeRate} sat/byte`);
593
- return feeRate;
594
- }
595
- };
596
-
597
- export {
598
- BitcoinApi
599
- };
@@ -1,44 +0,0 @@
1
- "use client";
2
- import {
3
- abcConnector
4
- } from "./chunk-6JKWIEGA.js";
5
- import {
6
- ABC_WALLET_METADATA
7
- } from "./chunk-VETRBBA2.js";
8
-
9
- // src/wallets/walletConnectors/abcWallet/abcWallet.ts
10
- var abcWallet = (specificOptions) => ({ projectId }) => {
11
- const waasUrl = specificOptions?.waasUrl || process.env.NEXT_PUBLIC_ABC_WAAS_URL || process.env.VITE_ABC_WAAS_URL;
12
- if (!waasUrl) {
13
- throw new Error(
14
- 'ABC WaaS URL is required. Please provide it via:\n1. abcWallet({ waasUrl: "..." }) options, or\n2. NEXT_PUBLIC_ABC_WAAS_URL environment variable, or\n3. VITE_ABC_WAAS_URL environment variable'
15
- );
16
- }
17
- const config = {
18
- waasUrl,
19
- apiKey: specificOptions?.apiKey,
20
- plain: specificOptions?.plain || "",
21
- // Deprecated - not used (secure.ts uses random generation)
22
- environment: specificOptions?.environment || "development",
23
- projectId
24
- };
25
- return {
26
- id: ABC_WALLET_METADATA.id,
27
- name: ABC_WALLET_METADATA.name,
28
- rdns: ABC_WALLET_METADATA.rdns,
29
- iconUrl: async () => (await import("./abcWallet-AYWSIGAG.js")).default,
30
- iconBackground: ABC_WALLET_METADATA.iconBackground,
31
- // Embedded wallet - no installation required
32
- installed: void 0,
33
- // No download URLs for embedded wallet
34
- downloadUrls: void 0,
35
- // Create connector - wrapper function required by Wallet type
36
- createConnector: (_walletDetails) => abcConnector({ config }),
37
- // Embedded wallet always available
38
- hidden: () => false
39
- };
40
- };
41
-
42
- export {
43
- abcWallet
44
- };
@@ -1,44 +0,0 @@
1
- "use client";
2
- import {
3
- abcConnector
4
- } from "./chunk-WPHTIILX.js";
5
- import {
6
- ABC_WALLET_METADATA
7
- } from "./chunk-VETRBBA2.js";
8
-
9
- // src/wallets/walletConnectors/abcWallet/abcWallet.ts
10
- var abcWallet = (specificOptions) => ({ projectId }) => {
11
- const waasUrl = specificOptions?.waasUrl || process.env.NEXT_PUBLIC_ABC_WAAS_URL || process.env.VITE_ABC_WAAS_URL;
12
- if (!waasUrl) {
13
- throw new Error(
14
- 'ABC WaaS URL is required. Please provide it via:\n1. abcWallet({ waasUrl: "..." }) options, or\n2. NEXT_PUBLIC_ABC_WAAS_URL environment variable, or\n3. VITE_ABC_WAAS_URL environment variable'
15
- );
16
- }
17
- const config = {
18
- waasUrl,
19
- apiKey: specificOptions?.apiKey,
20
- plain: specificOptions?.plain || "",
21
- // Deprecated - not used (secure.ts uses random generation)
22
- environment: specificOptions?.environment || "development",
23
- projectId
24
- };
25
- return {
26
- id: ABC_WALLET_METADATA.id,
27
- name: ABC_WALLET_METADATA.name,
28
- rdns: ABC_WALLET_METADATA.rdns,
29
- iconUrl: async () => (await import("./abcWallet-AYWSIGAG.js")).default,
30
- iconBackground: ABC_WALLET_METADATA.iconBackground,
31
- // Embedded wallet - no installation required
32
- installed: void 0,
33
- // No download URLs for embedded wallet
34
- downloadUrls: void 0,
35
- // Create connector - wrapper function required by Wallet type
36
- createConnector: (_walletDetails) => abcConnector({ config }),
37
- // Embedded wallet always available
38
- hidden: () => false
39
- };
40
- };
41
-
42
- export {
43
- abcWallet
44
- };