@chainvue/verus-sdk 0.5.0 → 0.5.1

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.
package/README.md CHANGED
@@ -1,75 +1,59 @@
1
1
  # @chainvue/verus-sdk
2
2
 
3
- **100% offline Verus transaction signing.** Build and sign Verus
4
- transactionsnative transfers, token/currency transfers, conversions,
5
- and the full VerusID lifecycle (name commitment, registration, sub-IDs,
6
- update/revoke/recover, message signing) with no daemon and no network
7
- access. You bring UTXOs and a WIF; the SDK returns signed transaction hex.
8
-
9
- Serialization delegates to VerusCoin's own primitives
10
- (`verus-typescript-primitives`) and a fork of `@bitgo/utxo-lib`, so the
11
- wire format is the daemon's, not a reimplementation.
12
-
13
- ## Install
3
+ Offline Verus transaction signing. Bring UTXOs and a WIF; get back signed
4
+ transaction hex no daemon, no network. Native transfers, token/currency
5
+ transfers, conversions, and the full VerusID lifecycle. Serialization uses
6
+ VerusCoin's own primitives, so the wire format is the daemon's, not a reimpl.
14
7
 
15
8
  ```bash
16
- npm install @chainvue/verus-sdk
9
+ npm i @chainvue/verus-sdk
17
10
  ```
18
11
 
19
- The published package is a **self-contained bundle**: the VerusCoin forks
20
- (utxo-lib, primitives, bitcoin-ops) are inlined, so there are no `github:`
21
- dependencies or install-time patches in your dependency graph. Regular npm
22
- dependencies (`tiny-secp256k1`, `ecpair`, `bs58check`, `bn.js`,
23
- `create-hash`, `wif`) install normally.
24
-
25
- > **TypeScript consumers:** the type declarations reference the fork
26
- > packages' types, so set `"skipLibCheck": true` in your `tsconfig.json`
27
- > until the declarations are rolled up. Runtime is unaffected.
28
-
29
- ## Usage
30
-
31
12
  ```ts
32
- import { VerusSDK } from '@chainvue/verus-sdk';
13
+ import { VerusSDK } from "@chainvue/verus-sdk";
33
14
 
34
- const sdk = new VerusSDK({ network: 'testnet' }); // or 'mainnet'
15
+ const sdk = new VerusSDK({ network: "testnet" }); // or "mainnet"
35
16
 
36
- // Native transfer — returns { signedTx, txid, fee, inputsUsed, nativeChange }
37
- const result = sdk.transfer({
38
- wif: '<WIF>',
39
- to: 'R...recipient',
40
- amount: 100_000_000, // satoshis
41
- utxos: [/* { txid, outputIndex, satoshis, script } */],
42
- changeAddress: 'R...change',
17
+ const { signedTx, txid, fee } = sdk.transfer({
18
+ wif: "<WIF>",
19
+ to: "R…recipient",
20
+ amount: 100_000_000n, // satoshis (bigint)
21
+ utxos: [{ txid, outputIndex, satoshis: 500_000_000n, script }],
22
+ changeAddress: "R…change",
43
23
  });
44
- // broadcast result.signedTx via your own RPC (e.g. verus-rpc sendrawtransaction)
45
-
46
- // Decode a signed tx for a wallet ledger:
47
- import { utils } from '@chainvue/verus-sdk';
48
- const summary = utils.summarizeSignedTransaction(result.signedTx, 'testnet');
49
- // { txid, inputs: [{txid, vout}], outputs: [{valueSat, scriptHex, address}] }
24
+ // broadcast signedTx yourself, e.g. verus-rpc `sendrawtransaction`
50
25
  ```
51
26
 
