@ecency/hive-tx 7.1.0

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 (214) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +206 -0
  3. package/dist/browser/hive-tx.min.js +3 -0
  4. package/dist/browser/hive-tx.min.js.LICENSE.txt +5 -0
  5. package/dist/browser/hive-tx.min.js.map +1 -0
  6. package/dist/cjs/Transaction.d.ts +71 -0
  7. package/dist/cjs/Transaction.d.ts.map +1 -0
  8. package/dist/cjs/Transaction.js +199 -0
  9. package/dist/cjs/Transaction.js.map +1 -0
  10. package/dist/cjs/config.d.ts +37 -0
  11. package/dist/cjs/config.d.ts.map +1 -0
  12. package/dist/cjs/config.js +54 -0
  13. package/dist/cjs/config.js.map +1 -0
  14. package/dist/cjs/helpers/Asset.d.ts +21 -0
  15. package/dist/cjs/helpers/Asset.d.ts.map +1 -0
  16. package/dist/cjs/helpers/Asset.js +74 -0
  17. package/dist/cjs/helpers/Asset.js.map +1 -0
  18. package/dist/cjs/helpers/ByteBuffer.d.ts +75 -0
  19. package/dist/cjs/helpers/ByteBuffer.d.ts.map +1 -0
  20. package/dist/cjs/helpers/ByteBuffer.js +555 -0
  21. package/dist/cjs/helpers/ByteBuffer.js.map +1 -0
  22. package/dist/cjs/helpers/HexBuffer.d.ts +10 -0
  23. package/dist/cjs/helpers/HexBuffer.d.ts.map +1 -0
  24. package/dist/cjs/helpers/HexBuffer.js +33 -0
  25. package/dist/cjs/helpers/HexBuffer.js.map +1 -0
  26. package/dist/cjs/helpers/PrivateKey.d.ts +114 -0
  27. package/dist/cjs/helpers/PrivateKey.d.ts.map +1 -0
  28. package/dist/cjs/helpers/PrivateKey.js +212 -0
  29. package/dist/cjs/helpers/PrivateKey.js.map +1 -0
  30. package/dist/cjs/helpers/PublicKey.d.ts +47 -0
  31. package/dist/cjs/helpers/PublicKey.d.ts.map +1 -0
  32. package/dist/cjs/helpers/PublicKey.js +97 -0
  33. package/dist/cjs/helpers/PublicKey.js.map +1 -0
  34. package/dist/cjs/helpers/Signature.d.ts +38 -0
  35. package/dist/cjs/helpers/Signature.d.ts.map +1 -0
  36. package/dist/cjs/helpers/Signature.js +85 -0
  37. package/dist/cjs/helpers/Signature.js.map +1 -0
  38. package/dist/cjs/helpers/aes.d.ts +15 -0
  39. package/dist/cjs/helpers/aes.d.ts.map +1 -0
  40. package/dist/cjs/helpers/aes.js +87 -0
  41. package/dist/cjs/helpers/aes.js.map +1 -0
  42. package/dist/cjs/helpers/call.d.ts +119 -0
  43. package/dist/cjs/helpers/call.d.ts.map +1 -0
  44. package/dist/cjs/helpers/call.js +498 -0
  45. package/dist/cjs/helpers/call.js.map +1 -0
  46. package/dist/cjs/helpers/deserializer.d.ts +4 -0
  47. package/dist/cjs/helpers/deserializer.d.ts.map +1 -0
  48. package/dist/cjs/helpers/deserializer.js +58 -0
  49. package/dist/cjs/helpers/deserializer.js.map +1 -0
  50. package/dist/cjs/helpers/memo.d.ts +36 -0
  51. package/dist/cjs/helpers/memo.d.ts.map +1 -0
  52. package/dist/cjs/helpers/memo.js +167 -0
  53. package/dist/cjs/helpers/memo.js.map +1 -0
  54. package/dist/cjs/helpers/serializer.d.ts +14 -0
  55. package/dist/cjs/helpers/serializer.d.ts.map +1 -0
  56. package/dist/cjs/helpers/serializer.js +639 -0
  57. package/dist/cjs/helpers/serializer.js.map +1 -0
  58. package/dist/cjs/helpers/sleep.d.ts +2 -0
  59. package/dist/cjs/helpers/sleep.d.ts.map +1 -0
  60. package/dist/cjs/helpers/sleep.js +8 -0
  61. package/dist/cjs/helpers/sleep.js.map +1 -0
  62. package/dist/cjs/helpers/utils.d.ts +122 -0
  63. package/dist/cjs/helpers/utils.d.ts.map +1 -0
  64. package/dist/cjs/helpers/utils.js +202 -0
  65. package/dist/cjs/helpers/utils.js.map +1 -0
  66. package/dist/cjs/index.d.ts +10 -0
  67. package/dist/cjs/index.d.ts.map +1 -0
  68. package/dist/cjs/index.js +60 -0
  69. package/dist/cjs/index.js.map +1 -0
  70. package/dist/cjs/type_generators/types/balance.d.ts +1096 -0
  71. package/dist/cjs/type_generators/types/balance.d.ts.map +1 -0
  72. package/dist/cjs/type_generators/types/balance.js +3 -0
  73. package/dist/cjs/type_generators/types/balance.js.map +1 -0
  74. package/dist/cjs/type_generators/types/hafah.d.ts +2154 -0
  75. package/dist/cjs/type_generators/types/hafah.d.ts.map +1 -0
  76. package/dist/cjs/type_generators/types/hafah.js +3 -0
  77. package/dist/cjs/type_generators/types/hafah.js.map +1 -0
  78. package/dist/cjs/type_generators/types/hafbe.d.ts +2121 -0
  79. package/dist/cjs/type_generators/types/hafbe.d.ts.map +1 -0
  80. package/dist/cjs/type_generators/types/hafbe.js +3 -0
  81. package/dist/cjs/type_generators/types/hafbe.js.map +1 -0
  82. package/dist/cjs/type_generators/types/hafsql.d.ts +2439 -0
  83. package/dist/cjs/type_generators/types/hafsql.d.ts.map +1 -0
  84. package/dist/cjs/type_generators/types/hafsql.js +3 -0
  85. package/dist/cjs/type_generators/types/hafsql.js.map +1 -0
  86. package/dist/cjs/type_generators/types/hivemind.d.ts +202 -0
  87. package/dist/cjs/type_generators/types/hivemind.d.ts.map +1 -0
  88. package/dist/cjs/type_generators/types/hivemind.js +3 -0
  89. package/dist/cjs/type_generators/types/hivemind.js.map +1 -0
  90. package/dist/cjs/type_generators/types/hivesense.d.ts +448 -0
  91. package/dist/cjs/type_generators/types/hivesense.d.ts.map +1 -0
  92. package/dist/cjs/type_generators/types/hivesense.js +3 -0
  93. package/dist/cjs/type_generators/types/hivesense.js.map +1 -0
  94. package/dist/cjs/type_generators/types/nft-tracker.d.ts +348 -0
  95. package/dist/cjs/type_generators/types/nft-tracker.d.ts.map +1 -0
  96. package/dist/cjs/type_generators/types/nft-tracker.js +3 -0
  97. package/dist/cjs/type_generators/types/nft-tracker.js.map +1 -0
  98. package/dist/cjs/type_generators/types/reputation.d.ts +182 -0
  99. package/dist/cjs/type_generators/types/reputation.d.ts.map +1 -0
  100. package/dist/cjs/type_generators/types/reputation.js +3 -0
  101. package/dist/cjs/type_generators/types/reputation.js.map +1 -0
  102. package/dist/cjs/type_generators/types/status.d.ts +139 -0
  103. package/dist/cjs/type_generators/types/status.d.ts.map +1 -0
  104. package/dist/cjs/type_generators/types/status.js +3 -0
  105. package/dist/cjs/type_generators/types/status.js.map +1 -0
  106. package/dist/cjs/types.d.ts +415 -0
  107. package/dist/cjs/types.d.ts.map +1 -0
  108. package/dist/cjs/types.js +3 -0
  109. package/dist/cjs/types.js.map +1 -0
  110. package/dist/esm/Transaction.d.ts +71 -0
  111. package/dist/esm/Transaction.d.ts.map +1 -0
  112. package/dist/esm/Transaction.js +195 -0
  113. package/dist/esm/Transaction.js.map +1 -0
  114. package/dist/esm/config.d.ts +37 -0
  115. package/dist/esm/config.d.ts.map +1 -0
  116. package/dist/esm/config.js +51 -0
  117. package/dist/esm/config.js.map +1 -0
  118. package/dist/esm/helpers/Asset.d.ts +21 -0
  119. package/dist/esm/helpers/Asset.d.ts.map +1 -0
  120. package/dist/esm/helpers/Asset.js +70 -0
  121. package/dist/esm/helpers/Asset.js.map +1 -0
  122. package/dist/esm/helpers/ByteBuffer.d.ts +75 -0
  123. package/dist/esm/helpers/ByteBuffer.d.ts.map +1 -0
  124. package/dist/esm/helpers/ByteBuffer.js +551 -0
  125. package/dist/esm/helpers/ByteBuffer.js.map +1 -0
  126. package/dist/esm/helpers/HexBuffer.d.ts +10 -0
  127. package/dist/esm/helpers/HexBuffer.d.ts.map +1 -0
  128. package/dist/esm/helpers/HexBuffer.js +29 -0
  129. package/dist/esm/helpers/HexBuffer.js.map +1 -0
  130. package/dist/esm/helpers/PrivateKey.d.ts +114 -0
  131. package/dist/esm/helpers/PrivateKey.d.ts.map +1 -0
  132. package/dist/esm/helpers/PrivateKey.js +205 -0
  133. package/dist/esm/helpers/PrivateKey.js.map +1 -0
  134. package/dist/esm/helpers/PublicKey.d.ts +47 -0
  135. package/dist/esm/helpers/PublicKey.d.ts.map +1 -0
  136. package/dist/esm/helpers/PublicKey.js +90 -0
  137. package/dist/esm/helpers/PublicKey.js.map +1 -0
  138. package/dist/esm/helpers/Signature.d.ts +38 -0
  139. package/dist/esm/helpers/Signature.d.ts.map +1 -0
  140. package/dist/esm/helpers/Signature.js +81 -0
  141. package/dist/esm/helpers/Signature.js.map +1 -0
  142. package/dist/esm/helpers/aes.d.ts +15 -0
  143. package/dist/esm/helpers/aes.d.ts.map +1 -0
  144. package/dist/esm/helpers/aes.js +81 -0
  145. package/dist/esm/helpers/aes.js.map +1 -0
  146. package/dist/esm/helpers/call.d.ts +119 -0
  147. package/dist/esm/helpers/call.d.ts.map +1 -0
  148. package/dist/esm/helpers/call.js +490 -0
  149. package/dist/esm/helpers/call.js.map +1 -0
  150. package/dist/esm/helpers/deserializer.d.ts +4 -0
  151. package/dist/esm/helpers/deserializer.d.ts.map +1 -0
  152. package/dist/esm/helpers/deserializer.js +55 -0
  153. package/dist/esm/helpers/deserializer.js.map +1 -0
  154. package/dist/esm/helpers/memo.d.ts +36 -0
  155. package/dist/esm/helpers/memo.d.ts.map +1 -0
  156. package/dist/esm/helpers/memo.js +128 -0
  157. package/dist/esm/helpers/memo.js.map +1 -0
  158. package/dist/esm/helpers/serializer.d.ts +14 -0
  159. package/dist/esm/helpers/serializer.d.ts.map +1 -0
  160. package/dist/esm/helpers/serializer.js +636 -0
  161. package/dist/esm/helpers/serializer.js.map +1 -0
  162. package/dist/esm/helpers/sleep.d.ts +2 -0
  163. package/dist/esm/helpers/sleep.d.ts.map +1 -0
  164. package/dist/esm/helpers/sleep.js +4 -0
  165. package/dist/esm/helpers/sleep.js.map +1 -0
  166. package/dist/esm/helpers/utils.d.ts +122 -0
  167. package/dist/esm/helpers/utils.d.ts.map +1 -0
  168. package/dist/esm/helpers/utils.js +196 -0
  169. package/dist/esm/helpers/utils.js.map +1 -0
  170. package/dist/esm/index.d.ts +10 -0
  171. package/dist/esm/index.d.ts.map +1 -0
  172. package/dist/esm/index.js +11 -0
  173. package/dist/esm/index.js.map +1 -0
  174. package/dist/esm/type_generators/types/balance.d.ts +1096 -0
  175. package/dist/esm/type_generators/types/balance.d.ts.map +1 -0
  176. package/dist/esm/type_generators/types/balance.js +2 -0
  177. package/dist/esm/type_generators/types/balance.js.map +1 -0
  178. package/dist/esm/type_generators/types/hafah.d.ts +2154 -0
  179. package/dist/esm/type_generators/types/hafah.d.ts.map +1 -0
  180. package/dist/esm/type_generators/types/hafah.js +2 -0
  181. package/dist/esm/type_generators/types/hafah.js.map +1 -0
  182. package/dist/esm/type_generators/types/hafbe.d.ts +2121 -0
  183. package/dist/esm/type_generators/types/hafbe.d.ts.map +1 -0
  184. package/dist/esm/type_generators/types/hafbe.js +2 -0
  185. package/dist/esm/type_generators/types/hafbe.js.map +1 -0
  186. package/dist/esm/type_generators/types/hafsql.d.ts +2439 -0
  187. package/dist/esm/type_generators/types/hafsql.d.ts.map +1 -0
  188. package/dist/esm/type_generators/types/hafsql.js +2 -0
  189. package/dist/esm/type_generators/types/hafsql.js.map +1 -0
  190. package/dist/esm/type_generators/types/hivemind.d.ts +202 -0
  191. package/dist/esm/type_generators/types/hivemind.d.ts.map +1 -0
  192. package/dist/esm/type_generators/types/hivemind.js +2 -0
  193. package/dist/esm/type_generators/types/hivemind.js.map +1 -0
  194. package/dist/esm/type_generators/types/hivesense.d.ts +448 -0
  195. package/dist/esm/type_generators/types/hivesense.d.ts.map +1 -0
  196. package/dist/esm/type_generators/types/hivesense.js +2 -0
  197. package/dist/esm/type_generators/types/hivesense.js.map +1 -0
  198. package/dist/esm/type_generators/types/nft-tracker.d.ts +348 -0
  199. package/dist/esm/type_generators/types/nft-tracker.d.ts.map +1 -0
  200. package/dist/esm/type_generators/types/nft-tracker.js +2 -0
  201. package/dist/esm/type_generators/types/nft-tracker.js.map +1 -0
  202. package/dist/esm/type_generators/types/reputation.d.ts +182 -0
  203. package/dist/esm/type_generators/types/reputation.d.ts.map +1 -0
  204. package/dist/esm/type_generators/types/reputation.js +2 -0
  205. package/dist/esm/type_generators/types/reputation.js.map +1 -0
  206. package/dist/esm/type_generators/types/status.d.ts +139 -0
  207. package/dist/esm/type_generators/types/status.d.ts.map +1 -0
  208. package/dist/esm/type_generators/types/status.js +2 -0
  209. package/dist/esm/type_generators/types/status.js.map +1 -0
  210. package/dist/esm/types.d.ts +415 -0
  211. package/dist/esm/types.d.ts.map +1 -0
  212. package/dist/esm/types.js +2 -0
  213. package/dist/esm/types.js.map +1 -0
  214. package/package.json +83 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Mahdi Yari
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,206 @@
1
+ # hive-tx
2
+
3
+ [![npm version](https://badge.fury.io/js/hive-tx.svg)](https://www.npmjs.com/package/hive-tx)
4
+ [![npm downloads](https://img.shields.io/npm/dm/hive-tx.svg)](https://www.npmjs.com/package/hive-tx)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/mahdiyari/hive-tx/blob/master/LICENSE)
6
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.9-blue.svg)](https://www.typescriptlang.org/)
7
+ [![Node.js](https://img.shields.io/badge/Node.js-%3E%3D20-green.svg)](https://nodejs.org/)
8
+
9
+ The most lightweight library for Hive blockchain while being a complete library. Regularly maintained to support the latest features of the blockchain. For Web and NodeJS.
10
+
11
+ Library size: ~29KB minified+gzipped (including all the dependencies)
12
+
13
+ ## Comprehensive Documentation
14
+
15
+ - 🚀 [Quick Start Guide](docs/QUICKSTART.md) - Get up and running in minutes
16
+ - 💻 [Examples](docs/EXAMPLES.md) - Practical usage examples
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ # Require nodejs +20
22
+ npm install hive-tx --save
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ ```js
28
+ import { Transaction, PrivateKey, callRPC } from 'hive-tx'
29
+ ```
30
+
31
+ The library has two build outputs:
32
+
33
+ - ES Module (esm)
34
+ - CommonJS (cjs)
35
+
36
+ Your application will automatically pick the right build for your environment but you can also import either of them directly from `hive-tx/esm` and `hive-tx/cjs`.
37
+
38
+ There is also a browser build which you can use like this:
39
+
40
+ ```html
41
+ <script src="https://cdn.jsdelivr.net/npm/hive-tx@7/dist/browser/hive-tx.min.js"></script>
42
+ <!-- hiveTx will be available globally -->
43
+ ```
44
+
45
+ ## Quick Usage Examples
46
+
47
+ ### New Transaction API (v7+)
48
+
49
+ ```js
50
+ import { Transaction, PrivateKey } from 'hive-tx'
51
+
52
+ // Create and broadcast a vote
53
+ const tx = new Transaction()
54
+ await tx.addOperation('vote', {
55
+ voter: 'your-username',
56
+ author: 'post-author',
57
+ permlink: 'post-permlink',
58
+ weight: 10000 // 100%
59
+ })
60
+
61
+ const key = PrivateKey.from('your-private-key')
62
+ tx.sign(key)
63
+ const result = await tx.broadcast()
64
+ console.log('Vote successful!', result.result.tx_id)
65
+ ```
66
+
67
+ ### Transfer HIVE
68
+
69
+ ```js
70
+ import { Transaction, PrivateKey } from 'hive-tx'
71
+
72
+ const tx = new Transaction()
73
+ await tx.addOperation('transfer', {
74
+ from: 'sender',
75
+ to: 'receiver',
76
+ amount: '1.000 HIVE',
77
+ memo: 'Thanks for your help!'
78
+ })
79
+
80
+ const key = PrivateKey.from('your-active-key')
81
+ tx.sign(key)
82
+ const result = await tx.broadcast()
83
+ console.log('Transfer successful!', result.result.tx_id)
84
+ ```
85
+
86
+ ### API Calls
87
+
88
+ ```js
89
+ import { callRPC, callREST, callWithQuorum } from 'hive-tx'
90
+
91
+ // Get account information
92
+ const accounts = await callRPC('condenser_api.get_accounts', [['username']])
93
+ console.log('Account:', result[0])
94
+
95
+ // Get blockchain properties
96
+ const props = await callRPC('condenser_api.get_dynamic_global_properties')
97
+ console.log('Head block:', props.head_block_number)
98
+
99
+ const balance = await callREST('balance', '/accounts/{account-name}/balances', {
100
+ 'account-name': 'alice'
101
+ })
102
+ console.log(balance)
103
+
104
+ // Cross-check the result of the call with 2 nodes
105
+ const accounts = await callWithQuorum('condenser_api.get_accounts', [['username']], 2)
106
+ console.log('Account:', result[0])
107
+ ```
108
+
109
+ ### Key Management
110
+
111
+ ```js
112
+ import { PrivateKey } from 'hive-tx'
113
+
114
+ // Create keys in multiple ways
115
+ const key1 = PrivateKey.from('5JdeC9P7Pbd1uGdFVEsJ41EkEnADbbHGq6p1BwFxm6txNBsQnsw')
116
+ const key2 = PrivateKey.randomKey()
117
+ const key3 = PrivateKey.fromLogin('username', 'password', 'posting')
118
+ const key4 = PrivateKey.fromSeed('my-secret-seed')
119
+ ```
120
+
121
+ ## Configuration
122
+
123
+ ```js
124
+ import { config } from 'hive-tx'
125
+
126
+ // Configure API nodes with failover
127
+ // Default nodes that are already set:
128
+ config.nodes = [
129
+ 'https://api.hive.blog',
130
+ 'https://api.deathwing.me',
131
+ 'https://api.openhive.network',
132
+ 'https://rpc.mahdiyari.info',
133
+ 'https://techcoderx.com',
134
+ 'https://hiveapi.actifit.io',
135
+ 'https://api.c0ff33a.uk'
136
+ ]
137
+
138
+ // Custom timeout and retry settings
139
+ config.timeout = 10_000 // 10 seconds
140
+ config.retry = 8 // 8 retry attempts before throwing an error
141
+ ```
142
+
143
+ ### Breaking Changes in v7
144
+
145
+ v7 is a complete TypeScript rewrite with significant API improvements. See [CHANGELOG.md](CHANGELOG.md) for full details.
146
+
147
+ **Key Breaking Changes:**
148
+
149
+ - `tx.create()` => `await tx.addOperation(opName, opBody)`
150
+ - `call()` => `callRPC()` - Returns result directly, throws RPCError on errors
151
+ - `Transaction.broadcast(timeout?, retry?)` => `Transaction.broadcast(checkStatus?)`
152
+ - All timeout/expiration values now in milliseconds (was seconds)
153
+ - `new Transaction(transaction)` => `new Transaction({transaction, expiration})`
154
+ - `Transaction.signedTransaction` removed - Use `Transaction.transaction`
155
+ - `config.node` (string) => `config.nodes` (array)
156
+ - `config.healthcheckInterval` removed
157
+
158
+ **Migration Examples:**
159
+
160
+ ```js
161
+ // v6: Creating transactions
162
+ const tx = new Transaction()
163
+ await tx.create([['vote', { voter: 'alice', author: 'bob', permlink: 'post', weight: 10000 }]])
164
+
165
+ // v7: Creating transactions
166
+ const tx = new Transaction()
167
+ await tx.addOperation('vote', { voter: 'alice', author: 'bob', permlink: 'post', weight: 10000 })
168
+ ```
169
+
170
+ ```js
171
+ // v6: API calls
172
+ const result = await call('condenser_api.get_accounts', [['alice']])
173
+ const accounts = result.result
174
+
175
+ // v7: API calls
176
+ const accounts = await callRPC('condenser_api.get_accounts', [['alice']])
177
+ ```
178
+
179
+ ```js
180
+ // v6: Configuration
181
+ config.node = 'https://api.hive.blog'
182
+ config.timeout = 10 // seconds
183
+
184
+ // v7: Configuration
185
+ config.nodes = ['https://api.hive.blog', 'https://api.deathwing.me']
186
+ config.timeout = 10_000 // milliseconds
187
+ ```
188
+
189
+ ### What's new in v7
190
+
191
+ - Codebase reworked in TypeScript
192
+ - All methods now have good JSDoc documentation
193
+ - Added types for all operations
194
+ - Added `callWithQuorum()` - JSONRPC call that cross-checks the result with multiple nodes
195
+ - Added `callREST()` with full typing for new REST APIs
196
+ - Added tests including operation tests to keep them up to date with hived
197
+ - Added docs/EXAMPLES.md and docs/QUICKSTART.md
198
+ - Output 3 builds: ESM, CJS, UMD minified .js for browser
199
+
200
+ ## License
201
+
202
+ MIT
203
+
204
+ ## Support
205
+
206
+ - #dev-chat at [Hive's Discord server](https://myhive.li/discord)
@@ -0,0 +1,3 @@
1
+ /*! For license information please see hive-tx.min.js.LICENSE.txt */
2
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.hiveTx=e():t.hiveTx=e()}(self,()=>(()=>{"use strict";var t={d(e,r){for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{Memo:()=>Pn,PrivateKey:()=>qr,PublicKey:()=>je,Signature:()=>qe,Transaction:()=>Hr,callREST:()=>Nr,callRPC:()=>Lr,callRPCBroadcast:()=>Tr,callWithQuorum:()=>Dr,config:()=>$,utils:()=>r});var r={};function n(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name}function o(t,e=""){if(!Number.isSafeInteger(t)||t<0)throw Error(`${e&&`"${e}" `}expected integer >= 0, got ${t}`)}function i(t,e,r=""){const o=n(t),i=t?.length,s=void 0!==e;if(!o||s&&i!==e)throw Error((r&&`"${r}" `)+"expected Uint8Array"+(s?" of length "+e:"")+", got "+(o?"length="+i:"type="+typeof t));return t}function s(t){if("function"!=typeof t||"function"!=typeof t.create)throw Error("Hash must wrapped by utils.createHasher");o(t.outputLen),o(t.blockLen)}function a(t,e=!0){if(t.destroyed)throw Error("Hash instance has been destroyed");if(e&&t.finished)throw Error("Hash#digest() has already been called")}function c(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function f(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function h(t,e){return t<<32-e|t>>>e}function u(t,e){return t<<e|t>>>32-e>>>0}t.r(r),t.d(r,{buildWitnessSetProperties:()=>$n,makeBitMaskFilter:()=>Zn,operations:()=>zn,validateUsername:()=>jn});const l=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),d=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function p(t){if(i(t),l)return t.toHex();let e="";for(let r=0;r<t.length;r++)e+=d[t[r]];return e}function g(t){return t>=48&&t<=57?t-48:t>=65&&t<=70?t-55:t>=97&&t<=102?t-87:void 0}function w(t){if("string"!=typeof t)throw Error("hex string expected, got "+typeof t);if(l)return Uint8Array.fromHex(t);const e=t.length,r=e/2;if(e%2)throw Error("hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(r);for(let e=0,o=0;e<r;e++,o+=2){const r=g(t.charCodeAt(o)),i=g(t.charCodeAt(o+1));if(void 0===r||void 0===i)throw Error('hex string expected, got non-hex character "'+(t[o]+t[o+1])+'" at index '+o);n[e]=16*r+i}return n}function y(...t){let e=0;for(let r=0;r<t.length;r++){const n=t[r];i(n),e+=n.length}const r=new Uint8Array(e);for(let e=0,n=0;e<t.length;e++){const o=t[e];r.set(o,n),n+=o.length}return r}function b(t,e={}){const r=(e,r)=>t(r).update(e).digest(),n=t(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.create=e=>t(e),Object.assign(r,e),Object.freeze(r)}function m(t=32){const e="object"==typeof globalThis?globalThis.crypto:null;if("function"!=typeof e?.getRandomValues)throw Error("crypto.getRandomValues must be defined");return e.getRandomValues(new Uint8Array(t))}const _=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])}),E=new ArrayBuffer(0),v=new TextEncoder,x=new TextDecoder;class A{constructor(t=A.DEFAULT_CAPACITY,e=A.DEFAULT_ENDIAN){this.readUInt32=this.readUint32,this.buffer=0===t?E:new ArrayBuffer(t),this.view=0===t?new DataView(E):new DataView(this.buffer),this.offset=0,this.markedOffset=-1,this.limit=t,this.littleEndian=e}static allocate(t,e){return new A(t,e)}static concat(t,e){let r=0;for(let e=0;e<t.length;++e){const n=t[e];if(n instanceof A)r+=n.limit-n.offset;else if(n instanceof Uint8Array)r+=n.length;else if(n instanceof ArrayBuffer)r+=n.byteLength;else{if(!Array.isArray(n))throw TypeError("Illegal buffer");r+=n.length}}if(0===r)return new A(0,e);const n=new A(r,e),o=new Uint8Array(n.buffer);let i=0;for(let e=0;e<t.length;++e){let r=t[e];r instanceof A?(o.set(new Uint8Array(r.buffer,r.offset,r.limit-r.offset),i),i+=r.limit-r.offset):r instanceof Uint8Array?(o.set(r,i),i+=r.length):r instanceof ArrayBuffer?(o.set(new Uint8Array(r),i),i+=r.byteLength):(o.set(r,i),i+=r.length)}return n.limit=n.offset=i,n.offset=0,n}static wrap(t,e){if(t instanceof A){const e=t.clone();return e.markedOffset=-1,e}let r;if(t instanceof Uint8Array)r=new A(0,e),t.length>0&&(r.buffer=t.buffer,r.offset=t.byteOffset,r.limit=t.byteOffset+t.byteLength,r.view=new DataView(t.buffer));else if(t instanceof ArrayBuffer)r=new A(0,e),t.byteLength>0&&(r.buffer=t,r.offset=0,r.limit=t.byteLength,r.view=t.byteLength>0?new DataView(t):new DataView(E));else{if(!Array.isArray(t))throw TypeError("Illegal buffer");r=new A(t.length,e),r.limit=t.length,new Uint8Array(r.buffer).set(t)}return r}writeBytes(t,e){return this.append(t,e)}writeInt8(t,e){const r=void 0===e;return r&&(e=this.offset),e+1>this.buffer.byteLength&&this.resize(e+1),this.view.setInt8(e,t),r&&(this.offset+=1),this}writeByte(t,e){return this.writeInt8(t,e)}writeUint8(t,e){const r=void 0===e;return r&&(e=this.offset),e+1>this.buffer.byteLength&&this.resize(e+1),this.view.setUint8(e,t),r&&(this.offset+=1),this}writeUInt8(t,e){return this.writeUint8(t,e)}readUint8(t){const e=void 0===t;e&&(t=this.offset);const r=this.view.getUint8(t);return e&&(this.offset+=1),r}readUInt8(t){return this.readUint8(t)}writeInt16(t,e){const r=void 0===e;return r&&(e=this.offset),e+2>this.buffer.byteLength&&this.resize(e+2),this.view.setInt16(e,t,this.littleEndian),r&&(this.offset+=2),this}writeShort(t,e){return this.writeInt16(t,e)}writeUint16(t,e){const r=void 0===e;return r&&(e=this.offset),e+2>this.buffer.byteLength&&this.resize(e+2),this.view.setUint16(e,t,this.littleEndian),r&&(this.offset+=2),this}writeUInt16(t,e){return this.writeUint16(t,e)}writeInt32(t,e){const r=void 0===e;return r&&(e=this.offset),e+4>this.buffer.byteLength&&this.resize(e+4),this.view.setInt32(e,t,this.littleEndian),r&&(this.offset+=4),this}writeInt(t,e){return this.writeInt32(t,e)}writeUint32(t,e){const r=void 0===e;return r&&(e=this.offset),e+4>this.buffer.byteLength&&this.resize(e+4),this.view.setUint32(e,t,this.littleEndian),r&&(this.offset+=4),this}writeUInt32(t,e){return this.writeUint32(t,e)}readUint32(t){const e=void 0===t;e&&(t=this.offset);const r=this.view.getUint32(t,this.littleEndian);return e&&(this.offset+=4),r}append(t,e){const r=void 0===e;let n;return r&&(e=this.offset),t instanceof A?(n=new Uint8Array(t.buffer,t.offset,t.limit-t.offset),t.offset+=n.length):n=t instanceof Uint8Array?t:(ArrayBuffer,new Uint8Array(t)),n.length<=0||(e+n.length>this.buffer.byteLength&&this.resize(e+n.length),new Uint8Array(this.buffer).set(n,e),r&&(this.offset+=n.length)),this}clone(t){const e=new A(0,this.littleEndian);return t?(e.buffer=new ArrayBuffer(this.buffer.byteLength),new Uint8Array(e.buffer).set(new Uint8Array(this.buffer)),e.view=new DataView(e.buffer)):(e.buffer=this.buffer,e.view=this.view),e.offset=this.offset,e.markedOffset=this.markedOffset,e.limit=this.limit,e}copy(t,e){if(void 0===t&&(t=this.offset),void 0===e&&(e=this.limit),t===e)return new A(0,this.littleEndian);const r=e-t,n=new A(r,this.littleEndian);return n.offset=0,n.limit=r,new Uint8Array(n.buffer).set(new Uint8Array(this.buffer).subarray(t,e),0),n}copyTo(t,e,r,n){const o=void 0===e,i=void 0===r;e=o?t.offset:e;const s=(n=void 0===n?this.limit:n)-(r=i?this.offset:r);return 0===s?t:(t.ensureCapacity(e+s),new Uint8Array(t.buffer).set(new Uint8Array(this.buffer).subarray(r,n),e),i&&(this.offset+=s),o&&(t.offset+=s),this)}ensureCapacity(t){let e=this.buffer.byteLength;return e<t?this.resize((e*=2)>t?e:t):this}flip(){return this.limit=this.offset,this.offset=0,this}resize(t){if(this.buffer.byteLength<t){const e=new ArrayBuffer(t);new Uint8Array(e).set(new Uint8Array(this.buffer)),this.buffer=e,this.view=new DataView(e)}return this}skip(t){return this.offset+=t,this}writeInt64(t,e){const r=void 0===e;return r&&(e=this.offset),"number"==typeof t&&(t=BigInt(t)),e+8>this.buffer.byteLength&&this.resize(e+8),this.view.setBigInt64(e,t,this.littleEndian),r&&(this.offset+=8),this}writeLong(t,e){return this.writeInt64(t,e)}readInt64(t){const e=void 0===t;e&&(t=this.offset);const r=this.view.getBigInt64(t,this.littleEndian);return e&&(this.offset+=8),r}readLong(t){return this.readInt64(t)}writeUint64(t,e){const r=void 0===e;return r&&(e=this.offset),"number"==typeof t&&(t=BigInt(t)),e+8>this.buffer.byteLength&&this.resize(e+8),this.view.setBigUint64(e,t,this.littleEndian),r&&(this.offset+=8),this}writeUInt64(t,e){return this.writeUint64(t,e)}readUint64(t){const e=void 0===t;e&&(t=this.offset);const r=this.view.getBigUint64(t,this.littleEndian);return e&&(this.offset+=8),r}readUInt64(t){return this.readUint64(t)}toBuffer(t){const e=this.offset,r=this.limit;return t||0!==e||r!==this.buffer.byteLength?e===r?E:this.buffer.slice(e,r):this.buffer}toArrayBuffer(t){return this.toBuffer(t)}writeVarint32(t,e){const r=void 0===e;r&&(e=this.offset);const n=this.calculateVarint32(t);for(e+n>this.buffer.byteLength&&this.resize(e+n),t>>>=0;t>=128;)this.view.setUint8(e++,127&t|128),t>>>=7;return this.view.setUint8(e++,t),r?(this.offset=e,this):n}readVarint32(t){const e=void 0===t;void 0===t&&(t=this.offset);let r,n=0,o=0;do{r=this.view.getUint8(t++),n<5&&(o|=(127&r)<<7*n),++n}while(128&r);return o|=0,e?(this.offset=t,o):{value:o,length:n}}calculateVarint32(t){return(t>>>=0)<128?1:t<16384?2:t<1<<21?3:t<1<<28?4:5}writeVString(t,e){const r=void 0===e;let n=r?this.offset:e;const o=v.encode(t),i=o.length,s=this.calculateVarint32(i);return n+s+i>this.buffer.byteLength&&this.resize(n+s+i),this.writeVarint32(i,n),n+=s,new Uint8Array(this.buffer).set(o,n),n+=i,r?(this.offset=n,this):n-(e||0)}readVString(t){const e=void 0===t;e&&(t=this.offset);const r=t,n=this.readVarint32(t),o=n.value;t+=n.length;const i=x.decode(new Uint8Array(this.buffer,t,o));return t+=o,e?(this.offset=t,i):{string:i,length:t-r}}readUTF8String(t,e){const r=void 0===e;r&&(e=this.offset);const n=x.decode(new Uint8Array(this.buffer,e,t));return r?(this.offset+=t,n):{string:n,length:t}}}function B(t,e,r){return t&e^~t&r}function U(t,e,r){return t&e^t&r^e&r}A.LITTLE_ENDIAN=!0,A.BIG_ENDIAN=!1,A.DEFAULT_CAPACITY=16,A.DEFAULT_ENDIAN=A.BIG_ENDIAN;class I{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(t,e,r,n){this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,this.buffer=new Uint8Array(t),this.view=f(this.buffer)}update(t){a(this),i(t);const{view:e,buffer:r,blockLen:n}=this,o=t.length;for(let i=0;i<o;){const s=Math.min(n-this.pos,o-i);if(s===n){const e=f(t);for(;n<=o-i;i+=n)this.process(e,i);continue}r.set(t.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===n&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){a(this),function(t,e){i(t,void 0,"digestInto() output");const r=e.outputLen;if(t.length<r)throw Error('"digestInto() output" expected to be of length >='+r)}(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:n,isLE:o}=this;let{pos:s}=this;e[s++]=128,c(this.buffer.subarray(s)),this.padOffset>n-s&&(this.process(r,0),s=0);for(let t=s;t<n;t++)e[t]=0;r.setBigUint64(n-8,BigInt(8*this.length),o),this.process(r,0);const h=f(t),u=this.outputLen;if(u%4)throw Error("_sha2: outputLen must be aligned to 32bit");const l=u/4,d=this.get();if(l>d.length)throw Error("_sha2: outputLen bigger than state");for(let t=0;t<l;t++)h.setUint32(4*t,d[t],o)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||=new this.constructor,t.set(...this.get());const{blockLen:e,buffer:r,length:n,finished:o,destroyed:i,pos:s}=this;return t.destroyed=i,t.finished=o,t.length=n,t.pos=s,n%e&&t.buffer.set(r),t}clone(){return this._cloneInto()}}const S=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),O=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),k=Uint8Array.from([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),L=(()=>Uint8Array.from(Array(16).fill(0).map((t,e)=>e)))(),T=(()=>L.map(t=>(9*t+5)%16))(),R=(()=>{const t=[[L],[T]];for(let e=0;e<4;e++)for(let r of t)r.push(r[e].map(t=>k[t]));return t})(),N=(()=>R[0])(),D=(()=>R[1])(),F=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(t=>Uint8Array.from(t)),C=N.map((t,e)=>t.map(t=>F[e][t])),H=D.map((t,e)=>t.map(t=>F[e][t])),V=Uint32Array.from([0,1518500249,1859775393,2400959708,2840853838]),q=Uint32Array.from([1352829926,1548603684,1836072691,2053994217,0]);function P(t,e,r,n){return 0===t?e^r^n:1===t?e&r|~e&n:2===t?(e|~r)^n:3===t?e&n|r&~n:e^(r|~n)}const j=new Uint32Array(16);class z extends I{h0=1732584193;h1=-271733879;h2=-1732584194;h3=271733878;h4=-1009589776;constructor(){super(64,20,8,!0)}get(){const{h0:t,h1:e,h2:r,h3:n,h4:o}=this;return[t,e,r,n,o]}set(t,e,r,n,o){this.h0=0|t,this.h1=0|e,this.h2=0|r,this.h3=0|n,this.h4=0|o}process(t,e){for(let r=0;r<16;r++,e+=4)j[r]=t.getUint32(e,!0);let r=0|this.h0,n=r,o=0|this.h1,i=o,s=0|this.h2,a=s,c=0|this.h3,f=c,h=0|this.h4,l=h;for(let t=0;t<5;t++){const e=4-t,d=V[t],p=q[t],g=N[t],w=D[t],y=C[t],b=H[t];for(let e=0;e<16;e++){const n=u(r+P(t,o,s,c)+j[g[e]]+d,y[e])+h|0;r=h,h=c,c=0|u(s,10),s=o,o=n}for(let t=0;t<16;t++){const r=u(n+P(e,i,a,f)+j[w[t]]+p,b[t])+l|0;n=l,l=f,f=0|u(a,10),a=i,i=r}}this.set(this.h1+s+f|0,this.h2+c+l|0,this.h3+h+n|0,this.h4+r+i|0,this.h0+o+a|0)}roundClean(){c(j)}destroy(){this.destroyed=!0,c(this.buffer),this.set(0,0,0,0,0)}}const Z=b(()=>new z),M=function(t){const e=new Uint8Array(256);for(let t=0;t<e.length;t++)e[t]=255;for(let r=0;r<58;r++){const n=t.charAt(r),o=n.charCodeAt(0);if(255!==e[o])throw new TypeError(n+" is ambiguous");e[o]=r}function r(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return new Uint8Array;let r=0,n=0,o=0;for(;"1"===t[r];)n++,r++;const i=.7322476243909465*(t.length-r)+1>>>0,s=new Uint8Array(i);for(;r<t.length;){const n=t.charCodeAt(r);if(n>255)return;let a=e[n];if(255===a)return;let c=0;for(let t=i-1;(0!==a||c<o)&&-1!==t;t--,c++)a+=58*s[t]>>>0,s[t]=a%256>>>0,a=a/256>>>0;if(0!==a)throw Error("Non-zero carry");o=c,r++}let a=i-o;for(;a!==i&&0===s[a];)a++;const c=new Uint8Array(n+(i-a));let f=n;for(;a!==i;)c[f++]=s[a++];return c}return{encode(e){if(e instanceof Uint8Array||(ArrayBuffer.isView(e)?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Array.isArray(e)&&(e=Uint8Array.from(e))),!(e instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===e.length)return"";let r=0,n=0,o=0;const i=e.length;for(;o!==i&&0===e[o];)o++,r++;const s=1.365658237309761*(i-o)+1>>>0,a=new Uint8Array(s);for(;o!==i;){let t=e[o],r=0;for(let e=s-1;(0!==t||r<n)&&-1!==e;e--,r++)t+=256*a[e]>>>0,a[e]=t%58>>>0,t=t/58>>>0;if(0!==t)throw Error("Non-zero carry");n=r,o++}let c=s-n;for(;c!==s&&0===a[c];)c++;let f="1".repeat(r);for(;c<s;++c)f+=t.charAt(a[c]);return f},decodeUnsafe:r,decode(t){const e=r(t);if(e)return e;throw Error("Non-base58 character")}}}("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),$={nodes:["https://api.hive.blog","https://api.deathwing.me","https://api.openhive.network","https://rpc.mahdiyari.info","https://techcoderx.com","https://hiveapi.actifit.io","https://api.c0ff33a.uk"],restNodes:["https://api.hive.blog","https://rpc.mahdiyari.info","https://techcoderx.com","https://hiveapi.actifit.io","https://api.c0ff33a.uk"],chain_id:"beeab0de00000000000000000000000000000000000000000000000000000000",address_prefix:"STM",timeout:1e4,retry:8},K=BigInt(2**32-1),Y=BigInt(32);function G(t,e=!1){return e?{h:+(t&K),l:+(t>>Y&K)}:{h:0|+(t>>Y&K),l:0|+(t&K)}}const W=(t,e,r)=>t>>>r,X=(t,e,r)=>t<<32-r|e>>>r,J=(t,e,r)=>t>>>r|e<<32-r,Q=(t,e,r)=>t<<32-r|e>>>r,tt=(t,e,r)=>t<<64-r|e>>>r-32,et=(t,e,r)=>t>>>r-32|e<<64-r;function rt(t,e,r,n){const o=(e>>>0)+(n>>>0);return{h:t+r+(o/2**32|0)|0,l:0|o}}const nt=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),ot=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,it=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),st=(t,e,r,n,o)=>e+r+n+o+(t/2**32|0)|0,at=(t,e,r,n,o)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(o>>>0),ct=(t,e,r,n,o,i)=>e+r+n+o+i+(t/2**32|0)|0,ft=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ht=new Uint32Array(64);class ut extends I{constructor(t){super(64,t,8,!1)}get(){const{A:t,B:e,C:r,D:n,E:o,F:i,G:s,H:a}=this;return[t,e,r,n,o,i,s,a]}set(t,e,r,n,o,i,s,a){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|o,this.F=0|i,this.G=0|s,this.H=0|a}process(t,e){for(let r=0;r<16;r++,e+=4)ht[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=ht[t-15],r=ht[t-2],n=h(e,7)^h(e,18)^e>>>3,o=h(r,17)^h(r,19)^r>>>10;ht[t]=o+ht[t-7]+n+ht[t-16]|0}let{A:r,B:n,C:o,D:i,E:s,F:a,G:c,H:f}=this;for(let t=0;t<64;t++){const e=f+(h(s,6)^h(s,11)^h(s,25))+B(s,a,c)+ft[t]+ht[t]|0,u=(h(r,2)^h(r,13)^h(r,22))+U(r,n,o)|0;f=c,c=a,a=s,s=i+e|0,i=o,o=n,n=r,r=e+u|0}r=r+this.A|0,n=n+this.B|0,o=o+this.C|0,i=i+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,f=f+this.H|0,this.set(r,n,o,i,s,a,c,f)}roundClean(){c(ht)}destroy(){this.set(0,0,0,0,0,0,0,0),c(this.buffer)}}class lt extends ut{A=0|S[0];B=0|S[1];C=0|S[2];D=0|S[3];E=0|S[4];F=0|S[5];G=0|S[6];H=0|S[7];constructor(){super(32)}}const dt=(()=>function(t,e=!1){const r=t.length;let n=new Uint32Array(r),o=new Uint32Array(r);for(let i=0;i<r;i++){const{h:r,l:s}=G(t[i],e);[n[i],o[i]]=[r,s]}return[n,o]}(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))))(),pt=(()=>dt[0])(),gt=(()=>dt[1])(),wt=new Uint32Array(80),yt=new Uint32Array(80);class bt extends I{constructor(t){super(128,t,16,!1)}get(){const{Ah:t,Al:e,Bh:r,Bl:n,Ch:o,Cl:i,Dh:s,Dl:a,Eh:c,El:f,Fh:h,Fl:u,Gh:l,Gl:d,Hh:p,Hl:g}=this;return[t,e,r,n,o,i,s,a,c,f,h,u,l,d,p,g]}set(t,e,r,n,o,i,s,a,c,f,h,u,l,d,p,g){this.Ah=0|t,this.Al=0|e,this.Bh=0|r,this.Bl=0|n,this.Ch=0|o,this.Cl=0|i,this.Dh=0|s,this.Dl=0|a,this.Eh=0|c,this.El=0|f,this.Fh=0|h,this.Fl=0|u,this.Gh=0|l,this.Gl=0|d,this.Hh=0|p,this.Hl=0|g}process(t,e){for(let r=0;r<16;r++,e+=4)wt[r]=t.getUint32(e),yt[r]=t.getUint32(e+=4);for(let t=16;t<80;t++){const e=0|wt[t-15],r=0|yt[t-15],n=J(e,r,1)^J(e,r,8)^W(e,0,7),o=Q(e,r,1)^Q(e,r,8)^X(e,r,7),i=0|wt[t-2],s=0|yt[t-2],a=J(i,s,19)^tt(i,s,61)^W(i,0,6),c=Q(i,s,19)^et(i,s,61)^X(i,s,6),f=it(o,c,yt[t-7],yt[t-16]),h=st(f,n,a,wt[t-7],wt[t-16]);wt[t]=0|h,yt[t]=0|f}let{Ah:r,Al:n,Bh:o,Bl:i,Ch:s,Cl:a,Dh:c,Dl:f,Eh:h,El:u,Fh:l,Fl:d,Gh:p,Gl:g,Hh:w,Hl:y}=this;for(let t=0;t<80;t++){const e=J(h,u,14)^J(h,u,18)^tt(h,u,41),b=Q(h,u,14)^Q(h,u,18)^et(h,u,41),m=h&l^~h&p,_=at(y,b,u&d^~u&g,gt[t],yt[t]),E=ct(_,w,e,m,pt[t],wt[t]),v=0|_,x=J(r,n,28)^tt(r,n,34)^tt(r,n,39),A=Q(r,n,28)^et(r,n,34)^et(r,n,39),B=r&o^r&s^o&s,U=n&i^n&a^i&a;w=0|p,y=0|g,p=0|l,g=0|d,l=0|h,d=0|u,({h,l:u}=rt(0|c,0|f,0|E,0|v)),c=0|s,f=0|a,s=0|o,a=0|i,o=0|r,i=0|n;const I=nt(v,A,U);r=ot(I,E,x,B),n=0|I}({h:r,l:n}=rt(0|this.Ah,0|this.Al,0|r,0|n)),({h:o,l:i}=rt(0|this.Bh,0|this.Bl,0|o,0|i)),({h:s,l:a}=rt(0|this.Ch,0|this.Cl,0|s,0|a)),({h:c,l:f}=rt(0|this.Dh,0|this.Dl,0|c,0|f)),({h,l:u}=rt(0|this.Eh,0|this.El,0|h,0|u)),({h:l,l:d}=rt(0|this.Fh,0|this.Fl,0|l,0|d)),({h:p,l:g}=rt(0|this.Gh,0|this.Gl,0|p,0|g)),({h:w,l:y}=rt(0|this.Hh,0|this.Hl,0|w,0|y)),this.set(r,n,o,i,s,a,c,f,h,u,l,d,p,g,w,y)}roundClean(){c(wt,yt)}destroy(){c(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class mt extends bt{Ah=0|O[0];Al=0|O[1];Bh=0|O[2];Bl=0|O[3];Ch=0|O[4];Cl=0|O[5];Dh=0|O[6];Dl=0|O[7];Eh=0|O[8];El=0|O[9];Fh=0|O[10];Fl=0|O[11];Gh=0|O[12];Gl=0|O[13];Hh=0|O[14];Hl=0|O[15];constructor(){super(64)}}const _t=b(()=>new lt,_(1)),Et=b(()=>new mt,_(3)),vt=BigInt(0),xt=BigInt(1);function At(t,e=""){if("boolean"!=typeof t)throw Error((e&&`"${e}" `)+"expected boolean, got type="+typeof t);return t}function Bt(t){if("bigint"==typeof t){if(!Tt(t))throw Error("positive bigint expected, got "+t)}else o(t);return t}function Ut(t){const e=Bt(t).toString(16);return 1&e.length?"0"+e:e}function It(t){if("string"!=typeof t)throw Error("hex string expected, got "+typeof t);return""===t?vt:BigInt("0x"+t)}function St(t){return It(p(t))}function Ot(t){return It(p(function(t){return Uint8Array.from(t)}(i(t)).reverse()))}function kt(t,e){o(e);const r=w((t=Bt(t)).toString(16).padStart(2*e,"0"));if(r.length!==e)throw Error("number too large");return r}function Lt(t,e){return kt(t,e).reverse()}const Tt=t=>"bigint"==typeof t&&vt<=t,Rt=t=>(xt<<BigInt(t))-xt;function Nt(t,e={},r={}){if(!t||"object"!=typeof t)throw Error("expected valid options object");const n=(e,r)=>Object.entries(e).forEach(([e,n])=>function(e,r,n){const o=t[e];if(n&&void 0===o)return;const i=typeof o;if(i!==r||null===o)throw Error(`param "${e}" is invalid: expected ${r}, got ${i}`)}(e,n,r));n(e,!1),n(r,!0)}function Dt(t){const e=new WeakMap;return(r,...n)=>{const o=e.get(r);if(void 0!==o)return o;const i=t(r,...n);return e.set(r,i),i}}const Ft=BigInt(0),Ct=BigInt(1),Ht=BigInt(2),Vt=BigInt(3),qt=BigInt(4),Pt=BigInt(5),jt=BigInt(7),zt=BigInt(8),Zt=BigInt(9),Mt=BigInt(16);function $t(t,e){const r=t%e;return r>=Ft?r:e+r}function Kt(t,e,r){let n=t;for(;e-- >Ft;)n*=n,n%=r;return n}function Yt(t,e){if(t===Ft)throw Error("invert: expected non-zero number");if(e<=Ft)throw Error("invert: expected positive modulus, got "+e);let r=$t(t,e),n=e,o=Ft,i=Ct,s=Ct,a=Ft;for(;r!==Ft;){const t=n/r,e=n%r,c=o-s*t,f=i-a*t;n=r,r=e,o=s,i=a,s=c,a=f}if(n!==Ct)throw Error("invert: does not exist");return $t(o,e)}function Gt(t,e,r){if(!t.eql(t.sqr(e),r))throw Error("Cannot find square root")}function Wt(t,e){const r=t.pow(e,(t.ORDER+Ct)/qt);return Gt(t,r,e),r}function Xt(t,e){const r=(t.ORDER-Pt)/zt,n=t.mul(e,Ht),o=t.pow(n,r),i=t.mul(e,o),s=t.mul(t.mul(i,Ht),o),a=t.mul(i,t.sub(s,t.ONE));return Gt(t,a,e),a}function Jt(t){if(t<Vt)throw Error("sqrt is not defined for small field");let e=t-Ct,r=0;for(;e%Ht===Ft;)e/=Ht,r++;let n=Ht;const o=ne(t);for(;1===ee(o,n);)if(n++>1e3)throw Error("Cannot find square root: probably non-prime P");if(1===r)return Wt;let i=o.pow(n,e);const s=(e+Ct)/Ht;return function(t,n){if(t.is0(n))return n;if(1!==ee(t,n))throw Error("Cannot find square root");let o=r,a=t.mul(t.ONE,i),c=t.pow(n,e),f=t.pow(n,s);for(;!t.eql(c,t.ONE);){if(t.is0(c))return t.ZERO;let e=1,r=t.sqr(c);for(;!t.eql(r,t.ONE);)if(e++,r=t.sqr(r),e===o)throw Error("Cannot find square root");const n=Ct<<BigInt(o-e-1),i=t.pow(a,n);o=e,a=t.sqr(i),c=t.mul(c,a),f=t.mul(f,i)}return f}}const Qt=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function te(t,e,r=!1){const n=Array(e.length).fill(r?t.ZERO:void 0),o=e.reduce((e,r,o)=>t.is0(r)?e:(n[o]=e,t.mul(e,r)),t.ONE),i=t.inv(o);return e.reduceRight((e,r,o)=>t.is0(r)?e:(n[o]=t.mul(e,n[o]),t.mul(e,r)),i),n}function ee(t,e){const r=t.pow(e,(t.ORDER-Ct)/Ht),n=t.eql(r,t.ONE),o=t.eql(r,t.ZERO),i=t.eql(r,t.neg(t.ONE));if(!n&&!o&&!i)throw Error("invalid Legendre symbol result");return n?1:o?0:-1}class re{ORDER;BITS;BYTES;isLE;ZERO=Ft;ONE=Ct;_lengths;_sqrt;_mod;constructor(t,e={}){if(t<=Ft)throw Error("invalid field: expected ORDER > 0, got "+t);let r;this.isLE=!1,null!=e&&"object"==typeof e&&("number"==typeof e.BITS&&(r=e.BITS),"function"==typeof e.sqrt&&(this.sqrt=e.sqrt),"boolean"==typeof e.isLE&&(this.isLE=e.isLE),e.allowedLengths&&(this._lengths=e.allowedLengths?.slice()),"boolean"==typeof e.modFromBytes&&(this._mod=e.modFromBytes));const{nBitLength:n,nByteLength:i}=function(t,e){void 0!==e&&o(e);const r=void 0!==e?e:t.toString(2).length;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}(t,r);if(i>2048)throw Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=n,this.BYTES=i,this._sqrt=void 0,Object.preventExtensions(this)}create(t){return $t(t,this.ORDER)}isValid(t){if("bigint"!=typeof t)throw Error("invalid field element: expected bigint, got "+typeof t);return Ft<=t&&t<this.ORDER}is0(t){return t===Ft}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&Ct)===Ct}neg(t){return $t(-t,this.ORDER)}eql(t,e){return t===e}sqr(t){return $t(t*t,this.ORDER)}add(t,e){return $t(t+e,this.ORDER)}sub(t,e){return $t(t-e,this.ORDER)}mul(t,e){return $t(t*e,this.ORDER)}pow(t,e){return function(t,e,r){if(r<Ft)throw Error("invalid exponent, negatives unsupported");if(r===Ft)return t.ONE;if(r===Ct)return e;let n=t.ONE,o=e;for(;r>Ft;)r&Ct&&(n=t.mul(n,o)),o=t.sqr(o),r>>=Ct;return n}(this,t,e)}div(t,e){return $t(t*Yt(e,this.ORDER),this.ORDER)}sqrN(t){return t*t}addN(t,e){return t+e}subN(t,e){return t-e}mulN(t,e){return t*e}inv(t){return Yt(t,this.ORDER)}sqrt(t){return this._sqrt||(this._sqrt=(e=this.ORDER)%qt===Vt?Wt:e%zt===Pt?Xt:e%Mt===Zt?function(t){const e=ne(t),r=Jt(t),n=r(e,e.neg(e.ONE)),o=r(e,n),i=r(e,e.neg(n)),s=(t+jt)/Mt;return(t,e)=>{let r=t.pow(e,s),a=t.mul(r,n);const c=t.mul(r,o),f=t.mul(r,i),h=t.eql(t.sqr(a),e),u=t.eql(t.sqr(c),e);r=t.cmov(r,a,h),a=t.cmov(f,c,u);const l=t.eql(t.sqr(a),e),d=t.cmov(r,a,l);return Gt(t,d,e),d}}(e):Jt(e)),this._sqrt(this,t);var e}toBytes(t){return this.isLE?Lt(t,this.BYTES):kt(t,this.BYTES)}fromBytes(t,e=!1){i(t);const{_lengths:r,BYTES:n,isLE:o,ORDER:s,_mod:a}=this;if(r){if(!r.includes(t.length)||t.length>n)throw Error("Field.fromBytes: expected "+r+" bytes, got "+t.length);const e=new Uint8Array(n);e.set(t,o?0:e.length-t.length),t=e}if(t.length!==n)throw Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let c=o?Ot(t):St(t);if(a&&(c=$t(c,s)),!e&&!this.isValid(c))throw Error("invalid field element: outside of range 0..ORDER");return c}invertBatch(t){return te(this,t)}cmov(t,e,r){return r?e:t}}function ne(t,e={}){return new re(t,e)}function oe(t){if("bigint"!=typeof t)throw Error("field order must be bigint");return Math.ceil(t.toString(2).length/8)}function ie(t){const e=oe(t);return e+Math.ceil(e/2)}const se=BigInt(0),ae=BigInt(1);function ce(t,e){const r=e.negate();return t?r:e}function fe(t,e){const r=te(t.Fp,e.map(t=>t.Z));return e.map((e,n)=>t.fromAffine(e.toAffine(r[n])))}function he(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw Error("invalid window size, expected [1.."+e+"], got W="+t)}function ue(t,e){he(t,e);const r=2**t;return{windows:Math.ceil(e/t)+1,windowSize:2**(t-1),mask:Rt(t),maxNumber:r,shiftBy:BigInt(t)}}function le(t,e,r){const{windowSize:n,mask:o,maxNumber:i,shiftBy:s}=r;let a=+(t&o),c=t>>s;a>n&&(a-=i,c+=ae);const f=e*n;return{nextN:c,offset:f+Math.abs(a)-1,isZero:0===a,isNeg:a<0,isNegF:e%2!=0,offsetF:f}}const de=new WeakMap,pe=new WeakMap;function ge(t){return pe.get(t)||1}function we(t){if(t!==se)throw Error("invalid wNAF")}class ye{BASE;ZERO;Fn;bits;constructor(t,e){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=e}_unsafeLadder(t,e,r=this.ZERO){let n=t;for(;e>se;)e&ae&&(r=r.add(n)),n=n.double(),e>>=ae;return r}precomputeWindow(t,e){const{windows:r,windowSize:n}=ue(e,this.bits),o=[];let i=t,s=i;for(let t=0;t<r;t++){s=i,o.push(s);for(let t=1;t<n;t++)s=s.add(i),o.push(s);i=s.double()}return o}wNAF(t,e,r){if(!this.Fn.isValid(r))throw Error("invalid scalar");let n=this.ZERO,o=this.BASE;const i=ue(t,this.bits);for(let t=0;t<i.windows;t++){const{nextN:s,offset:a,isZero:c,isNeg:f,isNegF:h,offsetF:u}=le(r,t,i);r=s,c?o=o.add(ce(h,e[u])):n=n.add(ce(f,e[a]))}return we(r),{p:n,f:o}}wNAFUnsafe(t,e,r,n=this.ZERO){const o=ue(t,this.bits);for(let t=0;t<o.windows&&r!==se;t++){const{nextN:i,offset:s,isZero:a,isNeg:c}=le(r,t,o);if(r=i,!a){const t=e[s];n=n.add(c?t.negate():t)}}return we(r),n}getPrecomputes(t,e,r){let n=de.get(e);return n||(n=this.precomputeWindow(e,t),1!==t&&("function"==typeof r&&(n=r(n)),de.set(e,n))),n}cached(t,e,r){const n=ge(t);return this.wNAF(n,this.getPrecomputes(n,t,r),e)}unsafe(t,e,r,n){const o=ge(t);return 1===o?this._unsafeLadder(t,e,n):this.wNAFUnsafe(o,this.getPrecomputes(o,t,r),e,n)}createCache(t,e){he(e,this.bits),pe.set(t,e),de.delete(t)}hasCache(t){return 1!==ge(t)}}function be(t,e,r){if(e){if(e.ORDER!==t)throw Error("Field.ORDER must match order: Fp == p, Fn == n");return function(t){Nt(t,Qt.reduce((t,e)=>(t[e]="function",t),{ORDER:"bigint",BYTES:"number",BITS:"number"}))}(e),e}return ne(t,{isLE:r})}var me;me="HashToScalar-",Uint8Array.from(me,(t,e)=>{const r=t.charCodeAt(0);if(1!==t.length||r>127)throw Error(`string contains non-ASCII character "${me[e]}" with code ${r} at position ${e}`);return r});class _e{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(t,e){if(s(t),i(e,void 0,"key"),this.iHash=t.create(),"function"!=typeof this.iHash.update)throw Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,n=new Uint8Array(r);n.set(e.length>r?t.create().update(e).digest():e);for(let t=0;t<n.length;t++)n[t]^=54;this.iHash.update(n),this.oHash=t.create();for(let t=0;t<n.length;t++)n[t]^=106;this.oHash.update(n),c(n)}update(t){return a(this),this.iHash.update(t),this}digestInto(t){a(this),i(t,this.outputLen,"output"),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||=Object.create(Object.getPrototypeOf(this),{});const{oHash:e,iHash:r,finished:n,destroyed:o,blockLen:i,outputLen:s}=this;return t.finished=n,t.destroyed=o,t.blockLen=i,t.outputLen=s,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Ee=(t,e,r)=>new _e(t,e).update(r).digest();Ee.create=(t,e)=>new _e(t,e);const ve=(t,e)=>(t+(t>=0?e:-e)/Se)/e;function xe(t){if(!["compact","recovered","der"].includes(t))throw Error('Signature format must be "compact", "recovered", or "der"');return t}function Ae(t,e){const r={};for(let n of Object.keys(e))r[n]=void 0===t[n]?e[n]:t[n];return At(r.lowS,"lowS"),At(r.prehash,"prehash"),void 0!==r.format&&xe(r.format),r}const Be={Err:class extends Error{constructor(t=""){super(t)}},_tlv:{encode(t,e){const{Err:r}=Be;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(1&e.length)throw new r("tlv.encode: unpadded data");const n=e.length/2,o=Ut(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");const i=n>127?Ut(o.length/2|128):"";return Ut(t)+i+o+e},decode(t,e){const{Err:r}=Be;let n=0;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length<2||e[n++]!==t)throw new r("tlv.decode: wrong tlv");const o=e[n++];let i=0;if(128&o){const t=127&o;if(!t)throw new r("tlv.decode(long): indefinite length not supported");if(t>4)throw new r("tlv.decode(long): byte length is too big");const s=e.subarray(n,n+t);if(s.length!==t)throw new r("tlv.decode: length bytes not complete");if(0===s[0])throw new r("tlv.decode(long): zero leftmost byte");for(const t of s)i=i<<8|t;if(n+=t,i<128)throw new r("tlv.decode(long): not minimal encoding")}else i=o;const s=e.subarray(n,n+i);if(s.length!==i)throw new r("tlv.decode: wrong value length");return{v:s,l:e.subarray(n+i)}}},_int:{encode(t){const{Err:e}=Be;if(t<Ue)throw new e("integer: negative integers are not allowed");let r=Ut(t);if(8&Number.parseInt(r[0],16)&&(r="00"+r),1&r.length)throw new e("unexpected DER parsing assertion: unpadded hex");return r},decode(t){const{Err:e}=Be;if(128&t[0])throw new e("invalid signature integer: negative");if(0===t[0]&&!(128&t[1]))throw new e("invalid signature integer: unnecessary leading zero");return St(t)}},toSig(t){const{Err:e,_int:r,_tlv:n}=Be,o=i(t,void 0,"signature"),{v:s,l:a}=n.decode(48,o);if(a.length)throw new e("invalid signature: left bytes after parsing");const{v:c,l:f}=n.decode(2,s),{v:h,l:u}=n.decode(2,f);if(u.length)throw new e("invalid signature: left bytes after parsing");return{r:r.decode(c),s:r.decode(h)}},hexFromSig(t){const{_tlv:e,_int:r}=Be,n=e.encode(2,r.encode(t.r)),o=e.encode(2,r.encode(t.s));return e.encode(48,n+o)}},Ue=BigInt(0),Ie=BigInt(1),Se=BigInt(2),Oe=BigInt(3),ke=BigInt(4);function Le(t,e={}){const r=function(t,e,r={},n){if(void 0===n&&(n="edwards"===t),!e||"object"!=typeof e)throw Error(`expected valid ${t} CURVE object`);for(const t of["p","n","h"]){const r=e[t];if(!("bigint"==typeof r&&r>se))throw Error(`CURVE.${t} must be positive bigint`)}const o=be(e.p,r.Fp,n),i=be(e.n,r.Fn,n),s=["Gx","Gy","a","weierstrass"===t?"b":"d"];for(const t of s)if(!o.isValid(e[t]))throw Error(`CURVE.${t} must be valid field element of CURVE.Fp`);return{CURVE:e=Object.freeze(Object.assign({},e)),Fp:o,Fn:i}}("weierstrass",t,e),{Fp:n,Fn:o}=r;let s=r.CURVE;const{h:a,n:c}=s;Nt(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});const{endo:f}=e;if(f&&(!n.is0(s.a)||"bigint"!=typeof f.beta||!Array.isArray(f.basises)))throw Error('invalid endo: expected "beta": bigint and "basises": array');const h=Re(n,o);function u(){if(!n.isOdd)throw Error("compression is not supported: Field does not have .isOdd()")}const l=e.toBytes||function(t,e,r){const{x:o,y:i}=e.toAffine(),s=n.toBytes(o);return At(r,"isCompressed"),r?(u(),y(Te(!n.isOdd(i)),s)):y(Uint8Array.of(4),s,n.toBytes(i))},d=e.fromBytes||function(t){i(t,void 0,"Point");const{publicKey:e,publicKeyUncompressed:r}=h,o=t.length,s=t[0],a=t.subarray(1);if(o!==e||2!==s&&3!==s){if(o===r&&4===s){const t=n.BYTES,e=n.fromBytes(a.subarray(0,t)),r=n.fromBytes(a.subarray(t,2*t));if(!b(e,r))throw Error("bad point: is not on curve");return{x:e,y:r}}throw Error(`bad point: got length ${o}, expected compressed=${e} or uncompressed=${r}`)}{const t=n.fromBytes(a);if(!n.isValid(t))throw Error("bad point: is not on curve, wrong x");const e=g(t);let r;try{r=n.sqrt(e)}catch(t){throw Error("bad point: is not on curve, sqrt error"+(t instanceof Error?": "+t.message:""))}return u(),!(1&~s)!==n.isOdd(r)&&(r=n.neg(r)),{x:t,y:r}}};function g(t){const e=n.sqr(t),r=n.mul(e,t);return n.add(n.add(r,n.mul(t,s.a)),s.b)}function b(t,e){const r=n.sqr(e),o=g(t);return n.eql(r,o)}if(!b(s.Gx,s.Gy))throw Error("bad curve params: generator point");const m=n.mul(n.pow(s.a,Oe),ke),_=n.mul(n.sqr(s.b),BigInt(27));if(n.is0(n.add(m,_)))throw Error("bad curve params: a or b");function E(t,e,r=!1){if(!n.isValid(e)||r&&n.is0(e))throw Error("bad point coordinate "+t);return e}function v(t){if(!(t instanceof I))throw Error("Weierstrass Point expected")}function x(t){if(!f||!f.basises)throw Error("no endo");return function(t,e,r){const[[n,o],[i,s]]=e,a=ve(s*t,r),c=ve(-o*t,r);let f=t-a*n-c*i,h=-a*o-c*s;const u=f<Ue,l=h<Ue;u&&(f=-f),l&&(h=-h);const d=Rt(Math.ceil(function(t){let e;for(e=0;t>vt;t>>=xt,e+=1);return e}(r)/2))+Ie;if(f<Ue||f>=d||h<Ue||h>=d)throw Error("splitScalar (endomorphism): failed, k="+t);return{k1neg:u,k1:f,k2neg:l,k2:h}}(t,f.basises,o.ORDER)}const A=Dt((t,e)=>{const{X:r,Y:o,Z:i}=t;if(n.eql(i,n.ONE))return{x:r,y:o};const s=t.is0();null==e&&(e=s?n.ONE:n.inv(i));const a=n.mul(r,e),c=n.mul(o,e),f=n.mul(i,e);if(s)return{x:n.ZERO,y:n.ZERO};if(!n.eql(f,n.ONE))throw Error("invZ was invalid");return{x:a,y:c}}),B=Dt(t=>{if(t.is0()){if(e.allowInfinityPoint&&!n.is0(t.Y))return;throw Error("bad point: ZERO")}const{x:r,y:o}=t.toAffine();if(!n.isValid(r)||!n.isValid(o))throw Error("bad point: x or y not field elements");if(!b(r,o))throw Error("bad point: equation left != right");if(!t.isTorsionFree())throw Error("bad point: not in prime-order subgroup");return!0});function U(t,e,r,o,i){return r=new I(n.mul(r.X,t),r.Y,r.Z),e=ce(o,e),r=ce(i,r),e.add(r)}class I{static BASE=new I(s.Gx,s.Gy,n.ONE);static ZERO=new I(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=o;X;Y;Z;constructor(t,e,r){this.X=E("x",t),this.Y=E("y",e,!0),this.Z=E("z",r),Object.freeze(this)}static CURVE(){return s}static fromAffine(t){const{x:e,y:r}=t||{};if(!t||!n.isValid(e)||!n.isValid(r))throw Error("invalid affine point");if(t instanceof I)throw Error("projective point not allowed");return n.is0(e)&&n.is0(r)?I.ZERO:new I(e,r,n.ONE)}static fromBytes(t){const e=I.fromAffine(d(i(t,void 0,"point")));return e.assertValidity(),e}static fromHex(t){return I.fromBytes(w(t))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(t=8,e=!0){return O.createCache(this,t),e||this.multiply(Oe),this}assertValidity(){B(this)}hasEvenY(){const{y:t}=this.toAffine();if(!n.isOdd)throw Error("Field doesn't support isOdd");return!n.isOdd(t)}equals(t){v(t);const{X:e,Y:r,Z:o}=this,{X:i,Y:s,Z:a}=t,c=n.eql(n.mul(e,a),n.mul(i,o)),f=n.eql(n.mul(r,a),n.mul(s,o));return c&&f}negate(){return new I(this.X,n.neg(this.Y),this.Z)}double(){const{a:t,b:e}=s,r=n.mul(e,Oe),{X:o,Y:i,Z:a}=this;let c=n.ZERO,f=n.ZERO,h=n.ZERO,u=n.mul(o,o),l=n.mul(i,i),d=n.mul(a,a),p=n.mul(o,i);return p=n.add(p,p),h=n.mul(o,a),h=n.add(h,h),c=n.mul(t,h),f=n.mul(r,d),f=n.add(c,f),c=n.sub(l,f),f=n.add(l,f),f=n.mul(c,f),c=n.mul(p,c),h=n.mul(r,h),d=n.mul(t,d),p=n.sub(u,d),p=n.mul(t,p),p=n.add(p,h),h=n.add(u,u),u=n.add(h,u),u=n.add(u,d),u=n.mul(u,p),f=n.add(f,u),d=n.mul(i,a),d=n.add(d,d),u=n.mul(d,p),c=n.sub(c,u),h=n.mul(d,l),h=n.add(h,h),h=n.add(h,h),new I(c,f,h)}add(t){v(t);const{X:e,Y:r,Z:o}=this,{X:i,Y:a,Z:c}=t;let f=n.ZERO,h=n.ZERO,u=n.ZERO;const l=s.a,d=n.mul(s.b,Oe);let p=n.mul(e,i),g=n.mul(r,a),w=n.mul(o,c),y=n.add(e,r),b=n.add(i,a);y=n.mul(y,b),b=n.add(p,g),y=n.sub(y,b),b=n.add(e,o);let m=n.add(i,c);return b=n.mul(b,m),m=n.add(p,w),b=n.sub(b,m),m=n.add(r,o),f=n.add(a,c),m=n.mul(m,f),f=n.add(g,w),m=n.sub(m,f),u=n.mul(l,b),f=n.mul(d,w),u=n.add(f,u),f=n.sub(g,u),u=n.add(g,u),h=n.mul(f,u),g=n.add(p,p),g=n.add(g,p),w=n.mul(l,w),b=n.mul(d,b),g=n.add(g,w),w=n.sub(p,w),w=n.mul(l,w),b=n.add(b,w),p=n.mul(g,b),h=n.add(h,p),p=n.mul(m,b),f=n.mul(y,f),f=n.sub(f,p),p=n.mul(y,g),u=n.mul(m,u),u=n.add(u,p),new I(f,h,u)}subtract(t){return this.add(t.negate())}is0(){return this.equals(I.ZERO)}multiply(t){const{endo:r}=e;if(!o.isValidNot0(t))throw Error("invalid scalar: out of range");let n,i;const s=t=>O.cached(this,t,t=>fe(I,t));if(r){const{k1neg:e,k1:o,k2neg:a,k2:c}=x(t),{p:f,f:h}=s(o),{p:u,f:l}=s(c);i=h.add(l),n=U(r.beta,f,u,e,a)}else{const{p:e,f:r}=s(t);n=e,i=r}return fe(I,[n,i])[0]}multiplyUnsafe(t){const{endo:r}=e,n=this;if(!o.isValid(t))throw Error("invalid scalar: out of range");if(t===Ue||n.is0())return I.ZERO;if(t===Ie)return n;if(O.hasCache(this))return this.multiply(t);if(r){const{k1neg:e,k1:o,k2neg:i,k2:s}=x(t),{p1:a,p2:c}=function(t,e,r,n){let o=e,i=t.ZERO,s=t.ZERO;for(;r>se||n>se;)r&ae&&(i=i.add(o)),n&ae&&(s=s.add(o)),o=o.double(),r>>=ae,n>>=ae;return{p1:i,p2:s}}(I,n,o,s);return U(r.beta,a,c,e,i)}return O.unsafe(n,t)}toAffine(t){return A(this,t)}isTorsionFree(){const{isTorsionFree:t}=e;return a===Ie||(t?t(I,this):O.unsafe(this,c).is0())}clearCofactor(){const{clearCofactor:t}=e;return a===Ie?this:t?t(I,this):this.multiplyUnsafe(a)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}toBytes(t=!0){return At(t,"isCompressed"),this.assertValidity(),l(I,this,t)}toHex(t=!0){return p(this.toBytes(t))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}const S=o.BITS,O=new ye(I,e.endo?Math.ceil(S/2):S);return I.BASE.precompute(8),I}function Te(t){return Uint8Array.of(t?2:3)}function Re(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function Ne(t,e,r={}){s(e),Nt(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const a=(r=Object.assign({},r)).randomBytes||m,c=r.hmac||((t,r)=>Ee(e,t,r)),{Fp:f,Fn:h}=t,{ORDER:u,BITS:l}=h,{keygen:d,getPublicKey:g,getSharedSecret:b,utils:_,lengths:E}=function(t,e={}){const{Fn:r}=t,o=e.randomBytes||m,s=Object.assign(Re(t.Fp,r),{seed:ie(r.ORDER)});function a(t=o(s.seed)){return function(t,e,r=!1){i(t);const n=t.length,o=oe(e),s=ie(e);if(n<16||n<s||n>1024)throw Error("expected "+s+"-1024 bytes of input, got "+n);const a=$t(r?Ot(t):St(t),e-Ct)+Ct;return r?Lt(a,o):kt(a,o)}(i(t,s.seed,"seed"),r.ORDER)}function c(e,n=!0){return t.BASE.multiply(r.fromBytes(e)).toBytes(n)}function f(t){const{secretKey:e,publicKey:o,publicKeyUncompressed:a}=s;if(!n(t))return;if("_lengths"in r&&r._lengths||e===o)return;const c=i(t,void 0,"key").length;return c===o||c===a}const h={isValidSecretKey(t){try{const e=r.fromBytes(t);return r.isValidNot0(e)}catch(t){return!1}},isValidPublicKey(e,r){const{publicKey:n,publicKeyUncompressed:o}=s;try{const i=e.length;return!(!0===r&&i!==n||!1===r&&i!==o||!t.fromBytes(e))}catch(t){return!1}},randomSecretKey:a},u=function(t,e){return function(r){const n=t(r);return{secretKey:n,publicKey:e(n)}}}(a,c);return Object.freeze({getPublicKey:c,getSharedSecret(e,n,o=!0){if(!0===f(e))throw Error("first arg must be private key");if(!1===f(n))throw Error("second arg must be public key");const i=r.fromBytes(e);return t.fromBytes(n).multiply(i).toBytes(o)},keygen:u,Point:t,utils:h,lengths:s})}(t,r),v={prehash:!0,lowS:"boolean"!=typeof r.lowS||r.lowS,format:"compact",extraEntropy:!1},x=u*Se<f.ORDER;function A(t){return t>u>>Ie}function B(t,e){if(!h.isValidNot0(e))throw Error(`invalid signature ${t}: out of range 1..Point.Fn.ORDER`);return e}function U(){if(x)throw Error('"recovered" sig type is not supported for cofactor >2 curves')}function I(t,e){xe(e);const r=E.signature;return i(t,"compact"===e?r:"recovered"===e?r+1:void 0)}class S{r;s;recovery;constructor(t,e,r){if(this.r=B("r",t),this.s=B("s",e),null!=r){if(U(),![0,1,2,3].includes(r))throw Error("invalid recovery id");this.recovery=r}Object.freeze(this)}static fromBytes(t,e=v.format){let r;if(I(t,e),"der"===e){const{r:e,s:r}=Be.toSig(i(t));return new S(e,r)}"recovered"===e&&(r=t[0],e="compact",t=t.subarray(1));const n=E.signature/2,o=t.subarray(0,n),s=t.subarray(n,2*n);return new S(h.fromBytes(o),h.fromBytes(s),r)}static fromHex(t,e){return this.fromBytes(w(t),e)}assertRecovery(){const{recovery:t}=this;if(null==t)throw Error("invalid recovery id: must be present");return t}addRecoveryBit(t){return new S(this.r,this.s,t)}recoverPublicKey(e){const{r,s:n}=this,o=this.assertRecovery(),s=2===o||3===o?r+u:r;if(!f.isValid(s))throw Error("invalid recovery id: sig.r+curve.n != R.x");const a=f.toBytes(s),c=t.fromBytes(y(Te(!(1&o)),a)),l=h.inv(s),d=k(i(e,void 0,"msgHash")),p=h.create(-d*l),g=h.create(n*l),w=t.BASE.multiplyUnsafe(p).add(c.multiplyUnsafe(g));if(w.is0())throw Error("invalid recovery: point at infinify");return w.assertValidity(),w}hasHighS(){return A(this.s)}toBytes(t=v.format){if(xe(t),"der"===t)return w(Be.hexFromSig(this));const{r:e,s:r}=this,n=h.toBytes(e),o=h.toBytes(r);return"recovered"===t?(U(),y(Uint8Array.of(this.assertRecovery()),n,o)):y(n,o)}toHex(t){return p(this.toBytes(t))}}const O=r.bits2int||function(t){if(t.length>8192)throw Error("input is too large");const e=St(t),r=8*t.length-l;return r>0?e>>BigInt(r):e},k=r.bits2int_modN||function(t){return h.create(O(t))},L=Rt(l);function T(t){return function(t,e,r,n){if(!function(t,e,r){return Tt(t)&&Tt(e)&&Tt(r)&&e<=t&&t<r}(e,r,n))throw Error("expected valid "+t+": "+r+" <= n < "+n+", got "+e)}("num < 2^"+l,t,Ue,L),h.toBytes(t)}function R(t,r){return i(t,void 0,"message"),r?i(e(t),void 0,"prehashed message"):t}return Object.freeze({keygen:d,getPublicKey:g,getSharedSecret:b,utils:_,lengths:E,Point:t,sign(r,n,s={}){const{seed:f,k2sig:u}=function(e,r,n){const{lowS:o,prehash:s,extraEntropy:c}=Ae(n,v);e=R(e,s);const f=k(e),u=h.fromBytes(r);if(!h.isValidNot0(u))throw Error("invalid private key");const l=[T(u),T(f)];if(null!=c&&!1!==c){const t=!0===c?a(E.secretKey):c;l.push(i(t,void 0,"extraEntropy"))}const d=y(...l),p=f;return{seed:d,k2sig(e){const r=O(e);if(!h.isValidNot0(r))return;const n=h.inv(r),i=t.BASE.multiply(r).toAffine(),s=h.create(i.x);if(s===Ue)return;const a=h.create(n*h.create(p+s*u));if(a===Ue)return;let c=(i.x===s?0:2)|+(i.y&Ie),f=a;return o&&A(a)&&(f=h.neg(a),c^=1),new S(s,f,x?void 0:c)}}}(r,n,s);return function(t,e,r){if(o(t,"hashLen"),o(e,"qByteLen"),"function"!=typeof r)throw Error("hmacFn must be a function");const n=t=>new Uint8Array(t),i=Uint8Array.of(),s=Uint8Array.of(0),a=Uint8Array.of(1);let c=n(t),f=n(t),h=0;const u=()=>{c.fill(1),f.fill(0),h=0},l=(...t)=>r(f,y(c,...t)),d=(t=i)=>{f=l(s,t),c=l(),0!==t.length&&(f=l(a,t),c=l())},p=()=>{if(h++>=1e3)throw Error("drbg: tried max amount of iterations");let t=0;const r=[];for(;t<e;){c=l();const e=c.slice();r.push(e),t+=c.length}return y(...r)};return(t,e)=>{let r;for(u(),d(t);!(r=e(p()));)d();return u(),r}}(e.outputLen,h.BYTES,c)(f,u).toBytes(s.format)},verify(e,r,o,s={}){const{lowS:a,prehash:c,format:f}=Ae(s,v);if(o=i(o,void 0,"publicKey"),r=R(r,c),!n(e))throw Error("verify expects Uint8Array signature"+(e instanceof S?", use sig.toBytes()":""));I(e,f);try{const n=S.fromBytes(e,f),i=t.fromBytes(o);if(a&&n.hasHighS())return!1;const{r:s,s:c}=n,u=k(r),l=h.inv(c),d=h.create(u*l),p=h.create(s*l),g=t.BASE.multiplyUnsafe(d).add(i.multiplyUnsafe(p));return!g.is0()&&h.create(g.x)===s}catch(t){return!1}},recoverPublicKey(t,e,r={}){const{prehash:n}=Ae(r,v);return e=R(e,n),S.fromBytes(t,"recovered").recoverPublicKey(e).toBytes()},Signature:S,hash:e})}const De={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},Fe={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},Ce=BigInt(2),He=ne(De.p,{sqrt(t){const e=De.p,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),f=t*t*t%e,h=f*f*t%e,u=Kt(h,r,e)*h%e,l=Kt(u,r,e)*h%e,d=Kt(l,Ce,e)*f%e,p=Kt(d,o,e)*d%e,g=Kt(p,i,e)*p%e,w=Kt(g,a,e)*g%e,y=Kt(w,c,e)*w%e,b=Kt(y,a,e)*g%e,m=Kt(b,r,e)*h%e,_=Kt(m,s,e)*p%e,E=Kt(_,n,e)*f%e,v=Kt(E,Ce,e);if(!He.eql(He.sqr(v),t))throw Error("Cannot find square root");return v}}),Ve=Ne(Le(De,{Fp:He,endo:Fe}),_t);class qe{constructor(t,e,r){this.data=t,this.recovery=e,this.compressed=r??!0}static from(t){if("string"==typeof t){const e=w(t);let r=parseInt(p(e.subarray(0,1)),16)-31,n=!0;r<0&&(n=!1,r+=4);const o=e.subarray(1);return new qe(o,r,n)}throw Error("Expected string for data")}toBuffer(){const t=new Uint8Array(65).fill(0);return t[0]=this.compressed?this.recovery+31&255:this.recovery+27&255,t.set(this.data,1),t}customToString(){return p(this.toBuffer())}getPublicKey(t){if(t instanceof Uint8Array&&32!==t.length||"string"==typeof t&&64!==t.length)throw Error("Expected a valid sha256 hash as message");"string"==typeof t&&(t=w(t));const e=Ve.Signature.fromBytes(this.data,"compact"),r=new Ve.Signature(e.r,e.s,this.recovery);return new je(r.recoverPublicKey(t).toBytes())}}const Pe=$.address_prefix;class je{constructor(t,e){this.key=t,this.prefix=e??Pe}static fromString(t){const{key:e,prefix:r}=Ze(t);return new je(e,r)}static from(t){return t instanceof je?t:je.fromString(t)}verify(t,e){return"string"==typeof e&&(e=qe.from(e)),Ve.verify(e.data,t,this.key,{prehash:!1,format:"compact"})}toString(){return ze(this.key,this.prefix)}toJSON(){return""+this}inspect(){return"PublicKey: "+this}}const ze=(t,e)=>{const r=Z(t);return e+M.encode(new Uint8Array([...t,...r.subarray(0,4)]))},Ze=t=>{const e=t.slice(0,3);t=t.slice(3);const r=M.decode(t);return{key:r.subarray(0,r.length-4),prefix:e}};class Me{constructor(t,e){this.amount=t,this.symbol="HIVE"===e?"STEEM":"HBD"===e?"SBD":e}static fromString(t,e=null){const[r,n]=t.split(" ");if(-1===["STEEM","VESTS","SBD","TESTS","TBD","HIVE","HBD"].indexOf(n))throw Error("Invalid asset symbol: "+n);if(e&&n!==e)throw Error(`Invalid asset, expected symbol: ${e} got: ${n}`);const o=Number.parseFloat(r);if(!Number.isFinite(o))throw Error("Invalid asset amount: "+r);return new Me(o,n)}static from(t,e){if(t instanceof Me){if(e&&t.symbol!==e)throw Error(`Invalid asset, expected symbol: ${e} got: ${t.symbol}`);return t}if("number"==typeof t&&Number.isFinite(t))return new Me(t,e||"STEEM");if("string"==typeof t)return Me.fromString(t,e);throw Error(`Invalid asset '${t+""}'`)}getPrecision(){switch(this.symbol){case"TESTS":case"TBD":case"STEEM":case"SBD":case"HBD":case"HIVE":default:return 3;case"VESTS":return 6}}toString(){return`${this.amount.toFixed(this.getPrecision())} ${this.symbol}`}toJSON(){return""+this}}class $e{static from(t){return t instanceof $e?t:t instanceof Uint8Array?new $e(t):new $e("string"==typeof t?w(t):new Uint8Array(t))}constructor(t){this.buffer=t}toString(){return p(this.buffer)}toJSON(){return""+this}}const Ke=()=>{throw Error("Void can not be serialized")},Ye=(t,e)=>{t.writeVString(e)},Ge=(t,e)=>{t.writeInt64(e)},We=(t,e)=>{t.writeUint8(e)},Xe=(t,e)=>{t.writeUint16(e)},Je=(t,e)=>{t.writeUint32(e)},Qe=(t,e)=>{t.writeUint64(e)},tr=(t,e)=>{t.writeByte(e?1:0)},er=t=>(e,r)=>{const[n,o]=r;e.writeVarint32(n),t[n](e,o)},rr=(t,e)=>{const r=Me.from(e),n=r.getPrecision();t.writeInt64(Math.round(r.amount*Math.pow(10,n))),t.writeUint8(n);for(let e=0;e<7;e++)t.writeUint8(r.symbol.charCodeAt(e)||0)},nr=(t,e)=>{t.writeUint32(Math.floor(new Date(e+"Z").getTime()/1e3))},or=(t,e)=>{null===e||"string"==typeof e&&"1111111111111111111111111111111114T1Anm"===e.slice(-39)?t.append(new Uint8Array(33).fill(0)):t.append(je.from(e).key)},ir=(t=null)=>(e,r)=>{const n=(r=$e.from(r)).buffer.length;if(t){if(n!==t)throw Error(`Unable to serialize binary. Expected ${t} bytes, got ${n}`)}else e.writeVarint32(n);e.append(r.buffer)},sr=ir(),ar=(t,e)=>(r,n)=>{r.writeVarint32(n.length);for(const[o,i]of n)t(r,o),e(r,i)},cr=t=>(e,r)=>{e.writeVarint32(r.length);for(const n of r)t(e,n)},fr=t=>(e,r)=>{for(const[n,o]of t)try{o(e,r[n])}catch(t){throw t.message=`${n}: ${t.message}`,t}},hr=t=>(e,r)=>{void 0!==r?(e.writeByte(1),t(e,r)):e.writeByte(0)},ur=fr([["weight_threshold",Je],["account_auths",ar(Ye,Xe)],["key_auths",ar(or,Xe)]]),lr=fr([["account",Ye],["weight",Xe]]),dr=fr([["base",rr],["quote",rr]]),pr=fr([["account_creation_fee",rr],["maximum_block_size",Je],["hbd_interest_rate",Xe]]),gr=(t,e)=>{const r=fr(e);return(e,n)=>{e.writeVarint32(t),r(e,n)}},wr={};wr.account_create=gr(9,[["fee",rr],["creator",Ye],["new_account_name",Ye],["owner",ur],["active",ur],["posting",ur],["memo_key",or],["json_metadata",Ye]]),wr.account_create_with_delegation=gr(41,[["fee",rr],["delegation",rr],["creator",Ye],["new_account_name",Ye],["owner",ur],["active",ur],["posting",ur],["memo_key",or],["json_metadata",Ye],["extensions",cr(Ke)]]),wr.account_update=gr(10,[["account",Ye],["owner",hr(ur)],["active",hr(ur)],["posting",hr(ur)],["memo_key",or],["json_metadata",Ye]]),wr.account_witness_proxy=gr(13,[["account",Ye],["proxy",Ye]]),wr.account_witness_vote=gr(12,[["account",Ye],["witness",Ye],["approve",tr]]),wr.cancel_transfer_from_savings=gr(34,[["from",Ye],["request_id",Je]]),wr.change_recovery_account=gr(26,[["account_to_recover",Ye],["new_recovery_account",Ye],["extensions",cr(Ke)]]),wr.claim_account=gr(22,[["creator",Ye],["fee",rr],["extensions",cr(Ke)]]),wr.claim_reward_balance=gr(39,[["account",Ye],["reward_hive",rr],["reward_hbd",rr],["reward_vests",rr]]),wr.comment=gr(1,[["parent_author",Ye],["parent_permlink",Ye],["author",Ye],["permlink",Ye],["title",Ye],["body",Ye],["json_metadata",Ye]]),wr.comment_options=gr(19,[["author",Ye],["permlink",Ye],["max_accepted_payout",rr],["percent_hbd",Xe],["allow_votes",tr],["allow_curation_rewards",tr],["extensions",cr(er([fr([["beneficiaries",cr(lr)]])]))]]),wr.convert=gr(8,[["owner",Ye],["requestid",Je],["amount",rr]]),wr.create_claimed_account=gr(23,[["creator",Ye],["new_account_name",Ye],["owner",ur],["active",ur],["posting",ur],["memo_key",or],["json_metadata",Ye],["extensions",cr(Ke)]]),wr.custom=gr(15,[["required_auths",cr(Ye)],["id",Xe],["data",sr]]),wr.custom_json=gr(18,[["required_auths",cr(Ye)],["required_posting_auths",cr(Ye)],["id",Ye],["json",Ye]]),wr.decline_voting_rights=gr(36,[["account",Ye],["decline",tr]]),wr.delegate_vesting_shares=gr(40,[["delegator",Ye],["delegatee",Ye],["vesting_shares",rr]]),wr.delete_comment=gr(17,[["author",Ye],["permlink",Ye]]),wr.escrow_approve=gr(31,[["from",Ye],["to",Ye],["agent",Ye],["who",Ye],["escrow_id",Je],["approve",tr]]),wr.escrow_dispute=gr(28,[["from",Ye],["to",Ye],["agent",Ye],["who",Ye],["escrow_id",Je]]),wr.escrow_release=gr(29,[["from",Ye],["to",Ye],["agent",Ye],["who",Ye],["receiver",Ye],["escrow_id",Je],["hbd_amount",rr],["hive_amount",rr]]),wr.escrow_transfer=gr(27,[["from",Ye],["to",Ye],["hbd_amount",rr],["hive_amount",rr],["escrow_id",Je],["agent",Ye],["fee",rr],["json_meta",Ye],["ratification_deadline",nr],["escrow_expiration",nr]]),wr.feed_publish=gr(7,[["publisher",Ye],["exchange_rate",dr]]),wr.limit_order_cancel=gr(6,[["owner",Ye],["orderid",Je]]),wr.limit_order_create=gr(5,[["owner",Ye],["orderid",Je],["amount_to_sell",rr],["min_to_receive",rr],["fill_or_kill",tr],["expiration",nr]]),wr.limit_order_create2=gr(21,[["owner",Ye],["orderid",Je],["amount_to_sell",rr],["exchange_rate",dr],["fill_or_kill",tr],["expiration",nr]]),wr.recover_account=gr(25,[["account_to_recover",Ye],["new_owner_authority",ur],["recent_owner_authority",ur],["extensions",cr(Ke)]]),wr.request_account_recovery=gr(24,[["recovery_account",Ye],["account_to_recover",Ye],["new_owner_authority",ur],["extensions",cr(Ke)]]),wr.reset_account=gr(37,[["reset_account",Ye],["account_to_reset",Ye],["new_owner_authority",ur]]),wr.set_reset_account=gr(38,[["account",Ye],["current_reset_account",Ye],["reset_account",Ye]]),wr.set_withdraw_vesting_route=gr(20,[["from_account",Ye],["to_account",Ye],["percent",Xe],["auto_vest",tr]]),wr.transfer=gr(2,[["from",Ye],["to",Ye],["amount",rr],["memo",Ye]]),wr.transfer_from_savings=gr(33,[["from",Ye],["request_id",Je],["to",Ye],["amount",rr],["memo",Ye]]),wr.transfer_to_savings=gr(32,[["from",Ye],["to",Ye],["amount",rr],["memo",Ye]]),wr.transfer_to_vesting=gr(3,[["from",Ye],["to",Ye],["amount",rr]]),wr.vote=gr(0,[["voter",Ye],["author",Ye],["permlink",Ye],["weight",(t,e)=>{t.writeInt16(e)}]]),wr.withdraw_vesting=gr(4,[["account",Ye],["vesting_shares",rr]]),wr.witness_update=gr(11,[["owner",Ye],["url",Ye],["block_signing_key",or],["props",pr],["fee",rr]]),wr.witness_set_properties=gr(42,[["owner",Ye],["props",ar(Ye,sr)],["extensions",cr(Ke)]]),wr.account_update2=gr(43,[["account",Ye],["owner",hr(ur)],["active",hr(ur)],["posting",hr(ur)],["memo_key",hr(or)],["json_metadata",Ye],["posting_json_metadata",Ye],["extensions",cr(Ke)]]),wr.create_proposal=gr(44,[["creator",Ye],["receiver",Ye],["start_date",nr],["end_date",nr],["daily_pay",rr],["subject",Ye],["permlink",Ye],["extensions",cr(Ke)]]),wr.update_proposal_votes=gr(45,[["voter",Ye],["proposal_ids",cr(Ge)],["approve",tr],["extensions",cr(Ke)]]),wr.remove_proposal=gr(46,[["proposal_owner",Ye],["proposal_ids",cr(Ge)],["extensions",cr(Ke)]]);const yr=fr([["end_date",nr]]);wr.update_proposal=gr(47,[["proposal_id",Qe],["creator",Ye],["daily_pay",rr],["subject",Ye],["permlink",Ye],["extensions",cr(er([Ke,yr]))]]),wr.collateralized_convert=gr(48,[["owner",Ye],["requestid",Je],["amount",rr]]),wr.recurrent_transfer=gr(49,[["from",Ye],["to",Ye],["amount",rr],["memo",Ye],["recurrence",Xe],["executions",Xe],["extensions",cr(fr([["type",We],["value",fr([["pair_id",We]])]]))]]);const br=fr([["ref_block_num",Xe],["ref_block_prefix",Je],["expiration",nr],["operations",cr((t,e)=>{const r=wr[e[0]];if(!r)throw Error("No serializer for operation: "+e[0]);try{r(t,e[1])}catch(t){throw t.message=`${e[0]}: ${t.message}`,t}})],["extensions",cr(Ye)]]),mr={Asset:rr,Memo:fr([["from",or],["to",or],["nonce",Qe],["check",Je],["encrypted",ir()]]),Price:dr,PublicKey:or,String:Ye,Transaction:br,UInt16:Xe,UInt32:Je},_r=t=>new Promise(e=>setTimeout(e,t));class Er extends Error{constructor(t){super(t.message),this.name="RPCError",this.stack=void 0,this.code=t.code,"data"in t&&(this.data=t.data)}}class vr extends Error{constructor(t,e,r=0){super(e),this.node=t,this.rateLimitMs=r}}const xr=["ECONNREFUSED","ENOTFOUND","EHOSTUNREACH","EAI_AGAIN"];function Ar(t){if(!t)return!1;const e=[(t.message||"")+"",(t.code||"")+""];let r=t.cause;for(let t=0;r&&t<5;t++)e.push((r.code||"")+"",(r.message||"")+""),r=r.cause;const n=e.join(" ");return xr.some(t=>n.includes(t))}class Br{constructor(){this.health=new Map}getOrCreate(t){let e=this.health.get(t);return e||(e={consecutiveFailures:0,lastFailureTime:0,rateLimitedUntil:0},this.health.set(t,e)),e}recordSuccess(t){this.getOrCreate(t).consecutiveFailures=0}recordFailure(t){const e=this.getOrCreate(t);e.consecutiveFailures++,e.lastFailureTime=Date.now()}recordRateLimit(t,e=1e4){const r=this.getOrCreate(t);r.rateLimitedUntil=Date.now()+e,r.consecutiveFailures++,r.lastFailureTime=Date.now()}isNodeHealthy(t){const e=this.health.get(t);return!(e&&(e.rateLimitedUntil>Date.now()||e.consecutiveFailures>=3&&Date.now()-e.lastFailureTime<3e4))}getOrderedNodes(t){const e=[],r=[];for(const n of t)this.isNodeHealthy(n)?e.push(n):r.push(n);return[...e,...r]}}const Ur=new Br,Ir=new Br;function Sr(t,e,r){r instanceof vr&&r.rateLimitMs>0?t.recordRateLimit(e,r.rateLimitMs):t.recordFailure(e)}const Or=async(t,e,r,n=$.timeout,o=!1)=>{const i=Math.floor(1e8*Math.random()),s={jsonrpc:"2.0",method:e,params:r,id:i};try{const e=await fetch(t,{method:"POST",body:JSON.stringify(s),headers:{"Content-Type":"application/json"},signal:AbortSignal.timeout(n)});if(429===e.status){const r=e.headers.get("Retry-After");throw new vr(t,"HTTP 429 Rate Limited",r?1e3*parseInt(r,10):1e4)}if(503===e.status)throw new vr(t,"HTTP 503 Service Unavailable");const r=await e.json();if(!r||void 0===r.id||r.id!==i||"2.0"!==r.jsonrpc)throw Error("JSONRPC id mismatch");if("result"in r)return r.result;if("error"in r){const t=r.error;if("message"in t&&"code"in t)throw new Er(t);throw r.error}throw r}catch(i){if(i instanceof Er)throw i;if(i instanceof vr)throw i;if(o)return Or(t,e,r,n,!1);throw i}};function kr(){return _r(50+50*Math.random())}const Lr=async(t,e=[],r=$.timeout,n=$.retry)=>{if(!Array.isArray($.nodes))throw Error("config.nodes is not an array");if(0===$.nodes.length)throw Error("config.nodes is empty");const o=new Set;let i;for(let s=0;s<=n;s++){const a=Ur.getOrderedNodes($.nodes);let c=a.find(t=>!o.has(t));c||(o.clear(),c=a[0]),o.add(c);try{const n=await Or(c,t,e,r);return Ur.recordSuccess(c),n}catch(t){if(t instanceof Er)throw t;Sr(Ur,c,t),i=t,s<n&&await kr()}}throw i},Tr=async(t,e=[],r=$.timeout)=>{if(!Array.isArray($.nodes))throw Error("config.nodes is not an array");if(0===$.nodes.length)throw Error("config.nodes is empty");const n=new Set;let o;for(let i=0;i<$.nodes.length;i++){const i=Ur.getOrderedNodes($.nodes).find(t=>!n.has(t));if(!i)break;n.add(i);try{const n=await Or(i,t,e,r);return Ur.recordSuccess(i),n}catch(t){if(t instanceof Er)throw t;if(Sr(Ur,i,t),o=t,!Ar(t))throw t}}throw o},Rr={balance:"/balance-api",hafah:"/hafah-api",hafbe:"/hafbe-api",hivemind:"/hivemind-api",hivesense:"/hivesense-api",reputation:"/reputation-api","nft-tracker":"/nft-tracker-api",hafsql:"/hafsql",status:"/status-api"};async function Nr(t,e,r,n=$.timeout,o=$.retry){if(!Array.isArray($.restNodes))throw Error("config.restNodes is not an array");if(0===$.restNodes.length)throw Error("config.restNodes is empty");const i=new Set;let s,a=!1;for(let c=0;c<=o;c++){const f=Ir.getOrderedNodes($.restNodes);let h=f.find(t=>!i.has(t));h||(i.clear(),h=f[0]),i.add(h);const u=h+Rr[t];let l=e;const d=r||{},p=new Set;Object.entries(d).forEach(([t,e])=>{l.includes(`{${t}}`)&&(l=l.replace(`{${t}}`,encodeURIComponent(e+"")),p.add(t))});const g=new URL(u+l);Object.entries(d).forEach(([t,e])=>{p.has(t)||(Array.isArray(e)?e.forEach(e=>g.searchParams.append(t,e+"")):g.searchParams.set(t,e+""))}),a=!1;try{const t=await fetch(""+g,{signal:AbortSignal.timeout(n)});if(404===t.status)throw Error("HTTP 404 - Hint: can happen on wrong params");if(429===t.status){const e=t.headers.get("Retry-After");throw Ir.recordRateLimit(h,e?1e3*parseInt(e,10):1e4),a=!0,Error("HTTP 429 Rate Limited by "+h)}if(503===t.status)throw Ir.recordFailure(h),a=!0,Error("HTTP 503 Service Unavailable from "+h);return Ir.recordSuccess(h),t.json()}catch(t){if(t?.message?.includes("HTTP 404"))throw t;a||Ir.recordFailure(h),s=t,c<o&&await kr()}}throw s}const Dr=async(t,e=[],r=2)=>{if(!Array.isArray($.nodes))throw Error("config.nodes is not an Array");if(r>$.nodes.length)throw Error("quorum > config.nodes.length");let n=(o=$.nodes,[...o].sort(()=>Math.random()-.5));var o;let i=Math.min(r,n.length),s=[];for(;i>0&&n.length>0;){const o=n.splice(0,i),a=[],c=[];for(let r=0;r<o.length;r++)a.push(Or(o[r],t,e,void 0,!0).then(t=>c.push(t)).catch(()=>{}));await Promise.all(a),s.push(...c);const f=Fr(s,r);if(f)return f;if(i=Math.min(r,n.length),0===i)throw Error("No more nodes available.")}throw Error("Couldn't reach quorum.")};function Fr(t,e){const r=new Map;for(const e of t){const t=JSON.stringify(e);r.has(t)||r.set(t,[]),r.get(t).push(e)}const n=Array.from(r.values()).find(t=>t.length>=e);return n?n[0]:null}const Cr=w($.chain_id);class Hr{constructor(t){this.expiration=6e4,this.createTransaction=async t=>{const e=await Lr("condenser_api.get_dynamic_global_properties",[]),r=w(e.head_block_id),n=+new Uint32Array(r.buffer,r.byteOffset+4,1)[0],o=new Date(Date.now()+t).toISOString().slice(0,-5);this.transaction={expiration:o,extensions:[],operations:[],ref_block_num:65535&e.head_block_number,ref_block_prefix:n,signatures:[]}},t?.transaction&&(t.transaction instanceof Hr?(this.transaction=t.transaction.transaction,this.expiration=t.transaction.expiration):this.transaction=t.transaction,this.txId=this.digest().txId),t?.expiration&&(this.expiration=t.expiration)}async addOperation(t,e){this.transaction||await this.createTransaction(this.expiration),this.transaction.operations.push([t,e])}sign(t){if(!this.transaction)throw Error("First create a transaction by .addOperation()");if(this.transaction){const{digest:e,txId:r}=this.digest();Array.isArray(t)||(t=[t]);for(const r of t){const t=r.sign(e);this.transaction.signatures.push(t.customToString())}return this.txId=r,this.transaction}throw Error("No transaction to sign")}async broadcast(t=!1){if(!this.transaction)throw Error("Attempted to broadcast an empty transaction. Add operations by .addOperation()");if(0===this.transaction.signatures.length)throw Error("Attempted to broadcast a transaction with no signatures. Sign using .sign(keys)");try{await Tr("condenser_api.broadcast_transaction",[this.transaction])}catch(t){if(!(t instanceof Er&&t.message.includes("Duplicate transaction check failed")))throw t}if(this.txId||(this.txId=this.digest().txId),!t)return{tx_id:this.txId,status:"unknown"};await _r(1e3);let e=await this.checkStatus(),r=1;for(;"within_irreversible_block"!==e?.status&&"expired_irreversible"!==e?.status&&"too_old"!==e?.status&&r<60;)await _r(1e3+300*r),e=await this.checkStatus(),r++;return{tx_id:this.txId,status:e?.status??"unknown"}}digest(){if(!this.transaction)throw Error("First create a transaction by .addOperation()");const t=new A(A.DEFAULT_CAPACITY,A.LITTLE_ENDIAN),e={...this.transaction};try{mr.Transaction(t,e)}catch(t){throw Error("Unable to serialize transaction: "+t)}t.flip();const r=new Uint8Array(t.toBuffer()),n=p(_t(r)).slice(0,40);return{digest:_t(new Uint8Array([...Cr,...r])),txId:n}}addSignature(t){if(!this.transaction)throw Error("First create a transaction by .create(operations)");if("string"!=typeof t)throw Error("Signature must be string");if(130!==t.length)throw Error("Signature must be 130 characters long");return this.transaction.signatures.push(t),this.transaction}async checkStatus(){return this.txId||(this.txId=this.digest().txId),Lr("transaction_status_api.find_transaction",{transaction_id:this.txId,expiration:this.transaction?.expiration})}}const Vr=new Uint8Array([128]);class qr{constructor(t){this.key=t;try{Ve.getPublicKey(t)}catch(t){throw Error("invalid private key")}}static from(t){return"string"==typeof t?qr.fromString(t):new qr(t)}static fromString(t){return new qr(zr(t).subarray(1))}static fromSeed(t){return"string"==typeof t&&(t=/^[0-9a-fA-F]+$/.test(t)?w(t):(new TextEncoder).encode(t)),new qr(_t(t))}static fromLogin(t,e,r="active"){return qr.fromSeed(t+r+e)}sign(t){const e=Ve.sign(t,this.key,{extraEntropy:!0,format:"recovered",prehash:!1}),r=parseInt(p(e.subarray(0,1)),16);return qe.from((r+31).toString(16)+p(e.subarray(1)))}createPublic(t){return new je(Ve.getPublicKey(this.key),t)}toString(){return jr(new Uint8Array([...Vr,...this.key]))}inspect(){const t=""+this;return`PrivateKey: ${t.slice(0,6)}...${t.slice(-6)}`}getSharedSecret(t){const e=Ve.getSharedSecret(this.key,t.key);return Et(e.subarray(1))}static randomKey(){return new qr(Ve.keygen().secretKey)}}const Pr=t=>_t(_t(t)),jr=t=>{const e=Pr(t);return M.encode(new Uint8Array([...t,...e.slice(0,4)]))},zr=t=>{const e=M.decode(t);if(!Zr(e.slice(0,1),Vr))throw Error("Private key network id mismatch");const r=e.slice(-4),n=e.slice(0,-4),o=Pr(n).slice(0,4);if(!Zr(r,o))throw Error("Private key checksum mismatch");return n},Zr=(t,e)=>{if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;const r=t.byteLength;let n=0;for(;n<r&&t[n]===e[n];)n++;return n===r};function Mr(t,e,r=""){const n=(o=t)instanceof Uint8Array||ArrayBuffer.isView(o)&&"Uint8Array"===o.constructor.name;var o;const i=t?.length,s=void 0!==e;if(!n||s&&i!==e)throw Error((r&&`"${r}" `)+"expected Uint8Array"+(s?" of length "+e:"")+", got "+(n?"length="+i:"type="+typeof t));return t}function $r(t,e=!0){if(t.destroyed)throw Error("Hash instance has been destroyed");if(e&&t.finished)throw Error("Hash#digest() has already been called")}function Kr(t,e){Mr(t,void 0,"output");const r=e.outputLen;if(t.length<r)throw Error("digestInto() expects output buffer of length at least "+r)}function Yr(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Gr(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}const Wr=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])();function Xr(t,e){if((r=t).buffer===(n=e).buffer&&r.byteOffset<n.byteOffset+n.byteLength&&n.byteOffset<r.byteOffset+r.byteLength&&t.byteOffset<e.byteOffset)throw Error("complex overlap of input and output is not supported");var r,n}const Jr=(t,e)=>{function r(r,...n){if(Mr(r,void 0,"key"),!Wr)throw Error("Non little-endian hardware is not yet supported");void 0!==t.nonceLength&&Mr(n[0],t.varSizeNonce?void 0:t.nonceLength,"nonce");const o=t.tagLength;o&&void 0!==n[1]&&Mr(n[1],void 0,"AAD");const i=e(r,...n),s=(t,e)=>{if(void 0!==e){if(2!==t)throw Error("cipher output not supported");Mr(e,void 0,"output")}};let a=!1;return{encrypt(t,e){if(a)throw Error("cannot encrypt() twice with same key + nonce");return a=!0,Mr(t),s(i.encrypt.length,e),i.encrypt(t,e)},decrypt(t,e){if(Mr(t),o&&t.length<o)throw Error('"ciphertext" expected length bigger than tagLength='+o);return s(i.decrypt.length,e),i.decrypt(t,e)}}}return Object.assign(r,t),r};function Qr(t,e,r=!0){if(void 0===e)return new Uint8Array(t);if(e.length!==t)throw Error('"output" expected Uint8Array of length '+t+", got: "+e.length);if(r&&!tn(e))throw Error("invalid output, must be aligned");return e}function tn(t){return t.byteOffset%4==0}function en(t){return Uint8Array.from(t)}const rn=16,nn=new Uint8Array(16),on=Yr(nn),sn=(t,e,r,n)=>({s3:r<<31|n>>>1,s2:e<<31|r>>>1,s1:t<<31|e>>>1,s0:t>>>1^225<<24&-(1&n)}),an=t=>(t>>>0&255)<<24|(t>>>8&255)<<16|(t>>>16&255)<<8|t>>>24&255;class cn{blockLen=rn;outputLen=rn;s0=0;s1=0;s2=0;s3=0;finished=!1;t;W;windowSize;constructor(t,e){Mr(t,16,"key");const r=(n=t=en(t),new DataView(n.buffer,n.byteOffset,n.byteLength));var n;let o=r.getUint32(0,!1),i=r.getUint32(4,!1),s=r.getUint32(8,!1),a=r.getUint32(12,!1);const c=[];for(let t=0;t<128;t++)c.push({s0:an(o),s1:an(i),s2:an(s),s3:an(a)}),({s0:o,s1:i,s2:s,s3:a}=sn(o,i,s,a));const f=(h=e||1024)>65536?8:h>1024?4:2;var h;if(![1,2,4,8].includes(f))throw Error("ghash: invalid window size, expected 2, 4 or 8");this.W=f;const u=128/f,l=this.windowSize=2**f,d=[];for(let t=0;t<u;t++)for(let e=0;e<l;e++){let r=0,n=0,o=0,i=0;for(let s=0;s<f;s++){if(!(e>>>f-s-1&1))continue;const{s0:a,s1:h,s2:u,s3:l}=c[f*t+s];r^=a,n^=h,o^=u,i^=l}d.push({s0:r,s1:n,s2:o,s3:i})}this.t=d}_updateBlock(t,e,r,n){t^=this.s0,e^=this.s1,r^=this.s2,n^=this.s3;const{W:o,t:i,windowSize:s}=this;let a=0,c=0,f=0,h=0;const u=(1<<o)-1;let l=0;for(const d of[t,e,r,n])for(let t=0;t<4;t++){const e=d>>>8*t&255;for(let t=8/o-1;t>=0;t--){const r=e>>>o*t&u,{s0:n,s1:d,s2:p,s3:g}=i[l*s+r];a^=n,c^=d,f^=p,h^=g,l+=1}}this.s0=a,this.s1=c,this.s2=f,this.s3=h}update(t){$r(this),Mr(t);const e=Yr(t=en(t)),r=Math.floor(t.length/rn),n=t.length%rn;for(let t=0;t<r;t++)this._updateBlock(e[4*t+0],e[4*t+1],e[4*t+2],e[4*t+3]);return n&&(nn.set(t.subarray(r*rn)),this._updateBlock(on[0],on[1],on[2],on[3]),Gr(on)),this}destroy(){const{t}=this;for(const e of t)e.s0=0,e.s1=0,e.s2=0,e.s3=0}digestInto(t){$r(this),Kr(t,this),this.finished=!0;const{s0:e,s1:r,s2:n,s3:o}=this,i=Yr(t);return i[0]=e,i[1]=r,i[2]=n,i[3]=o,t}digest(){const t=new Uint8Array(rn);return this.digestInto(t),this.destroy(),t}}class fn extends cn{constructor(t,e){Mr(t);const r=function(t){t.reverse();const e=1&t[15];let r=0;for(let e=0;e<t.length;e++){const n=t[e];t[e]=n>>>1|r,r=(1&n)<<7}return t[0]^=225&-e,t}(en(t));super(r,e),Gr(r)}update(t){$r(this),Mr(t);const e=Yr(t=en(t)),r=t.length%rn,n=Math.floor(t.length/rn);for(let t=0;t<n;t++)this._updateBlock(an(e[4*t+3]),an(e[4*t+2]),an(e[4*t+1]),an(e[4*t+0]));return r&&(nn.set(t.subarray(n*rn)),this._updateBlock(an(on[3]),an(on[2]),an(on[1]),an(on[0])),Gr(on)),this}digestInto(t){$r(this),Kr(t,this),this.finished=!0;const{s0:e,s1:r,s2:n,s3:o}=this,i=Yr(t);return i[0]=e,i[1]=r,i[2]=n,i[3]=o,t.reverse()}}function hn(t){const e=(e,r)=>t(r,e.length).update(e).digest(),r=t(new Uint8Array(16),0);return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=(e,r)=>t(e,r),e}hn((t,e)=>new cn(t,e)),hn((t,e)=>new fn(t,e));const un=16;function ln(t){return t<<1^283&-(t>>7)}function dn(t,e){let r=0;for(;e>0;e>>=1)r^=t&-(1&e),t=ln(t);return r}const pn=(()=>{const t=new Uint8Array(256);for(let e=0,r=1;e<256;e++,r^=ln(r))t[e]=r;const e=new Uint8Array(256);e[0]=99;for(let r=0;r<255;r++){let n=t[255-r];n|=n<<8,e[t[r]]=255&(n^n>>4^n>>5^n>>6^n>>7^99)}return Gr(t),e})(),gn=pn.map((t,e)=>pn.indexOf(e)),wn=t=>t<<24|t>>>8,yn=t=>t<<8|t>>>24;function bn(t,e){if(256!==t.length)throw Error("Wrong sbox length");const r=new Uint32Array(256).map((r,n)=>e(t[n])),n=r.map(yn),o=n.map(yn),i=o.map(yn),s=new Uint32Array(65536),a=new Uint32Array(65536),c=new Uint16Array(65536);for(let e=0;e<256;e++)for(let f=0;f<256;f++){const h=256*e+f;s[h]=r[e]^n[f],a[h]=o[e]^i[f],c[h]=t[e]<<8|t[f]}return{sbox:t,sbox2:c,T0:r,T1:n,T2:o,T3:i,T01:s,T23:a}}const mn=bn(pn,t=>dn(t,3)<<24|t<<16|t<<8|dn(t,2)),_n=bn(gn,t=>dn(t,11)<<24|dn(t,13)<<16|dn(t,9)<<8|dn(t,14)),En=(()=>{const t=new Uint8Array(16);for(let e=0,r=1;e<16;e++,r=ln(r))t[e]=r;return t})();function vn(t){Mr(t);const e=t.length;!function(t){if(![16,24,32].includes(t.length))throw Error('"aes key" expected Uint8Array of length 16/24/32, got length='+t.length)}(t);const{sbox2:r}=mn,n=[];tn(t)||n.push(t=en(t));const o=Yr(t),i=o.length,s=t=>An(r,t,t,t,t),a=new Uint32Array(e+28);a.set(o);for(let t=i;t<a.length;t++){let e=a[t-1];t%i===0?e=s(wn(e))^En[t/i-1]:i>6&&t%i===4&&(e=s(e)),a[t]=a[t-i]^e}return Gr(...n),a}function xn(t,e,r,n,o,i){return t[r<<8&65280|n>>>8&255]^e[o>>>8&65280|i>>>24&255]}function An(t,e,r,n,o){return t[255&e|65280&r]|t[n>>>16&255|o>>>16&65280]<<16}function Bn(t,e,r,n,o){const{sbox2:i,T01:s,T23:a}=mn;let c=0;e^=t[c++],r^=t[c++],n^=t[c++],o^=t[c++];const f=t.length/4-2;for(let i=0;i<f;i++){const i=t[c++]^xn(s,a,e,r,n,o),f=t[c++]^xn(s,a,r,n,o,e),h=t[c++]^xn(s,a,n,o,e,r),u=t[c++]^xn(s,a,o,e,r,n);e=i,r=f,n=h,o=u}return{s0:t[c++]^An(i,e,r,n,o),s1:t[c++]^An(i,r,n,o,e),s2:t[c++]^An(i,n,o,e,r),s3:t[c++]^An(i,o,e,r,n)}}function Un(t,e,r,n,o){const{sbox2:i,T01:s,T23:a}=_n;let c=0;e^=t[c++],r^=t[c++],n^=t[c++],o^=t[c++];const f=t.length/4-2;for(let i=0;i<f;i++){const i=t[c++]^xn(s,a,e,o,n,r),f=t[c++]^xn(s,a,r,e,o,n),h=t[c++]^xn(s,a,n,r,e,o),u=t[c++]^xn(s,a,o,n,r,e);e=i,r=f,n=h,o=u}return{s0:t[c++]^An(i,e,o,n,r),s1:t[c++]^An(i,r,e,o,n),s2:t[c++]^An(i,n,r,e,o),s3:t[c++]^An(i,o,n,r,e)}}const In=Jr({blockSize:16,nonceLength:16},function(t,e,r={}){const n=!r.disablePadding;return{encrypt(r,o){const i=vn(t),{b:s,o:a,out:c}=function(t,e,r){Mr(t);let n=t.length;const o=n%un;if(!e&&0!==o)throw Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");tn(t)||(t=en(t));const i=Yr(t);if(e){let t=un-o;t||(t=un),n+=t}return Xr(t,r=Qr(n,r)),{b:i,o:Yr(r),out:r}}(r,n,o);let f=e;const h=[i];tn(f)||h.push(f=en(f));const u=Yr(f);let l=u[0],d=u[1],p=u[2],g=u[3],w=0;for(;w+4<=s.length;)l^=s[w+0],d^=s[w+1],p^=s[w+2],g^=s[w+3],({s0:l,s1:d,s2:p,s3:g}=Bn(i,l,d,p,g)),a[w++]=l,a[w++]=d,a[w++]=p,a[w++]=g;if(n){const t=function(t){const e=new Uint8Array(16),r=Yr(e);e.set(t);const n=un-t.length;for(let t=un-n;t<un;t++)e[t]=n;return r}(r.subarray(4*w));l^=t[0],d^=t[1],p^=t[2],g^=t[3],({s0:l,s1:d,s2:p,s3:g}=Bn(i,l,d,p,g)),a[w++]=l,a[w++]=d,a[w++]=p,a[w++]=g}return Gr(...h),c},decrypt(r,o){!function(t){if(Mr(t),t.length%un!==0)throw Error("aes-(cbc/ecb).decrypt ciphertext should consist of blocks with size 16")}(r);const i=function(t){const e=vn(t),r=e.slice(),n=e.length,{sbox2:o}=mn,{T0:i,T1:s,T2:a,T3:c}=_n;for(let t=0;t<n;t+=4)for(let o=0;o<4;o++)r[t+o]=e[n-t-4+o];Gr(e);for(let t=4;t<n-4;t++){const e=r[t],n=An(o,e,e,e,e);r[t]=i[255&n]^s[n>>>8&255]^a[n>>>16&255]^c[n>>>24]}return r}(t);let s=e;const a=[i];tn(s)||a.push(s=en(s));const c=Yr(s);o=Qr(r.length,o),tn(r)||a.push(r=en(r)),Xr(r,o);const f=Yr(r),h=Yr(o);let u=c[0],l=c[1],d=c[2],p=c[3];for(let t=0;t+4<=f.length;){const e=u,r=l,n=d,o=p;u=f[t+0],l=f[t+1],d=f[t+2],p=f[t+3];const{s0:s,s1:a,s2:c,s3:g}=Un(i,u,l,d,p);h[t++]=s^e,h[t++]=a^r,h[t++]=c^n,h[t++]=g^o}return Gr(...a),function(t,e){if(!e)return t;const r=t.length;if(!r)throw Error("aes/pcks5: empty ciphertext not allowed");const n=t[r-1];if(n<=0||n>16)throw Error("aes/pcks5: wrong padding");const o=t.subarray(0,-n);for(let e=0;e<n;e++)if(t[r-e-1]!==n)throw Error("aes/pcks5: wrong padding");return o}(o,n)}}}),Sn=(t,e,r,n,o)=>{const i="bigint"==typeof r?r:BigInt(r),s=t.getSharedSecret(e);let a=new A(A.DEFAULT_CAPACITY,A.LITTLE_ENDIAN);a.writeUint64(i),a.append(s),a.flip();const c=Et(new Uint8Array(a.toBuffer())),f=c.subarray(32,48),h=c.subarray(0,32),u=_t(c).subarray(0,4),l=new A(A.DEFAULT_CAPACITY,A.LITTLE_ENDIAN);l.append(u),l.flip();const d=l.readUint32();if(o){if(d!==o)throw Error("Invalid key");n=On(n,h,f)}else n=kn(n,h,f);return{nonce:i,message:n,checksum:d}},On=(t,e,r)=>{let n=t;return n=In(e,r).decrypt(n),n},kn=(t,e,r)=>{let n=t;return n=In(e,r).encrypt(n),n};let Ln=null;const Tn=t=>{const e=function(t){if(t){const e=t.copy(t.offset,t.offset+33);return t.skip(33),new Uint8Array(e.toBuffer())}throw Error("No buffer found on first parameter")}(t);return new je(e)};var Rn;const Nn={Memo:(Rn=[["from",Tn],["to",Tn],["nonce",t=>t.readUint64()],["check",t=>t.readUint32()],["encrypted",t=>{const e=t.readVarint32(),r=t.copy(t.offset,t.offset+e);return t.skip(e),new Uint8Array(r.toBuffer())}]],t=>{const e={},r=new A(A.DEFAULT_CAPACITY,A.LITTLE_ENDIAN);r.append(t),r.flip();for(const[t,n]of Rn)try{e[t]=n(r)}catch(e){throw e.message=`${t}: ${e.message}`,e}return e})},Dn=(t,e,r,n)=>{if(!r.startsWith("#"))return r;r=r.substring(1),Hn(),t=Vn(t),e=qn(e);const o=new A(A.DEFAULT_CAPACITY,A.LITTLE_ENDIAN);o.writeVString(r);const i=new Uint8Array(o.copy(0,o.offset).toBuffer()),{nonce:s,message:a,checksum:c}=((t,e,r,n=(()=>{if(null===Ln){const t=Ve.utils.randomSecretKey();Ln=Math.round(t[0]<<8|t[1])}let t=BigInt(Date.now());const e=++Ln%65535;return t=t<<BigInt(16)|BigInt(e),t})())=>Sn(t,e,n,r))(t,e,i,n),f=new A(A.DEFAULT_CAPACITY,A.LITTLE_ENDIAN);mr.Memo(f,{check:c,encrypted:a,from:t.createPublic(),nonce:s,to:e}),f.flip();const h=new Uint8Array(f.toBuffer());return"#"+M.encode(h)},Fn=(t,e)=>{if(!e.startsWith("#"))return e;e=e.substring(1),Hn(),t=Vn(t);let r=Nn.Memo(M.decode(e));const{from:n,to:o,nonce:i,check:s,encrypted:a}=r,c=""+t.createPublic();r=((t,e,r,n,o)=>Sn(t,e,r,n,o).message)(t,c===""+new je(n.key)?new je(o.key):new je(n.key),i,a,s);const f=new A(A.DEFAULT_CAPACITY,A.LITTLE_ENDIAN);return f.append(r),f.flip(),"#"+f.readVString()};let Cn;const Hn=()=>{if(void 0===Cn){let t;Cn=!0;try{const e="5JdeC9P7Pbd1uGdFVEsJ41EkEnADbbHGq6p1BwFxm6txNBsQnsw",r=Dn(e,"STM8m5UgaFAAYQRuaNejYdS8FVLVp9Ss3K1qAVk5de6F8s3HnVbvA","#memo爱");t=Fn(e,r)}finally{Cn="#memo爱"===t}}if(!1===Cn)throw Error("This environment does not support encryption.")},Vn=t=>"string"==typeof t?qr.fromString(t):t,qn=t=>"string"==typeof t?je.fromString(t):t,Pn={decode:Fn,encode:Dn},jn=t=>{let e="Account name should ";if(!t)return e+"not be empty.";const r=t.length;if(r<3)return e+"be longer.";if(r>16)return e+"be shorter.";/\./.test(t)&&(e="Each account segment should ");const n=t.split("."),o=n.length;for(let t=0;t<o;t++){const r=n[t];if(!/^[a-z]/.test(r))return e+"start with a lowercase letter.";if(!/^[a-z0-9-]*$/.test(r))return e+"have only lowercase letters, digits, or dashes.";if(!/[a-z0-9]$/.test(r))return e+"end with a lowercase letter or digit.";if(!(r.length>=3))return e+"be longer"}return null},zn={vote:0,comment:1,transfer:2,transfer_to_vesting:3,withdraw_vesting:4,limit_order_create:5,limit_order_cancel:6,feed_publish:7,convert:8,account_create:9,account_update:10,witness_update:11,account_witness_vote:12,account_witness_proxy:13,pow:14,custom:15,report_over_production:16,delete_comment:17,custom_json:18,comment_options:19,set_withdraw_vesting_route:20,limit_order_create2:21,claim_account:22,create_claimed_account:23,request_account_recovery:24,recover_account:25,change_recovery_account:26,escrow_transfer:27,escrow_dispute:28,escrow_release:29,pow2:30,escrow_approve:31,transfer_to_savings:32,transfer_from_savings:33,cancel_transfer_from_savings:34,custom_binary:35,decline_voting_rights:36,reset_account:37,set_reset_account:38,claim_reward_balance:39,delegate_vesting_shares:40,account_create_with_delegation:41,witness_set_properties:42,account_update2:43,create_proposal:44,update_proposal_votes:45,remove_proposal:46,update_proposal:47,collateralized_convert:48,recurrent_transfer:49,fill_convert_request:50,author_reward:51,curation_reward:52,comment_reward:53,liquidity_reward:54,interest:55,fill_vesting_withdraw:56,fill_order:57,shutdown_witness:58,fill_transfer_from_savings:59,hardfork:60,comment_payout_update:61,return_vesting_delegation:62,comment_benefactor_reward:63,producer_reward:64,clear_null_account_balance:65,proposal_pay:66,sps_fund:67,hardfork_hive:68,hardfork_hive_restore:69,delayed_voting:70,consolidate_treasury_balance:71,effective_comment_vote:72,ineffective_delete_comment:73,sps_convert:74,expired_account_notification:75,changed_recovery_account:76,transfer_to_vesting_completed:77,pow_reward:78,vesting_shares_split:79,account_created:80,fill_collateralized_convert_request:81,system_warning:82,fill_recurrent_transfer:83,failed_recurrent_transfer:84,limit_order_cancelled:85,producer_missed:86,proposal_fee:87,collateralized_convert_immediate_conversion:88,escrow_approved:89,escrow_rejected:90,proxy_cleared:91,declined_voting_rights:92},Zn=t=>t.reduce(Mn,[BigInt(0),BigInt(0)]).map(t=>t!==BigInt(0)?""+t:null),Mn=([t,e],r)=>r<64?[t|BigInt(1)<<BigInt(r),e]:[t,e|BigInt(1)<<BigInt(r-64)],$n=(t,e)=>{const r={extensions:[],owner:t,props:[]};for(const t of Object.keys(e)){let n;switch(t){case"key":case"new_signing_key":n=mr.PublicKey;break;case"account_subsidy_budget":case"account_subsidy_decay":case"maximum_block_size":n=mr.UInt32;break;case"hbd_interest_rate":n=mr.UInt16;break;case"url":n=mr.String;break;case"hbd_exchange_rate":n=mr.Price;break;case"account_creation_fee":n=mr.Asset;break;default:throw Error("Unknown witness prop: "+t)}r.props.push([t,Kn(n,e[t])])}return r.props.sort((t,e)=>t[0].localeCompare(e[0])),["witness_set_properties",r]},Kn=(t,e)=>{const r=new A(A.DEFAULT_CAPACITY,A.LITTLE_ENDIAN);return t(r,e),r.flip(),p(new Uint8Array(r.toBuffer()))};return e})());
3
+ //# sourceMappingURL=hive-tx.min.js.map
@@ -0,0 +1,5 @@
1
+ /*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */
2
+
3
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
4
+
5
+ /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */