@smartledger/bsv 9.11.2 → 9.12.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 +52 -0
- package/README.md +19 -19
- package/bsv-gdaf.min.js +50 -50
- package/bsv-smartcontract.min.js +1 -1
- package/bsv.bundle.js +50 -50
- package/bsv.d.ts +35 -2
- package/bsv.min.js +50 -50
- package/docs/AUDIT_SCOPE.md +7 -7
- package/docs/MODULE_REFERENCE_COMPLETE.md +27 -27
- package/docs/advanced/UTXO_MANAGER_GUIDE.md +1 -1
- package/docs/audit-rfq/cure53.txt +2 -2
- package/docs/audit-rfq/ncc-group.txt +2 -2
- package/docs/audit-rfq/trail-of-bits.txt +2 -2
- 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/smartledger-anchor.js +4 -1
- package/lib/notaryhash/index.js +64 -12
- package/lib/spv/headerchain.js +31 -10
- package/lib/spv/index.js +1 -0
- package/lib/spv/merkleproof.js +168 -16
- package/package.json +1 -1
- package/version.js +1 -1
package/bsv.d.ts
CHANGED
|
@@ -983,21 +983,42 @@ declare module '@smartledger/bsv' {
|
|
|
983
983
|
// -------- SPV (trustless Merkle inclusion proofs) -------------------
|
|
984
984
|
|
|
985
985
|
export namespace SPV {
|
|
986
|
+
/**
|
|
987
|
+
* The easiest target a header may declare and still be believed: difficulty 1,
|
|
988
|
+
* 0x1d00ffff, the proof-of-work limit of mainnet and testnet. Regtest declares
|
|
989
|
+
* 0x207fffff, so regtest headers need `powLimit` set explicitly.
|
|
990
|
+
*/
|
|
991
|
+
const POW_LIMIT_BITS: number;
|
|
986
992
|
/** A Merkle branch proof. All hashes are DISPLAY-order hex; a node of '*' means "duplicate the working hash". */
|
|
987
993
|
interface MerkleProof { txid: string; index: number; nodes: string[]; merkleRoot: string; }
|
|
988
994
|
interface InclusionParams {
|
|
989
995
|
txid: string;
|
|
990
996
|
index: number;
|
|
991
997
|
nodes: string[];
|
|
992
|
-
/** a bsv.BlockHeader, an 80-byte Buffer, or 80-byte hex. */
|
|
998
|
+
/** a bsv.BlockHeader, an 80-byte Buffer, or 80-byte hex. Nothing else is a header. */
|
|
993
999
|
header: any;
|
|
994
|
-
/** default true — require the header
|
|
1000
|
+
/** default true — require the header's proof of work, its declared target and `minWork`. */
|
|
995
1001
|
requirePow?: boolean;
|
|
1002
|
+
/**
|
|
1003
|
+
* The easiest target a header may declare, as compact bits (number or hex string)
|
|
1004
|
+
* or a BN target. Defaults to POW_LIMIT_BITS; regtest needs 0x207fffff. A header
|
|
1005
|
+
* declares its own target, so without this a forged header costs nothing to make.
|
|
1006
|
+
*/
|
|
1007
|
+
powLimit?: number | string | object;
|
|
1008
|
+
/** Minimum work the header must represent: 2^256 / (target + 1). Difficulty 1 is about 4.295e9. */
|
|
1009
|
+
minWork?: number | string | object;
|
|
996
1010
|
}
|
|
997
1011
|
interface InclusionResult {
|
|
998
1012
|
valid: boolean;
|
|
999
1013
|
rootMatches: boolean;
|
|
1014
|
+
/** The header meets the target it declares for itself. */
|
|
1000
1015
|
powValid: boolean;
|
|
1016
|
+
/** That declared target is no easier than `powLimit`. True when not checked. */
|
|
1017
|
+
targetAllowed: boolean;
|
|
1018
|
+
/** The work it represents is at least `minWork`. True when not checked. */
|
|
1019
|
+
workSufficient: boolean;
|
|
1020
|
+
/** Work the header represents, as a decimal string. */
|
|
1021
|
+
work: string;
|
|
1001
1022
|
merkleRoot: string;
|
|
1002
1023
|
blockHash: string;
|
|
1003
1024
|
}
|
|
@@ -1699,6 +1720,18 @@ declare module '@smartledger/bsv' {
|
|
|
1699
1720
|
* it to have it checked against `spv.blockHeight`.
|
|
1700
1721
|
*/
|
|
1701
1722
|
height?: number;
|
|
1723
|
+
/**
|
|
1724
|
+
* The block hash the caller's own chain source has at that height. No amount of
|
|
1725
|
+
* proof of work detects an orphan: a block that lost a race carries real work.
|
|
1726
|
+
*/
|
|
1727
|
+
blockHashAtHeight?: string;
|
|
1728
|
+
/**
|
|
1729
|
+
* The easiest target the header may declare, as compact bits. Defaults to
|
|
1730
|
+
* SPV.POW_LIMIT_BITS (difficulty 1); regtest headers need 0x207fffff.
|
|
1731
|
+
*/
|
|
1732
|
+
powLimit?: number | string;
|
|
1733
|
+
/** Minimum work the header must represent. Difficulty 1 is about 4.295e9. */
|
|
1734
|
+
minWork?: number | string;
|
|
1702
1735
|
/** Pass false only for test fixtures. Defaults to true. */
|
|
1703
1736
|
requirePow?: boolean;
|
|
1704
1737
|
}
|