verus-rpc 0.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 (75) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +139 -0
  3. package/dist/amount.d.ts +32 -0
  4. package/dist/amount.d.ts.map +1 -0
  5. package/dist/amount.js +65 -0
  6. package/dist/amount.js.map +1 -0
  7. package/dist/client.d.ts +60 -0
  8. package/dist/client.d.ts.map +1 -0
  9. package/dist/client.js +61 -0
  10. package/dist/client.js.map +1 -0
  11. package/dist/errors.d.ts +81 -0
  12. package/dist/errors.d.ts.map +1 -0
  13. package/dist/errors.js +107 -0
  14. package/dist/errors.js.map +1 -0
  15. package/dist/index.d.ts +16 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +21 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/lossless.d.ts +32 -0
  20. package/dist/lossless.d.ts.map +1 -0
  21. package/dist/lossless.js +64 -0
  22. package/dist/lossless.js.map +1 -0
  23. package/dist/mapping.d.ts +41 -0
  24. package/dist/mapping.d.ts.map +1 -0
  25. package/dist/mapping.js +139 -0
  26. package/dist/mapping.js.map +1 -0
  27. package/dist/methods/addressindex.d.ts +69 -0
  28. package/dist/methods/addressindex.d.ts.map +1 -0
  29. package/dist/methods/addressindex.js +97 -0
  30. package/dist/methods/addressindex.js.map +1 -0
  31. package/dist/methods/blockchain.d.ts +99 -0
  32. package/dist/methods/blockchain.d.ts.map +1 -0
  33. package/dist/methods/blockchain.js +141 -0
  34. package/dist/methods/blockchain.js.map +1 -0
  35. package/dist/methods/chain.d.ts +39 -0
  36. package/dist/methods/chain.d.ts.map +1 -0
  37. package/dist/methods/chain.js +44 -0
  38. package/dist/methods/chain.js.map +1 -0
  39. package/dist/methods/currency.d.ts +210 -0
  40. package/dist/methods/currency.d.ts.map +1 -0
  41. package/dist/methods/currency.js +303 -0
  42. package/dist/methods/currency.js.map +1 -0
  43. package/dist/methods/identity.d.ts +284 -0
  44. package/dist/methods/identity.d.ts.map +1 -0
  45. package/dist/methods/identity.js +333 -0
  46. package/dist/methods/identity.js.map +1 -0
  47. package/dist/methods/shielded.d.ts +136 -0
  48. package/dist/methods/shielded.d.ts.map +1 -0
  49. package/dist/methods/shielded.js +175 -0
  50. package/dist/methods/shielded.js.map +1 -0
  51. package/dist/methods/t2.d.ts +8 -0
  52. package/dist/methods/t2.d.ts.map +1 -0
  53. package/dist/methods/t2.js +10 -0
  54. package/dist/methods/t2.js.map +1 -0
  55. package/dist/methods/wallet-types.d.ts +143 -0
  56. package/dist/methods/wallet-types.d.ts.map +1 -0
  57. package/dist/methods/wallet-types.js +6 -0
  58. package/dist/methods/wallet-types.js.map +1 -0
  59. package/dist/methods/wallet.d.ts +206 -0
  60. package/dist/methods/wallet.d.ts.map +1 -0
  61. package/dist/methods/wallet.js +455 -0
  62. package/dist/methods/wallet.js.map +1 -0
  63. package/dist/mock.d.ts +28 -0
  64. package/dist/mock.d.ts.map +1 -0
  65. package/dist/mock.js +61 -0
  66. package/dist/mock.js.map +1 -0
  67. package/dist/resilience.d.ts +20 -0
  68. package/dist/resilience.d.ts.map +1 -0
  69. package/dist/resilience.js +32 -0
  70. package/dist/resilience.js.map +1 -0
  71. package/dist/transport.d.ts +38 -0
  72. package/dist/transport.d.ts.map +1 -0
  73. package/dist/transport.js +79 -0
  74. package/dist/transport.js.map +1 -0
  75. package/package.json +59 -0
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,139 @@
1
+ # verus-rpc
2
+
3
+ The npm-published, full-coverage, precision-honest TypeScript client for
4
+ talking to your own `verusd` — daemon-first JSON-RPC transport and types.
5
+
6
+ ```bash
7
+ npm install verus-rpc # or: pnpm add verus-rpc
8
+ ```
9
+
10
+ ```ts
11
+ import { VerusClient, formatAmount } from "verus-rpc";
12
+
13
+ // Read-only against the public mainnet RPC — no daemon, no credentials.
14
+ const client = new VerusClient({
15
+ url: "https://api.verus.services",
16
+ user: "public",
17
+ pass: "public",
18
+ });
19
+
20
+ const id = await client.identity.getIdentity({ nameOrAddress: "Verus Coin Foundation@" });
21
+ console.log(id.identity.identityaddress);
22
+
23
+ const balance = await client.wallet.getBalance(); // 200_000_000n (bigint sats)
24
+ console.log(formatAmount(balance)); // "2.00000000"
25
+ ```
26
+
27
+ ## The one invariant
28
+
29
+ **No float ever crosses the public API for a value field.**
30
+
31
+ The daemon emits amounts as JSON decimal numbers (`{"VRSCTEST":2.00000000}`,
32
+ and on mainnet even `relayfee:1e-6`). A client that runs those through
33
+ `JSON.parse` puts float64 in its money path. `verus-rpc` parses the response
34
+ body losslessly and maps every value field to an exact type:
35
+
36
+ - **Curated methods** → `bigint` satoshis (Verus = 8 decimals). Helpers:
37
+ `parseAmount("2.00000000") === 200_000_000n`, `formatAmount(200_000_000n) === "2.00000000"`.
38
+ - **Typed methods** → exact decimal `string`.
39
+ - **`call()` escape hatch** → safe integers become `number`, everything else
40
+ an exact decimal `string`; opt into raw float64 with `{ numbers: "js" }`.
41
+
42
+ Heights, counts and timestamps stay `number`. Unknown fields a newer daemon
43
+ adds are passed through (safe integer → `number`, otherwise exact string) —
44
+ never stripped, never rounded.
45
+
46
+ ## What this is (and isn't)
47
+
48
+ Deliberately complementary to the official VerusCoin TypeScript stack. This
49
+ library is the **daemon-first RPC transport + types** — the layer VerusCoin
50
+ doesn't ship on npm. It does **not** do client-side signing, login consent,
51
+ VerusPay invoices, or transaction construction — that is
52
+ [`verusid-ts-client`](https://github.com/VerusCoin/verusid-ts-client) and the
53
+ BitGo `utxo-lib-verus` fork. Link to them; don't reimplement them.
54
+
55
+ | Lane | Library |
56
+ |---|---|
57
+ | Talk to your own `verusd` (this) | **`verus-rpc`** |
58
+ | VerusID signing / login / VerusPay | `verusid-ts-client` |
59
+ | Transaction building | `@bitgo/utxo-lib` (Verus fork) |
60
+ | ZMQ block/tx events | `verus-zmq-client` |
61
+
62
+ ## Coverage tiers
63
+
64
+ A tier is a promise about **testing**, not just typing.
65
+
66
+ | Tier | Contract | Families |
67
+ |---|---|---|
68
+ | **T1 — curated** | Named-options params, curated response types, value fields as `bigint` sats, recorded-fixture conformance test per method | Chain reads, wallet + sends, identity (read + lifecycle), currency/conversion reads, addressindex, `getvdxfid` |
69
+ | **T2 — typed** | Typed params/results, value fields as exact decimal strings | Shielded (`z_*`), marketplace, raw-transaction chain, network/util reads, identity signatures/trust |
70
+ | **T3 — escape hatch** | `client.call(method, params)` — untyped, always available | everything else — mining/staking, notarization internals, `definecurrency` depth |
71
+
72
+ Promotion T3→T2→T1 is demand-driven. `call()` means the client never blocks
73
+ you on missing coverage.
74
+
75
+ ## Client namespaces
76
+
77
+ ```ts
78
+ client.chain // getInfo, getBlockCount
79
+ client.blockchain // blocks, raw-tx chain, network/util reads, getVdxfId
80
+ client.wallet // balances, transactions, sends, sendCurrencyAndWait, keys
81
+ client.shielded // z_* family + z-operation polling helpers
82
+ client.identity // reads, lifecycle, registerIdentityFlow
83
+ client.currency // getCurrency, listCurrencies, estimateConversion, marketplace
84
+ client.addressIndex // getAddressBalance/Utxos/Deltas (arbitrary addresses)
85
+ client.call(method, params, { numbers }) // anything else
86
+ ```
87
+
88
+ ### High-level helpers
89
+
90
+ - `wallet.sendCurrencyAndWait(...)` — `sendcurrency` returns an operation id;
91
+ this polls `z_getoperationstatus` to success/failure and resolves with the
92
+ txid (or throws `OperationFailedError` / `OperationTimeoutError`).
93
+ - `identity.registerIdentityFlow(...)` — `registernamecommitment` →
94
+ wait-for-confirmation → `registeridentity` as one guided call.
95
+ - `shielded.zSendManyAndWait(...)` — the same opid pattern for `z_sendmany`.
96
+
97
+ ## Resilience (opt-in)
98
+
99
+ This is a library — you own your retry/breaker posture. A circuit breaker +
100
+ per-attempt timeout are available and **off by default**; application errors
101
+ never trip the breaker.
102
+
103
+ ```ts
104
+ new VerusClient({ url, user, pass, resilience: { timeoutMs: 5000, breaker: { failuresBeforeOpen: 5 } } });
105
+ ```
106
+
107
+ ## Errors
108
+
109
+ - `VerusRpcError(method, code, message)` — the daemon answered with an error.
110
+ Branch on `error.code` via the `RpcErrorCode` enum (no message string-matching).
111
+ - `TransportError(reason, message)` — network / timeout / bad-response / circuit-open.
112
+ - `ResponseMappingError` — a curated response didn't match the mapper (daemon
113
+ drift); the raw value is still reachable via `call()`.
114
+
115
+ ## Testing
116
+
117
+ Three rings (see `test/`):
118
+
119
+ 1. **Unit** — `MockTransport` (exported for your tests too); every method's
120
+ param marshalling, error paths, amount edge cases.
121
+ 2. **Fixture conformance** — responses recorded from a real daemon
122
+ (`fixtures/`), curated mappers validated **offline**. This is the
123
+ type-honesty check.
124
+ 3. **Gated integration** — set `VERUS_RPC_URL` to run read-only against your
125
+ node; `VERUS_RPC_MAINNET_SMOKE=1` runs a read-only smoke against
126
+ api.verus.services.
127
+
128
+ Examples in `examples/` are executed as-is (guarded in the test suite) — the
129
+ code you read is the code that runs.
130
+
131
+ ## Compatibility
132
+
133
+ - Node ≥ 22. Isomorphic-clean core (no `Buffer`/`fs` in the client path).
134
+ - Types are curated against **daemon v1.2.17**; `getInfo().VRSCversion` lets
135
+ you check at runtime. Unknown response fields pass through.
136
+
137
+ ## License
138
+
139
+ Apache-2.0
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Exact amount handling — the library's core invariant is that no float ever
3
+ * crosses the public API for a value field. Curated (T1) methods surface
4
+ * amounts as `bigint` satoshis; these helpers convert between that and the
5
+ * daemon's 8-decimal notation.
6
+ */
7
+ /** Verus amounts have 8 decimal places: 1 VRSC = 100_000_000 satoshis. */
8
+ export declare const SATS_PER_COIN = 100000000n;
9
+ export interface ParseAmountOptions {
10
+ /**
11
+ * Accept negative amounts. Off by default — most value fields are
12
+ * non-negative; signed fields (e.g. `gettransaction.amount`) opt in.
13
+ */
14
+ allowNegative?: boolean;
15
+ }
16
+ /**
17
+ * Parse an exact decimal amount string into bigint satoshis.
18
+ *
19
+ * `parseAmount("2.00000000") === 200_000_000n`
20
+ *
21
+ * Throws `RangeError` on anything that is not an exact amount: malformed
22
+ * input, more than 8 decimal places of significance, or (by default)
23
+ * negative values.
24
+ */
25
+ export declare function parseAmount(value: string, options?: ParseAmountOptions): bigint;
26
+ /**
27
+ * Format bigint satoshis as the daemon's 8-decimal notation.
28
+ *
29
+ * `formatAmount(200_000_000n) === "2.00000000"`
30
+ */
31
+ export declare function formatAmount(sats: bigint): string;
32
+ //# sourceMappingURL=amount.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"amount.d.ts","sourceRoot":"","sources":["../src/amount.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,0EAA0E;AAC1E,eAAO,MAAM,aAAa,aAAe,CAAC;AAO1C,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,MAAM,CA+B/E;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMjD"}
package/dist/amount.js ADDED
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Exact amount handling — the library's core invariant is that no float ever
3
+ * crosses the public API for a value field. Curated (T1) methods surface
4
+ * amounts as `bigint` satoshis; these helpers convert between that and the
5
+ * daemon's 8-decimal notation.
6
+ */
7
+ /** Verus amounts have 8 decimal places: 1 VRSC = 100_000_000 satoshis. */
8
+ export const SATS_PER_COIN = 100000000n;
9
+ const AMOUNT_DECIMALS = 8;
10
+ // Full JSON number grammar plus an optional leading "+" for human input.
11
+ const DECIMAL_RE = /^([+-]?)(\d+)(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/;
12
+ /**
13
+ * Parse an exact decimal amount string into bigint satoshis.
14
+ *
15
+ * `parseAmount("2.00000000") === 200_000_000n`
16
+ *
17
+ * Throws `RangeError` on anything that is not an exact amount: malformed
18
+ * input, more than 8 decimal places of significance, or (by default)
19
+ * negative values.
20
+ */
21
+ export function parseAmount(value, options) {
22
+ const match = DECIMAL_RE.exec(value);
23
+ if (match === null) {
24
+ throw new RangeError(`not a decimal amount: ${JSON.stringify(value)}`);
25
+ }
26
+ const [, sign = "", intPart = "", fracPart = "", expPart] = match;
27
+ const exponent = expPart === undefined ? 0 : Number(expPart);
28
+ // Shift the decimal point right by (AMOUNT_DECIMALS + exponent) places.
29
+ const digits = intPart + fracPart;
30
+ const pointIndex = intPart.length + exponent + AMOUNT_DECIMALS;
31
+ if (pointIndex < 0) {
32
+ // Entire value sits below 1 sat — only exact zero is representable.
33
+ if (/^0*$/.test(digits))
34
+ return 0n;
35
+ throw new RangeError(`more than ${AMOUNT_DECIMALS} decimal places: ${value}`);
36
+ }
37
+ const head = digits.slice(0, pointIndex).padEnd(pointIndex, "0");
38
+ const tail = digits.slice(pointIndex);
39
+ if (!/^0*$/.test(tail)) {
40
+ throw new RangeError(`more than ${AMOUNT_DECIMALS} decimal places: ${value}`);
41
+ }
42
+ const sats = head === "" ? 0n : BigInt(head);
43
+ if (sign === "-") {
44
+ if (sats === 0n)
45
+ return 0n; // normalize -0
46
+ if (options?.allowNegative !== true) {
47
+ throw new RangeError(`negative amount: ${value}`);
48
+ }
49
+ return -sats;
50
+ }
51
+ return sats;
52
+ }
53
+ /**
54
+ * Format bigint satoshis as the daemon's 8-decimal notation.
55
+ *
56
+ * `formatAmount(200_000_000n) === "2.00000000"`
57
+ */
58
+ export function formatAmount(sats) {
59
+ const negative = sats < 0n;
60
+ const abs = negative ? -sats : sats;
61
+ const coins = abs / SATS_PER_COIN;
62
+ const frac = abs % SATS_PER_COIN;
63
+ return `${negative ? "-" : ""}${coins}.${frac.toString().padStart(AMOUNT_DECIMALS, "0")}`;
64
+ }
65
+ //# sourceMappingURL=amount.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"amount.js","sourceRoot":"","sources":["../src/amount.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,0EAA0E;AAC1E,MAAM,CAAC,MAAM,aAAa,GAAG,UAAY,CAAC;AAE1C,MAAM,eAAe,GAAG,CAAC,CAAC;AAE1B,yEAAyE;AACzE,MAAM,UAAU,GAAG,+CAA+C,CAAC;AAUnE;;;;;;;;GAQG;AACH,MAAM,UAAU,WAAW,CAAC,KAAa,EAAE,OAA4B;IACrE,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACrC,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACnB,MAAM,IAAI,UAAU,CAAC,yBAAyB,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACzE,CAAC;IACD,MAAM,CAAC,EAAE,IAAI,GAAG,EAAE,EAAE,OAAO,GAAG,EAAE,EAAE,QAAQ,GAAG,EAAE,EAAE,OAAO,CAAC,GAAG,KAAK,CAAC;IAClE,MAAM,QAAQ,GAAG,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAE7D,wEAAwE;IACxE,MAAM,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;IAClC,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,GAAG,QAAQ,GAAG,eAAe,CAAC;IAC/D,IAAI,UAAU,GAAG,CAAC,EAAE,CAAC;QACnB,oEAAoE;QACpE,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;YAAE,OAAO,EAAE,CAAC;QACnC,MAAM,IAAI,UAAU,CAAC,aAAa,eAAe,oBAAoB,KAAK,EAAE,CAAC,CAAC;IAChF,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,MAAM,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;IACjE,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACtC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,UAAU,CAAC,aAAa,eAAe,oBAAoB,KAAK,EAAE,CAAC,CAAC;IAChF,CAAC;IAED,MAAM,IAAI,GAAG,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC7C,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;QACjB,IAAI,IAAI,KAAK,EAAE;YAAE,OAAO,EAAE,CAAC,CAAC,eAAe;QAC3C,IAAI,OAAO,EAAE,aAAa,KAAK,IAAI,EAAE,CAAC;YACpC,MAAM,IAAI,UAAU,CAAC,oBAAoB,KAAK,EAAE,CAAC,CAAC;QACpD,CAAC;QACD,OAAO,CAAC,IAAI,CAAC;IACf,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAE,CAAC;IAC3B,MAAM,GAAG,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IACpC,MAAM,KAAK,GAAG,GAAG,GAAG,aAAa,CAAC;IAClC,MAAM,IAAI,GAAG,GAAG,GAAG,aAAa,CAAC;IACjC,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,eAAe,EAAE,GAAG,CAAC,EAAE,CAAC;AAC5F,CAAC"}
@@ -0,0 +1,60 @@
1
+ import { AddressIndexApi } from "./methods/addressindex.js";
2
+ import { BlockchainApi } from "./methods/blockchain.js";
3
+ import { ChainApi } from "./methods/chain.js";
4
+ import { CurrencyApi } from "./methods/currency.js";
5
+ import { IdentityApi } from "./methods/identity.js";
6
+ import { ShieldedApi } from "./methods/shielded.js";
7
+ import { WalletApi } from "./methods/wallet.js";
8
+ import { type ResilienceConfig } from "./resilience.js";
9
+ import { type RpcTransport } from "./transport.js";
10
+ export interface VerusClientConfig {
11
+ /** Daemon RPC endpoint, e.g. `http://127.0.0.1:27486`. */
12
+ url?: string;
13
+ user?: string;
14
+ pass?: string;
15
+ /** Injectable for tests and exotic runtimes; defaults to global `fetch`. */
16
+ fetchImpl?: typeof fetch;
17
+ /** Plain per-request timeout (ms) of the default transport. Default 60s. */
18
+ timeoutMs?: number;
19
+ /** Opt-in circuit breaker + policy timeout. Off by default. */
20
+ resilience?: ResilienceConfig;
21
+ /** Full transport override (tests, future GatewayTransport). */
22
+ transport?: RpcTransport;
23
+ }
24
+ /**
25
+ * How `call()` surfaces JSON numbers:
26
+ *
27
+ * - `"lossless"` (default): safe integers become `number`, everything else
28
+ * (fractional amounts, integers beyond 2^53) becomes an exact decimal
29
+ * `string`. No float64 rounding — safe for value fields.
30
+ * - `"js"`: classic `JSON.parse` semantics, every number a float64 `number`.
31
+ * Explicit opt-in; unsafe for arithmetic on amounts.
32
+ */
33
+ export type CallNumbersMode = "lossless" | "js";
34
+ export interface CallOptions {
35
+ numbers?: CallNumbersMode;
36
+ }
37
+ /**
38
+ * Typed client for the Verus daemon JSON-RPC interface.
39
+ *
40
+ * Curated (T1) methods live on the family namespaces (`client.chain`,
41
+ * `client.wallet`, `client.identity`, …); `client.call()` reaches every
42
+ * other daemon method untyped — nothing ever blocks on missing coverage.
43
+ */
44
+ export declare class VerusClient {
45
+ readonly chain: ChainApi;
46
+ readonly wallet: WalletApi;
47
+ readonly identity: IdentityApi;
48
+ readonly currency: CurrencyApi;
49
+ readonly shielded: ShieldedApi;
50
+ readonly addressIndex: AddressIndexApi;
51
+ readonly blockchain: BlockchainApi;
52
+ private readonly transport;
53
+ constructor(config: VerusClientConfig);
54
+ /**
55
+ * Escape hatch: call any daemon RPC method with positional params.
56
+ * Untyped by design — see `CallNumbersMode` for how numbers arrive.
57
+ */
58
+ call(method: string, params?: unknown[], options?: CallOptions): Promise<unknown>;
59
+ }
60
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAkB,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAmB,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEpE,MAAM,WAAW,iBAAiB;IAChC,0DAA0D;IAC1D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,4EAA4E;IAC5E,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;IACzB,4EAA4E;IAC5E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,gEAAgE;IAChE,SAAS,CAAC,EAAE,YAAY,CAAC;CAC1B;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,eAAe,GAAG,UAAU,GAAG,IAAI,CAAC;AAEhD,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,EAAE,eAAe,CAAC;CAC3B;AAED;;;;;;GAMG;AACH,qBAAa,WAAW;IACtB,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;IAC/B,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;IAC/B,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;IAC/B,QAAQ,CAAC,YAAY,EAAE,eAAe,CAAC;IACvC,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC;IAEnC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAe;gBAE7B,MAAM,EAAE,iBAAiB;IAyBrC;;;OAGG;IACG,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,GAAE,OAAO,EAAO,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;CAI5F"}
package/dist/client.js ADDED
@@ -0,0 +1,61 @@
1
+ import { toJsNumbers, toSafeNumbers } from "./lossless.js";
2
+ import { AddressIndexApi } from "./methods/addressindex.js";
3
+ import { BlockchainApi } from "./methods/blockchain.js";
4
+ import { ChainApi } from "./methods/chain.js";
5
+ import { CurrencyApi } from "./methods/currency.js";
6
+ import { IdentityApi } from "./methods/identity.js";
7
+ import { ShieldedApi } from "./methods/shielded.js";
8
+ import { WalletApi } from "./methods/wallet.js";
9
+ import { withResilience } from "./resilience.js";
10
+ import { DaemonTransport } from "./transport.js";
11
+ /**
12
+ * Typed client for the Verus daemon JSON-RPC interface.
13
+ *
14
+ * Curated (T1) methods live on the family namespaces (`client.chain`,
15
+ * `client.wallet`, `client.identity`, …); `client.call()` reaches every
16
+ * other daemon method untyped — nothing ever blocks on missing coverage.
17
+ */
18
+ export class VerusClient {
19
+ chain;
20
+ wallet;
21
+ identity;
22
+ currency;
23
+ shielded;
24
+ addressIndex;
25
+ blockchain;
26
+ transport;
27
+ constructor(config) {
28
+ if (config.transport !== undefined) {
29
+ this.transport = config.transport;
30
+ }
31
+ else {
32
+ if (config.url === undefined || config.user === undefined || config.pass === undefined) {
33
+ throw new TypeError("VerusClient: url, user and pass are required (or pass a transport)");
34
+ }
35
+ const daemon = new DaemonTransport({
36
+ url: config.url,
37
+ user: config.user,
38
+ pass: config.pass,
39
+ ...(config.fetchImpl !== undefined ? { fetchImpl: config.fetchImpl } : {}),
40
+ ...(config.timeoutMs !== undefined ? { timeoutMs: config.timeoutMs } : {}),
41
+ });
42
+ this.transport = config.resilience !== undefined ? withResilience(daemon, config.resilience) : daemon;
43
+ }
44
+ this.chain = new ChainApi(this.transport);
45
+ this.wallet = new WalletApi(this.transport);
46
+ this.identity = new IdentityApi(this.transport);
47
+ this.currency = new CurrencyApi(this.transport);
48
+ this.shielded = new ShieldedApi(this.transport);
49
+ this.addressIndex = new AddressIndexApi(this.transport);
50
+ this.blockchain = new BlockchainApi(this.transport);
51
+ }
52
+ /**
53
+ * Escape hatch: call any daemon RPC method with positional params.
54
+ * Untyped by design — see `CallNumbersMode` for how numbers arrive.
55
+ */
56
+ async call(method, params = [], options) {
57
+ const raw = await this.transport.request(method, params);
58
+ return options?.numbers === "js" ? toJsNumbers(raw) : toSafeNumbers(raw);
59
+ }
60
+ }
61
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Error taxonomy — the split matters for resilience:
3
+ *
4
+ * - `VerusRpcError` — the daemon answered with a JSON-RPC error (bad params,
5
+ * unknown identity, insufficient funds, …). The node is HEALTHY; these never
6
+ * count toward the optional circuit breaker, otherwise malformed requests
7
+ * could trip it and deny service (v402 lesson).
8
+ * - `TransportError` — the node could not be reached, did not answer in time,
9
+ * answered with an unparseable body, or the breaker is open.
10
+ */
11
+ export type TransportFailureReason = "network" | "timeout" | "bad-response" | "circuit-open";
12
+ export declare class TransportError extends Error {
13
+ readonly reason: TransportFailureReason;
14
+ constructor(reason: TransportFailureReason, message: string);
15
+ }
16
+ /**
17
+ * Common daemon error codes (Bitcoin/Zcash lineage, `rpcprotocol.h`) so
18
+ * consumers can branch on `error.code` without string-matching messages.
19
+ */
20
+ export declare const RpcErrorCode: {
21
+ readonly RPC_INVALID_REQUEST: -32600;
22
+ readonly RPC_METHOD_NOT_FOUND: -32601;
23
+ readonly RPC_INVALID_PARAMS: -32602;
24
+ readonly RPC_INTERNAL_ERROR: -32603;
25
+ readonly RPC_PARSE_ERROR: -32700;
26
+ readonly RPC_MISC_ERROR: -1;
27
+ readonly RPC_FORBIDDEN_BY_SAFE_MODE: -2;
28
+ readonly RPC_TYPE_ERROR: -3;
29
+ readonly RPC_INVALID_ADDRESS_OR_KEY: -5;
30
+ readonly RPC_OUT_OF_MEMORY: -7;
31
+ readonly RPC_INVALID_PARAMETER: -8;
32
+ readonly RPC_DATABASE_ERROR: -20;
33
+ readonly RPC_DESERIALIZATION_ERROR: -22;
34
+ readonly RPC_VERIFY_ERROR: -25;
35
+ readonly RPC_VERIFY_REJECTED: -26;
36
+ readonly RPC_VERIFY_ALREADY_IN_CHAIN: -27;
37
+ readonly RPC_IN_WARMUP: -28;
38
+ readonly RPC_CLIENT_NOT_CONNECTED: -9;
39
+ readonly RPC_CLIENT_IN_INITIAL_DOWNLOAD: -10;
40
+ readonly RPC_CLIENT_NODE_ALREADY_ADDED: -23;
41
+ readonly RPC_CLIENT_NODE_NOT_ADDED: -24;
42
+ readonly RPC_WALLET_ERROR: -4;
43
+ readonly RPC_WALLET_INSUFFICIENT_FUNDS: -6;
44
+ readonly RPC_WALLET_INVALID_ACCOUNT_NAME: -11;
45
+ readonly RPC_WALLET_KEYPOOL_RAN_OUT: -12;
46
+ readonly RPC_WALLET_UNLOCK_NEEDED: -13;
47
+ readonly RPC_WALLET_PASSPHRASE_INCORRECT: -14;
48
+ readonly RPC_WALLET_WRONG_ENC_STATE: -15;
49
+ readonly RPC_WALLET_ENCRYPTION_FAILED: -16;
50
+ readonly RPC_WALLET_ALREADY_UNLOCKED: -17;
51
+ };
52
+ export type RpcErrorCode = (typeof RpcErrorCode)[keyof typeof RpcErrorCode];
53
+ /** The daemon answered the call with a JSON-RPC error body. */
54
+ export declare class VerusRpcError extends Error {
55
+ readonly method: string;
56
+ readonly code: number;
57
+ constructor(method: string, code: number, message: string);
58
+ }
59
+ /**
60
+ * A curated (T1) response did not have the shape the mapper expects — the
61
+ * daemon version drifted or the type curation is wrong. The raw value is
62
+ * intact on the wire; `client.call()` always works as the escape hatch.
63
+ */
64
+ export declare class ResponseMappingError extends Error {
65
+ readonly method: string;
66
+ readonly field: string;
67
+ constructor(method: string, field: string, message: string);
68
+ }
69
+ /** An async wallet operation (opid) finished with status "failed" or "cancelled". */
70
+ export declare class OperationFailedError extends Error {
71
+ readonly opid: string;
72
+ readonly status: string;
73
+ readonly code: number | undefined;
74
+ constructor(opid: string, status: string, code: number | undefined, message: string);
75
+ }
76
+ /** An async wallet operation (opid) did not reach a final state within the polling deadline. */
77
+ export declare class OperationTimeoutError extends Error {
78
+ readonly opid: string;
79
+ constructor(opid: string, timeoutMs: number);
80
+ }
81
+ //# sourceMappingURL=errors.d.ts.map