@smartledger/bsv 7.3.0 → 7.5.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 +100 -0
- package/README.md +38 -38
- package/bsv-gdaf.min.js +43 -43
- package/bsv-ltp.min.js +43 -43
- package/bsv-smartcontract.min.js +1 -1
- package/bsv.bundle.js +43 -43
- package/bsv.d.ts +37 -9
- package/bsv.min.js +43 -43
- 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/ordinals/README.md +15 -5
- package/lib/ordinals/bsv20.js +96 -3
- package/lib/script/interpreter.js +47 -6
- package/package.json +1 -1
- package/test/ordinals/bsv20.js +115 -0
- package/test/ordinals/inscription.js +94 -0
- package/test/ordinals/ordlock.js +10 -20
- 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/test/ordinals/bsv20.js
CHANGED
|
@@ -216,7 +216,122 @@ describe('Ordinals BSV-20 fungible tokens', function () {
|
|
|
216
216
|
B.isBsv20(B.buildMint({ address: address, tick: 'ORDI', amt: '1' })).should.equal(true)
|
|
217
217
|
B.isBsv20(B.buildTransfer({ address: address, id: OUTPOINT, amt: '1' })).should.equal(true)
|
|
218
218
|
B.isBsv20(B.buildDeployMint({ address: address, amt: '1000' })).should.equal(true)
|
|
219
|
+
B.isBsv20(B.buildBurn({ address: address, id: OUTPOINT, amt: '1' })).should.equal(true)
|
|
220
|
+
B.isBsv20(B.buildAuth({ address: address, id: OUTPOINT })).should.equal(true)
|
|
221
|
+
B.isBsv20(B.buildDeployAuth({ address: address, sym: 'STABLE' })).should.equal(true)
|
|
219
222
|
})
|
|
220
223
|
})
|
|
221
224
|
})
|
|
225
|
+
|
|
226
|
+
// BSV-21 authority model: deploy+auth creates no supply, an auth output carries the right
|
|
227
|
+
// to mint, and mint names its token by `id`. Previously only the fixed-supply deploy+mint
|
|
228
|
+
// path could be built, so these operations could be read but never written.
|
|
229
|
+
describe('BSV-21 authority operations', function () {
|
|
230
|
+
var OUTPOINT = '3b31'.repeat(16) + '_0'
|
|
231
|
+
|
|
232
|
+
it('mints by id, which requires an auth input on chain', function () {
|
|
233
|
+
var p = B.parseBsv20(B.buildMint({ address: address, id: OUTPOINT, amt: '1000000' }))
|
|
234
|
+
p.op.should.equal('mint')
|
|
235
|
+
p.id.should.equal(OUTPOINT)
|
|
236
|
+
p.amt.should.equal('1000000')
|
|
237
|
+
;(p.tick === undefined).should.equal(true)
|
|
238
|
+
})
|
|
239
|
+
|
|
240
|
+
it('leaves the v1 ticker mint byte-for-byte unchanged', function () {
|
|
241
|
+
var p = B.parseBsv20(B.buildMint({ address: address, tick: 'ORDI', amt: '1000' }))
|
|
242
|
+
JSON.stringify(p).should.equal('{"p":"bsv-20","op":"mint","tick":"ORDI","amt":"1000"}')
|
|
243
|
+
})
|
|
244
|
+
|
|
245
|
+
it('refuses to guess which token an operation means', function () {
|
|
246
|
+
// Naming both used to silently drop the tick — a different token, not a preference.
|
|
247
|
+
(function () {
|
|
248
|
+
B.buildMint({ address: address, tick: 'ORDI', id: OUTPOINT, amt: '1' })
|
|
249
|
+
}).should.throw(/not both/)
|
|
250
|
+
;(function () {
|
|
251
|
+
B.buildTransfer({ address: address, tick: 'ORDI', id: OUTPOINT, amt: '1' })
|
|
252
|
+
}).should.throw(/not both/)
|
|
253
|
+
;(function () {
|
|
254
|
+
B.buildMint({ address: address, amt: '1' })
|
|
255
|
+
}).should.throw(/requires `tick` \(v1\) or `id`/)
|
|
256
|
+
})
|
|
257
|
+
|
|
258
|
+
it('builds a burn', function () {
|
|
259
|
+
var p = B.parseBsv20(B.buildBurn({ address: address, id: OUTPOINT, amt: '5' }))
|
|
260
|
+
p.op.should.equal('burn')
|
|
261
|
+
p.id.should.equal(OUTPOINT)
|
|
262
|
+
p.amt.should.equal('5')
|
|
263
|
+
})
|
|
264
|
+
|
|
265
|
+
it('rejects a ticker burn, which the spec does not define', function () {
|
|
266
|
+
(function () {
|
|
267
|
+
B.buildBurn({ address: address, tick: 'ORDI', amt: '5' })
|
|
268
|
+
}).should.throw(/BSV-21 operation/)
|
|
269
|
+
})
|
|
270
|
+
|
|
271
|
+
it('builds deploy+auth with no supply', function () {
|
|
272
|
+
var p = B.parseBsv20(B.buildDeployAuth({ address: address, sym: 'STABLE', dec: 6 }))
|
|
273
|
+
p.op.should.equal('deploy+auth')
|
|
274
|
+
p.sym.should.equal('STABLE')
|
|
275
|
+
p.dec.should.equal('6')
|
|
276
|
+
;(p.amt === undefined).should.equal(true)
|
|
277
|
+
// Every field is optional.
|
|
278
|
+
B.parseBsv20(B.buildDeployAuth({ address: address })).op.should.equal('deploy+auth')
|
|
279
|
+
})
|
|
280
|
+
|
|
281
|
+
it('builds an auth output carrying no amount', function () {
|
|
282
|
+
var p = B.parseBsv20(B.buildAuth({ address: address, id: OUTPOINT }))
|
|
283
|
+
p.op.should.equal('auth')
|
|
284
|
+
p.id.should.equal(OUTPOINT)
|
|
285
|
+
;(p.amt === undefined).should.equal(true)
|
|
286
|
+
})
|
|
287
|
+
|
|
288
|
+
it('refuses to attach an amt where the spec forbids one', function () {
|
|
289
|
+
(function () {
|
|
290
|
+
B.buildAuth({ address: address, id: OUTPOINT, amt: '1' })
|
|
291
|
+
}).should.throw(/must not carry an amt/)
|
|
292
|
+
;(function () {
|
|
293
|
+
B.buildDeployAuth({ address: address, sym: 'X', amt: '1' })
|
|
294
|
+
}).should.throw(/must not carry an amt/)
|
|
295
|
+
})
|
|
296
|
+
|
|
297
|
+
it('applies the same amount rules as the other operations', function () {
|
|
298
|
+
(function () {
|
|
299
|
+
B.buildBurn({ address: address, id: OUTPOINT, amt: '0' })
|
|
300
|
+
}).should.throw(/greater than zero/)
|
|
301
|
+
;(function () {
|
|
302
|
+
B.buildBurn({ address: address, id: OUTPOINT, amt: '9'.repeat(26) })
|
|
303
|
+
}).should.throw(/exceeds the uint64 maximum/)
|
|
304
|
+
;(function () {
|
|
305
|
+
B.buildMint({ address: address, id: 'notanid', amt: '1' })
|
|
306
|
+
}).should.throw(/<txid>/)
|
|
307
|
+
;(function () {
|
|
308
|
+
B.buildDeployAuth({ address: address, sym: {} })
|
|
309
|
+
}).should.throw(/sym must be a string/)
|
|
310
|
+
})
|
|
311
|
+
|
|
312
|
+
it('builds 1-sat outputs for each new operation', function () {
|
|
313
|
+
var outs = [
|
|
314
|
+
B.createBurnOutput({ address: address, id: OUTPOINT, amt: '5' }),
|
|
315
|
+
B.createAuthOutput({ address: address, id: OUTPOINT }),
|
|
316
|
+
B.createDeployAuthOutput({ address: address, sym: 'STABLE' })
|
|
317
|
+
]
|
|
318
|
+
outs.forEach(function (o) {
|
|
319
|
+
o.satoshis.should.equal(1)
|
|
320
|
+
B.isBsv20(o.script).should.equal(true)
|
|
321
|
+
})
|
|
322
|
+
})
|
|
323
|
+
|
|
324
|
+
it('round-trips a full authority lifecycle', function () {
|
|
325
|
+
// deploy+auth -> auth output delegating mint rights -> mint by id -> burn.
|
|
326
|
+
var deploy = B.parseBsv20(B.buildDeployAuth({ address: address, sym: 'GOLD', dec: 8 }))
|
|
327
|
+
var auth = B.parseBsv20(B.buildAuth({ address: address, id: OUTPOINT }))
|
|
328
|
+
var mint = B.parseBsv20(B.buildMint({ address: address, id: OUTPOINT, amt: '1000' }))
|
|
329
|
+
var burn = B.parseBsv20(B.buildBurn({ address: address, id: OUTPOINT, amt: '400' }))
|
|
330
|
+
deploy.op.should.equal('deploy+auth')
|
|
331
|
+
auth.op.should.equal('auth')
|
|
332
|
+
mint.amt.should.equal('1000')
|
|
333
|
+
burn.amt.should.equal('400')
|
|
334
|
+
;[deploy, auth, mint, burn].forEach(function (p) { p.p.should.equal('bsv-20') })
|
|
335
|
+
})
|
|
336
|
+
})
|
|
222
337
|
})
|
|
@@ -222,4 +222,98 @@ describe('Ordinals inscriptions', function () {
|
|
|
222
222
|
}).satoshis.should.equal(1)
|
|
223
223
|
})
|
|
224
224
|
})
|
|
225
|
+
|
|
226
|
+
// The case that motivated making the script-size cap configurable: transferring a
|
|
227
|
+
// large inscription. The envelope is inert, so the spend is an ordinary P2PKH — but
|
|
228
|
+
// the interpreter could not even load the script, because total script size was a
|
|
229
|
+
// hard-coded 10,000 bytes that useGenesisLimits() did not lift.
|
|
230
|
+
describe('transferring a large inscription', function () {
|
|
231
|
+
var I = bsv.Script.Interpreter
|
|
232
|
+
var Sighash = bsv.Transaction.Sighash
|
|
233
|
+
var BN = bsv.crypto.BN
|
|
234
|
+
var SIGHASH = bsv.crypto.Signature.SIGHASH_ALL | bsv.crypto.Signature.SIGHASH_FORKID
|
|
235
|
+
var FLAGS = I.SCRIPT_VERIFY_STRICTENC | I.SCRIPT_ENABLE_SIGHASH_FORKID
|
|
236
|
+
var saved
|
|
237
|
+
|
|
238
|
+
beforeEach(function () { saved = I.getLimits() })
|
|
239
|
+
afterEach(function () { I.setLimits(saved) })
|
|
240
|
+
|
|
241
|
+
// A signed transfer of a `kb`-sized inscription to a new owner.
|
|
242
|
+
function transfer (kb) {
|
|
243
|
+
var owner = bsv.PrivateKey.fromBuffer(Buffer.alloc(32, 11))
|
|
244
|
+
var recipient = bsv.PrivateKey.fromBuffer(Buffer.alloc(32, 22))
|
|
245
|
+
var lock = Ord.buildInscription({
|
|
246
|
+
address: owner.toAddress(),
|
|
247
|
+
contentType: 'image/png',
|
|
248
|
+
content: bsv.crypto.Random.getRandomBuffer(kb * 1024)
|
|
249
|
+
})
|
|
250
|
+
var spend = new bsv.Transaction()
|
|
251
|
+
spend.addInput(new bsv.Transaction.Input({
|
|
252
|
+
prevTxId: 'aa'.repeat(32), outputIndex: 0, script: bsv.Script.empty()
|
|
253
|
+
}), lock, 1)
|
|
254
|
+
spend.addOutput(new bsv.Transaction.Output({
|
|
255
|
+
script: bsv.Script.buildPublicKeyHashOut(recipient.toAddress()), satoshis: 1
|
|
256
|
+
}))
|
|
257
|
+
// Sign over the FULL previous locking script — envelope included. That is the
|
|
258
|
+
// script code the network uses; signing the base lock alone yields a signature
|
|
259
|
+
// that verifies against its own preimage and nothing else.
|
|
260
|
+
var sig = Sighash.sign(spend, owner, SIGHASH, 0, lock, new BN(1), FLAGS)
|
|
261
|
+
var unlock = new bsv.Script()
|
|
262
|
+
.add(Buffer.concat([sig.toDER(), Buffer.from([SIGHASH])]))
|
|
263
|
+
.add(owner.toPublicKey().toBuffer())
|
|
264
|
+
spend.inputs[0].setScript(unlock)
|
|
265
|
+
return { lock: lock, unlock: unlock, spend: spend, sig: sig, owner: owner }
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function evaluate (t) {
|
|
269
|
+
var interp = new I()
|
|
270
|
+
var ok = interp.verify(t.unlock, t.lock, t.spend, 0, FLAGS, new BN(1))
|
|
271
|
+
return { ok: ok, err: interp.errstr }
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
it('cannot be evaluated under pre-Genesis limits — two separate caps bite', function () {
|
|
275
|
+
// Under 10 KB the script loads and the 520-byte push cap rejects the content...
|
|
276
|
+
var small = evaluate(transfer(3))
|
|
277
|
+
small.ok.should.equal(false)
|
|
278
|
+
small.err.should.equal('SCRIPT_ERR_PUSH_SIZE')
|
|
279
|
+
// ...over 10 KB it never gets that far: evaluate() refuses the script outright.
|
|
280
|
+
// This is the cap useGenesisLimits() could not lift.
|
|
281
|
+
var big = evaluate(transfer(50))
|
|
282
|
+
big.ok.should.equal(false)
|
|
283
|
+
big.err.should.equal('SCRIPT_ERR_SCRIPT_SIZE')
|
|
284
|
+
})
|
|
285
|
+
|
|
286
|
+
it('evaluates once Genesis limits are enabled', function () {
|
|
287
|
+
bsv.SmartContract.enableGenesis()
|
|
288
|
+
var t = transfer(50)
|
|
289
|
+
t.lock.toBuffer().length.should.be.above(10000) // past the old hard-coded cap
|
|
290
|
+
evaluate(t).ok.should.equal(true)
|
|
291
|
+
})
|
|
292
|
+
|
|
293
|
+
it('agrees with a direct signature check against the sighash', function () {
|
|
294
|
+
// The fallback used when the interpreter cannot run: verify the signature over
|
|
295
|
+
// the sighash directly. It must agree with the interpreter where both work.
|
|
296
|
+
bsv.SmartContract.enableGenesis()
|
|
297
|
+
var t = transfer(50)
|
|
298
|
+
var hash = Sighash.sighash(t.spend, SIGHASH, 0, t.lock, new BN(1), FLAGS)
|
|
299
|
+
var sigOk = bsv.crypto.ECDSA.verify(hash, t.sig, t.owner.toPublicKey(), 'little')
|
|
300
|
+
sigOk.should.equal(true)
|
|
301
|
+
evaluate(t).ok.should.equal(true)
|
|
302
|
+
})
|
|
303
|
+
|
|
304
|
+
it('rejects a signature made over the base lock instead of the full script', function () {
|
|
305
|
+
bsv.SmartContract.enableGenesis()
|
|
306
|
+
var t = transfer(50)
|
|
307
|
+
var baseLock = bsv.Script.buildPublicKeyHashOut(t.owner.toAddress())
|
|
308
|
+
var wrong = Sighash.sign(t.spend, t.owner, SIGHASH, 0, baseLock, new BN(1), FLAGS)
|
|
309
|
+
var hash = Sighash.sighash(t.spend, SIGHASH, 0, t.lock, new BN(1), FLAGS)
|
|
310
|
+
// Verifies against its own (wrong) preimage, but not the one the network checks.
|
|
311
|
+
bsv.crypto.ECDSA.verify(hash, wrong, t.owner.toPublicKey(), 'little').should.equal(false)
|
|
312
|
+
t.spend.inputs[0].setScript(new bsv.Script()
|
|
313
|
+
.add(Buffer.concat([wrong.toDER(), Buffer.from([SIGHASH])]))
|
|
314
|
+
.add(t.owner.toPublicKey().toBuffer()))
|
|
315
|
+
var interp = new I()
|
|
316
|
+
interp.verify(t.spend.inputs[0].script, t.lock, t.spend, 0, FLAGS, new BN(1)).should.equal(false)
|
|
317
|
+
})
|
|
318
|
+
})
|
|
225
319
|
})
|
package/test/ordinals/ordlock.js
CHANGED
|
@@ -28,13 +28,11 @@ describe('Ordinals OrdLock marketplace', function () {
|
|
|
28
28
|
var saved
|
|
29
29
|
|
|
30
30
|
before(function () {
|
|
31
|
-
saved =
|
|
31
|
+
saved = I.getLimits()
|
|
32
32
|
SC.enableGenesis()
|
|
33
33
|
})
|
|
34
34
|
after(function () {
|
|
35
|
-
I.
|
|
36
|
-
I.MAXIMUM_ELEMENT_SIZE = saved.num
|
|
37
|
-
I.MAX_OPS_PER_SCRIPT = saved.ops
|
|
35
|
+
I.setLimits(saved)
|
|
38
36
|
})
|
|
39
37
|
|
|
40
38
|
var seller = PrivateKey.fromRandom()
|
|
@@ -173,13 +171,11 @@ describe('Ordinals OrdLock — multi-output payments (royalties + marketplace fe
|
|
|
173
171
|
var I = bsv.Script.Interpreter
|
|
174
172
|
var saved
|
|
175
173
|
before(function () {
|
|
176
|
-
saved =
|
|
174
|
+
saved = I.getLimits()
|
|
177
175
|
SC.enableGenesis()
|
|
178
176
|
})
|
|
179
177
|
after(function () {
|
|
180
|
-
I.
|
|
181
|
-
I.MAXIMUM_ELEMENT_SIZE = saved.num
|
|
182
|
-
I.MAX_OPS_PER_SCRIPT = saved.ops
|
|
178
|
+
I.setLimits(saved)
|
|
183
179
|
})
|
|
184
180
|
|
|
185
181
|
var seller = PrivateKey.fromRandom()
|
|
@@ -290,13 +286,11 @@ describe('Ordinals OrdLock — buildPurchaseTx (end-to-end)', function () {
|
|
|
290
286
|
var I = bsv.Script.Interpreter
|
|
291
287
|
var saved
|
|
292
288
|
before(function () {
|
|
293
|
-
saved =
|
|
289
|
+
saved = I.getLimits()
|
|
294
290
|
SC.enableGenesis()
|
|
295
291
|
})
|
|
296
292
|
after(function () {
|
|
297
|
-
I.
|
|
298
|
-
I.MAXIMUM_ELEMENT_SIZE = saved.num
|
|
299
|
-
I.MAX_OPS_PER_SCRIPT = saved.ops
|
|
293
|
+
I.setLimits(saved)
|
|
300
294
|
})
|
|
301
295
|
|
|
302
296
|
var seller = PrivateKey.fromRandom()
|
|
@@ -386,13 +380,11 @@ describe('Ordinals OrdLock — full lifecycle (list -> buy / cancel)', function
|
|
|
386
380
|
var I = bsv.Script.Interpreter
|
|
387
381
|
var saved
|
|
388
382
|
before(function () {
|
|
389
|
-
saved =
|
|
383
|
+
saved = I.getLimits()
|
|
390
384
|
SC.enableGenesis()
|
|
391
385
|
})
|
|
392
386
|
after(function () {
|
|
393
|
-
I.
|
|
394
|
-
I.MAXIMUM_ELEMENT_SIZE = saved.num
|
|
395
|
-
I.MAX_OPS_PER_SCRIPT = saved.ops
|
|
387
|
+
I.setLimits(saved)
|
|
396
388
|
})
|
|
397
389
|
|
|
398
390
|
var owner = PrivateKey.fromRandom() // current ordinal owner / seller
|
|
@@ -486,13 +478,11 @@ describe('Ordinals OrdLock — code-review regressions', function () {
|
|
|
486
478
|
var I = bsv.Script.Interpreter
|
|
487
479
|
var saved
|
|
488
480
|
before(function () {
|
|
489
|
-
saved =
|
|
481
|
+
saved = I.getLimits()
|
|
490
482
|
SC.enableGenesis()
|
|
491
483
|
})
|
|
492
484
|
after(function () {
|
|
493
|
-
I.
|
|
494
|
-
I.MAXIMUM_ELEMENT_SIZE = saved.num
|
|
495
|
-
I.MAX_OPS_PER_SCRIPT = saved.ops
|
|
485
|
+
I.setLimits(saved)
|
|
496
486
|
})
|
|
497
487
|
|
|
498
488
|
var owner = PrivateKey.fromRandom()
|
|
@@ -15,16 +15,10 @@ describe('Interpreter post-Genesis limits', function () {
|
|
|
15
15
|
var saved
|
|
16
16
|
|
|
17
17
|
beforeEach(function () {
|
|
18
|
-
saved =
|
|
19
|
-
el: Interpreter.MAX_SCRIPT_ELEMENT_SIZE,
|
|
20
|
-
num: Interpreter.MAXIMUM_ELEMENT_SIZE,
|
|
21
|
-
ops: Interpreter.MAX_OPS_PER_SCRIPT
|
|
22
|
-
}
|
|
18
|
+
saved = Interpreter.getLimits()
|
|
23
19
|
})
|
|
24
20
|
afterEach(function () {
|
|
25
|
-
Interpreter.
|
|
26
|
-
Interpreter.MAXIMUM_ELEMENT_SIZE = saved.num
|
|
27
|
-
Interpreter.MAX_OPS_PER_SCRIPT = saved.ops
|
|
21
|
+
Interpreter.setLimits(saved)
|
|
28
22
|
})
|
|
29
23
|
|
|
30
24
|
it('keeps pre-Genesis defaults out of the box', function () {
|
|
@@ -77,4 +71,46 @@ describe('Interpreter post-Genesis limits', function () {
|
|
|
77
71
|
Interpreter.useGenesisLimits()
|
|
78
72
|
run(manyOps).should.equal(true)
|
|
79
73
|
})
|
|
74
|
+
// Total script size was a hard-coded 10,000 in evaluate(), so useGenesisLimits()
|
|
75
|
+
// could not lift it: any script over 10 KB failed SCRIPT_ERR_SCRIPT_SIZE regardless
|
|
76
|
+
// of what the caller asked for. That put every sizeable 1Sat Ordinals inscription
|
|
77
|
+
// out of reach of the interpreter entirely.
|
|
78
|
+
function scriptOfSize (bytes) {
|
|
79
|
+
// OP_DROP a single large push, then OP_1 — trivially true, but big.
|
|
80
|
+
return new Script()
|
|
81
|
+
.add(Buffer.alloc(bytes))
|
|
82
|
+
.add(Opcode.OP_DROP)
|
|
83
|
+
.add(Opcode.OP_1)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
it('exposes the total script size cap as a constant, defaulting to pre-Genesis', function () {
|
|
87
|
+
Interpreter.MAX_SCRIPT_SIZE.should.equal(10000)
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
it('rejects a >10 KB script under default limits', function () {
|
|
91
|
+
Interpreter.useGenesisLimits() // lift element/ops caps so SIZE is what is under test
|
|
92
|
+
Interpreter.MAX_SCRIPT_SIZE = 10000 // ...but keep the pre-Genesis size cap
|
|
93
|
+
var interp = new Interpreter()
|
|
94
|
+
interp.verify(new Script(), scriptOfSize(20 * 1024)).should.equal(false)
|
|
95
|
+
interp.errstr.should.equal('SCRIPT_ERR_SCRIPT_SIZE')
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
it('allows a >10 KB script after useGenesisLimits()', function () {
|
|
99
|
+
Interpreter.useGenesisLimits()
|
|
100
|
+
run(scriptOfSize(20 * 1024)).should.equal(true)
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
it('useGenesisLimits raises all four caps, and getLimits/setLimits round-trip', function () {
|
|
104
|
+
var before = Interpreter.getLimits()
|
|
105
|
+
before.maxScriptSize.should.equal(10000)
|
|
106
|
+
Interpreter.useGenesisLimits(64 * 1024)
|
|
107
|
+
var after = Interpreter.getLimits()
|
|
108
|
+
after.maxScriptElementSize.should.equal(64 * 1024)
|
|
109
|
+
after.maximumElementSize.should.equal(64 * 1024)
|
|
110
|
+
after.maxOpsPerScript.should.equal(64 * 1024)
|
|
111
|
+
after.maxScriptSize.should.equal(64 * 1024)
|
|
112
|
+
Interpreter.setLimits(before)
|
|
113
|
+
Interpreter.getLimits().maxScriptSize.should.equal(10000)
|
|
114
|
+
Interpreter.MAX_SCRIPT_ELEMENT_SIZE.should.equal(520)
|
|
115
|
+
})
|
|
80
116
|
})
|
|
@@ -24,13 +24,11 @@ describe('SmartContract covenants (v4.2.0)', function () {
|
|
|
24
24
|
var saved
|
|
25
25
|
|
|
26
26
|
before(function () {
|
|
27
|
-
saved =
|
|
27
|
+
saved = I.getLimits()
|
|
28
28
|
SC.enableGenesis() // OP_PUSH_TX covenants need post-Genesis limits
|
|
29
29
|
})
|
|
30
30
|
after(function () {
|
|
31
|
-
I.
|
|
32
|
-
I.MAXIMUM_ELEMENT_SIZE = saved.num
|
|
33
|
-
I.MAX_OPS_PER_SCRIPT = saved.ops
|
|
31
|
+
I.setLimits(saved)
|
|
34
32
|
})
|
|
35
33
|
|
|
36
34
|
var alice = PrivateKey.fromRandom()
|
|
@@ -17,13 +17,11 @@ describe('SmartContract covenant DSL + debugger (v4.5.0)', function () {
|
|
|
17
17
|
var I = bsv.Script.Interpreter
|
|
18
18
|
var saved
|
|
19
19
|
before(function () {
|
|
20
|
-
saved =
|
|
20
|
+
saved = I.getLimits()
|
|
21
21
|
SC.enableGenesis()
|
|
22
22
|
})
|
|
23
23
|
after(function () {
|
|
24
|
-
I.
|
|
25
|
-
I.MAXIMUM_ELEMENT_SIZE = saved.num
|
|
26
|
-
I.MAX_OPS_PER_SCRIPT = saved.ops
|
|
24
|
+
I.setLimits(saved)
|
|
27
25
|
})
|
|
28
26
|
|
|
29
27
|
var alice = PrivateKey.fromRandom()
|
|
@@ -29,13 +29,11 @@ describe('Ordinal-safe transfer (1-sat, SIGHASH_ALL)', function () {
|
|
|
29
29
|
var bob = PrivateKey.fromRandom()
|
|
30
30
|
|
|
31
31
|
before(function () {
|
|
32
|
-
saved =
|
|
32
|
+
saved = I.getLimits()
|
|
33
33
|
SC.enableGenesis()
|
|
34
34
|
})
|
|
35
35
|
after(function () {
|
|
36
|
-
I.
|
|
37
|
-
I.MAXIMUM_ELEMENT_SIZE = saved.num
|
|
38
|
-
I.MAX_OPS_PER_SCRIPT = saved.ops
|
|
36
|
+
I.setLimits(saved)
|
|
39
37
|
})
|
|
40
38
|
|
|
41
39
|
it('transferOrdinal recreates the 1-sat token among funding outputs and verifies', function () {
|
|
@@ -32,13 +32,11 @@ describe('Configurable SIGHASH — SINGLE|ANYONECANPAY marketplace covenant', fu
|
|
|
32
32
|
var flag = P.SIGHASH_SINGLE_ANYONECANPAY_FORKID // 0xc3
|
|
33
33
|
|
|
34
34
|
before(function () {
|
|
35
|
-
saved =
|
|
35
|
+
saved = I.getLimits()
|
|
36
36
|
SC.enableGenesis()
|
|
37
37
|
})
|
|
38
38
|
after(function () {
|
|
39
|
-
I.
|
|
40
|
-
I.MAXIMUM_ELEMENT_SIZE = saved.num
|
|
41
|
-
I.MAX_OPS_PER_SCRIPT = saved.ops
|
|
39
|
+
I.setLimits(saved)
|
|
42
40
|
})
|
|
43
41
|
|
|
44
42
|
// Lock: authenticate the pushed preimage under `flag`, assert the flag, succeed.
|
|
@@ -24,13 +24,11 @@ describe('SmartContract generalized token (pluggable auth + multi-output)', func
|
|
|
24
24
|
var saved
|
|
25
25
|
|
|
26
26
|
before(function () {
|
|
27
|
-
saved =
|
|
27
|
+
saved = I.getLimits()
|
|
28
28
|
SC.enableGenesis()
|
|
29
29
|
})
|
|
30
30
|
after(function () {
|
|
31
|
-
I.
|
|
32
|
-
I.MAXIMUM_ELEMENT_SIZE = saved.num
|
|
33
|
-
I.MAX_OPS_PER_SCRIPT = saved.ops
|
|
31
|
+
I.setLimits(saved)
|
|
34
32
|
})
|
|
35
33
|
|
|
36
34
|
function spendOf (lock, sats, outputs) {
|
package/version.js
CHANGED