@smartledger/bsv 9.2.0 → 9.4.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.
@@ -0,0 +1,75 @@
1
+ /**
2
+ * CustomScriptHelper — script construction and signing helpers.
3
+ *
4
+ * All members are static; the class is never instantiated. Signatures follow
5
+ * the JSDoc in `lib/custom-script-helper.js`.
6
+ */
7
+ import { Transaction, Script, PrivateKey, PublicKey } from '@smartledger/bsv';
8
+
9
+ declare class CustomScriptHelper {
10
+ /** SIGHASH_ALL | SIGHASH_FORKID. */
11
+ static readonly SIGHASH_ALL: number;
12
+ /** SIGHASH_NONE | SIGHASH_FORKID. */
13
+ static readonly SIGHASH_NONE: number;
14
+ /** SIGHASH_SINGLE | SIGHASH_FORKID. */
15
+ static readonly SIGHASH_SINGLE: number;
16
+
17
+ /**
18
+ * DER signature with the sighash byte appended, ready to push.
19
+ * Defaults to SIGHASH_ALL | SIGHASH_FORKID.
20
+ */
21
+ static createSignature(
22
+ transaction: Transaction,
23
+ privateKey: PrivateKey,
24
+ inputIndex: number,
25
+ lockingScript: Script,
26
+ satoshis: number,
27
+ sighashType?: number | null
28
+ ): Buffer;
29
+
30
+ /** m-of-n locking script over the supplied keys. */
31
+ static createMultisigScript(m: number, publicKeys: PublicKey[]): Script;
32
+ /** Unlocking script for a multisig input; prepends OP_0 for the CHECKMULTISIG off-by-one. */
33
+ static createMultisigUnlocking(signatures: Buffer[]): Script;
34
+ /** OP_IF / [OP_ELSE] / OP_ENDIF around the supplied branches. */
35
+ static createConditionalScript(ifScript: Script, elseScript?: Script | null): Script;
36
+
37
+ static createP2PKHScript(publicKey: PublicKey): Script;
38
+ static createP2PKHUnlocking(signature: Buffer, publicKey: PublicKey): Script;
39
+
40
+ /**
41
+ * BIP-143 preimage for the given input.
42
+ * Defaults to SIGHASH_ALL | SIGHASH_FORKID.
43
+ */
44
+ static getPreimage(
45
+ transaction: Transaction,
46
+ inputIndex: number,
47
+ lockingScript: Script,
48
+ satoshis: number,
49
+ sighashType?: number | null
50
+ ): Buffer;
51
+
52
+ /** A bare data push. A string is encoded as UTF-8. */
53
+ static createDataScript(data: Buffer | string): Script;
54
+ /** OP_FALSE OP_RETURN <data>. A string is encoded as UTF-8. */
55
+ static createOpReturnScript(data: Buffer | string): Script;
56
+
57
+ /** Returns false rather than throwing when verification fails. */
58
+ static validateTransaction(transaction: Transaction): boolean;
59
+ /** Runs the interpreter over one input. Returns false rather than throwing. */
60
+ static validateScript(
61
+ unlockingScript: Script,
62
+ lockingScript: Script,
63
+ transaction: Transaction,
64
+ inputIndex: number
65
+ ): boolean;
66
+
67
+ /** Builds a transaction at the given fee rate. Defaults to 10 sat/kb. */
68
+ static createLowFeeTransaction(
69
+ utxos: object[],
70
+ outputs: Array<{ address: string; satoshis: number }>,
71
+ feePerKb?: number
72
+ ): Transaction;
73
+ }
74
+
75
+ export = CustomScriptHelper;
@@ -0,0 +1,52 @@
1
+ /**
2
+ * SmartMiner — an in-process BSV miner simulator for tests and development.
3
+ *
4
+ * This simulates mempool acceptance and block assembly; it is not a miner and
5
+ * performs no proof of work.
6
+ */
7
+ import { Transaction } from '@smartledger/bsv';
8
+
9
+ declare class SmartMiner {
10
+ constructor(bsv: unknown, options?: {
11
+ difficulty?: number;
12
+ /** Milliseconds. Defaults to 10000. */
13
+ blockTime?: number;
14
+ /** Defaults to true. */
15
+ validateScripts?: boolean;
16
+ logLevel?: string;
17
+ [key: string]: unknown;
18
+ });
19
+
20
+ options: Record<string, unknown>;
21
+ mempool: Transaction[];
22
+ currentBlock: { height: number; transactions: Transaction[]; timestamp: number; hash?: string };
23
+
24
+ /** Accepts into the mempool, or returns false if rejected. */
25
+ acceptTransaction(transaction: Transaction): boolean;
26
+ validateTransactionSignatures(transaction: Transaction): boolean;
27
+ /** Assembles a block from the mempool. Defaults to 10 transactions. */
28
+ mineBlock(maxTransactions?: number): {
29
+ height: number;
30
+ transactions: Transaction[];
31
+ timestamp: number;
32
+ hash?: string;
33
+ [key: string]: unknown;
34
+ };
35
+ getMempoolStats(): {
36
+ transactionCount: number;
37
+ transactions: Array<{ id: string; size: number; inputs: number; outputs: number }>;
38
+ };
39
+ getBlockchainStats(): {
40
+ currentHeight: number;
41
+ currentBlockHash: string | undefined;
42
+ currentBlockTimestamp: number;
43
+ mempoolSize: number;
44
+ difficulty: number;
45
+ blockTime: number;
46
+ };
47
+ /** Returns the miner to genesis state and empties the mempool. */
48
+ reset(): void;
49
+ log(level: string, message: string): void;
50
+ }
51
+
52
+ export = SmartMiner;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Shamir secret sharing.
3
+ *
4
+ * Same class as `require("@smartledger/bsv").crypto.Shamir`. The underscore-
5
+ * prefixed `_*Legacy` helpers present at runtime are deliberately not declared:
6
+ * they exist to reconstruct shares produced by pre-6.x releases and are not
7
+ * part of the supported surface.
8
+ */
9
+ import { crypto } from '@smartledger/bsv';
10
+ export = crypto.Shamir;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Script-level contract construction: OP_PUSH_TX covenants, BIP-143 preimage
3
+ * tooling, the interpreter-backed tester, and the template library.
4
+ *
5
+ * Same surface as `require("@smartledger/bsv").SmartContract`.
6
+ */
7
+ import { SmartContract } from '@smartledger/bsv';
8
+ export = SmartContract;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * StatusList2021 revocation lists.
3
+ *
4
+ * Note `getCredentialStatusEntry` is async — awaiting it is not optional.
5
+ * Comparing the returned Promise to a string type-checks and is always false,
6
+ * which is how a revoked credential passes.
7
+ *
8
+ * Same surface as `require("@smartledger/bsv").StatusList`.
9
+ */
10
+ import { StatusList } from '@smartledger/bsv';
11
+ export = StatusList;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * W3C Verifiable Credentials as JWTs.
3
+ *
4
+ * Same surface as `require("@smartledger/bsv").VcJwt`, plus `ALG_TO_CRV`, which
5
+ * the module exports at runtime but the root declaration does not describe.
6
+ */
7
+ import { VcJwt } from '@smartledger/bsv';
8
+
9
+ declare namespace vcjwt {
10
+ /** Maps a JWS algorithm to the JWK curve it requires. */
11
+ const ALG_TO_CRV: Readonly<Record<string, string>>;
12
+ }
13
+ declare const vcjwt: typeof VcJwt & { readonly ALG_TO_CRV: Readonly<Record<string, string>> };
14
+
15
+ export = vcjwt;
package/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  'use strict'
2
2
  // GENERATED by scripts/sync-version.js on `npm version` — do not edit.
3
- module.exports = '9.2.0'
3
+ module.exports = '9.4.0'