@smartledger/bsv 7.8.0 → 7.9.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 +61 -0
- package/README.md +38 -38
- package/bsv-anchor.min.js +1 -1
- package/bsv-didweb.min.js +1 -1
- package/bsv-gdaf.min.js +47 -47
- package/bsv-ltp.min.js +47 -47
- package/bsv-mnemonic.min.js +1 -1
- package/bsv-shamir.min.js +1 -1
- package/bsv-smartcontract.min.js +6 -6
- package/bsv-statuslist.min.js +25 -25
- package/bsv-vcjwt.min.js +1 -1
- package/bsv.bundle.js +47 -47
- package/bsv.min.js +47 -47
- 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/script/interpreter.js +96 -31
- package/lib/smart_contract/covenant_helpers.js +12 -1
- package/package.json +1 -1
- package/test/script/chronicle.js +53 -10
- package/test/script/interpreter.js +9 -6
- package/test/script/string_ops.js +26 -10
- package/version.js +1 -1
|
@@ -7,10 +7,15 @@ var Interpreter = bsv.Script.Interpreter
|
|
|
7
7
|
var Script = bsv.Script
|
|
8
8
|
var Opcode = bsv.Opcode
|
|
9
9
|
var Transaction = bsv.Transaction
|
|
10
|
+
var CHRONICLE = Interpreter.SCRIPT_ENABLE_CHRONICLE
|
|
10
11
|
|
|
11
|
-
// OP_SUBSTR / OP_LEFT / OP_RIGHT —
|
|
12
|
-
//
|
|
13
|
-
//
|
|
12
|
+
// OP_SUBSTR / OP_LEFT / OP_RIGHT — Chronicle string opcodes at 0xb3/0xb4/0xb5.
|
|
13
|
+
//
|
|
14
|
+
// Every case here passes SCRIPT_ENABLE_CHRONICLE, because without it these
|
|
15
|
+
// bytes are UPGRADABLE NOPS, exactly as they are on a pre-Chronicle node. An
|
|
16
|
+
// earlier version of these tests ran them with flags=0 and passed, which is
|
|
17
|
+
// what hid the fact that the interpreter was executing them unconditionally —
|
|
18
|
+
// more permissively than the network.
|
|
14
19
|
describe('String opcodes OP_SUBSTR / OP_LEFT / OP_RIGHT', function () {
|
|
15
20
|
var DATA = Buffer.from('aabbccdd', 'hex')
|
|
16
21
|
|
|
@@ -20,14 +25,14 @@ describe('String opcodes OP_SUBSTR / OP_LEFT / OP_RIGHT', function () {
|
|
|
20
25
|
buildOps(lock)
|
|
21
26
|
lock.add(Buffer.from(expectedHex, 'hex')).add(Opcode.OP_EQUAL)
|
|
22
27
|
var interp = new Interpreter()
|
|
23
|
-
return interp.verify(new Script(), lock, new Transaction(), 0,
|
|
28
|
+
return interp.verify(new Script(), lock, new Transaction(), 0, CHRONICLE)
|
|
24
29
|
}
|
|
25
30
|
function errors (buildOps) {
|
|
26
31
|
var lock = new Script().add(DATA)
|
|
27
32
|
buildOps(lock)
|
|
28
33
|
var interp = new Interpreter()
|
|
29
34
|
var ok
|
|
30
|
-
try { ok = interp.verify(new Script(), lock, new Transaction(), 0,
|
|
35
|
+
try { ok = interp.verify(new Script(), lock, new Transaction(), 0, CHRONICLE) } catch (e) { ok = false }
|
|
31
36
|
return ok === false
|
|
32
37
|
}
|
|
33
38
|
|
|
@@ -52,12 +57,23 @@ describe('String opcodes OP_SUBSTR / OP_LEFT / OP_RIGHT', function () {
|
|
|
52
57
|
yields(function (s) { s.add(Opcode.OP_1).add(Opcode.OP_2).add(Opcode.OP_SUBSTR) }, 'bbcc').should.equal(true)
|
|
53
58
|
})
|
|
54
59
|
|
|
55
|
-
|
|
56
|
-
|
|
60
|
+
// The node ERRORS rather than clamping:
|
|
61
|
+
// if(len < 0 || len > size) return SCRIPT_ERR_INVALID_NUMBER_RANGE;
|
|
62
|
+
// Clamping made scripts the node rejects succeed here.
|
|
63
|
+
it('OP_LEFT rejects n greater than the length', function () {
|
|
64
|
+
errors(function (s) { s.add(Opcode.OP_10).add(Opcode.OP_LEFT) }).should.equal(true)
|
|
57
65
|
})
|
|
58
66
|
|
|
59
|
-
it('OP_RIGHT
|
|
60
|
-
|
|
67
|
+
it('OP_RIGHT rejects n greater than the length', function () {
|
|
68
|
+
errors(function (s) { s.add(Opcode.OP_10).add(Opcode.OP_RIGHT) }).should.equal(true)
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
it('is a no-op without SCRIPT_ENABLE_CHRONICLE, as a pre-Chronicle node is', function () {
|
|
72
|
+
const interp = new Interpreter()
|
|
73
|
+
const lock = new Script().add(DATA).add(Opcode.OP_2).add(Opcode.OP_LEFT)
|
|
74
|
+
interp.verify(new Script(), lock, new Transaction(), 0, 0).should.equal(true)
|
|
75
|
+
// Untouched: the opcode did nothing, so both operands survive.
|
|
76
|
+
interp.stack.length.should.equal(2)
|
|
61
77
|
})
|
|
62
78
|
|
|
63
79
|
it('rejects a negative size', function () {
|
|
@@ -67,6 +83,6 @@ describe('String opcodes OP_SUBSTR / OP_LEFT / OP_RIGHT', function () {
|
|
|
67
83
|
it('rejects OP_LEFT with too few stack items', function () {
|
|
68
84
|
var interp = new Interpreter()
|
|
69
85
|
var lock = new Script().add(Opcode.OP_LEFT) // nothing to operate on
|
|
70
|
-
interp.verify(new Script(), lock, new Transaction(), 0,
|
|
86
|
+
interp.verify(new Script(), lock, new Transaction(), 0, CHRONICLE).should.equal(false)
|
|
71
87
|
})
|
|
72
88
|
})
|
package/version.js
CHANGED