@talken/talkenkit 2.3.7 → 2.3.9

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 (219) hide show
  1. package/dist/Arc-ILTINY4C.js +8 -0
  2. package/dist/Brave-4L5B7JJR.js +8 -0
  3. package/dist/Browser-XMB4J5WD.js +8 -0
  4. package/dist/Chrome-6ZDQIHC5.js +8 -0
  5. package/dist/Edge-OAWCEU7H.js +8 -0
  6. package/dist/Firefox-O66FZK3V.js +8 -0
  7. package/dist/Linux-NUJF4EPC.js +8 -0
  8. package/dist/Macos-46EJ2NPK.js +8 -0
  9. package/dist/Opera-KTUB3UWN.js +8 -0
  10. package/dist/Safari-A3Q6PIT2.js +8 -0
  11. package/dist/Windows-NL32NG52.js +8 -0
  12. package/dist/abcWallet-ES4OPRSK.js +8 -0
  13. package/dist/ar_AR-YBBYUEGS.js +8 -0
  14. package/dist/arbitrum-D2TUFPZI.js +8 -0
  15. package/dist/argentWallet-A5HM5FRP.js +8 -0
  16. package/dist/assets-4NDWRKXE.js +8 -0
  17. package/dist/avalanche-BOOSH35S.js +8 -0
  18. package/dist/base-3JMRS35B.js +8 -0
  19. package/dist/berasigWallet-6IOU73YL.js +8 -0
  20. package/dist/bestWallet-6LJUU6OL.js +8 -0
  21. package/dist/bifrostWallet-SLPPXZ2K.js +8 -0
  22. package/dist/binanceWallet-Z67J7362.js +8 -0
  23. package/dist/bitgetWallet-DLLOWMCI.js +8 -0
  24. package/dist/bitskiWallet-CPOXGABT.js +8 -0
  25. package/dist/bitverseWallet-SAK4MIS6.js +8 -0
  26. package/dist/blast-4GF24NR7.js +8 -0
  27. package/dist/bloomWallet-YIRCNQZJ.js +8 -0
  28. package/dist/braveWallet-PNBKQKJC.js +8 -0
  29. package/dist/bsc-KU6MBOYR.js +8 -0
  30. package/dist/bybitWallet-GCDBAJKO.js +8 -0
  31. package/dist/celo-5A5VXMPX.js +8 -0
  32. package/dist/chunk-M2CMB5B2.js +93 -0
  33. package/dist/chunk-TJX4M23U.js +27 -0
  34. package/dist/clvWallet-R6YRCMZO.js +8 -0
  35. package/dist/coin98Wallet-4Y3ROAGP.js +8 -0
  36. package/dist/coinbaseWallet-L4QDZB5W.js +8 -0
  37. package/dist/compassWallet-NNBX35AV.js +8 -0
  38. package/dist/components/AbcLoginModal/AbcAuthModal.d.ts +11 -1
  39. package/dist/components/ConnectButton/ConnectButtonRenderer.d.ts +1 -1
  40. package/dist/components/ConnectOptions/CompactMobileOptions.css.d.ts +26 -0
  41. package/dist/components/ConnectOptions/CompactMobileOptions.d.ts +19 -0
  42. package/dist/components/ConnectOptions/DesktopOptions.d.ts +9 -2
  43. package/dist/components/RainbowKitProvider/RainbowKitConfigProvider.d.ts +20 -0
  44. package/dist/components/RainbowKitProvider/RainbowKitProvider.d.ts +17 -2
  45. package/dist/config/networks.d.ts +125 -0
  46. package/dist/connect-Q2RLUT5B.js +8 -0
  47. package/dist/contexts/index.d.ts +2 -2
  48. package/dist/coreWallet-PN2LMNGN.js +8 -0
  49. package/dist/create-HQ4QXTKY.js +8 -0
  50. package/dist/cronos-KZAB32FC.js +8 -0
  51. package/dist/dawnWallet-AMO43DL3.js +8 -0
  52. package/dist/de_DE-RUWMVYCQ.js +8 -0
  53. package/dist/desigWallet-AD335WX5.js +8 -0
  54. package/dist/en_US-NQ25CUR4.js +8 -0
  55. package/dist/encryption-3YHRI3PA.js +14 -0
  56. package/dist/enkryptWallet-OOP27GE2.js +8 -0
  57. package/dist/es_419-HKJPYJRI.js +8 -0
  58. package/dist/ethereum-WAFT6DML.js +8 -0
  59. package/dist/flow-XANNOAPJ.js +8 -0
  60. package/dist/foxWallet-UDUWOW52.js +8 -0
  61. package/dist/fr_FR-2O5ZDLPQ.js +1356 -0
  62. package/dist/frameWallet-BEABTFIT.js +8 -0
  63. package/dist/frontierWallet-RG47M3C5.js +8 -0
  64. package/dist/gateWallet-XOP74BMB.js +8 -0
  65. package/dist/gnosis-7GFI4V27.js +8 -0
  66. package/dist/hardhat-6HKZWC4T.js +8 -0
  67. package/dist/hi_IN-XRZ4YIUW.js +8 -0
  68. package/dist/hooks/useDeviceType.d.ts +9 -0
  69. package/dist/id_ID-REEY4CSS.js +8 -0
  70. package/dist/imTokenWallet-LTPKXYUD.js +8 -0
  71. package/dist/index.d.ts +9 -1
  72. package/dist/index.js +1960 -1040
  73. package/dist/injectedWallet-YCFZTULL.js +8 -0
  74. package/dist/iopayWallet-XS37QAUO.js +8 -0
  75. package/dist/ja_JP-2OPCVN6X.js +8 -0
  76. package/dist/kaia-DQ3OSYXE.js +8 -0
  77. package/dist/kaiaWallet-2XZDQZ63.js +8 -0
  78. package/dist/kaikasWallet-V2GCFPEB.js +8 -0
  79. package/dist/ko_KR-DDXBZTYT.js +8 -0
  80. package/dist/krakenWallet-3VM7ZM2O.js +8 -0
  81. package/dist/kresusWallet-4MXFQP4P.js +8 -0
  82. package/dist/ledgerWallet-YC3HF3NJ.js +8 -0
  83. package/dist/login-DGIK764Z.js +8 -0
  84. package/dist/magicEden-BLYGUG47.js +8 -0
  85. package/dist/manta-OEF3QP66.js +8 -0
  86. package/dist/mantle-EYIH4GGM.js +8 -0
  87. package/dist/metaMaskWallet-ZZMFVM52.js +8 -0
  88. package/dist/mewWallet-D6JN37EZ.js +8 -0
  89. package/dist/ms_MY-PX7G4XTD.js +8 -0
  90. package/dist/nestWallet-X3CDHKNV.js +8 -0
  91. package/dist/oktoWallet-ZYLL2RLN.js +8 -0
  92. package/dist/okxWallet-FLICEG4S.js +8 -0
  93. package/dist/omniWallet-DAQHKHUN.js +8 -0
  94. package/dist/oneInchWallet-BRGGUXND.js +8 -0
  95. package/dist/oneKeyWallet-KDU2JIFD.js +8 -0
  96. package/dist/optimism-6GXRYJDW.js +8 -0
  97. package/dist/paraSwapWallet-7UHWT54G.js +8 -0
  98. package/dist/phantomWallet-BSCGZT6L.js +8 -0
  99. package/dist/polygon-YNJM552P.js +8 -0
  100. package/dist/pt_BR-A5R4SBSC.js +8 -0
  101. package/dist/rabbyWallet-RZIUL3YN.js +8 -0
  102. package/dist/rainbowWallet-4ALDT5ZL.js +8 -0
  103. package/dist/ramperWallet-IB3JRE2F.js +8 -0
  104. package/dist/refresh-R5NYTT3S.js +8 -0
  105. package/dist/ronin-LU7LZPWA.js +8 -0
  106. package/dist/roninWallet-BS7VDK7U.js +8 -0
  107. package/dist/ru_RU-4QDZLRSW.js +1356 -0
  108. package/dist/safeWallet-5NR62MJV.js +8 -0
  109. package/dist/safeheronWallet-7ELUSU44.js +8 -0
  110. package/dist/safepalWallet-CZJABQ5N.js +8 -0
  111. package/dist/scan-BVZ7DVJ4.js +8 -0
  112. package/dist/scroll-XRP46UTI.js +8 -0
  113. package/dist/secure-GEK7TTJY.js +8 -0
  114. package/dist/seifWallet-XLBMTX4R.js +8 -0
  115. package/dist/sign-PREOQ4RR.js +8 -0
  116. package/dist/solana/SolanaWalletProvider.d.ts +1 -1
  117. package/dist/subWallet-47USA4OE.js +8 -0
  118. package/dist/tahoWallet-N3XXJ3NW.js +8 -0
  119. package/dist/talismanWallet-SV3B42TQ.js +8 -0
  120. package/dist/th_TH-4TWPYDKX.js +1356 -0
  121. package/dist/themes/baseTheme.js +1 -0
  122. package/dist/themes/darkTheme.js +1 -0
  123. package/dist/themes/lightTheme.js +1 -0
  124. package/dist/themes/midnightTheme.js +1 -0
  125. package/dist/tokenPocketWallet-7IYW3MIL.js +8 -0
  126. package/dist/tokenaryWallet-7D2LN65X.js +8 -0
  127. package/dist/tr_TR-C37KIU7M.js +1356 -0
  128. package/dist/trustWallet-HJQBMBC6.js +8 -0
  129. package/dist/uk_UA-I77HS4GO.js +1356 -0
  130. package/dist/uniswapWallet-JZ2ULELN.js +8 -0
  131. package/dist/utils/abcWaasAdapter.d.ts +75 -0
  132. package/dist/valoraWallet-PCTL6UBB.js +8 -0
  133. package/dist/vi_VN-KVPDLW26.js +8 -0
  134. package/dist/walletConnectWallet-AJ36XVBT.js +8 -0
  135. package/dist/wallets/walletConnectors/abcWallet/abcBitcoinConnector.d.ts +11 -8
  136. package/dist/wallets/walletConnectors/abcWallet/abcBitcoinConnector.js +1 -1
  137. package/dist/wallets/walletConnectors/abcWallet/abcBitcoinProvider.d.ts +4 -11
  138. package/dist/wallets/walletConnectors/abcWallet/abcBitcoinProvider.js +1 -1
  139. package/dist/wallets/walletConnectors/abcWallet/api/BitcoinApi.d.ts +1 -19
  140. package/dist/wallets/walletConnectors/abcWallet/api/BitcoinApi.js +1 -1
  141. package/dist/wallets/walletConnectors/abcWallet/api/index.js +5 -5
  142. package/dist/wallets/walletConnectors/abcWallet/index.js +5 -5
  143. package/dist/wallets/walletConnectors/abcWallet/types.d.ts +2 -0
  144. package/dist/wallets/walletConnectors/chunk-2GIBC7XF.js +39 -0
  145. package/dist/wallets/walletConnectors/chunk-2J66VMY5.js +152 -0
  146. package/dist/wallets/walletConnectors/chunk-34WMJDUY.js +481 -0
  147. package/dist/wallets/walletConnectors/chunk-3J3XZMJ7.js +39 -0
  148. package/dist/wallets/walletConnectors/chunk-3WVSOTC4.js +63 -0
  149. package/dist/wallets/walletConnectors/chunk-43LOEA55.js +63 -0
  150. package/dist/wallets/walletConnectors/chunk-4IRVZPIN.js +63 -0
  151. package/dist/wallets/walletConnectors/chunk-4NLOE5S3.js +63 -0
  152. package/dist/wallets/walletConnectors/chunk-5MSMALF7.js +63 -0
  153. package/dist/wallets/walletConnectors/chunk-5OFAP55G.js +44 -0
  154. package/dist/wallets/walletConnectors/chunk-6KOHIL7T.js +63 -0
  155. package/dist/wallets/walletConnectors/chunk-6YPK343Z.js +63 -0
  156. package/dist/wallets/walletConnectors/chunk-7FFIZE76.js +63 -0
  157. package/dist/wallets/walletConnectors/chunk-7P5HZGEV.js +627 -0
  158. package/dist/wallets/walletConnectors/chunk-A6LBRVGP.js +63 -0
  159. package/dist/wallets/walletConnectors/chunk-BKXPGZMQ.js +228 -0
  160. package/dist/wallets/walletConnectors/chunk-CNHVIXPV.js +228 -0
  161. package/dist/wallets/walletConnectors/chunk-DAZZIITX.js +1678 -0
  162. package/dist/wallets/walletConnectors/chunk-ESRU5KCF.js +151 -0
  163. package/dist/wallets/walletConnectors/chunk-F4JFONDA.js +601 -0
  164. package/dist/wallets/walletConnectors/chunk-GXHCAEWR.js +63 -0
  165. package/dist/wallets/walletConnectors/chunk-HDYBRMYW.js +194 -0
  166. package/dist/wallets/walletConnectors/chunk-HOE4UOHR.js +514 -0
  167. package/dist/wallets/walletConnectors/chunk-HS2FAOAJ.js +63 -0
  168. package/dist/wallets/walletConnectors/chunk-IA4EQFSS.js +474 -0
  169. package/dist/wallets/walletConnectors/chunk-IHM7I7D5.js +63 -0
  170. package/dist/wallets/walletConnectors/chunk-JJAJOFZI.js +63 -0
  171. package/dist/wallets/walletConnectors/chunk-KFIUFVQH.js +624 -0
  172. package/dist/wallets/walletConnectors/chunk-KFROJI25.js +535 -0
  173. package/dist/wallets/walletConnectors/chunk-KHVILXGK.js +514 -0
  174. package/dist/wallets/walletConnectors/chunk-LGT7LQAJ.js +63 -0
  175. package/dist/wallets/walletConnectors/chunk-LHBQ2Z3Q.js +63 -0
  176. package/dist/wallets/walletConnectors/chunk-M76GLEFL.js +63 -0
  177. package/dist/wallets/walletConnectors/chunk-MFIE6UCG.js +63 -0
  178. package/dist/wallets/walletConnectors/chunk-NA5G3LSC.js +63 -0
  179. package/dist/wallets/walletConnectors/chunk-NASGGIUS.js +63 -0
  180. package/dist/wallets/walletConnectors/chunk-NKJLO4QH.js +39 -0
  181. package/dist/wallets/walletConnectors/chunk-NURTFXQU.js +568 -0
  182. package/dist/wallets/walletConnectors/chunk-NVM3JZ4L.js +63 -0
  183. package/dist/wallets/walletConnectors/chunk-NWDLOM7Q.js +646 -0
  184. package/dist/wallets/walletConnectors/chunk-OHRTTVNJ.js +44 -0
  185. package/dist/wallets/walletConnectors/chunk-OMYDLPUM.js +63 -0
  186. package/dist/wallets/walletConnectors/chunk-P2MTINFI.js +280 -0
  187. package/dist/wallets/walletConnectors/chunk-PLL7P7HY.js +63 -0
  188. package/dist/wallets/walletConnectors/chunk-PUFQKZA7.js +63 -0
  189. package/dist/wallets/walletConnectors/chunk-RLBGBBIO.js +309 -0
  190. package/dist/wallets/walletConnectors/chunk-RUZBOPMI.js +63 -0
  191. package/dist/wallets/walletConnectors/chunk-S2B56ZVJ.js +481 -0
  192. package/dist/wallets/walletConnectors/chunk-SFP47DS6.js +63 -0
  193. package/dist/wallets/walletConnectors/chunk-SNZL5LJ6.js +637 -0
  194. package/dist/wallets/walletConnectors/chunk-SPR4W5TG.js +474 -0
  195. package/dist/wallets/walletConnectors/chunk-SSDCG5BG.js +63 -0
  196. package/dist/wallets/walletConnectors/chunk-SUXK3JW6.js +280 -0
  197. package/dist/wallets/walletConnectors/chunk-TUUNSVKZ.js +345 -0
  198. package/dist/wallets/walletConnectors/chunk-U2CUEL35.js +240 -0
  199. package/dist/wallets/walletConnectors/chunk-VLEVJVJR.js +63 -0
  200. package/dist/wallets/walletConnectors/chunk-W2VDZD74.js +478 -0
  201. package/dist/wallets/walletConnectors/chunk-WAO3KL5U.js +285 -0
  202. package/dist/wallets/walletConnectors/chunk-WYSKBMHW.js +280 -0
  203. package/dist/wallets/walletConnectors/chunk-XDRZSWHB.js +63 -0
  204. package/dist/wallets/walletConnectors/chunk-XKVRDEDK.js +63 -0
  205. package/dist/wallets/walletConnectors/chunk-XYAAXWWU.js +63 -0
  206. package/dist/wallets/walletConnectors/chunk-XYPR4BAF.js +436 -0
  207. package/dist/wallets/walletConnectors/index.js +68 -68
  208. package/dist/wigwamWallet-D3MVGB5Z.js +8 -0
  209. package/dist/xdc-5NQHQJE5.js +8 -0
  210. package/dist/xdefiWallet-B4O6HAIP.js +8 -0
  211. package/dist/zealWallet-6SPNICRX.js +8 -0
  212. package/dist/zerionWallet-XZ3JCAOO.js +8 -0
  213. package/dist/zetachain-U6IILKZJ.js +8 -0
  214. package/dist/zh_CN-KGLAIP3N.js +8 -0
  215. package/dist/zh_HK-AEXEN6P6.js +8 -0
  216. package/dist/zh_TW-6C7R5V3K.js +8 -0
  217. package/dist/zkSync-TMPB52ZN.js +8 -0
  218. package/dist/zora-S46CHEOU.js +8 -0
  219. package/package.json +1 -1
