@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,514 @@
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
+
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
+ * Send Bitcoin transaction
180
+ * Broadcasts signed transaction to Bitcoin network
181
+ *
182
+ * @param params - Transaction broadcast parameters
183
+ * @returns Transaction hash
184
+ */
185
+ async sendBitcoinTransaction(params) {
186
+ const url = `${this.baseURL}/wapi/v2/bitcoin/tx/sendTransaction`;
187
+ console.log("[BitcoinApi] \u{1F4E1} Broadcasting Bitcoin transaction...");
188
+ const response = await fetch(url, {
189
+ method: "POST",
190
+ headers: {
191
+ ...DEFAULT_HEADERS,
192
+ ...this.accessToken ? { Authorization: `Bearer ${this.accessToken}` } : {}
193
+ },
194
+ body: JSON.stringify({
195
+ network: params.network,
196
+ rawTransaction: params.rawTransaction,
197
+ ...params.psbt && { psbt: params.psbt }
198
+ })
199
+ });
200
+ const data = await response.json();
201
+ if (!response.ok || data.status !== "success") {
202
+ console.error("[BitcoinApi] \u274C Transaction broadcast failed:", data);
203
+ throw createAbcError(
204
+ "NETWORK_ERROR" /* NETWORK_ERROR */,
205
+ "Failed to send Bitcoin transaction",
206
+ data
207
+ );
208
+ }
209
+ const txHash = data.result?.data;
210
+ console.log("[BitcoinApi] \u2705 Transaction broadcasted:", txHash);
211
+ return {
212
+ txHash
213
+ };
214
+ }
215
+ /**
216
+ * Generate Bitcoin transaction (Step 1 of 3)
217
+ * Creates PSBT and returns hashes to sign
218
+ *
219
+ * @param params - Transaction parameters
220
+ * @returns Transaction data with hashes to sign
221
+ */
222
+ async generateTransaction(params) {
223
+ const url = `${this.baseURL}/wapi/v2/btc/transaction/generate`;
224
+ console.log("[BitcoinApi] \u{1F527} Generating transaction...", params);
225
+ const response = await fetch(url, {
226
+ method: "POST",
227
+ headers: {
228
+ "Content-Type": "application/json",
229
+ ...this.accessToken ? { Authorization: `Bearer ${this.accessToken}` } : {}
230
+ },
231
+ body: JSON.stringify(params)
232
+ });
233
+ const data = await response.json();
234
+ if (!response.ok || !data.hashes) {
235
+ const errorMsg = typeof data.error === "string" ? data.error : JSON.stringify(data.error || data);
236
+ console.error("[BitcoinApi] \u274C Generate failed:", errorMsg);
237
+ throw createAbcError(
238
+ "NETWORK_ERROR" /* NETWORK_ERROR */,
239
+ `Failed to generate transaction: ${errorMsg}`,
240
+ data
241
+ );
242
+ }
243
+ console.log(
244
+ `[BitcoinApi] \u2705 Generated ${data.hashes.length} hashes to sign`
245
+ );
246
+ return data;
247
+ }
248
+ /**
249
+ * Sign transaction hash (Step 2 of 3)
250
+ * Uses Secure Channel encryption for signing
251
+ * Based on tg-wallet-frontend reference implementation
252
+ *
253
+ * @param hash - Transaction hash to sign
254
+ * @param wallet - Full wallet object with Bitcoin signing fields
255
+ * @param pinHash - Hashed PIN for device password
256
+ * @param secureService - Secure service instance for encryption
257
+ * @returns Signature hex string (r + s without 0x prefix on s)
258
+ */
259
+ async signHash(hash, wallet, pinHash, secureService) {
260
+ console.log("[BitcoinApi] \u{1F510} Signing hash:", `${hash.substring(0, 20)}...`);
261
+ if (!wallet.wid || !wallet.pvencstr) {
262
+ console.error("[BitcoinApi] \u274C Missing Bitcoin signing fields:", {
263
+ hasWid: !!wallet.wid,
264
+ hasPvencstr: !!wallet.pvencstr,
265
+ hasSid: !!wallet.sid,
266
+ hasUid: !!wallet.uid
267
+ });
268
+ throw createAbcError(
269
+ "WALLET_NOT_FOUND" /* WALLET_NOT_FOUND */,
270
+ "Wallet missing required fields for Bitcoin signing (wid, pvencstr)",
271
+ { hasWid: !!wallet.wid, hasPvencstr: !!wallet.pvencstr }
272
+ );
273
+ }
274
+ console.log("[BitcoinApi] \u2705 Wallet fields validated for Bitcoin signing");
275
+ console.log("[BitcoinApi] \u{1F4CB} Wallet PLAINTEXT values:", {
276
+ hasWid: !!wallet.wid,
277
+ widLength: wallet.wid?.length,
278
+ hasPvencstr: !!wallet.pvencstr,
279
+ pvencstrLength: wallet.pvencstr?.length,
280
+ hasEncryptDevicePassword: !!wallet.encryptDevicePassword,
281
+ encryptDevicePasswordLength: wallet.encryptDevicePassword?.length
282
+ });
283
+ const encryptDevicePassword = await secureService.getEncryptPlain(
284
+ wallet.encryptDevicePassword || pinHash
285
+ );
286
+ const pvencstr = await secureService.getEncryptPlain(wallet.pvencstr);
287
+ const wid = await secureService.getEncryptPlain(wallet.wid);
288
+ const secureChannelId = await secureService.getSecureChannelId();
289
+ console.log("[BitcoinApi] \u{1F510} Encrypted values:", {
290
+ encryptDevicePasswordLength: encryptDevicePassword.length,
291
+ pvencstrLength: pvencstr.length,
292
+ widLength: wid.length,
293
+ secureChannelId
294
+ });
295
+ const params = new URLSearchParams({
296
+ uid: wallet.uid,
297
+ sid: wallet.sid || "",
298
+ // Handle optional sid
299
+ hash,
300
+ pvencstr,
301
+ wid,
302
+ encryptDevicePassword
303
+ });
304
+ console.log("[BitcoinApi] \u{1F4E4} Request params:", {
305
+ uid: wallet.uid,
306
+ sid: wallet.sid || "",
307
+ hashLength: hash.length,
308
+ bodyLength: params.toString().length
309
+ });
310
+ const url = `${this.baseURL}/wapi/v2/sign/hash`;
311
+ const response = await fetch(url, {
312
+ method: "POST",
313
+ headers: {
314
+ "Content-Type": "application/x-www-form-urlencoded",
315
+ "Secure-Channel": secureChannelId,
316
+ ...this.accessToken ? { Authorization: `Bearer ${this.accessToken}` } : {}
317
+ },
318
+ body: params.toString()
319
+ });
320
+ const responseText = await response.text();
321
+ console.log("[BitcoinApi] \u{1F4E5} Raw response:", {
322
+ status: response.status,
323
+ statusText: response.statusText,
324
+ text: responseText.substring(0, 200)
325
+ });
326
+ if (!responseText) {
327
+ throw createAbcError(
328
+ "NETWORK_ERROR" /* NETWORK_ERROR */,
329
+ "Empty response from sign hash API",
330
+ { status: response.status }
331
+ );
332
+ }
333
+ let data;
334
+ try {
335
+ data = JSON.parse(responseText);
336
+ } catch (parseError) {
337
+ console.error("[BitcoinApi] \u274C JSON parse error:", parseError);
338
+ throw createAbcError(
339
+ "NETWORK_ERROR" /* NETWORK_ERROR */,
340
+ "Invalid JSON response from sign hash API",
341
+ { responseText, parseError }
342
+ );
343
+ }
344
+ if (!response.ok || data.iserr === true || !data.signstr) {
345
+ const errorDetails = data.errmsg || data.errors?.[0] || data.message || data;
346
+ console.error("[BitcoinApi] \u274C Sign failed:", errorDetails);
347
+ throw createAbcError(
348
+ "SIGNATURE_FAILED" /* SIGNATURE_FAILED */,
349
+ `Failed to sign hash: ${JSON.stringify(errorDetails)}`,
350
+ data
351
+ );
352
+ }
353
+ console.log("[BitcoinApi] \u2705 Sign successful, parsing signature...");
354
+ const signstr = JSON.parse(data.signstr);
355
+ const sig_list = signstr.sig_list;
356
+ const signatures = [];
357
+ for (const sig of sig_list) {
358
+ const r = sig.r;
359
+ const s = sig.s.startsWith("0x") ? sig.s.substring(2) : sig.s;
360
+ const combinedSig = r + s;
361
+ signatures.push(combinedSig);
362
+ }
363
+ console.log(
364
+ "[BitcoinApi] \u2705 Signature generated:",
365
+ `${signatures[0].substring(0, 32)}...`
366
+ );
367
+ return signatures[0];
368
+ }
369
+ /**
370
+ * Finalize and broadcast transaction (Step 3 of 3)
371
+ * Broadcasts signed transaction to Bitcoin network
372
+ *
373
+ * @param params - Transaction parameters with signatures
374
+ * @returns Transaction hash
375
+ */
376
+ async finalizeTransaction(params) {
377
+ const url = `${this.baseURL}/wapi/v2/btc/transaction/finalize`;
378
+ console.log("[BitcoinApi] \u{1F4E1} Broadcasting transaction...");
379
+ console.log("[BitcoinApi] \u{1F4E4} Finalize params:", {
380
+ signatureCount: params.signatureHex.length,
381
+ amount: params.amount,
382
+ to: params.to,
383
+ pubkey: `${params.pubkey.substring(0, 20)}...`
384
+ });
385
+ const response = await fetch(url, {
386
+ method: "POST",
387
+ headers: {
388
+ "Content-Type": "application/json",
389
+ ...this.accessToken ? { Authorization: `Bearer ${this.accessToken}` } : {}
390
+ },
391
+ body: JSON.stringify(params)
392
+ });
393
+ const responseText = await response.text();
394
+ console.log("[BitcoinApi] \u{1F4E5} Finalize raw response:", {
395
+ status: response.status,
396
+ statusText: response.statusText,
397
+ text: responseText.substring(0, 200)
398
+ });
399
+ if (!responseText) {
400
+ throw createAbcError(
401
+ "NETWORK_ERROR" /* NETWORK_ERROR */,
402
+ "Empty response from finalize API",
403
+ { status: response.status }
404
+ );
405
+ }
406
+ let data;
407
+ try {
408
+ data = JSON.parse(responseText);
409
+ } catch (parseError) {
410
+ console.error("[BitcoinApi] \u274C JSON parse error:", parseError);
411
+ throw createAbcError(
412
+ "NETWORK_ERROR" /* NETWORK_ERROR */,
413
+ "Invalid JSON response from finalize API",
414
+ { responseText, parseError }
415
+ );
416
+ }
417
+ console.log("[BitcoinApi] \u{1F4CB} Finalize parsed data:", data);
418
+ if (!response.ok) {
419
+ const errorMsg = data.error || data.message || data.errmsg || "Unknown error";
420
+ console.error("[BitcoinApi] \u274C Finalize failed:", errorMsg);
421
+ throw createAbcError(
422
+ "NETWORK_ERROR" /* NETWORK_ERROR */,
423
+ `Failed to finalize transaction: ${errorMsg}`,
424
+ data
425
+ );
426
+ }
427
+ const txHash = data.result?.tx_hash || data.tx_hash || data.result?.txHash || data.txHash;
428
+ if (!txHash) {
429
+ console.error("[BitcoinApi] \u274C No tx_hash in response:", data);
430
+ throw createAbcError(
431
+ "NETWORK_ERROR" /* NETWORK_ERROR */,
432
+ "Transaction hash not found in response",
433
+ data
434
+ );
435
+ }
436
+ console.log("[BitcoinApi] \u2705 Transaction sent:", txHash);
437
+ return txHash;
438
+ }
439
+ /**
440
+ * Send Bitcoin transaction (Complete flow: generate → sign → finalize)
441
+ * High-level API that handles all 3 steps
442
+ *
443
+ * @param params - Transaction parameters
444
+ * @param wallet - EVM wallet credentials
445
+ * @param pinHash - Hashed PIN
446
+ * @param secureService - Secure service instance
447
+ * @returns Transaction hash
448
+ */
449
+ async sendTransaction(params, wallet, pinHash, secureService) {
450
+ console.log("[BitcoinApi] \u{1F4B8} Starting Bitcoin transaction flow...");
451
+ const generateData = await this.generateTransaction({
452
+ amount: params.amount,
453
+ pubkey: params.pubkey,
454
+ to: params.to,
455
+ feeRate: "2"
456
+ // Default fee rate
457
+ });
458
+ const { hashes, fee_rate } = generateData;
459
+ const signatureHex = [];
460
+ for (let i = 0; i < hashes.length; i++) {
461
+ const signature = await this.signHash(
462
+ hashes[i],
463
+ wallet,
464
+ pinHash,
465
+ secureService
466
+ );
467
+ signatureHex.push(signature);
468
+ }
469
+ const txHash = await this.finalizeTransaction({
470
+ network: params.network,
471
+ signatureHex,
472
+ feeRate: fee_rate,
473
+ amount: params.amount,
474
+ pubkey: params.pubkey,
475
+ to: params.to
476
+ });
477
+ console.log("[BitcoinApi] \u2705 Transaction complete:", txHash);
478
+ return txHash;
479
+ }
480
+ /**
481
+ * Estimate Bitcoin transaction fee
482
+ * Gets recommended fee rate (satoshis per byte) for target confirmation blocks
483
+ *
484
+ * @param network - Bitcoin network
485
+ * @param targetBlocks - Target confirmation blocks (default: 6)
486
+ * @returns Fee rate in satoshis per byte
487
+ */
488
+ async estimateFee(network, targetBlocks = 6) {
489
+ const url = `${this.baseURL}/wapi/v2/bitcoin/fee/estimate`;
490
+ const params = new URLSearchParams({
491
+ network,
492
+ targetBlocks: targetBlocks.toString()
493
+ });
494
+ const response = await fetch(`${url}?${params}`, {
495
+ method: "GET",
496
+ headers: {
497
+ ...DEFAULT_HEADERS,
498
+ ...this.accessToken ? { Authorization: `Bearer ${this.accessToken}` } : {}
499
+ }
500
+ });
501
+ const data = await response.json();
502
+ if (!response.ok || data.status !== "success") {
503
+ console.warn("[BitcoinApi] \u26A0\uFE0F Fee estimation failed, using fallback");
504
+ return 1;
505
+ }
506
+ const feeRate = data.result?.feeRate || 1;
507
+ console.log(`[BitcoinApi] \u26FD Estimated fee rate: ${feeRate} sat/byte`);
508
+ return feeRate;
509
+ }
510
+ };
511
+
512
+ export {
513
+ BitcoinApi
514
+ };
@@ -0,0 +1,63 @@
1
+ "use client";
2
+ import {
3
+ TransactionApi
4
+ } from "./chunk-KD2OAMDA.js";
5
+ import {
6
+ WalletApi
7
+ } from "./chunk-JBRW4UTW.js";
8
+ import {
9
+ BitcoinApi
10
+ } from "./chunk-SPR4W5TG.js";
11
+ import {
12
+ AuthApi
13
+ } from "./chunk-W7R3JGSC.js";
14
+ import {
15
+ SigningApi
16
+ } from "./chunk-4UGXLYKP.js";
17
+ import {
18
+ SolanaApi
19
+ } from "./chunk-DMRM7XAS.js";
20
+
21
+ // src/wallets/walletConnectors/abcWallet/api/index.ts
22
+ var AbcWaasApiClient = class {
23
+ constructor(config) {
24
+ this.auth = new AuthApi(config);
25
+ this.wallet = new WalletApi(config);
26
+ this.transaction = new TransactionApi(config);
27
+ this.signing = new SigningApi(config);
28
+ this.solana = new SolanaApi(config);
29
+ this.bitcoin = new BitcoinApi(config);
30
+ }
31
+ /**
32
+ * Check if user is authenticated
33
+ */
34
+ isAuthenticated() {
35
+ return this.auth.isAuthenticated();
36
+ }
37
+ /**
38
+ * Check if access token is expired
39
+ */
40
+ isTokenExpired() {
41
+ return this.auth.isTokenExpired();
42
+ }
43
+ /**
44
+ * Get current access token
45
+ */
46
+ getAccessToken() {
47
+ return this.auth.getAccessToken();
48
+ }
49
+ /**
50
+ * Logout (clear tokens)
51
+ */
52
+ async logout() {
53
+ await this.auth.logout();
54
+ }
55
+ };
56
+ function createAbcWaasApiClient(config) {
57
+ return new AbcWaasApiClient(config);
58
+ }
59
+
60
+ export {
61
+ AbcWaasApiClient,
62
+ createAbcWaasApiClient
63
+ };
@@ -0,0 +1,63 @@
1
+ "use client";
2
+ import {
3
+ TransactionApi
4
+ } from "./chunk-KD2OAMDA.js";
5
+ import {
6
+ WalletApi
7
+ } from "./chunk-JBRW4UTW.js";
8
+ import {
9
+ BitcoinApi
10
+ } from "./chunk-KFIUFVQH.js";
11
+ import {
12
+ SigningApi
13
+ } from "./chunk-4UGXLYKP.js";
14
+ import {
15
+ AuthApi
16
+ } from "./chunk-W7R3JGSC.js";
17
+ import {
18
+ SolanaApi
19
+ } from "./chunk-DMRM7XAS.js";
20
+
21
+ // src/wallets/walletConnectors/abcWallet/api/index.ts
22
+ var AbcWaasApiClient = class {
23
+ constructor(config) {
24
+ this.auth = new AuthApi(config);
25
+ this.wallet = new WalletApi(config);
26
+ this.transaction = new TransactionApi(config);
27
+ this.signing = new SigningApi(config);
28
+ this.solana = new SolanaApi(config);
29
+ this.bitcoin = new BitcoinApi(config);
30
+ }
31
+ /**
32
+ * Check if user is authenticated
33
+ */
34
+ isAuthenticated() {
35
+ return this.auth.isAuthenticated();
36
+ }
37
+ /**
38
+ * Check if access token is expired
39
+ */
40
+ isTokenExpired() {
41
+ return this.auth.isTokenExpired();
42
+ }
43
+ /**
44
+ * Get current access token
45
+ */
46
+ getAccessToken() {
47
+ return this.auth.getAccessToken();
48
+ }
49
+ /**
50
+ * Logout (clear tokens)
51
+ */
52
+ async logout() {
53
+ await this.auth.logout();
54
+ }
55
+ };
56
+ function createAbcWaasApiClient(config) {
57
+ return new AbcWaasApiClient(config);
58
+ }
59
+
60
+ export {
61
+ AbcWaasApiClient,
62
+ createAbcWaasApiClient
63
+ };
@@ -0,0 +1,63 @@
1
+ "use client";
2
+ import {
3
+ SigningApi
4
+ } from "./chunk-4UGXLYKP.js";
5
+ import {
6
+ AuthApi
7
+ } from "./chunk-W7R3JGSC.js";
8
+ import {
9
+ BitcoinApi
10
+ } from "./chunk-SNZL5LJ6.js";
11
+ import {
12
+ SolanaApi
13
+ } from "./chunk-DMRM7XAS.js";
14
+ import {
15
+ TransactionApi
16
+ } from "./chunk-KD2OAMDA.js";
17
+ import {
18
+ WalletApi
19
+ } from "./chunk-JBRW4UTW.js";
20
+
21
+ // src/wallets/walletConnectors/abcWallet/api/index.ts
22
+ var AbcWaasApiClient = class {
23
+ constructor(config) {
24
+ this.auth = new AuthApi(config);
25
+ this.wallet = new WalletApi(config);
26
+ this.transaction = new TransactionApi(config);
27
+ this.signing = new SigningApi(config);
28
+ this.solana = new SolanaApi(config);
29
+ this.bitcoin = new BitcoinApi(config);
30
+ }
31
+ /**
32
+ * Check if user is authenticated
33
+ */
34
+ isAuthenticated() {
35
+ return this.auth.isAuthenticated();
36
+ }
37
+ /**
38
+ * Check if access token is expired
39
+ */
40
+ isTokenExpired() {
41
+ return this.auth.isTokenExpired();
42
+ }
43
+ /**
44
+ * Get current access token
45
+ */
46
+ getAccessToken() {
47
+ return this.auth.getAccessToken();
48
+ }
49
+ /**
50
+ * Logout (clear tokens)
51
+ */
52
+ async logout() {
53
+ await this.auth.logout();
54
+ }
55
+ };
56
+ function createAbcWaasApiClient(config) {
57
+ return new AbcWaasApiClient(config);
58
+ }
59
+
60
+ export {
61
+ AbcWaasApiClient,
62
+ createAbcWaasApiClient
63
+ };