@smartledger/bsv 9.0.0 → 9.1.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 +164 -0
- package/README.md +152 -1041
- package/STABILITY.md +134 -0
- package/bsv-gdaf.min.js +53 -48
- package/bsv-ltp.min.js +23 -18
- package/bsv-smartcontract.min.js +18 -18
- package/bsv.bundle.js +53 -48
- package/bsv.min.js +53 -48
- 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/docs/proposals/10.0.0-package-split.md +131 -0
- package/index.js +5 -0
- package/lib/block/merkleblock.js +53 -9
- package/lib/hdprivatekey.js +15 -0
- package/lib/script/interpreter.js +109 -1
- package/lib/smart_contract/builder.js +14 -0
- package/lib/util/deprecate.js +159 -0
- package/package.json +19 -82
- package/version.js +1 -1
- package/.mocharc.json +0 -5
- package/test/address.js +0 -629
- package/test/block/block.js +0 -239
- package/test/block/blockheader.js +0 -270
- package/test/block/merkleblock.js +0 -207
- package/test/build/bundle_crypto_shim.js +0 -104
- package/test/build/bundle_externals.js +0 -125
- package/test/build/bundle_smoke.js +0 -55
- package/test/build/esbuild_main.js +0 -65
- package/test/build/esm_wrapper.js +0 -97
- package/test/build/exports_resolution.js +0 -84
- package/test/build/version_sync.js +0 -14
- package/test/cli/smoke.js +0 -261
- package/test/consensus/base58-vectors.js +0 -120
- package/test/consensus/sv-script-vectors.js +0 -81
- package/test/consensus/sv-sighash-vectors.js +0 -51
- package/test/consensus/sv-tx-vectors.js +0 -48
- package/test/credentials-test.js +0 -332
- package/test/crypto/backend_selection.js +0 -126
- package/test/crypto/bn.js +0 -168
- package/test/crypto/ecdsa.js +0 -426
- package/test/crypto/elliptic-fixed.js +0 -61
- package/test/crypto/hash.browser.js +0 -121
- package/test/crypto/hash.js +0 -122
- package/test/crypto/point.js +0 -193
- package/test/crypto/random.js +0 -105
- package/test/crypto/security.js +0 -176
- package/test/crypto/shamir.js +0 -177
- package/test/crypto/shamir_rngcap.js +0 -29
- package/test/crypto/signature.js +0 -399
- package/test/data/bip69.json +0 -215
- package/test/data/bitcoin-sv/README.md +0 -170
- package/test/data/bitcoin-sv/base58_encode_decode.json +0 -14
- package/test/data/bitcoin-sv/base58_keys_invalid.json +0 -152
- package/test/data/bitcoin-sv/base58_keys_valid.json +0 -452
- package/test/data/bitcoin-sv/script_tests.json +0 -2591
- package/test/data/bitcoin-sv/sighash.json +0 -1003
- package/test/data/bitcoin-sv/tx_invalid.json +0 -285
- package/test/data/bitcoin-sv/tx_valid.json +0 -367
- package/test/data/bitcoind/base58_keys_invalid.json +0 -152
- package/test/data/bitcoind/base58_keys_valid.json +0 -452
- package/test/data/bitcoind/blocks.json +0 -27
- package/test/data/bitcoind/script_tests.json +0 -2244
- package/test/data/bitcoind/sig_canonical.json +0 -7
- package/test/data/bitcoind/sig_noncanonical.json +0 -22
- package/test/data/bitcoind/tx_invalid.json +0 -177
- package/test/data/bitcoind/tx_valid.json +0 -224
- package/test/data/blk86756-testnet.dat +0 -0
- package/test/data/blk86756-testnet.js +0 -12
- package/test/data/blk86756-testnet.json +0 -684
- package/test/data/brc220-batch-vector.json +0 -129
- package/test/data/ecdsa.json +0 -230
- package/test/data/merkleblocks.js +0 -486
- package/test/data/messages.json +0 -22
- package/test/data/sighash.json +0 -1004
- package/test/data/tx_creation.json +0 -85
- package/test/didweb/relationships.js +0 -144
- package/test/ecies/bitcore-ecies.js +0 -178
- package/test/ecies/electrum-ecies.js +0 -206
- package/test/encoding/base58.js +0 -131
- package/test/encoding/base58check.js +0 -145
- package/test/encoding/bufferreader.js +0 -328
- package/test/encoding/bufferwriter.js +0 -160
- package/test/encoding/varint.js +0 -104
- package/test/gdaf/anchor_no_key_leak.js +0 -146
- package/test/gdaf/anchor_spv.js +0 -163
- package/test/gdaf/canonicalization.js +0 -106
- package/test/gdaf/canonicalize.js +0 -140
- package/test/gdaf/zk_prover.js +0 -204
- package/test/hdkeys.js +0 -365
- package/test/hdprivatekey.js +0 -339
- package/test/hdpublickey.js +0 -293
- package/test/index.js +0 -16
- package/test/ltp/ids.js +0 -74
- package/test/ltp/right.js +0 -198
- package/test/ltp/verify_failclosed.js +0 -134
- package/test/message/message.js +0 -190
- package/test/mnemonic/data/fixtures.json +0 -300
- package/test/mnemonic/mnemonic.js +0 -277
- package/test/mnemonic/mocha.opts +0 -1
- package/test/mnemonic/pbkdf2.test.js +0 -43
- package/test/networks.js +0 -207
- package/test/notaryhash/batch_leaf.js +0 -140
- package/test/notaryhash/batch_vector.js +0 -282
- package/test/notaryhash/certificate.js +0 -249
- package/test/notaryhash/encoding.js +0 -186
- package/test/notaryhash/interop.js +0 -112
- package/test/notaryhash/merkle.js +0 -181
- package/test/notaryhash/script.js +0 -270
- package/test/notaryhash/verify.js +0 -342
- package/test/opcode.js +0 -186
- package/test/ordinals/bsv20.js +0 -337
- package/test/ordinals/inscription.js +0 -329
- package/test/ordinals/ordlock.js +0 -567
- package/test/privatekey.js +0 -540
- package/test/publickey.js +0 -411
- package/test/regressions.js +0 -215
- package/test/script/chronicle.js +0 -543
- package/test/script/defaults.js +0 -160
- package/test/script/genesis_limits.js +0 -203
- package/test/script/interpreter.js +0 -776
- package/test/script/script.js +0 -1259
- package/test/script/string_ops.js +0 -88
- package/test/security/fail_closed_contracts.js +0 -104
- package/test/security/threat_model_coverage.js +0 -31
- package/test/smart_contract/covenants.js +0 -207
- package/test/smart_contract/dsl_debugger.js +0 -92
- package/test/smart_contract/extract_field.js +0 -61
- package/test/smart_contract/nonenforcing_guard.js +0 -44
- package/test/smart_contract/ordinal_transfer.js +0 -71
- package/test/smart_contract/preimage.js +0 -98
- package/test/smart_contract/sighash_marketplace.js +0 -98
- package/test/smart_contract/token_generalized.js +0 -175
- package/test/spv/headerchain.js +0 -86
- package/test/spv/merkleproof.js +0 -133
- package/test/statuslist/failclosed.js +0 -78
- package/test/transaction/deserialize.js +0 -33
- package/test/transaction/input/input.js +0 -92
- package/test/transaction/input/multisig.js +0 -174
- package/test/transaction/input/multisigscripthash.js +0 -111
- package/test/transaction/input/publickey.js +0 -68
- package/test/transaction/input/publickeyhash.js +0 -59
- package/test/transaction/output.js +0 -185
- package/test/transaction/sighash.js +0 -91
- package/test/transaction/signature.js +0 -127
- package/test/transaction/transaction.js +0 -1299
- package/test/transaction/unspentoutput.js +0 -97
- package/test/types/dts_drift.js +0 -124
- package/test/types/surface_honesty.js +0 -102
- package/test/util/id.js +0 -72
- package/test/util/js.js +0 -76
- package/test/util/preconditions.js +0 -79
- package/test/vcjwt/interop.js +0 -126
|
@@ -65,7 +65,7 @@ var Interpreter = function Interpreter (obj) {
|
|
|
65
65
|
*
|
|
66
66
|
* Translated from bitcoind's VerifyScript
|
|
67
67
|
*/
|
|
68
|
-
Interpreter.prototype.
|
|
68
|
+
Interpreter.prototype._verifyCore = function (scriptSig, scriptPubkey, tx, nin, flags, satoshisBN) {
|
|
69
69
|
var Transaction = require('../transaction')
|
|
70
70
|
|
|
71
71
|
if (_.isUndefined(tx)) {
|
|
@@ -506,6 +506,114 @@ Interpreter.SCRIPT_UTXO_AFTER_CHRONICLE = (1 << 21)
|
|
|
506
506
|
*/
|
|
507
507
|
Interpreter.CHRONICLE_ACTIVATION_HEIGHT = 943816
|
|
508
508
|
|
|
509
|
+
/**
|
|
510
|
+
* Flags and *limits* are separate mechanisms. The era bits below are what the
|
|
511
|
+
* interpreter derives its element-size, script-size, opcode-count and
|
|
512
|
+
* script-number caps from — so a caller who hand-assembles a flag word out of
|
|
513
|
+
* named constants gets the feature opcodes they asked for while silently keeping
|
|
514
|
+
* the pre-Genesis caps. The script runs, which is what makes it hard to see;
|
|
515
|
+
* nothing looks wrong until a large push is rejected and the error names the
|
|
516
|
+
* push rather than the flags.
|
|
517
|
+
*
|
|
518
|
+
* Warning on every era-less verify() is not an option. Pre-Genesis validation is
|
|
519
|
+
* legitimate and common: the reference script_tests.json vectors are era-less by
|
|
520
|
+
* construction, and roughly three quarters of this library's own verify() calls
|
|
521
|
+
* are era-less for that reason. So the notice fires only on the intersection of
|
|
522
|
+
* two facts — an explicit era-less flag word AND a failure whose threshold is
|
|
523
|
+
* era-derived. Measured across the suite that combination accounts for ~5% of
|
|
524
|
+
* era-less failures, all of them genuine pre-Genesis vectors, and it is exactly
|
|
525
|
+
* the state a covenant author who guessed at flags ends up in.
|
|
526
|
+
*/
|
|
527
|
+
/**
|
|
528
|
+
* Failures whose threshold moved with an era: the cap that moved, and the flag
|
|
529
|
+
* that ACTUALLY lifts it.
|
|
530
|
+
*
|
|
531
|
+
* `lifts` is per-error on purpose. An earlier version tested a single ERA_FLAGS
|
|
532
|
+
* word containing all four era bits, which silenced the notice for the most likely
|
|
533
|
+
* form of the mistake: `SCRIPT_GENESIS` is the constant a hand-assembling caller
|
|
534
|
+
* reaches for — it is the one named "GENESIS" — but the size caps read
|
|
535
|
+
* `isAfterGenesis()`, which tests SCRIPT_UTXO_AFTER_GENESIS and nothing else. A
|
|
536
|
+
* flag word carrying SCRIPT_GENESIS alone still gets the 520-byte cap, still fails
|
|
537
|
+
* with PUSH_SIZE, and got no explanation.
|
|
538
|
+
*
|
|
539
|
+
* Each entry therefore names the bit its own cap is derived from:
|
|
540
|
+
* maxScriptElementSize/maxScriptSize/maxOpsPerScript -> isAfterGenesis()
|
|
541
|
+
* maxScriptNumLength -> isAfterChronicle(), then isAfterGenesis()
|
|
542
|
+
*/
|
|
543
|
+
Interpreter.ERA_SENSITIVE_ERRORS = {
|
|
544
|
+
SCRIPT_ERR_PUSH_SIZE: {
|
|
545
|
+
cap: 'stack element size (capped at 520 bytes pre-Genesis, unbounded after)',
|
|
546
|
+
lifts: Interpreter.SCRIPT_UTXO_AFTER_GENESIS
|
|
547
|
+
},
|
|
548
|
+
SCRIPT_ERR_SCRIPT_SIZE: {
|
|
549
|
+
cap: 'total script size (capped at 10,000 bytes pre-Genesis, unbounded after)',
|
|
550
|
+
lifts: Interpreter.SCRIPT_UTXO_AFTER_GENESIS
|
|
551
|
+
},
|
|
552
|
+
SCRIPT_ERR_OP_COUNT: {
|
|
553
|
+
cap: 'opcode count (capped at 201 pre-Genesis, unbounded after)',
|
|
554
|
+
lifts: Interpreter.SCRIPT_UTXO_AFTER_GENESIS
|
|
555
|
+
},
|
|
556
|
+
SCRIPT_ERR_SCRIPTNUM_OVERFLOW: {
|
|
557
|
+
cap: 'script number width (4 bytes pre-Genesis, 750,000 after Genesis, 32,000,000 after Chronicle)',
|
|
558
|
+
lifts: Interpreter.SCRIPT_UTXO_AFTER_GENESIS | Interpreter.SCRIPT_UTXO_AFTER_CHRONICLE
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* Every era bit, kept for callers that want to ask "is this flag word era-aware at
|
|
564
|
+
* all". NOT used to gate the diagnostic — see ERA_SENSITIVE_ERRORS.lifts.
|
|
565
|
+
*/
|
|
566
|
+
Interpreter.ERA_FLAGS =
|
|
567
|
+
Interpreter.SCRIPT_GENESIS |
|
|
568
|
+
Interpreter.SCRIPT_UTXO_AFTER_GENESIS |
|
|
569
|
+
Interpreter.SCRIPT_ENABLE_CHRONICLE |
|
|
570
|
+
Interpreter.SCRIPT_UTXO_AFTER_CHRONICLE
|
|
571
|
+
|
|
572
|
+
/** Set false to silence the notice. `eraHint` is still populated. */
|
|
573
|
+
Interpreter.eraDiagnostics =
|
|
574
|
+
!(typeof process !== 'undefined' && process.env && process.env.BSV_NO_ERA_HINT === '1')
|
|
575
|
+
|
|
576
|
+
var eraWarned = false
|
|
577
|
+
|
|
578
|
+
Interpreter.prototype._eraDiagnose = function (flags) {
|
|
579
|
+
// Only an EXPLICIT flag word can be wrong this way; omitting flags already
|
|
580
|
+
// resolves to current mainnet via currentConsensusFlags().
|
|
581
|
+
if (flags === undefined) return
|
|
582
|
+
var entry = Interpreter.ERA_SENSITIVE_ERRORS[this.errstr]
|
|
583
|
+
if (!entry) return
|
|
584
|
+
// Gate on the bit that lifts THIS cap, not on any era bit being present.
|
|
585
|
+
if ((flags & entry.lifts) !== 0) return
|
|
586
|
+
var cap = entry.cap
|
|
587
|
+
|
|
588
|
+
this.eraHint =
|
|
589
|
+
this.errstr + ' was produced under PRE-GENESIS limits: ' + cap + '.\n' +
|
|
590
|
+
'The flags passed to verify() (0x' + (flags >>> 0).toString(16) + ') carry no era bit, ' +
|
|
591
|
+
'so those caps applied regardless of which feature opcodes were enabled.\n' +
|
|
592
|
+
'To validate against BSV as it is today, omit the flags argument or pass ' +
|
|
593
|
+
'Interpreter.mainnetFlags(). If you are deliberately testing pre-Genesis ' +
|
|
594
|
+
'consensus this failure is correct — set Interpreter.eraDiagnostics = false ' +
|
|
595
|
+
'(or BSV_NO_ERA_HINT=1) to silence this.'
|
|
596
|
+
|
|
597
|
+
if (Interpreter.eraDiagnostics && !eraWarned) {
|
|
598
|
+
eraWarned = true
|
|
599
|
+
console.warn('\n[@smartledger/bsv] ' + this.eraHint + '\n(shown once per process)\n')
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
* Verify, then explain an era-caused failure if that is what happened.
|
|
605
|
+
* Wraps _verifyCore rather than editing its ten-odd early returns.
|
|
606
|
+
*/
|
|
607
|
+
Interpreter.prototype.verify = function (scriptSig, scriptPubkey, tx, nin, flags, satoshisBN) {
|
|
608
|
+
this.eraHint = null
|
|
609
|
+
var ok = this._verifyCore(scriptSig, scriptPubkey, tx, nin, flags, satoshisBN)
|
|
610
|
+
if (!ok) this._eraDiagnose(flags)
|
|
611
|
+
return ok
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
/** Test hook: forget that the notice has been shown. */
|
|
615
|
+
Interpreter._resetEraWarning = function () { eraWarned = false }
|
|
616
|
+
|
|
509
617
|
/**
|
|
510
618
|
* The script-verification flags matching BSV mainnet consensus.
|
|
511
619
|
*
|
|
@@ -20,6 +20,7 @@ var Hash = require('../crypto/hash')
|
|
|
20
20
|
var BN = require('../crypto/bn')
|
|
21
21
|
var Transaction = require('../transaction')
|
|
22
22
|
var Script = require('../script')
|
|
23
|
+
var deprecate = require('../util/deprecate')
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
26
|
* @deprecated NON-ENFORCING. `buildLockingScript` / `createCovenant` emit
|
|
@@ -57,6 +58,19 @@ function Builder(privateKey, options) {
|
|
|
57
58
|
// The scripts this class builds are non-enforcing (see the class @deprecated note).
|
|
58
59
|
// Refuse to hand one back as if it were a real covenant unless explicitly acknowledged.
|
|
59
60
|
Builder.prototype._assertEnforcingAllowed = function () {
|
|
61
|
+
if (this.allowNonEnforcing) {
|
|
62
|
+
// Opting in is legitimate (demos, tests, the docs' worked examples) but it
|
|
63
|
+
// is not permanent. Say so once, and here rather than at construction, so the
|
|
64
|
+
// notice fires only for callers actually taking a script away with them.
|
|
65
|
+
deprecate({
|
|
66
|
+
what: 'SmartContract.Builder ({ allowNonEnforcing: true })',
|
|
67
|
+
since: '9.1.0',
|
|
68
|
+
removeIn: '10.0.0',
|
|
69
|
+
use: 'SmartContract.policy(), or SmartContract.PushTx / Token / valueCovenant',
|
|
70
|
+
why: 'the scripts it emits reduce to plain P2PK and constrain nothing about the spend'
|
|
71
|
+
})
|
|
72
|
+
return
|
|
73
|
+
}
|
|
60
74
|
if (!this.allowNonEnforcing) {
|
|
61
75
|
throw new Error(
|
|
62
76
|
'SmartContract.Builder produces a NON-ENFORCING script (constant hash-lock → ' +
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Runtime deprecation notices.
|
|
5
|
+
*
|
|
6
|
+
* A semver major is a promise that the consumer's code breaks. Between 4.0.0
|
|
7
|
+
* (2026-05-31) and 9.0.0 (2026-08-21) this library made that promise six times,
|
|
8
|
+
* and the mechanism was almost always the same: an API that had become wrong was
|
|
9
|
+
* changed to `throw`, in the same release that decided it was wrong. Correct
|
|
10
|
+
* diagnosis, no warning period.
|
|
11
|
+
*
|
|
12
|
+
* `MerkleBlock#filterdTxsHash` was one of those and now delegates with a notice.
|
|
13
|
+
* `HDPrivateKey#derive` still throws deliberately: its replacements return
|
|
14
|
+
* different keys, so guessing on the caller's behalf risks funds. That is the
|
|
15
|
+
* narrow exception in STABILITY.md, not a gap in this module.
|
|
16
|
+
*
|
|
17
|
+
* The fix is not to keep bad APIs. It is to separate the moment we say "this is
|
|
18
|
+
* wrong" from the moment we break callers:
|
|
19
|
+
*
|
|
20
|
+
* minor mark it. Callers see a warning naming the replacement, and keep
|
|
21
|
+
* working. `removeIn` states the version that will break them.
|
|
22
|
+
* major remove it, on a schedule announced at least one minor in advance.
|
|
23
|
+
*
|
|
24
|
+
* Deprecating is therefore a NON-breaking act and belongs in a minor. That is
|
|
25
|
+
* what makes a long-lived 9.x possible: correctness fixes ship continuously,
|
|
26
|
+
* breakage batches into one planned major with a migration path already in the
|
|
27
|
+
* consumer's logs.
|
|
28
|
+
*
|
|
29
|
+
* Nothing here ever throws. A deprecation that throws is just a breaking change
|
|
30
|
+
* wearing a warning's name.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
var seen = Object.create(null)
|
|
34
|
+
|
|
35
|
+
/** Every notice fired this process, for tests and for `--audit`-style tooling. */
|
|
36
|
+
var fired = []
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Warnings are on unless explicitly silenced. Consumers who have logged the
|
|
40
|
+
* migration and do not want the noise set BSV_NO_DEPRECATION_WARNINGS=1; the
|
|
41
|
+
* record in `fired` is kept either way so tooling still sees it.
|
|
42
|
+
*/
|
|
43
|
+
// Guarded like every other process.env read in lib/ (see lib/smartutxo.js,
|
|
44
|
+
// lib/browser-utxo-manager.js). This module is inlined into every feature bundle,
|
|
45
|
+
// and `exports` publishes lib/ subpaths directly, so an unguarded read here is a
|
|
46
|
+
// ReferenceError in any browser bundler that does not shim `process`.
|
|
47
|
+
var enabled = !(typeof process !== 'undefined' && process.env &&
|
|
48
|
+
process.env.BSV_NO_DEPRECATION_WARNINGS === '1')
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* `what` is the one field with no sensible default: it is the string the notice is
|
|
52
|
+
* keyed and deduplicated on. Everything else degrades gracefully.
|
|
53
|
+
*/
|
|
54
|
+
function assertOpts (opts, caller) {
|
|
55
|
+
if (!opts || typeof opts.what !== 'string' || opts.what === '') {
|
|
56
|
+
throw new TypeError(caller + '() requires { what: string }')
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function format (opts) {
|
|
61
|
+
var msg = '[@smartledger/bsv] ' + opts.what + ' is deprecated'
|
|
62
|
+
if (opts.since) msg += ' since ' + opts.since
|
|
63
|
+
msg += '.'
|
|
64
|
+
if (opts.why) msg += ' ' + opts.why.charAt(0).toUpperCase() + opts.why.slice(1) + '.'
|
|
65
|
+
if (opts.use) msg += ' Use ' + opts.use + ' instead.'
|
|
66
|
+
msg += opts.removeIn
|
|
67
|
+
? ' It will be removed in ' + opts.removeIn + '.'
|
|
68
|
+
: ' A removal version has not been set; it will not be removed in a 9.x release.'
|
|
69
|
+
return msg
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Emit a deprecation notice at most once per `what` per process.
|
|
74
|
+
*
|
|
75
|
+
* @param {object} opts
|
|
76
|
+
* @param {string} opts.what the API being deprecated, as a caller writes it
|
|
77
|
+
* @param {string} [opts.since] version that deprecated it
|
|
78
|
+
* @param {string} [opts.removeIn] version that will remove it (a major)
|
|
79
|
+
* @param {string} [opts.use] the replacement, as a caller would write it
|
|
80
|
+
* @param {string} [opts.why] one clause; why it is wrong, not what to do
|
|
81
|
+
* @returns {boolean} true if this call emitted (false if already seen)
|
|
82
|
+
*/
|
|
83
|
+
function deprecate (opts) {
|
|
84
|
+
if (!opts || !opts.what) throw new TypeError('deprecate() requires { what }')
|
|
85
|
+
if (seen[opts.what]) return false
|
|
86
|
+
seen[opts.what] = true
|
|
87
|
+
|
|
88
|
+
var message = format(opts)
|
|
89
|
+
fired.push({
|
|
90
|
+
what: opts.what,
|
|
91
|
+
since: opts.since || null,
|
|
92
|
+
removeIn: opts.removeIn || null,
|
|
93
|
+
use: opts.use || null,
|
|
94
|
+
message: message
|
|
95
|
+
})
|
|
96
|
+
if (enabled) console.warn(message)
|
|
97
|
+
return true
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Wrap a function so calling it warns once, then behaves exactly as before.
|
|
102
|
+
* Preserves name, arity and `this`, so it is safe on prototype methods.
|
|
103
|
+
*
|
|
104
|
+
* Klass.prototype.old = deprecate.fn(Klass.prototype.old, {
|
|
105
|
+
* what: 'Klass#old', since: '9.1.0', removeIn: '10.0.0', use: 'Klass#new'
|
|
106
|
+
* })
|
|
107
|
+
*/
|
|
108
|
+
deprecate.fn = function (fn, opts) {
|
|
109
|
+
if (typeof fn !== 'function') throw new TypeError('deprecate.fn() requires a function')
|
|
110
|
+
// Validate HERE, not inside the wrapper. Deferring it meant `deprecate.fn(f)` wrapped
|
|
111
|
+
// cleanly and then threw on every subsequent call — turning a deprecation into the
|
|
112
|
+
// breaking change this module exists to avoid, at a call site far from the mistake.
|
|
113
|
+
// Wrapping is a one-time author action; failing there is loud, immediate and cheap.
|
|
114
|
+
assertOpts(opts, 'deprecate.fn')
|
|
115
|
+
var wrapper = function () {
|
|
116
|
+
deprecate(opts)
|
|
117
|
+
return fn.apply(this, arguments)
|
|
118
|
+
}
|
|
119
|
+
Object.defineProperty(wrapper, 'name', { value: fn.name, configurable: true })
|
|
120
|
+
Object.defineProperty(wrapper, 'length', { value: fn.length, configurable: true })
|
|
121
|
+
wrapper.__wrapped = fn
|
|
122
|
+
wrapper.__deprecation = opts
|
|
123
|
+
return wrapper
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Deprecate a property access (an alias namespace, a renamed field).
|
|
128
|
+
* Warns on first read; the value is computed once and cached.
|
|
129
|
+
*/
|
|
130
|
+
deprecate.property = function (target, name, get, opts) {
|
|
131
|
+
assertOpts(opts, 'deprecate.property')
|
|
132
|
+
var cached
|
|
133
|
+
var loaded = false
|
|
134
|
+
Object.defineProperty(target, name, {
|
|
135
|
+
configurable: true,
|
|
136
|
+
enumerable: true,
|
|
137
|
+
get: function () {
|
|
138
|
+
deprecate(opts)
|
|
139
|
+
if (!loaded) { cached = get(); loaded = true }
|
|
140
|
+
return cached
|
|
141
|
+
}
|
|
142
|
+
})
|
|
143
|
+
return target
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** Notices fired this process, in order. */
|
|
147
|
+
deprecate.fired = function () { return fired.slice() }
|
|
148
|
+
|
|
149
|
+
/** Silence output. The `fired` record is still kept. */
|
|
150
|
+
deprecate.setEnabled = function (v) { enabled = !!v }
|
|
151
|
+
deprecate.isEnabled = function () { return enabled }
|
|
152
|
+
|
|
153
|
+
/** Test hook: forget what has been warned about. */
|
|
154
|
+
deprecate.reset = function () {
|
|
155
|
+
seen = Object.create(null)
|
|
156
|
+
fired.length = 0
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
module.exports = deprecate
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smartledger/bsv",
|
|
3
|
-
"version": "9.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "9.1.1",
|
|
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",
|
|
7
7
|
"bugs": {
|
|
@@ -98,10 +98,12 @@
|
|
|
98
98
|
"test:browser": "echo 'Open tests/standalone-modules-test.html in browser for comprehensive testing'",
|
|
99
99
|
"test:bundle": "echo 'Open tests/bundle-completeness-test.html in browser to verify bundle completeness'",
|
|
100
100
|
"preimage:extract": "node examples/preimage/extract_preimage_bidirectional.js",
|
|
101
|
-
"prepublishOnly": "npm run build-all && npm run check:readme",
|
|
101
|
+
"prepublishOnly": "npm run build-all && npm run check:readme && npm run check:api",
|
|
102
102
|
"sync-cdn": "node scripts/sync-cdn-urls.js",
|
|
103
103
|
"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
|
-
"test:browser:ci": "node tests/browser-smoke-runner.js"
|
|
104
|
+
"test:browser:ci": "node tests/browser-smoke-runner.js",
|
|
105
|
+
"api:snapshot": "node scripts/api-surface.js",
|
|
106
|
+
"check:api": "mocha test/api_surface.js --no-config"
|
|
105
107
|
},
|
|
106
108
|
"unpkg": "bsv.min.js",
|
|
107
109
|
"jsdelivr": "bsv.min.js",
|
|
@@ -110,8 +112,6 @@
|
|
|
110
112
|
"index.js",
|
|
111
113
|
"index.mjs",
|
|
112
114
|
"version.js",
|
|
113
|
-
"test/",
|
|
114
|
-
".mocharc.json",
|
|
115
115
|
"lib/",
|
|
116
116
|
"utilities/*.js",
|
|
117
117
|
"utilities/README.md",
|
|
@@ -142,88 +142,25 @@
|
|
|
142
142
|
"LICENSE",
|
|
143
143
|
"README.md",
|
|
144
144
|
"SECURITY.md",
|
|
145
|
-
"CHANGELOG.md"
|
|
145
|
+
"CHANGELOG.md",
|
|
146
|
+
"STABILITY.md"
|
|
146
147
|
],
|
|
147
148
|
"keywords": [
|
|
148
|
-
"bitcoin",
|
|
149
149
|
"bitcoin-sv",
|
|
150
150
|
"bsv",
|
|
151
|
-
"
|
|
152
|
-
"
|
|
153
|
-
"legal-tokens",
|
|
154
|
-
"primitives-only",
|
|
155
|
-
"legal-compliance",
|
|
156
|
-
"property-rights",
|
|
157
|
-
"obligations",
|
|
158
|
-
"attestations",
|
|
159
|
-
"gdaf",
|
|
160
|
-
"global-digital-attestation",
|
|
161
|
-
"w3c-credentials",
|
|
162
|
-
"verifiable-credentials",
|
|
163
|
-
"decentralized-identity",
|
|
164
|
-
"shamir-secret-sharing",
|
|
165
|
-
"threshold-cryptography",
|
|
166
|
-
"cryptocurrency",
|
|
167
|
-
"blockchain",
|
|
168
|
-
"smart-contracts",
|
|
169
|
-
"defi",
|
|
151
|
+
"bitcoin-script",
|
|
152
|
+
"opcode",
|
|
170
153
|
"covenant",
|
|
171
|
-
"
|
|
172
|
-
"script-debugger",
|
|
173
|
-
"debug-tools",
|
|
174
|
-
"modular-loading",
|
|
175
|
-
"standalone-modules",
|
|
176
|
-
"elliptic-curve-fix",
|
|
177
|
-
"smartledger",
|
|
178
|
-
"transaction",
|
|
179
|
-
"address",
|
|
180
|
-
"signature",
|
|
181
|
-
"wallet",
|
|
182
|
-
"hd-wallet",
|
|
183
|
-
"mnemonic",
|
|
184
|
-
"ecies",
|
|
185
|
-
"encryption",
|
|
186
|
-
"message-signing",
|
|
187
|
-
"pushtx",
|
|
188
|
-
"pels",
|
|
154
|
+
"op-push-tx",
|
|
189
155
|
"bip143",
|
|
190
156
|
"preimage",
|
|
191
|
-
"
|
|
192
|
-
"
|
|
193
|
-
"
|
|
194
|
-
"
|
|
195
|
-
"
|
|
196
|
-
"
|
|
197
|
-
"
|
|
198
|
-
"multisig",
|
|
199
|
-
"timelock",
|
|
200
|
-
"conditional-scripts",
|
|
201
|
-
"utxo-management",
|
|
202
|
-
"ultra-low-fees",
|
|
203
|
-
"javascript-to-script",
|
|
204
|
-
"opcode-mapping",
|
|
205
|
-
"covenant-builder",
|
|
206
|
-
"script-simulation",
|
|
207
|
-
"bitcoin-script",
|
|
208
|
-
"asm-generation",
|
|
209
|
-
"advanced-features",
|
|
210
|
-
"script-development",
|
|
211
|
-
"blockchain-simulator",
|
|
212
|
-
"miner-simulator",
|
|
213
|
-
"testing-tools",
|
|
214
|
-
"development-framework",
|
|
215
|
-
"browser-compatible",
|
|
216
|
-
"nodejs-compatible",
|
|
217
|
-
"webpack-ready",
|
|
218
|
-
"cdn-ready",
|
|
219
|
-
"typescript-definitions",
|
|
220
|
-
"drop-in-replacement",
|
|
221
|
-
"performance-optimized",
|
|
222
|
-
"bip21",
|
|
223
|
-
"bip32",
|
|
224
|
-
"bip37",
|
|
225
|
-
"bip69",
|
|
226
|
-
"bip70"
|
|
157
|
+
"smart-contracts",
|
|
158
|
+
"script-interpreter",
|
|
159
|
+
"transaction",
|
|
160
|
+
"utxo",
|
|
161
|
+
"verifiable-credentials",
|
|
162
|
+
"did-web",
|
|
163
|
+
"legal-token-protocol"
|
|
227
164
|
],
|
|
228
165
|
"repository": {
|
|
229
166
|
"type": "git",
|
|
@@ -246,7 +183,7 @@
|
|
|
246
183
|
"chai": "6.2.2",
|
|
247
184
|
"create-hash": "^1.2.0",
|
|
248
185
|
"create-hmac": "^1.1.7",
|
|
249
|
-
"esbuild": "^0.28.
|
|
186
|
+
"esbuild": "^0.28.2",
|
|
250
187
|
"events": "^3.3.0",
|
|
251
188
|
"jose": "^5.10.0",
|
|
252
189
|
"mocha": "^11.8.0",
|
package/version.js
CHANGED