@smartledger/bsv 9.11.2 → 9.13.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 +80 -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 +48 -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 +83 -12
- package/lib/spv/headerchain.js +31 -10
- package/lib/spv/index.js +1 -0
- package/lib/spv/merkleproof.js +177 -16
- package/package.json +1 -1
- package/version.js +1 -1
package/bsv.d.ts
CHANGED
|
@@ -983,21 +983,46 @@ 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
|
+
* This rules out a FREE forgery, not a cheap one: a header at difficulty 1 costs
|
|
992
|
+
* about 4.3e9 double-SHA256 attempts, against about 1e20 for a real mainnet header.
|
|
993
|
+
* Use `minWork`, or check the header against your own chain source.
|
|
994
|
+
*/
|
|
995
|
+
const POW_LIMIT_BITS: number;
|
|
986
996
|
/** A Merkle branch proof. All hashes are DISPLAY-order hex; a node of '*' means "duplicate the working hash". */
|
|
987
997
|
interface MerkleProof { txid: string; index: number; nodes: string[]; merkleRoot: string; }
|
|
988
998
|
interface InclusionParams {
|
|
989
999
|
txid: string;
|
|
990
1000
|
index: number;
|
|
991
1001
|
nodes: string[];
|
|
992
|
-
/** a bsv.BlockHeader, an 80-byte Buffer, or 80-byte hex. */
|
|
1002
|
+
/** a bsv.BlockHeader, an 80-byte Buffer, or 80-byte hex. Nothing else is a header. */
|
|
993
1003
|
header: any;
|
|
994
|
-
/** default true — require the header
|
|
1004
|
+
/** default true — require the header's proof of work, its declared target and `minWork`. */
|
|
995
1005
|
requirePow?: boolean;
|
|
1006
|
+
/**
|
|
1007
|
+
* The easiest target a header may declare, as compact bits (number or hex string)
|
|
1008
|
+
* or a BN target. Defaults to POW_LIMIT_BITS; regtest needs 0x207fffff. A header
|
|
1009
|
+
* declares its own target, so without this a forged header costs nothing to make.
|
|
1010
|
+
*/
|
|
1011
|
+
powLimit?: number | string | object;
|
|
1012
|
+
/** Minimum work the header must represent: 2^256 / (target + 1). Difficulty 1 is about 4.295e9. */
|
|
1013
|
+
minWork?: number | string | object;
|
|
996
1014
|
}
|
|
997
1015
|
interface InclusionResult {
|
|
998
1016
|
valid: boolean;
|
|
999
1017
|
rootMatches: boolean;
|
|
1018
|
+
/** The header meets the target it declares for itself. */
|
|
1000
1019
|
powValid: boolean;
|
|
1020
|
+
/** That declared target is no easier than `powLimit`. True when not checked. */
|
|
1021
|
+
targetAllowed: boolean;
|
|
1022
|
+
/** The work it represents is at least `minWork`. True when not checked. */
|
|
1023
|
+
workSufficient: boolean;
|
|
1024
|
+
/** Work the header represents, as a decimal string. */
|
|
1025
|
+
work: string;
|
|
1001
1026
|
merkleRoot: string;
|
|
1002
1027
|
blockHash: string;
|
|
1003
1028
|
}
|
|
@@ -1699,6 +1724,27 @@ declare module '@smartledger/bsv' {
|
|
|
1699
1724
|
* it to have it checked against `spv.blockHeight`.
|
|
1700
1725
|
*/
|
|
1701
1726
|
height?: number;
|
|
1727
|
+
/**
|
|
1728
|
+
* The block hash the caller's own chain source has at that height. No amount of
|
|
1729
|
+
* proof of work detects an orphan: a block that lost a race carries real work.
|
|
1730
|
+
*
|
|
1731
|
+
* Supplying this or `minWork` will be REQUIRED in 10.0.0: the proof-of-work limit
|
|
1732
|
+
* rules out a free forgery, not a cheap one — a header at difficulty 1 costs about
|
|
1733
|
+
* 4.3e9 hashes, while a real mainnet header carries about 1e20. Verifying with a
|
|
1734
|
+
* header alone warns since 9.13.0.
|
|
1735
|
+
*/
|
|
1736
|
+
blockHashAtHeight?: string;
|
|
1737
|
+
/**
|
|
1738
|
+
* The easiest target the header may declare, as compact bits. Defaults to
|
|
1739
|
+
* SPV.POW_LIMIT_BITS (difficulty 1); regtest headers need 0x207fffff.
|
|
1740
|
+
*/
|
|
1741
|
+
powLimit?: number | string;
|
|
1742
|
+
/**
|
|
1743
|
+
* Minimum work the header must represent. Difficulty 1 is about 4.295e9, and a
|
|
1744
|
+
* real mainnet header carries about 1e20. Either this or `blockHashAtHeight` will
|
|
1745
|
+
* be required in 10.0.0.
|
|
1746
|
+
*/
|
|
1747
|
+
minWork?: number | string;
|
|
1702
1748
|
/** Pass false only for test fixtures. Defaults to true. */
|
|
1703
1749
|
requirePow?: boolean;
|
|
1704
1750
|
}
|