@@ -0,0 +1,646 @@
1
+ "use client";
2
+ import {
3
+ BaseApiClient
4
+ } from "./chunk-IOLHAU7H.js";
5
+ import {
6
+ createAbcError
7
+ } from "./chunk-W23N7VC4.js";
8
+ import {
9
+ DEFAULT_HEADERS
10
+ } from "./chunk-VETRBBA2.js";
11
+ import {
12
+ AbcErrorCode
13
+ } from "./chunk-5UEBEMEE.js";
14
+
15
+ // src/wallets/walletConnectors/abcWallet/api/BitcoinApi.ts
16
+ var BitcoinApi = class extends BaseApiClient {
17
+ /**
18
+ * Generate Bitcoin wallet
19
+ * Uses V3 API with secp256k1 curve (same as EVM but compressed public key)
20
+ *
21
+ * @param pin - Hashed PIN (SHA-256)
22
+ * @param network - Bitcoin network (mainnet or testnet)
23
+ * @param addressType - Bitcoin address type (bech32 recommended)
24
+ * @returns Bitcoin wallet information
25
+ */
26
+ async generateBitcoinWallet(pin, network = "bitcoin", addressType = "bech32") {
27
+ console.log("[BitcoinApi] \u{1F527} Generating Bitcoin wallet...", {
28
+ network,
29
+ addressType
30
+ });
31
+ const response = await this.request("/v3/wallet/generate", {
32
+ method: "POST",
33
+ contentType: "json",
34
+ body: {
35
+ curve: "secp256k1",
36
+ // Same as EVM but compressed public key
37
+ password: pin,
38
+ network
39
+ }
40
+ });
41
+ if (response.status !== "success" || !response.result) {
42
+ console.error("[BitcoinApi] \u274C Generation failed:", response);
43
+ throw createAbcError(
44
+ "WALLET_NOT_FOUND" /* WALLET_NOT_FOUND */,
45
+ "Failed to generate Bitcoin wallet",
46
+ response
47
+ );
48
+ }
49
+ const result = response.result;
50
+ const addressResult = await this.getBitcoinAddress(
51
+ result.public_key,
52
+ network,
53
+ addressType
54
+ );
55
+ console.log("[BitcoinApi] \u2705 Bitcoin wallet generated:", addressResult);
56
+ return {
57
+ uid: result.uid || "",
58
+ sessionId: result.share_id,
59
+ shareId: result.share_id,
60
+ publicKey: result.public_key,
61
+ // Compressed (33 bytes, 0x02 or 0x03 prefix)
62
+ address: addressResult,
63
+ addressType,
64
+ keyId: result.key_id || result.share_id,
65
+ encryptedShare: result.encrypted_share || "",
66
+ network
67
+ };
68
+ }
69
+ /**
70
+ * Recover Bitcoin wallet
71
+ * Uses V3 API wallet recovery endpoint
72
+ *
73
+ * @param pin - Hashed PIN (SHA-256)
74
+ * @param network - Bitcoin network
75
+ * @param addressType - Bitcoin address type
76
+ * @returns Recovered Bitcoin wallet information
77
+ */
78
+ async recoverBitcoinWallet(pin, network = "bitcoin", addressType = "bech32") {
79
+ console.log("[BitcoinApi] \u{1F527} Recovering Bitcoin wallet...", {
80
+ network,
81
+ addressType
82
+ });
83
+ const response = await this.request("/v3/wallet/recover", {
84
+ method: "POST",
85
+ contentType: "json",
86
+ body: {
87
+ curve: "secp256k1",
88
+ password: pin,
89
+ network
90
+ }
91
+ });
92
+ if (response.status !== "success" || !response.result) {
93
+ console.error("[BitcoinApi] \u274C Recovery failed:", response);
94
+ throw createAbcError(
95
+ "WALLET_NOT_FOUND" /* WALLET_NOT_FOUND */,
96
+ "Failed to recover Bitcoin wallet",
97
+ response
98
+ );
99
+ }
100
+ const result = response.result;
101
+ const addressResult = await this.getBitcoinAddress(
102
+ result.public_key,
103
+ network,
104
+ addressType
105
+ );
106
+ console.log("[BitcoinApi] \u2705 Bitcoin wallet recovered:", addressResult);
107
+ return {
108
+ uid: result.uid || "",
109
+ sessionId: result.share_id,
110
+ shareId: result.share_id,
111
+ publicKey: result.public_key,
112
+ address: addressResult,
113
+ addressType,
114
+ keyId: result.key_id || result.share_id,
115
+ encryptedShare: result.encrypted_share || "",
116
+ network
117
+ };
118
+ }
119
+ /**
120
+ * Get Bitcoin address from compressed public key
121
+ * Converts compressed public key to Bitcoin address based on address type
122
+ *
123
+ * @param publicKey - Compressed public key (33 bytes, hex)
124
+ * @param network - Bitcoin network
125
+ * @param addressType - Address format type (currently not used by API)
126
+ * @returns Bitcoin address
127
+ */
128
+ async getBitcoinAddress(publicKey, network, _addressType = "bech32") {
129
+ const url = `${this.baseURL}/wapi/v2/btc/address`;
130
+ const params = new URLSearchParams({
131
+ pubkey: publicKey,
132
+ network
133
+ });
134
+ const response = await fetch(`${url}?${params}`, {
135
+ method: "GET",
136
+ headers: {
137
+ ...this.accessToken ? { Authorization: `Bearer ${this.accessToken}` } : {}
138
+ }
139
+ });
140
+ const data = await response.json();
141
+ if (!response.ok) {
142
+ throw createAbcError(
143
+ "NETWORK_ERROR" /* NETWORK_ERROR */,
144
+ "Failed to get Bitcoin address",
145
+ data
146
+ );
147
+ }
148
+ return data.address;
149
+ }
150
+ /**
151
+ * Get UTXOs (Unspent Transaction Outputs) for address
152
+ * Bitcoin uses UTXO model unlike EVM/Solana account model
153
+ *
154
+ * @param address - Bitcoin address
155
+ * @param network - Bitcoin network
156
+ * @returns Array of UTXOs
157
+ */
158
+ async getUtxos(address, network) {
159
+ const url = `${this.baseURL}/wapi/v2/bitcoin/utxo/list`;
160
+ const params = new URLSearchParams({ network, address });
161
+ console.log("[BitcoinApi] \u{1F50D} Fetching UTXOs for:", address);
162
+ const response = await fetch(`${url}?${params}`, {
163
+ method: "GET",
164
+ headers: {
165
+ ...DEFAULT_HEADERS,
166
+ ...this.accessToken ? { Authorization: `Bearer ${this.accessToken}` } : {}
167
+ }
168
+ });
169
+ const data = await response.json();
170
+ if (!response.ok || data.status !== "success") {
171
+ throw createAbcError(
172
+ "NETWORK_ERROR" /* NETWORK_ERROR */,
173
+ "Failed to get UTXOs",
174
+ data
175
+ );
176
+ }
177
+ const utxos = data.result?.utxos || [];
178
+ console.log(`[BitcoinApi] \u2705 Found ${utxos.length} UTXOs`);
179
+ return utxos;
180
+ }
181
+ /**
182
+ * Sign Bitcoin transaction (PSBT-based)
183
+ * @deprecated Bitcoin uses v2 API. Use sendTransaction() which uses the v2 flow (generate → signHash → finalize)
184
+ * This v3 API method is for Solana only
185
+ *
186
+ * @param params - Transaction signing parameters
187
+ * @returns Signed PSBT with multiple input signatures
188
+ */
189
+ async signBitcoinTransaction(params) {
190
+ console.warn("[BitcoinApi] \u26A0\uFE0F signBitcoinTransaction is deprecated. Bitcoin uses v2 API. Use sendTransaction() instead.");
191
+ const url = `${this.baseURL}/v3/wallet/sign`;
192
+ console.log("[BitcoinApi] \u{1F510} Signing Bitcoin transaction (PSBT)...");
193
+ const response = await fetch(url, {
194
+ method: "POST",
195
+ headers: {
196
+ "Content-Type": "application/json",
197
+ Accept: "application/json",
198
+ ...this.accessToken ? { Authorization: `Bearer ${this.accessToken}` } : {}
199
+ },
200
+ body: JSON.stringify({
201
+ uid: params.uid,
202
+ share_id: params.shareId,
203
+ message: params.psbt,
204
+ // PSBT in base64
205
+ password: params.pin,
206
+ network: params.network
207
+ })
208
+ });
209
+ const data = await response.json();
210
+ if (!response.ok || data.status !== "success") {
211
+ console.error("[BitcoinApi] \u274C Transaction signing failed:", data);
212
+ throw createAbcError(
213
+ "SIGNATURE_FAILED" /* SIGNATURE_FAILED */,
214
+ "Failed to sign Bitcoin transaction",
215
+ data
216
+ );
217
+ }
218
+ console.log("[BitcoinApi] \u2705 Transaction signed successfully");
219
+ return {
220
+ signedPsbt: data.result?.signedPsbt,
221
+ signatures: data.result?.signatures || []
222
+ };
223
+ }
224
+ /**
225
+ * Sign Bitcoin message (BIP-322)
226
+ * @deprecated Not supported - v3 API is Solana-only. Bitcoin uses v2 API which doesn't support message signing.
227
+ * Bitcoin only supports transaction signing via v2 API.
228
+ *
229
+ * @param params - Message signing parameters
230
+ * @returns BIP-322 signature
231
+ */
232
+ async signBitcoinMessage(params) {
233
+ console.warn("[BitcoinApi] \u26A0\uFE0F signBitcoinMessage is not supported. v3 API is Solana-only.");
234
+ throw createAbcError(
235
+ AbcErrorCode.UNSUPPORTED_METHOD,
236
+ "Bitcoin message signing not supported - v3 API is Solana-only"
237
+ );
238
+ const url = `${this.baseURL}/v3/wallet/sign`;
239
+ console.log("[BitcoinApi] \u{1F510} Signing Bitcoin message (BIP-322)...");
240
+ console.log("[BitcoinApi] \u{1F4E4} Request params:", {
241
+ uid: params.uid,
242
+ shareId: params.shareId,
243
+ keyId: params.keyId,
244
+ hasKeyId: !!params.keyId,
245
+ messageLength: params.message?.length,
246
+ network: params.network
247
+ });
248
+ const requestBody = {
249
+ uid: params.uid,
250
+ share_id: params.shareId,
251
+ key_id: params.keyId,
252
+ message: params.message,
253
+ // Hex-encoded message
254
+ password: params.pin,
255
+ messageType: params.messageType || "bip322",
256
+ network: params.network
257
+ };
258
+ console.log("[BitcoinApi] \u{1F4CB} Request body:", JSON.stringify(requestBody, null, 2));
259
+ const response = await fetch(url, {
260
+ method: "POST",
261
+ headers: {
262
+ "Content-Type": "application/json",
263
+ Accept: "application/json",
264
+ ...this.accessToken ? { Authorization: `Bearer ${this.accessToken}` } : {}
265
+ },
266
+ body: JSON.stringify(requestBody)
267
+ });
268
+ const responseText = await response.text();
269
+ console.log("[BitcoinApi] \u{1F4E5} Sign message raw response:", {
270
+ status: response.status,
271
+ statusText: response.statusText,
272
+ contentType: response.headers.get("content-type"),
273
+ text: responseText.substring(0, 500)
274
+ });
275
+ if (!responseText) {
276
+ throw createAbcError(
277
+ "NETWORK_ERROR" /* NETWORK_ERROR */,
278
+ "Empty response from sign message API",
279
+ { status: response.status }
280
+ );
281
+ }
282
+ let data;
283
+ try {
284
+ data = JSON.parse(responseText);
285
+ } catch (parseError) {
286
+ console.error("[BitcoinApi] \u274C JSON parse error:", parseError);
287
+ console.error("[BitcoinApi] \u{1F4C4} Full response text:", responseText);
288
+ throw createAbcError(
289
+ "NETWORK_ERROR" /* NETWORK_ERROR */,
290
+ `Server returned non-JSON response: ${responseText}`,
291
+ { responseText, parseError, status: response.status }
292
+ );
293
+ }
294
+ if (!response.ok || data.status !== "success") {
295
+ console.error("[BitcoinApi] \u274C Message signing failed:", data);
296
+ throw createAbcError(
297
+ "SIGNATURE_FAILED" /* SIGNATURE_FAILED */,
298
+ data.error || data.message || "Failed to sign Bitcoin message",
299
+ data
300
+ );
301
+ }
302
+ console.log("[BitcoinApi] \u2705 Message signed successfully");
303
+ return {
304
+ signature: data.result?.signature,
305
+ messageHash: data.result?.messageHash,
306
+ address: data.result?.address,
307
+ network: params.network
308
+ };
309
+ }
310
+ /**
311
+ * Send Bitcoin transaction
312
+ * Broadcasts signed transaction to Bitcoin network
313
+ *
314
+ * @param params - Transaction broadcast parameters
315
+ * @returns Transaction hash
316
+ */
317
+ async sendBitcoinTransaction(params) {
318
+ const url = `${this.baseURL}/wapi/v2/bitcoin/tx/sendTransaction`;
319
+ console.log("[BitcoinApi] \u{1F4E1} Broadcasting Bitcoin transaction...");
320
+ const response = await fetch(url, {
321
+ method: "POST",
322
+ headers: {
323
+ ...DEFAULT_HEADERS,
324
+ ...this.accessToken ? { Authorization: `Bearer ${this.accessToken}` } : {}
325
+ },
326
+ body: JSON.stringify({
327
+ network: params.network,
328
+ rawTransaction: params.rawTransaction,
329
+ ...params.psbt && { psbt: params.psbt }
330
+ })
331
+ });
332
+ const data = await response.json();
333
+ if (!response.ok || data.status !== "success") {
334
+ console.error("[BitcoinApi] \u274C Transaction broadcast failed:", data);
335
+ throw createAbcError(
336
+ "NETWORK_ERROR" /* NETWORK_ERROR */,
337
+ "Failed to send Bitcoin transaction",
338
+ data
339
+ );
340
+ }
341
+ const txHash = data.result?.data;
342
+ console.log("[BitcoinApi] \u2705 Transaction broadcasted:", txHash);
343
+ return {
344
+ txHash
345
+ };
346
+ }
347
+ /**
348
+ * Generate Bitcoin transaction (Step 1 of 3)
349
+ * Creates PSBT and returns hashes to sign
350
+ *
351
+ * @param params - Transaction parameters
352
+ * @returns Transaction data with hashes to sign
353
+ */
354
+ async generateTransaction(params) {
355
+ const url = `${this.baseURL}/wapi/v2/btc/transaction/generate`;
356
+ console.log("[BitcoinApi] \u{1F527} Generating transaction...", params);
357
+ const response = await fetch(url, {
358
+ method: "POST",
359
+ headers: {
360
+ "Content-Type": "application/json",
361
+ ...this.accessToken ? { Authorization: `Bearer ${this.accessToken}` } : {}
362
+ },
363
+ body: JSON.stringify(params)
364
+ });
365
+ const data = await response.json();
366
+ if (!response.ok || !data.hashes) {
367
+ const errorMsg = typeof data.error === "string" ? data.error : JSON.stringify(data.error || data);
368
+ console.error("[BitcoinApi] \u274C Generate failed:", errorMsg);
369
+ throw createAbcError(
370
+ "NETWORK_ERROR" /* NETWORK_ERROR */,
371
+ `Failed to generate transaction: ${errorMsg}`,
372
+ data
373
+ );
374
+ }
375
+ console.log(
376
+ `[BitcoinApi] \u2705 Generated ${data.hashes.length} hashes to sign`
377
+ );
378
+ return data;
379
+ }
380
+ /**
381
+ * Sign transaction hash (Step 2 of 3)
382
+ * Uses Secure Channel encryption for signing
383
+ * Based on tg-wallet-frontend reference implementation
384
+ *
385
+ * @param hash - Transaction hash to sign
386
+ * @param wallet - Full wallet object with Bitcoin signing fields
387
+ * @param pinHash - Hashed PIN for device password
388
+ * @param secureService - Secure service instance for encryption
389
+ * @returns Signature hex string (r + s without 0x prefix on s)
390
+ */
391
+ async signHash(hash, wallet, pinHash, secureService) {
392
+ console.log("[BitcoinApi] \u{1F510} Signing hash:", `${hash.substring(0, 20)}...`);
393
+ if (!wallet.wid || !wallet.pvencstr) {
394
+ console.error("[BitcoinApi] \u274C Missing Bitcoin signing fields:", {
395
+ hasWid: !!wallet.wid,
396
+ hasPvencstr: !!wallet.pvencstr,
397
+ hasSid: !!wallet.sid,
398
+ hasUid: !!wallet.uid
399
+ });
400
+ throw createAbcError(
401
+ "WALLET_NOT_FOUND" /* WALLET_NOT_FOUND */,
402
+ "Wallet missing required fields for Bitcoin signing (wid, pvencstr)",
403
+ { hasWid: !!wallet.wid, hasPvencstr: !!wallet.pvencstr }
404
+ );
405
+ }
406
+ console.log("[BitcoinApi] \u2705 Wallet fields validated for Bitcoin signing");
407
+ console.log("[BitcoinApi] \u{1F4CB} Wallet PLAINTEXT values:", {
408
+ hasWid: !!wallet.wid,
409
+ widLength: wallet.wid?.length,
410
+ hasPvencstr: !!wallet.pvencstr,
411
+ pvencstrLength: wallet.pvencstr?.length,
412
+ hasEncryptDevicePassword: !!wallet.encryptDevicePassword,
413
+ encryptDevicePasswordLength: wallet.encryptDevicePassword?.length
414
+ });
415
+ const encryptDevicePassword = await secureService.getEncryptPlain(
416
+ wallet.encryptDevicePassword || pinHash
417
+ );
418
+ const pvencstr = await secureService.getEncryptPlain(wallet.pvencstr);
419
+ const wid = await secureService.getEncryptPlain(wallet.wid);
420
+ const secureChannelId = await secureService.getSecureChannelId();
421
+ console.log("[BitcoinApi] \u{1F510} Encrypted values:", {
422
+ encryptDevicePasswordLength: encryptDevicePassword.length,
423
+ pvencstrLength: pvencstr.length,
424
+ widLength: wid.length,
425
+ secureChannelId
426
+ });
427
+ const params = new URLSearchParams({
428
+ uid: wallet.uid,
429
+ sid: wallet.sid || "",
430
+ // Handle optional sid
431
+ hash,
432
+ pvencstr,
433
+ wid,
434
+ encryptDevicePassword
435
+ });
436
+ console.log("[BitcoinApi] \u{1F4E4} Request params:", {
437
+ uid: wallet.uid,
438
+ sid: wallet.sid || "",
439
+ hashLength: hash.length,
440
+ bodyLength: params.toString().length
441
+ });
442
+ const url = `${this.baseURL}/wapi/v2/sign/hash`;
443
+ const response = await fetch(url, {
444
+ method: "POST",
445
+ headers: {
446
+ "Content-Type": "application/x-www-form-urlencoded",
447
+ "Secure-Channel": secureChannelId,
448
+ ...this.accessToken ? { Authorization: `Bearer ${this.accessToken}` } : {}
449
+ },
450
+ body: params.toString()
451
+ });
452
+ const responseText = await response.text();
453
+ console.log("[BitcoinApi] \u{1F4E5} Raw response:", {
454
+ status: response.status,
455
+ statusText: response.statusText,
456
+ text: responseText.substring(0, 200)
457
+ });
458
+ if (!responseText) {
459
+ throw createAbcError(
460
+ "NETWORK_ERROR" /* NETWORK_ERROR */,
461
+ "Empty response from sign hash API",
462
+ { status: response.status }
463
+ );
464
+ }
465
+ let data;
466
+ try {
467
+ data = JSON.parse(responseText);
468
+ } catch (parseError) {
469
+ console.error("[BitcoinApi] \u274C JSON parse error:", parseError);
470
+ throw createAbcError(
471
+ "NETWORK_ERROR" /* NETWORK_ERROR */,
472
+ "Invalid JSON response from sign hash API",
473
+ { responseText, parseError }
474
+ );
475
+ }
476
+ if (!response.ok || data.iserr === true || !data.signstr) {
477
+ const errorDetails = data.errmsg || data.errors?.[0] || data.message || data;
478
+ console.error("[BitcoinApi] \u274C Sign failed:", errorDetails);
479
+ throw createAbcError(
480
+ "SIGNATURE_FAILED" /* SIGNATURE_FAILED */,
481
+ `Failed to sign hash: ${JSON.stringify(errorDetails)}`,
482
+ data
483
+ );
484
+ }
485
+ console.log("[BitcoinApi] \u2705 Sign successful, parsing signature...");
486
+ const signstr = JSON.parse(data.signstr);
487
+ const sig_list = signstr.sig_list;
488
+ const signatures = [];
489
+ for (const sig of sig_list) {
490
+ const r = sig.r;
491
+ const s = sig.s.startsWith("0x") ? sig.s.substring(2) : sig.s;
492
+ const combinedSig = r + s;
493
+ signatures.push(combinedSig);
494
+ }
495
+ console.log(
496
+ "[BitcoinApi] \u2705 Signature generated:",
497
+ `${signatures[0].substring(0, 32)}...`
498
+ );
499
+ return signatures[0];
500
+ }
501
+ /**
502
+ * Finalize and broadcast transaction (Step 3 of 3)
503
+ * Broadcasts signed transaction to Bitcoin network
504
+ *
505
+ * @param params - Transaction parameters with signatures
506
+ * @returns Transaction hash
507
+ */
508
+ async finalizeTransaction(params) {
509
+ const url = `${this.baseURL}/wapi/v2/btc/transaction/finalize`;
510
+ console.log("[BitcoinApi] \u{1F4E1} Broadcasting transaction...");
511
+ console.log("[BitcoinApi] \u{1F4E4} Finalize params:", {
512
+ signatureCount: params.signatureHex.length,
513
+ amount: params.amount,
514
+ to: params.to,
515
+ pubkey: `${params.pubkey.substring(0, 20)}...`
516
+ });
517
+ const response = await fetch(url, {
518
+ method: "POST",
519
+ headers: {
520
+ "Content-Type": "application/json",
521
+ ...this.accessToken ? { Authorization: `Bearer ${this.accessToken}` } : {}
522
+ },
523
+ body: JSON.stringify(params)
524
+ });
525
+ const responseText = await response.text();
526
+ console.log("[BitcoinApi] \u{1F4E5} Finalize raw response:", {
527
+ status: response.status,
528
+ statusText: response.statusText,
529
+ text: responseText.substring(0, 200)
530
+ });
531
+ if (!responseText) {
532
+ throw createAbcError(
533
+ "NETWORK_ERROR" /* NETWORK_ERROR */,
534
+ "Empty response from finalize API",
535
+ { status: response.status }
536
+ );
537
+ }
538
+ let data;
539
+ try {
540
+ data = JSON.parse(responseText);
541
+ } catch (parseError) {
542
+ console.error("[BitcoinApi] \u274C JSON parse error:", parseError);
543
+ throw createAbcError(
544
+ "NETWORK_ERROR" /* NETWORK_ERROR */,
545
+ "Invalid JSON response from finalize API",
546
+ { responseText, parseError }
547
+ );
548
+ }
549
+ console.log("[BitcoinApi] \u{1F4CB} Finalize parsed data:", data);
550
+ if (!response.ok) {
551
+ const errorMsg = data.error || data.message || data.errmsg || "Unknown error";
552
+ console.error("[BitcoinApi] \u274C Finalize failed:", errorMsg);
553
+ throw createAbcError(
554
+ "NETWORK_ERROR" /* NETWORK_ERROR */,
555
+ `Failed to finalize transaction: ${errorMsg}`,
556
+ data
557
+ );
558
+ }
559
+ const txHash = data.result?.tx_hash || data.tx_hash || data.result?.txHash || data.txHash;
560
+ if (!txHash) {
561
+ console.error("[BitcoinApi] \u274C No tx_hash in response:", data);
562
+ throw createAbcError(
563
+ "NETWORK_ERROR" /* NETWORK_ERROR */,
564
+ "Transaction hash not found in response",
565
+ data
566
+ );
567
+ }
568
+ console.log("[BitcoinApi] \u2705 Transaction sent:", txHash);
569
+ return txHash;
570
+ }
571
+ /**
572
+ * Send Bitcoin transaction (Complete flow: generate → sign → finalize)
573
+ * High-level API that handles all 3 steps
574
+ *
575
+ * @param params - Transaction parameters
576
+ * @param wallet - EVM wallet credentials
577
+ * @param pinHash - Hashed PIN
578
+ * @param secureService - Secure service instance
579
+ * @returns Transaction hash
580
+ */
581
+ async sendTransaction(params, wallet, pinHash, secureService) {
582
+ console.log("[BitcoinApi] \u{1F4B8} Starting Bitcoin transaction flow...");
583
+ const generateData = await this.generateTransaction({
584
+ amount: params.amount,
585
+ pubkey: params.pubkey,
586
+ to: params.to,
587
+ feeRate: "2"
588
+ // Default fee rate
589
+ });
590
+ const { hashes, fee_rate } = generateData;
591
+ const signatureHex = [];
592
+ for (let i = 0; i < hashes.length; i++) {
593
+ const signature = await this.signHash(
594
+ hashes[i],
595
+ wallet,
596
+ pinHash,
597
+ secureService
598
+ );
599
+ signatureHex.push(signature);
600
+ }
601
+ const txHash = await this.finalizeTransaction({
602
+ network: params.network,
603
+ signatureHex,
604
+ feeRate: fee_rate,
605
+ amount: params.amount,
606
+ pubkey: params.pubkey,
607
+ to: params.to
608
+ });
609
+ console.log("[BitcoinApi] \u2705 Transaction complete:", txHash);
610
+ return txHash;
611
+ }
612
+ /**
613
+ * Estimate Bitcoin transaction fee
614
+ * Gets recommended fee rate (satoshis per byte) for target confirmation blocks
615
+ *
616
+ * @param network - Bitcoin network
617
+ * @param targetBlocks - Target confirmation blocks (default: 6)
618
+ * @returns Fee rate in satoshis per byte
619
+ */
620
+ async estimateFee(network, targetBlocks = 6) {
621
+ const url = `${this.baseURL}/wapi/v2/bitcoin/fee/estimate`;
622
+ const params = new URLSearchParams({
623
+ network,
624
+ targetBlocks: targetBlocks.toString()
625
+ });
626
+ const response = await fetch(`${url}?${params}`, {
627
+ method: "GET",
628
+ headers: {
629
+ ...DEFAULT_HEADERS,
630
+ ...this.accessToken ? { Authorization: `Bearer ${this.accessToken}` } : {}
631
+ }
632
+ });
633
+ const data = await response.json();
634
+ if (!response.ok || data.status !== "success") {
635
+ console.warn("[BitcoinApi] \u26A0\uFE0F Fee estimation failed, using fallback");
636
+ return 1;
637
+ }
638
+ const feeRate = data.result?.feeRate || 1;
639
+ console.log(`[BitcoinApi] \u26FD Estimated fee rate: ${feeRate} sat/byte`);
640
+ return feeRate;
641
+ }
642
+ };
643
+
644
+ export {
645
+ BitcoinApi
646
+ };
@@ -0,0 +1,44 @@
1
+ "use client";
2
+ import {
3
+ abcConnector
4
+ } from "./chunk-BKXPGZMQ.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
+ };