@smartledger/bsv 7.4.0 → 7.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/CHANGELOG.md +128 -0
- package/README.md +38 -38
- package/bsv-gdaf.min.js +33 -33
- package/bsv-ltp.min.js +33 -33
- package/bsv-smartcontract.min.js +1 -1
- package/bsv.bundle.js +33 -33
- package/bsv.d.ts +63 -16
- package/bsv.min.js +33 -33
- package/docs/MODULE_REFERENCE_COMPLETE.md +27 -27
- package/docs/advanced/UTXO_MANAGER_GUIDE.md +1 -1
- 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/lib/gdaf/index.js +29 -6
- package/lib/gdaf/smartledger-anchor.js +31 -1
- package/lib/privatekey.js +59 -10
- package/lib/script/interpreter.js +47 -6
- package/package.json +1 -1
- package/test/gdaf/anchor_no_key_leak.js +88 -0
- package/test/ordinals/inscription.js +94 -0
- package/test/ordinals/ordlock.js +10 -20
- package/test/privatekey.js +79 -2
- package/test/script/genesis_limits.js +44 -8
- package/test/smart_contract/covenants.js +2 -4
- package/test/smart_contract/dsl_debugger.js +2 -4
- package/test/smart_contract/ordinal_transfer.js +2 -4
- package/test/smart_contract/sighash_marketplace.js +2 -4
- package/test/smart_contract/token_generalized.js +2 -4
- package/version.js +1 -1
package/bsv.d.ts
CHANGED
|
@@ -176,19 +176,30 @@ declare module '@smartledger/bsv' {
|
|
|
176
176
|
toAddress(): Address;
|
|
177
177
|
toPublicKey(): PublicKey;
|
|
178
178
|
toString(): string;
|
|
179
|
-
|
|
180
|
-
|
|
179
|
+
/** Deliberate export, INCLUDING the secret scalar. Round-trips with fromObject(). */
|
|
180
|
+
toObject(): { bn: string; compressed: boolean; network: string };
|
|
181
|
+
/**
|
|
182
|
+
* What JSON.stringify() calls — the scalar is REDACTED. Use toObject() or toWIF()
|
|
183
|
+
* when you actually intend to export the secret.
|
|
184
|
+
*/
|
|
185
|
+
toJSON(): { bn: '[REDACTED]'; compressed: boolean; network: string };
|
|
181
186
|
toWIF(): string;
|
|
182
187
|
toHex(): string;
|
|
183
188
|
toBigNumber(): any; //BN;
|
|
184
189
|
toBuffer(): Buffer;
|
|
185
190
|
inspect(): string;
|
|
186
191
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
static
|
|
192
|
+
/**
|
|
193
|
+
* From a WIF string, or a hex-encoded scalar. `network` is honoured; for a WIF,
|
|
194
|
+
* which encodes its own network, a conflicting value throws.
|
|
195
|
+
*/
|
|
196
|
+
static fromString(str: string, network?: string | Networks.Network): PrivateKey;
|
|
197
|
+
static fromWIF(str: string, network?: string | Networks.Network): PrivateKey;
|
|
198
|
+
static fromRandom(network?: string): PrivateKey;
|
|
199
|
+
/** `compressed` defaults to true, matching every other constructor path. */
|
|
200
|
+
static fromBuffer(buf: Buffer, network?: string | Networks.Network, compressed?: boolean): PrivateKey;
|
|
201
|
+
/** `compressed` defaults to true, matching every other constructor path. */
|
|
202
|
+
static fromHex(hex: string, network?: string | Networks.Network, compressed?: boolean): PrivateKey;
|
|
192
203
|
static getValidationError(data: string): any | null;
|
|
193
204
|
static isValid(data: string): boolean;
|
|
194
205
|
}
|
|
@@ -344,20 +355,33 @@ declare module '@smartledger/bsv' {
|
|
|
344
355
|
namespace Interpreter {
|
|
345
356
|
const SCRIPT_ENABLE_SIGHASH_FORKID: any;
|
|
346
357
|
|
|
347
|
-
// Pre-Genesis consensus caps (defaults: 520 / 4 / 201).
|
|
358
|
+
// Pre-Genesis consensus caps (defaults: 520 / 4 / 201 / 10,000).
|
|
348
359
|
// Mutable: see useGenesisLimits() for a one-call opt-in.
|
|
349
360
|
let MAX_SCRIPT_ELEMENT_SIZE: number;
|
|
350
361
|
let MAXIMUM_ELEMENT_SIZE: number;
|
|
351
362
|
let MAX_OPS_PER_SCRIPT: number;
|
|
363
|
+
/** Total serialized script size. Anything larger fails SCRIPT_ERR_SCRIPT_SIZE. */
|
|
364
|
+
let MAX_SCRIPT_SIZE: number;
|
|
365
|
+
|
|
366
|
+
interface Limits {
|
|
367
|
+
maxScriptElementSize: number;
|
|
368
|
+
maximumElementSize: number;
|
|
369
|
+
maxOpsPerScript: number;
|
|
370
|
+
maxScriptSize: number;
|
|
371
|
+
}
|
|
352
372
|
|
|
353
373
|
/**
|
|
354
374
|
* Opt into post-Genesis BSV consensus limits (no caps on stack
|
|
355
|
-
* element size, script-number width,
|
|
356
|
-
* Interpreter-wide static state — call once at app
|
|
357
|
-
* Pass an explicit `max` (e.g. 64 KB) when verifying
|
|
358
|
-
* from untrusted sources.
|
|
375
|
+
* element size, script-number width, opcode count, or total script
|
|
376
|
+
* size). Mutates Interpreter-wide static state — call once at app
|
|
377
|
+
* startup. Pass an explicit `max` (e.g. 64 KB) when verifying
|
|
378
|
+
* scripts from untrusted sources.
|
|
359
379
|
*/
|
|
360
380
|
function useGenesisLimits(max?: number): typeof Interpreter;
|
|
381
|
+
/** Capture the four caps, for restoring with setLimits(). */
|
|
382
|
+
function getLimits(): Limits;
|
|
383
|
+
/** Restore caps captured by getLimits(). */
|
|
384
|
+
function setLimits(limits: Partial<Limits>): typeof Interpreter;
|
|
361
385
|
}
|
|
362
386
|
|
|
363
387
|
function Interpreter(): {
|
|
@@ -699,6 +723,24 @@ declare module '@smartledger/bsv' {
|
|
|
699
723
|
|
|
700
724
|
// -------- GDAF (Global Digital Attestation Framework) ---------------
|
|
701
725
|
|
|
726
|
+
/** A spendable output supplied to the anchoring helpers. */
|
|
727
|
+
export interface Utxo {
|
|
728
|
+
txId: string;
|
|
729
|
+
outputIndex: number;
|
|
730
|
+
script: string;
|
|
731
|
+
satoshis: number;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
export interface AnchorOptions {
|
|
735
|
+
/** UTXOs funding the anchor transaction. */
|
|
736
|
+
utxos?: Utxo[];
|
|
737
|
+
/**
|
|
738
|
+
* Serialised into the OP_RETURN: PUBLIC AND PERMANENT. Anchoring a PrivateKey, or
|
|
739
|
+
* any key-shaped field (`bn`, `wif`, `privateJwk`, `seed`, `xprv`, ...), throws.
|
|
740
|
+
*/
|
|
741
|
+
metadata?: object;
|
|
742
|
+
}
|
|
743
|
+
|
|
702
744
|
export class GDAF {
|
|
703
745
|
constructor(options?: {
|
|
704
746
|
attestationSigner?: object;
|
|
@@ -734,10 +776,15 @@ declare module '@smartledger/bsv' {
|
|
|
734
776
|
verifyMembershipProof(proof: object, validSet: string[]): boolean;
|
|
735
777
|
|
|
736
778
|
// Anchoring
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
779
|
+
/**
|
|
780
|
+
* Anchor options. `metadata` is JSON-serialised into the OP_RETURN and is therefore
|
|
781
|
+
* PUBLIC AND PERMANENT — anchoring anything key-shaped throws. A bare UTXO array is
|
|
782
|
+
* also accepted in place of this object.
|
|
783
|
+
*/
|
|
784
|
+
anchorCredential(credentialHash: string | Buffer, privateKey: PrivateKey, options?: AnchorOptions | Utxo[]): Promise<object>;
|
|
785
|
+
anchorBatch(credentialHashes: Array<string | Buffer>, privateKey: PrivateKey, options?: AnchorOptions | Utxo[]): Promise<object>;
|
|
786
|
+
registerDID(did: string, didDocument: object, privateKey: PrivateKey, options?: AnchorOptions | Utxo[]): Promise<object>;
|
|
787
|
+
revokeCredential(credentialId: string, reason: string, privateKey: PrivateKey, options?: AnchorOptions | Utxo[]): Promise<object>;
|
|
741
788
|
queryAnchoredData(hash: string): object;
|
|
742
789
|
|
|
743
790
|
// Schemas
|