52
- Static helpers: `VerusSDK.generateWif()`, `VerusSDK.deriveAddress(wif)`,
53
- `VerusSDK.deriveIdentityAddress(name, parent?)`,
54
- `VerusSDK.validateAddress(addr)`, `VerusSDK.validateWif(wif)`.
55
-
56
- Identity lifecycle: `createCommitment`, `registerIdentity`,
57
- `updateIdentity` / `lockIdentity` / `unlockIdentity` / `revokeIdentity` /
58
- `recoverIdentity`, plus `signMessage` / `verifyMessage`.
59
-
60
- ## Safety
61
-
62
- - **Every built transfer is validated** against its unfunded intent
63
- (utxo-lib's own funded-transfer validator: per-currency value
64
- conservation, change to the declared address) before the hex is returned
65
- a selection/change bug throws instead of producing a bad tx.
66
- - Signing is **offline**: the SDK never opens a socket. Broadcasting,
67
- UTXO fetching and confirmation tracking are the caller's job.
68
-
69
- ## Status
70
-
71
- Pre-release. The transaction wire format is proven against a live VRSCTEST
72
- daemon (decode round-trip + `sendrawtransaction` acceptance) — see
73
- [RISKS.md](./RISKS.md) for the live-proof harness and open items.
74
-
75
- License: Apache-2.0.
27
+ **Money is `bigint` satoshis end to end — never a float.** Convert at the edges:
28
+ `parseSats("1.5") → 150000000n`, `toCoins(150000000n) → "1.5"`.
29
+
30
+ ## What it does
31
+
32
+ - **Transfers** `transfer`, `transferToken`, `convert`, and `sendCurrency`
33
+ (full control over multi-output / cross-chain sends).
34
+ - **VerusID** — `createCommitment` → `registerIdentity` (incl. sub-IDs), then
35
+ `updateIdentity` / `lockIdentity` / `unlockIdentity` / `revokeIdentity` /
36
+ `recoverIdentity`, plus `signMessage` / `verifyMessage`.
37
+ - **Helpers** `VerusSDK.generateWif()`, `deriveAddress(wif)`,
38
+ `deriveIdentityAddress(name, parent?)`, `validateAddress`, `validateWif`;
39
+ `utils.summarizeSignedTransaction(hex)` decodes a signed tx (txid, spent
40
+ outpoints, addressed outputs) for your ledger.
41
+
42
+ Every built transfer is re-validated against its intent — per-currency value
43
+ conservation, change to the declared address — before the hex is returned. A
44
+ selection or change bug throws; it never hands you a bad transaction.
45
+
46
+ ## Good to know
47
+
48
+ - **Self-contained bundle**: the VerusCoin forks (utxo-lib, primitives,
49
+ bitcoin-ops) are inlined — no `github:` deps or install-time patches in your
50
+ tree. Regular npm deps install normally.
51
+ - **TypeScript**: self-contained declarations — no `skipLibCheck` needed and no
52
+ fork packages to install; the type surface for the bundled forks ships with the
53
+ package.
54
+ - **Signing only**: broadcasting, UTXO fetching, and confirmation tracking are
55
+ yours (see [`verus-rpc`](https://www.npmjs.com/package/verus-rpc)).
56
+ - Node ≥ 18. Wire format proven against a live VRSCTEST daemon — see
57
+ [RISKS.md](./RISKS.md).
58
+
59
+ Apache-2.0 · see [NOTICE](./NOTICE) for the bundled forks.
@@ -0,0 +1,50 @@
1
+ // Ambient type shims for the bundled VerusCoin forks.
2
+ //
3
+ // The forks (@bitgo/utxo-lib, verus-typescript-primitives) are INLINED into
4
+ // dist/bundle.js and are not installable by consumers, yet a few of the SDK's
5
+ // public type signatures reference them (VerusNetwork, TransactionBuilder,
6
+ // Identity, nameAndParentAddrToIAddr). Without a shim, a consumer's `tsc`
7
+ // reports "Cannot find module '@bitgo/utxo-lib'" unless they set
8
+ // `skipLibCheck: true`.
9
+ //
10
+ // This file is copied to dist/ and referenced from dist/index.d.ts at build
11
+ // time (scripts/finalize-types.mjs), so the published declarations are
12
+ // self-contained: no fork packages required, no skipLibCheck. It declares only
13
+ // the surface the public API exposes — intentionally minimal, and free of any
14
+ // transitive type dependency (e.g. bn.js).
15
+
16
+ declare module "@bitgo/utxo-lib" {
17
+ export interface VerusNetworkConfig {
18
+ messagePrefix: string;
19
+ bech32?: string;
20
+ bip32: { public: number; private: number };
21
+ pubKeyHash: number;
22
+ scriptHash: number;
23
+ wif: number;
24
+ coin: string;
25
+ [key: string]: unknown;
26
+ }
27
+
28
+ export const networks: {
29
+ verus: VerusNetworkConfig;
30
+ verustest: VerusNetworkConfig;
31
+ [key: string]: VerusNetworkConfig;
32
+ };
33
+
34
+ export class TransactionBuilder {
35
+ constructor(network?: VerusNetworkConfig, maximumFeeRate?: number);
36
+ setVersion(version: number): void;
37
+ setExpiryHeight(height: number): void;
38
+ setVersionGroupId(id: number): void;
39
+ addInput(txHash: string | Buffer, vout: number, sequence?: number, prevOutScript?: Buffer): number;
40
+ addOutput(scriptPubKeyOrAddress: Buffer | string, value: number): number;
41
+ build(): unknown;
42
+ buildIncomplete(): unknown;
43
+ }
44
+ }
45
+
46
+ declare module "verus-typescript-primitives" {
47
+ /** Opaque VerusID object — construct via the SDK's identity helpers. */
48
+ export class Identity {}
49
+ export function nameAndParentAddrToIAddr(name: string, parentIAddress?: string): string;
50
+ }
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ /// <reference path="./fork-shims.d.ts" />
1
2
  /**
2
3
  * @chainvue/verus-sdk
3
4
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chainvue/verus-sdk",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "100% offline, fully typed TypeScript SDK for Verus transaction signing",
5
5
  "author": "Robert Lech",
6
6
  "main": "dist/bundle.js",
@@ -38,7 +38,6 @@
38
38
  "@types/create-hash": "^1.2.6",
39
39
  "@types/node": "^20.19.33",
40
40
  "bitcoin-ops": "github:VerusCoin/bitcoin-ops#a5f8f56e658301bc39881d41740b3a0010530efd",
41
- "conventional-changelog-conventionalcommits": "^10.2.1",
42
41
  "eslint": "^10.7.0",
43
42
  "globals": "^17.7.0",
44
43
  "semantic-release": "^25.0.7",
@@ -57,7 +56,7 @@
57
56
  "LICENSE"
58
57
  ],
59
58
  "scripts": {
60
- "build": "tsc",
59
+ "build": "tsc && node scripts/finalize-types.mjs",
61
60
  "test": "vitest run",
62
61
  "test:watch": "vitest",
63
62
  "clean": "rm -rf dist",