@smartledger/bsv 9.1.1 → 9.3.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.
- package/CHANGELOG.md +126 -0
- package/README.md +19 -19
- package/SECURITY.md +23 -23
- package/anchor-entry.d.ts +8 -0
- package/bsv-gdaf.min.js +42 -42
- package/bsv-ltp.min.js +28 -28
- package/bsv-smartcontract.min.js +1 -1
- package/bsv.bundle.js +42 -42
- package/bsv.d.ts +54 -4
- package/bsv.min.js +42 -42
- package/covenant-entry.d.ts +17 -0
- package/didweb-entry.d.ts +7 -0
- package/docs/AUDIT_SCOPE.md +17 -11
- package/docs/MODULE_REFERENCE_COMPLETE.md +27 -27
- package/docs/ORDINALS_ENVELOPE_FIELDS.md +159 -0
- package/docs/advanced/UTXO_MANAGER_GUIDE.md +1 -1
- package/docs/audit-rfq/README.md +41 -0
- package/docs/audit-rfq/cure53.txt +49 -0
- package/docs/audit-rfq/ncc-group.txt +49 -0
- package/docs/audit-rfq/trail-of-bits.txt +49 -0
- package/docs/getting-started/INSTALLATION.md +23 -23
- package/docs/getting-started/QUICK_START.md +7 -7
- package/docs/migration/FROM_BSV_1_5_6.md +5 -5
- package/gdaf-entry.d.ts +7 -0
- package/index.js +5 -4
- package/index.mjs +1 -0
- package/jcs-entry.d.ts +12 -0
- package/jcs-entry.js +1 -0
- package/lib/ltp/claim.js +105 -14
- package/lib/ordinals/inscription.js +112 -0
- package/lib/util/jcs.js +44 -14
- package/ltp-entry.d.ts +7 -0
- package/package.json +56 -16
- package/script-helper-entry.d.ts +75 -0
- package/security-entry.d.ts +52 -0
- package/shamir-entry.d.ts +10 -0
- package/smartcontract-entry.d.ts +8 -0
- package/statuslist-entry.d.ts +11 -0
- package/vcjwt-entry.d.ts +15 -0
- package/version.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smartledger/bsv",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.3.0",
|
|
4
4
|
"description": "Bitcoin SV library with an interpreter-verified script engine: OP_PUSH_TX covenants, BIP-143 preimage tooling, and consensus flags that match what miners actually enforce. Also ships DID:web / W3C VC-JWT credentials and the Legal Token Protocol.",
|
|
5
5
|
"author": "SmartLedger Technology <hello@smartledger.technology> (https://smartledger.technology)",
|
|
6
6
|
"homepage": "https://github.com/codenlighten/smartledger-bsv#readme",
|
|
@@ -18,17 +18,54 @@
|
|
|
18
18
|
},
|
|
19
19
|
"./package.json": "./package.json",
|
|
20
20
|
"./version": "./version.js",
|
|
21
|
-
"./anchor":
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"./
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"./
|
|
30
|
-
|
|
31
|
-
|
|
21
|
+
"./anchor": {
|
|
22
|
+
"types": "./anchor-entry.d.ts",
|
|
23
|
+
"default": "./anchor-entry.js"
|
|
24
|
+
},
|
|
25
|
+
"./covenant": {
|
|
26
|
+
"types": "./covenant-entry.d.ts",
|
|
27
|
+
"default": "./covenant-entry.js"
|
|
28
|
+
},
|
|
29
|
+
"./didweb": {
|
|
30
|
+
"types": "./didweb-entry.d.ts",
|
|
31
|
+
"default": "./didweb-entry.js"
|
|
32
|
+
},
|
|
33
|
+
"./gdaf": {
|
|
34
|
+
"types": "./gdaf-entry.d.ts",
|
|
35
|
+
"default": "./gdaf-entry.js"
|
|
36
|
+
},
|
|
37
|
+
"./jcs": {
|
|
38
|
+
"types": "./jcs-entry.d.ts",
|
|
39
|
+
"default": "./jcs-entry.js"
|
|
40
|
+
},
|
|
41
|
+
"./ltp": {
|
|
42
|
+
"types": "./ltp-entry.d.ts",
|
|
43
|
+
"default": "./ltp-entry.js"
|
|
44
|
+
},
|
|
45
|
+
"./script-helper": {
|
|
46
|
+
"types": "./script-helper-entry.d.ts",
|
|
47
|
+
"default": "./script-helper-entry.js"
|
|
48
|
+
},
|
|
49
|
+
"./security": {
|
|
50
|
+
"types": "./security-entry.d.ts",
|
|
51
|
+
"default": "./security-entry.js"
|
|
52
|
+
},
|
|
53
|
+
"./shamir": {
|
|
54
|
+
"types": "./shamir-entry.d.ts",
|
|
55
|
+
"default": "./shamir-entry.js"
|
|
56
|
+
},
|
|
57
|
+
"./smartcontract": {
|
|
58
|
+
"types": "./smartcontract-entry.d.ts",
|
|
59
|
+
"default": "./smartcontract-entry.js"
|
|
60
|
+
},
|
|
61
|
+
"./statuslist": {
|
|
62
|
+
"types": "./statuslist-entry.d.ts",
|
|
63
|
+
"default": "./statuslist-entry.js"
|
|
64
|
+
},
|
|
65
|
+
"./vcjwt": {
|
|
66
|
+
"types": "./vcjwt-entry.d.ts",
|
|
67
|
+
"default": "./vcjwt-entry.js"
|
|
68
|
+
},
|
|
32
69
|
"./lib/anchor": "./lib/anchor/index.js",
|
|
33
70
|
"./lib/block": "./lib/block/index.js",
|
|
34
71
|
"./lib/covenant": "./lib/covenant/index.js",
|
|
@@ -81,7 +118,7 @@
|
|
|
81
118
|
"test:all": "npm test && npm run test:covenants && npm run test:scripts",
|
|
82
119
|
"coverage": "nyc --reporter=text npm run test",
|
|
83
120
|
"demo": "node demos/smart_contract_demo.js",
|
|
84
|
-
"demo:web": "echo '
|
|
121
|
+
"demo:web": "echo '\ud83c\udf10 Open demos/smart_contract_demo.html in your browser'",
|
|
85
122
|
"demo:basics": "node demos/smart_contract_demo.js --feature basics",
|
|
86
123
|
"demo:covenant": "node demos/smart_contract_demo.js --feature covenant",
|
|
87
124
|
"demo:preimage": "node demos/smart_contract_demo.js --feature preimage",
|
|
@@ -90,7 +127,7 @@
|
|
|
90
127
|
"demo:legacy": "npm run test:covenants",
|
|
91
128
|
"demo:legacy:basic": "npm run test:basic",
|
|
92
129
|
"demo:legacy:scripts": "npm run test:scripts",
|
|
93
|
-
"demo:legacy:preimage": "echo '
|
|
130
|
+
"demo:legacy:preimage": "echo '\ud83e\udde0 BIP-143 Preimage Extractor Demo' && node examples/preimage/extract_preimage_bidirectional.js",
|
|
94
131
|
"smart-contracts": "node examples/smart_contract_templates.js",
|
|
95
132
|
"smart-contracts:working": "node examples/final_working_contracts.js",
|
|
96
133
|
"workflow": "node examples/complete_workflow_demo.js",
|
|
@@ -98,12 +135,13 @@
|
|
|
98
135
|
"test:browser": "echo 'Open tests/standalone-modules-test.html in browser for comprehensive testing'",
|
|
99
136
|
"test:bundle": "echo 'Open tests/bundle-completeness-test.html in browser to verify bundle completeness'",
|
|
100
137
|
"preimage:extract": "node examples/preimage/extract_preimage_bidirectional.js",
|
|
101
|
-
"prepublishOnly": "npm run build-all && npm run check:readme && npm run check:api",
|
|
138
|
+
"prepublishOnly": "npm run build-all && npm run check:readme && npm run check:api && npm run check:types",
|
|
102
139
|
"sync-cdn": "node scripts/sync-cdn-urls.js",
|
|
103
140
|
"version": "node scripts/sync-cdn-urls.js && node scripts/sync-version.js && node scripts/gen-esm-wrapper.js && git add README.md docs version.js index.mjs",
|
|
104
141
|
"test:browser:ci": "node tests/browser-smoke-runner.js",
|
|
105
142
|
"api:snapshot": "node scripts/api-surface.js",
|
|
106
|
-
"check:api": "mocha test/api_surface.js --no-config"
|
|
143
|
+
"check:api": "mocha test/api_surface.js --no-config",
|
|
144
|
+
"check:types": "node scripts/check-types.js"
|
|
107
145
|
},
|
|
108
146
|
"unpkg": "bsv.min.js",
|
|
109
147
|
"jsdelivr": "bsv.min.js",
|
|
@@ -121,6 +159,7 @@
|
|
|
121
159
|
"build/",
|
|
122
160
|
"tools/",
|
|
123
161
|
"*-entry.js",
|
|
162
|
+
"*-entry.d.ts",
|
|
124
163
|
"bsv.min.js",
|
|
125
164
|
"bsv.bundle.js",
|
|
126
165
|
"bsv-ecies.min.js",
|
|
@@ -173,6 +212,7 @@
|
|
|
173
212
|
"@noble/ciphers": "^2.3.0",
|
|
174
213
|
"@noble/curves": "^2.3.0",
|
|
175
214
|
"@noble/hashes": "^2.3.0",
|
|
215
|
+
"@types/node": "^20.19.0",
|
|
176
216
|
"bn.js": "=4.12.5",
|
|
177
217
|
"secrets.js-grempe": "^2.0.0"
|
|
178
218
|
},
|
|
@@ -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;
|
package/vcjwt-entry.d.ts
ADDED
|
@@ -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