@neuraiproject/neurai-scripts 0.9.1 → 0.9.2
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/README.md +25 -9
- package/dist/NeuraiScripts.global.js +51 -32
- package/dist/NeuraiScripts.global.js.map +1 -1
- package/dist/browser.js +51 -32
- package/dist/browser.js.map +1 -1
- package/dist/core/opcodes.d.ts +12 -1
- package/dist/core/script-parser.d.ts +3 -10
- package/dist/covenants/partial-fill/script-pq.d.ts +1 -1
- package/dist/index.cjs +51 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +39 -6
- package/dist/index.js +51 -32
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +4 -4
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -136,10 +136,10 @@ interface PartialFillOrderPQParams {
|
|
|
136
136
|
/** Price in XNA satoshis per indivisible unit of the asset. */
|
|
137
137
|
unitPriceSats: bigint;
|
|
138
138
|
/**
|
|
139
|
-
* OP_TXHASH selector
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
139
|
+
* NIP-042 OP_TXHASH selector bound into the script as exactly two
|
|
140
|
+
* little-endian bytes. Default `0x1ff` commits all nine fields, including
|
|
141
|
+
* reference inputs. The seller signs `SHA256(OP_TXHASH(selector))` with
|
|
142
|
+
* their PQ key at cancel time.
|
|
143
143
|
*/
|
|
144
144
|
txHashSelector?: number;
|
|
145
145
|
/**
|
|
@@ -348,12 +348,16 @@ declare const CHAINCONTEXT_HEIGHT = 1;
|
|
|
348
348
|
declare const CHAINCONTEXT_MTP = 2;
|
|
349
349
|
declare const CHAINCONTEXT_CHAIN_ID = 3;
|
|
350
350
|
declare const OP_CHECKMERKLEINCLUSION = 193;
|
|
351
|
+
declare const OP_OUTPUTAUTHDEST = 194;
|
|
352
|
+
declare const OP_ZKVERIFY = 195;
|
|
353
|
+
declare const OP_INPUTFIELD = 196;
|
|
351
354
|
declare const OP_CAT = 126;
|
|
352
355
|
declare const OP_SPLIT = 183;
|
|
353
356
|
declare const OP_REVERSEBYTES = 188;
|
|
354
357
|
declare const TXFIELD_VALUE = 1;
|
|
355
358
|
declare const TXFIELD_AUTHSCRIPT_COMMITMENT = 2;
|
|
356
359
|
declare const TXFIELD_SCRIPTPUBKEY = 3;
|
|
360
|
+
declare const TXFIELD_AUTHDEST = 4;
|
|
357
361
|
declare const TXHASH_VERSION = 1;
|
|
358
362
|
declare const TXHASH_LOCKTIME = 2;
|
|
359
363
|
declare const TXHASH_INPUT_PREVOUTS = 4;
|
|
@@ -362,7 +366,8 @@ declare const TXHASH_OUTPUTS = 16;
|
|
|
362
366
|
declare const TXHASH_CURRENT_PREVOUT = 32;
|
|
363
367
|
declare const TXHASH_CURRENT_SEQUENCE = 64;
|
|
364
368
|
declare const TXHASH_CURRENT_INDEX = 128;
|
|
365
|
-
declare const
|
|
369
|
+
declare const TXHASH_REFINPUTS = 256;
|
|
370
|
+
declare const TXHASH_ALL = 511;
|
|
366
371
|
declare const ASSETFIELD_NAME = 1;
|
|
367
372
|
declare const ASSETFIELD_AMOUNT = 2;
|
|
368
373
|
declare const ASSETFIELD_UNITS = 3;
|
|
@@ -370,10 +375,17 @@ declare const ASSETFIELD_REISSUABLE = 4;
|
|
|
370
375
|
declare const ASSETFIELD_HAS_IPFS = 5;
|
|
371
376
|
declare const ASSETFIELD_IPFS_HASH = 6;
|
|
372
377
|
declare const ASSETFIELD_TYPE = 7;
|
|
378
|
+
declare const ASSETFIELD_MESSAGE = 8;
|
|
379
|
+
declare const MERKLE_SCHEME_BITCOIN_NEURAI = 1;
|
|
380
|
+
declare const MERKLE_SCHEME_SHA256_PLAIN = 2;
|
|
381
|
+
declare const MERKLE_SCHEME_KECCAK256_PLAIN = 3;
|
|
382
|
+
declare const MERKLE_SCHEME_BLAKE2B_PLAIN = 4;
|
|
383
|
+
declare const MERKLE_SCHEME_POSEIDON_BN254 = 5;
|
|
373
384
|
|
|
374
385
|
declare const opcodes_d_ASSETFIELD_AMOUNT: typeof ASSETFIELD_AMOUNT;
|
|
375
386
|
declare const opcodes_d_ASSETFIELD_HAS_IPFS: typeof ASSETFIELD_HAS_IPFS;
|
|
376
387
|
declare const opcodes_d_ASSETFIELD_IPFS_HASH: typeof ASSETFIELD_IPFS_HASH;
|
|
388
|
+
declare const opcodes_d_ASSETFIELD_MESSAGE: typeof ASSETFIELD_MESSAGE;
|
|
377
389
|
declare const opcodes_d_ASSETFIELD_NAME: typeof ASSETFIELD_NAME;
|
|
378
390
|
declare const opcodes_d_ASSETFIELD_REISSUABLE: typeof ASSETFIELD_REISSUABLE;
|
|
379
391
|
declare const opcodes_d_ASSETFIELD_TYPE: typeof ASSETFIELD_TYPE;
|
|
@@ -381,6 +393,11 @@ declare const opcodes_d_ASSETFIELD_UNITS: typeof ASSETFIELD_UNITS;
|
|
|
381
393
|
declare const opcodes_d_CHAINCONTEXT_CHAIN_ID: typeof CHAINCONTEXT_CHAIN_ID;
|
|
382
394
|
declare const opcodes_d_CHAINCONTEXT_HEIGHT: typeof CHAINCONTEXT_HEIGHT;
|
|
383
395
|
declare const opcodes_d_CHAINCONTEXT_MTP: typeof CHAINCONTEXT_MTP;
|
|
396
|
+
declare const opcodes_d_MERKLE_SCHEME_BITCOIN_NEURAI: typeof MERKLE_SCHEME_BITCOIN_NEURAI;
|
|
397
|
+
declare const opcodes_d_MERKLE_SCHEME_BLAKE2B_PLAIN: typeof MERKLE_SCHEME_BLAKE2B_PLAIN;
|
|
398
|
+
declare const opcodes_d_MERKLE_SCHEME_KECCAK256_PLAIN: typeof MERKLE_SCHEME_KECCAK256_PLAIN;
|
|
399
|
+
declare const opcodes_d_MERKLE_SCHEME_POSEIDON_BN254: typeof MERKLE_SCHEME_POSEIDON_BN254;
|
|
400
|
+
declare const opcodes_d_MERKLE_SCHEME_SHA256_PLAIN: typeof MERKLE_SCHEME_SHA256_PLAIN;
|
|
384
401
|
declare const opcodes_d_OP_0: typeof OP_0;
|
|
385
402
|
declare const opcodes_d_OP_0NOTEQUAL: typeof OP_0NOTEQUAL;
|
|
386
403
|
declare const opcodes_d_OP_1: typeof OP_1;
|
|
@@ -446,6 +463,7 @@ declare const opcodes_d_OP_IF: typeof OP_IF;
|
|
|
446
463
|
declare const opcodes_d_OP_IFDUP: typeof OP_IFDUP;
|
|
447
464
|
declare const opcodes_d_OP_INPUTASSETFIELD: typeof OP_INPUTASSETFIELD;
|
|
448
465
|
declare const opcodes_d_OP_INPUTCOUNT: typeof OP_INPUTCOUNT;
|
|
466
|
+
declare const opcodes_d_OP_INPUTFIELD: typeof OP_INPUTFIELD;
|
|
449
467
|
declare const opcodes_d_OP_INPUTVALUE: typeof OP_INPUTVALUE;
|
|
450
468
|
declare const opcodes_d_OP_KECCAK256: typeof OP_KECCAK256;
|
|
451
469
|
declare const opcodes_d_OP_LESSTHAN: typeof OP_LESSTHAN;
|
|
@@ -467,6 +485,7 @@ declare const opcodes_d_OP_NUMEQUALVERIFY: typeof OP_NUMEQUALVERIFY;
|
|
|
467
485
|
declare const opcodes_d_OP_NUMNOTEQUAL: typeof OP_NUMNOTEQUAL;
|
|
468
486
|
declare const opcodes_d_OP_OUTPUTASSETFIELD: typeof OP_OUTPUTASSETFIELD;
|
|
469
487
|
declare const opcodes_d_OP_OUTPUTAUTHCOMMITMENT: typeof OP_OUTPUTAUTHCOMMITMENT;
|
|
488
|
+
declare const opcodes_d_OP_OUTPUTAUTHDEST: typeof OP_OUTPUTAUTHDEST;
|
|
470
489
|
declare const opcodes_d_OP_OUTPUTCOUNT: typeof OP_OUTPUTCOUNT;
|
|
471
490
|
declare const opcodes_d_OP_OUTPUTSCRIPT: typeof OP_OUTPUTSCRIPT;
|
|
472
491
|
declare const opcodes_d_OP_OUTPUTVALUE: typeof OP_OUTPUTVALUE;
|
|
@@ -502,6 +521,8 @@ declare const opcodes_d_OP_TXLOCKTIME: typeof OP_TXLOCKTIME;
|
|
|
502
521
|
declare const opcodes_d_OP_VERIFY: typeof OP_VERIFY;
|
|
503
522
|
declare const opcodes_d_OP_WITHIN: typeof OP_WITHIN;
|
|
504
523
|
declare const opcodes_d_OP_XNA_ASSET: typeof OP_XNA_ASSET;
|
|
524
|
+
declare const opcodes_d_OP_ZKVERIFY: typeof OP_ZKVERIFY;
|
|
525
|
+
declare const opcodes_d_TXFIELD_AUTHDEST: typeof TXFIELD_AUTHDEST;
|
|
505
526
|
declare const opcodes_d_TXFIELD_AUTHSCRIPT_COMMITMENT: typeof TXFIELD_AUTHSCRIPT_COMMITMENT;
|
|
506
527
|
declare const opcodes_d_TXFIELD_SCRIPTPUBKEY: typeof TXFIELD_SCRIPTPUBKEY;
|
|
507
528
|
declare const opcodes_d_TXFIELD_VALUE: typeof TXFIELD_VALUE;
|
|
@@ -513,12 +534,14 @@ declare const opcodes_d_TXHASH_INPUT_PREVOUTS: typeof TXHASH_INPUT_PREVOUTS;
|
|
|
513
534
|
declare const opcodes_d_TXHASH_INPUT_SEQUENCES: typeof TXHASH_INPUT_SEQUENCES;
|
|
514
535
|
declare const opcodes_d_TXHASH_LOCKTIME: typeof TXHASH_LOCKTIME;
|
|
515
536
|
declare const opcodes_d_TXHASH_OUTPUTS: typeof TXHASH_OUTPUTS;
|
|
537
|
+
declare const opcodes_d_TXHASH_REFINPUTS: typeof TXHASH_REFINPUTS;
|
|
516
538
|
declare const opcodes_d_TXHASH_VERSION: typeof TXHASH_VERSION;
|
|
517
539
|
declare namespace opcodes_d {
|
|
518
540
|
export {
|
|
519
541
|
opcodes_d_ASSETFIELD_AMOUNT as ASSETFIELD_AMOUNT,
|
|
520
542
|
opcodes_d_ASSETFIELD_HAS_IPFS as ASSETFIELD_HAS_IPFS,
|
|
521
543
|
opcodes_d_ASSETFIELD_IPFS_HASH as ASSETFIELD_IPFS_HASH,
|
|
544
|
+
opcodes_d_ASSETFIELD_MESSAGE as ASSETFIELD_MESSAGE,
|
|
522
545
|
opcodes_d_ASSETFIELD_NAME as ASSETFIELD_NAME,
|
|
523
546
|
opcodes_d_ASSETFIELD_REISSUABLE as ASSETFIELD_REISSUABLE,
|
|
524
547
|
opcodes_d_ASSETFIELD_TYPE as ASSETFIELD_TYPE,
|
|
@@ -526,6 +549,11 @@ declare namespace opcodes_d {
|
|
|
526
549
|
opcodes_d_CHAINCONTEXT_CHAIN_ID as CHAINCONTEXT_CHAIN_ID,
|
|
527
550
|
opcodes_d_CHAINCONTEXT_HEIGHT as CHAINCONTEXT_HEIGHT,
|
|
528
551
|
opcodes_d_CHAINCONTEXT_MTP as CHAINCONTEXT_MTP,
|
|
552
|
+
opcodes_d_MERKLE_SCHEME_BITCOIN_NEURAI as MERKLE_SCHEME_BITCOIN_NEURAI,
|
|
553
|
+
opcodes_d_MERKLE_SCHEME_BLAKE2B_PLAIN as MERKLE_SCHEME_BLAKE2B_PLAIN,
|
|
554
|
+
opcodes_d_MERKLE_SCHEME_KECCAK256_PLAIN as MERKLE_SCHEME_KECCAK256_PLAIN,
|
|
555
|
+
opcodes_d_MERKLE_SCHEME_POSEIDON_BN254 as MERKLE_SCHEME_POSEIDON_BN254,
|
|
556
|
+
opcodes_d_MERKLE_SCHEME_SHA256_PLAIN as MERKLE_SCHEME_SHA256_PLAIN,
|
|
529
557
|
opcodes_d_OP_0 as OP_0,
|
|
530
558
|
opcodes_d_OP_0NOTEQUAL as OP_0NOTEQUAL,
|
|
531
559
|
opcodes_d_OP_1 as OP_1,
|
|
@@ -591,6 +619,7 @@ declare namespace opcodes_d {
|
|
|
591
619
|
opcodes_d_OP_IFDUP as OP_IFDUP,
|
|
592
620
|
opcodes_d_OP_INPUTASSETFIELD as OP_INPUTASSETFIELD,
|
|
593
621
|
opcodes_d_OP_INPUTCOUNT as OP_INPUTCOUNT,
|
|
622
|
+
opcodes_d_OP_INPUTFIELD as OP_INPUTFIELD,
|
|
594
623
|
opcodes_d_OP_INPUTVALUE as OP_INPUTVALUE,
|
|
595
624
|
opcodes_d_OP_KECCAK256 as OP_KECCAK256,
|
|
596
625
|
opcodes_d_OP_LESSTHAN as OP_LESSTHAN,
|
|
@@ -612,6 +641,7 @@ declare namespace opcodes_d {
|
|
|
612
641
|
opcodes_d_OP_NUMNOTEQUAL as OP_NUMNOTEQUAL,
|
|
613
642
|
opcodes_d_OP_OUTPUTASSETFIELD as OP_OUTPUTASSETFIELD,
|
|
614
643
|
opcodes_d_OP_OUTPUTAUTHCOMMITMENT as OP_OUTPUTAUTHCOMMITMENT,
|
|
644
|
+
opcodes_d_OP_OUTPUTAUTHDEST as OP_OUTPUTAUTHDEST,
|
|
615
645
|
opcodes_d_OP_OUTPUTCOUNT as OP_OUTPUTCOUNT,
|
|
616
646
|
opcodes_d_OP_OUTPUTSCRIPT as OP_OUTPUTSCRIPT,
|
|
617
647
|
opcodes_d_OP_OUTPUTVALUE as OP_OUTPUTVALUE,
|
|
@@ -647,6 +677,8 @@ declare namespace opcodes_d {
|
|
|
647
677
|
opcodes_d_OP_VERIFY as OP_VERIFY,
|
|
648
678
|
opcodes_d_OP_WITHIN as OP_WITHIN,
|
|
649
679
|
opcodes_d_OP_XNA_ASSET as OP_XNA_ASSET,
|
|
680
|
+
opcodes_d_OP_ZKVERIFY as OP_ZKVERIFY,
|
|
681
|
+
opcodes_d_TXFIELD_AUTHDEST as TXFIELD_AUTHDEST,
|
|
650
682
|
opcodes_d_TXFIELD_AUTHSCRIPT_COMMITMENT as TXFIELD_AUTHSCRIPT_COMMITMENT,
|
|
651
683
|
opcodes_d_TXFIELD_SCRIPTPUBKEY as TXFIELD_SCRIPTPUBKEY,
|
|
652
684
|
opcodes_d_TXFIELD_VALUE as TXFIELD_VALUE,
|
|
@@ -658,6 +690,7 @@ declare namespace opcodes_d {
|
|
|
658
690
|
opcodes_d_TXHASH_INPUT_SEQUENCES as TXHASH_INPUT_SEQUENCES,
|
|
659
691
|
opcodes_d_TXHASH_LOCKTIME as TXHASH_LOCKTIME,
|
|
660
692
|
opcodes_d_TXHASH_OUTPUTS as TXHASH_OUTPUTS,
|
|
693
|
+
opcodes_d_TXHASH_REFINPUTS as TXHASH_REFINPUTS,
|
|
661
694
|
opcodes_d_TXHASH_VERSION as TXHASH_VERSION,
|
|
662
695
|
};
|
|
663
696
|
}
|
|
@@ -1032,7 +1065,7 @@ declare function buildPartialFillScriptHex(params: PartialFillOrderParams): stri
|
|
|
1032
1065
|
* `./script.ts` for the three-branch layout description.
|
|
1033
1066
|
*/
|
|
1034
1067
|
|
|
1035
|
-
declare const DEFAULT_PQ_TXHASH_SELECTOR =
|
|
1068
|
+
declare const DEFAULT_PQ_TXHASH_SELECTOR = 511;
|
|
1036
1069
|
/**
|
|
1037
1070
|
* Build the scriptPubKey of a PQ Partial-Fill Sell Order covenant UTXO.
|
|
1038
1071
|
*/
|
package/dist/index.js
CHANGED
|
@@ -241,20 +241,27 @@ const CHAINCONTEXT_CHAIN_ID = 0x03;
|
|
|
241
241
|
// Native Merkle inclusion verifier. Consumes (leaf, scheme_id, proof,
|
|
242
242
|
// root) and pushes a boolean. Flag off → bad-opcode.
|
|
243
243
|
const OP_CHECKMERKLEINCLUSION = 0xc1;
|
|
244
|
+
// NIP-041: (outputIndex -- witnessVersion || 32-byte program).
|
|
245
|
+
const OP_OUTPUTAUTHDEST = 0xc2;
|
|
246
|
+
// NIP-018: verifies an AuthScript proof and returns a boolean.
|
|
247
|
+
const OP_ZKVERIFY = 0xc3;
|
|
248
|
+
// NIP-043: spent-input field introspection, distinct from reference inputs.
|
|
249
|
+
const OP_INPUTFIELD = 0xc4;
|
|
244
250
|
// ---------- Byte manipulation (DePIN-Test) ----------
|
|
245
251
|
const OP_CAT = 0x7e;
|
|
246
252
|
const OP_SPLIT = 0xb7;
|
|
247
253
|
const OP_REVERSEBYTES = 0xbc;
|
|
248
254
|
// ---------- Selectors for OP_TXFIELD / OP_REFINPUTFIELD ----------
|
|
249
|
-
//
|
|
250
|
-
//
|
|
255
|
+
// OP_TXFIELD, OP_INPUTFIELD and OP_REFINPUTFIELD share selectors 0x01..0x03.
|
|
256
|
+
// NIP-041 adds 0x04 for a strict 33-byte AuthScript destination.
|
|
251
257
|
const TXFIELD_VALUE = 0x01;
|
|
252
258
|
const TXFIELD_AUTHSCRIPT_COMMITMENT = 0x02;
|
|
253
259
|
const TXFIELD_SCRIPTPUBKEY = 0x03;
|
|
260
|
+
const TXFIELD_AUTHDEST = 0x04;
|
|
254
261
|
// ---------- Bitmask selectors for OP_TXHASH ----------
|
|
255
|
-
//
|
|
256
|
-
//
|
|
257
|
-
//
|
|
262
|
+
// NIP-042 requires a two-byte little-endian selector, even for low masks.
|
|
263
|
+
// Bits 0..8 select fields for the tagged NeuraiTxHash digest. Valid masks
|
|
264
|
+
// are 0x001..0x1ff; zero and all higher bits are rejected by consensus.
|
|
258
265
|
const TXHASH_VERSION = 0x01;
|
|
259
266
|
const TXHASH_LOCKTIME = 0x02;
|
|
260
267
|
const TXHASH_INPUT_PREVOUTS = 0x04;
|
|
@@ -263,12 +270,11 @@ const TXHASH_OUTPUTS = 0x10;
|
|
|
263
270
|
const TXHASH_CURRENT_PREVOUT = 0x20;
|
|
264
271
|
const TXHASH_CURRENT_SEQUENCE = 0x40;
|
|
265
272
|
const TXHASH_CURRENT_INDEX = 0x80;
|
|
266
|
-
const
|
|
273
|
+
const TXHASH_REFINPUTS = 0x100;
|
|
274
|
+
const TXHASH_ALL = 0x1ff;
|
|
267
275
|
// ---------- Selectors for OP_OUTPUTASSETFIELD / OP_INPUTASSETFIELD / OP_REFINPUTASSETFIELD ----------
|
|
268
|
-
// All three opcodes share
|
|
269
|
-
//
|
|
270
|
-
// payload; 0x07 is the asset operation type. (This matches the asset-op
|
|
271
|
-
// encoding in `src/assets/assets.cpp` and the NIP spec §3.1.)
|
|
276
|
+
// All three opcodes share this selector table. 0x08 is gated by NIP-043
|
|
277
|
+
// and extracts the optional transfer message from a strict asset wrapper.
|
|
272
278
|
const ASSETFIELD_NAME = 0x01;
|
|
273
279
|
const ASSETFIELD_AMOUNT = 0x02;
|
|
274
280
|
const ASSETFIELD_UNITS = 0x03;
|
|
@@ -276,12 +282,20 @@ const ASSETFIELD_REISSUABLE = 0x04;
|
|
|
276
282
|
const ASSETFIELD_HAS_IPFS = 0x05;
|
|
277
283
|
const ASSETFIELD_IPFS_HASH = 0x06;
|
|
278
284
|
const ASSETFIELD_TYPE = 0x07;
|
|
285
|
+
const ASSETFIELD_MESSAGE = 0x08;
|
|
286
|
+
// NIP-031/043 Merkle inclusion scheme identifiers.
|
|
287
|
+
const MERKLE_SCHEME_BITCOIN_NEURAI = 0x01;
|
|
288
|
+
const MERKLE_SCHEME_SHA256_PLAIN = 0x02;
|
|
289
|
+
const MERKLE_SCHEME_KECCAK256_PLAIN = 0x03;
|
|
290
|
+
const MERKLE_SCHEME_BLAKE2B_PLAIN = 0x04;
|
|
291
|
+
const MERKLE_SCHEME_POSEIDON_BN254 = 0x05;
|
|
279
292
|
|
|
280
293
|
var opcodes = /*#__PURE__*/Object.freeze({
|
|
281
294
|
__proto__: null,
|
|
282
295
|
ASSETFIELD_AMOUNT: ASSETFIELD_AMOUNT,
|
|
283
296
|
ASSETFIELD_HAS_IPFS: ASSETFIELD_HAS_IPFS,
|
|
284
297
|
ASSETFIELD_IPFS_HASH: ASSETFIELD_IPFS_HASH,
|
|
298
|
+
ASSETFIELD_MESSAGE: ASSETFIELD_MESSAGE,
|
|
285
299
|
ASSETFIELD_NAME: ASSETFIELD_NAME,
|
|
286
300
|
ASSETFIELD_REISSUABLE: ASSETFIELD_REISSUABLE,
|
|
287
301
|
ASSETFIELD_TYPE: ASSETFIELD_TYPE,
|
|
@@ -289,6 +303,11 @@ var opcodes = /*#__PURE__*/Object.freeze({
|
|
|
289
303
|
CHAINCONTEXT_CHAIN_ID: CHAINCONTEXT_CHAIN_ID,
|
|
290
304
|
CHAINCONTEXT_HEIGHT: CHAINCONTEXT_HEIGHT,
|
|
291
305
|
CHAINCONTEXT_MTP: CHAINCONTEXT_MTP,
|
|
306
|
+
MERKLE_SCHEME_BITCOIN_NEURAI: MERKLE_SCHEME_BITCOIN_NEURAI,
|
|
307
|
+
MERKLE_SCHEME_BLAKE2B_PLAIN: MERKLE_SCHEME_BLAKE2B_PLAIN,
|
|
308
|
+
MERKLE_SCHEME_KECCAK256_PLAIN: MERKLE_SCHEME_KECCAK256_PLAIN,
|
|
309
|
+
MERKLE_SCHEME_POSEIDON_BN254: MERKLE_SCHEME_POSEIDON_BN254,
|
|
310
|
+
MERKLE_SCHEME_SHA256_PLAIN: MERKLE_SCHEME_SHA256_PLAIN,
|
|
292
311
|
OP_0: OP_0,
|
|
293
312
|
OP_0NOTEQUAL: OP_0NOTEQUAL,
|
|
294
313
|
OP_1: OP_1,
|
|
@@ -354,6 +373,7 @@ var opcodes = /*#__PURE__*/Object.freeze({
|
|
|
354
373
|
OP_IFDUP: OP_IFDUP,
|
|
355
374
|
OP_INPUTASSETFIELD: OP_INPUTASSETFIELD,
|
|
356
375
|
OP_INPUTCOUNT: OP_INPUTCOUNT,
|
|
376
|
+
OP_INPUTFIELD: OP_INPUTFIELD,
|
|
357
377
|
OP_INPUTVALUE: OP_INPUTVALUE,
|
|
358
378
|
OP_KECCAK256: OP_KECCAK256,
|
|
359
379
|
OP_LESSTHAN: OP_LESSTHAN,
|
|
@@ -375,6 +395,7 @@ var opcodes = /*#__PURE__*/Object.freeze({
|
|
|
375
395
|
OP_NUMNOTEQUAL: OP_NUMNOTEQUAL,
|
|
376
396
|
OP_OUTPUTASSETFIELD: OP_OUTPUTASSETFIELD,
|
|
377
397
|
OP_OUTPUTAUTHCOMMITMENT: OP_OUTPUTAUTHCOMMITMENT,
|
|
398
|
+
OP_OUTPUTAUTHDEST: OP_OUTPUTAUTHDEST,
|
|
378
399
|
OP_OUTPUTCOUNT: OP_OUTPUTCOUNT,
|
|
379
400
|
OP_OUTPUTSCRIPT: OP_OUTPUTSCRIPT,
|
|
380
401
|
OP_OUTPUTVALUE: OP_OUTPUTVALUE,
|
|
@@ -410,6 +431,8 @@ var opcodes = /*#__PURE__*/Object.freeze({
|
|
|
410
431
|
OP_VERIFY: OP_VERIFY,
|
|
411
432
|
OP_WITHIN: OP_WITHIN,
|
|
412
433
|
OP_XNA_ASSET: OP_XNA_ASSET,
|
|
434
|
+
OP_ZKVERIFY: OP_ZKVERIFY,
|
|
435
|
+
TXFIELD_AUTHDEST: TXFIELD_AUTHDEST,
|
|
413
436
|
TXFIELD_AUTHSCRIPT_COMMITMENT: TXFIELD_AUTHSCRIPT_COMMITMENT,
|
|
414
437
|
TXFIELD_SCRIPTPUBKEY: TXFIELD_SCRIPTPUBKEY,
|
|
415
438
|
TXFIELD_VALUE: TXFIELD_VALUE,
|
|
@@ -421,6 +444,7 @@ var opcodes = /*#__PURE__*/Object.freeze({
|
|
|
421
444
|
TXHASH_INPUT_SEQUENCES: TXHASH_INPUT_SEQUENCES,
|
|
422
445
|
TXHASH_LOCKTIME: TXHASH_LOCKTIME,
|
|
423
446
|
TXHASH_OUTPUTS: TXHASH_OUTPUTS,
|
|
447
|
+
TXHASH_REFINPUTS: TXHASH_REFINPUTS,
|
|
424
448
|
TXHASH_VERSION: TXHASH_VERSION
|
|
425
449
|
});
|
|
426
450
|
|
|
@@ -2096,16 +2120,9 @@ function readPushPositiveInt(c, label) {
|
|
|
2096
2120
|
return decodeScriptNum(data, label);
|
|
2097
2121
|
}
|
|
2098
2122
|
/**
|
|
2099
|
-
* Read a
|
|
2100
|
-
*
|
|
2101
|
-
*
|
|
2102
|
-
* - `0x01 <byte>` raw 1-byte push → any value 1..255.
|
|
2103
|
-
*
|
|
2104
|
-
* Values 0x80..0xff MUST use the raw-push form; the CScriptNum encoding
|
|
2105
|
-
* would need a 0x00 padding byte and become 2 bytes on-stack, which
|
|
2106
|
-
* consensus `OP_TXHASH` rejects. The builder in `script-pq.ts` emits the
|
|
2107
|
-
* raw-push form unconditionally; the parser stays lenient so covenants
|
|
2108
|
-
* built by older tools (using OP_N for small values) still round-trip.
|
|
2123
|
+
* Read a one-byte unsigned selector. This accepts OP_1..OP_16 shorthand
|
|
2124
|
+
* and a raw one-byte push for scripts that permit either form. NIP-042
|
|
2125
|
+
* TXHASH masks use a separate strict two-byte parser.
|
|
2109
2126
|
*/
|
|
2110
2127
|
function readPushUint8(c, label) {
|
|
2111
2128
|
if (c.pos >= c.bytes.length) {
|
|
@@ -2424,7 +2441,7 @@ function buildPartialFillScriptHex(params) {
|
|
|
2424
2441
|
* `./script.ts` for the three-branch layout description.
|
|
2425
2442
|
*/
|
|
2426
2443
|
const ASSET_NAME_MAX = 32;
|
|
2427
|
-
const DEFAULT_PQ_TXHASH_SELECTOR =
|
|
2444
|
+
const DEFAULT_PQ_TXHASH_SELECTOR = 0x1ff;
|
|
2428
2445
|
function assertCommitment(commitment) {
|
|
2429
2446
|
if (!(commitment instanceof Uint8Array) || commitment.length !== 32) {
|
|
2430
2447
|
throw new Error('pubKeyCommitment must be a 32-byte Uint8Array (SHA256 of pubKey)');
|
|
@@ -2453,11 +2470,11 @@ function assertPrice(priceSats) {
|
|
|
2453
2470
|
}
|
|
2454
2471
|
}
|
|
2455
2472
|
function assertSelector(selector) {
|
|
2456
|
-
if (!Number.isInteger(selector) || selector < 0 || selector >
|
|
2457
|
-
throw new Error('txHashSelector must be
|
|
2473
|
+
if (!Number.isInteger(selector) || selector < 0 || selector > 0x1ff) {
|
|
2474
|
+
throw new Error('txHashSelector must be in the NIP-042 range (0x001..0x1ff)');
|
|
2458
2475
|
}
|
|
2459
2476
|
if (selector === 0) {
|
|
2460
|
-
throw new Error('txHashSelector
|
|
2477
|
+
throw new Error('txHashSelector 0x000 is rejected by OP_TXHASH');
|
|
2461
2478
|
}
|
|
2462
2479
|
}
|
|
2463
2480
|
/**
|
|
@@ -2477,16 +2494,14 @@ function buildPartialFillScriptPQ(params) {
|
|
|
2477
2494
|
// scriptSig: <sigPQ> <pubKeyPQ> <1>
|
|
2478
2495
|
// After OP_IF consumes the flag: [ sig, pubKey ]
|
|
2479
2496
|
//
|
|
2480
|
-
//
|
|
2481
|
-
//
|
|
2482
|
-
// 1..127 but emit a 2-byte CScriptNum for 0x80..0xff (sign-disambiguation
|
|
2483
|
-
// pad), which makes OP_TXHASH fail with SCRIPT_ERR_TXHASH.
|
|
2497
|
+
// NIP-042 consumes exactly two raw little-endian bytes. CScriptNum and
|
|
2498
|
+
// OP_N encodings are invalid even when they represent the same mask.
|
|
2484
2499
|
b.op(OP_IF)
|
|
2485
2500
|
.op(OP_DUP) // [ sig, pubKey, pubKey ]
|
|
2486
2501
|
.op(OP_SHA256) // [ sig, pubKey, H(pubKey) ]
|
|
2487
2502
|
.pushBytes(pubKeyCommitment) // [ sig, pubKey, H(pubKey), commitment ]
|
|
2488
2503
|
.op(OP_EQUALVERIFY) // [ sig, pubKey ]
|
|
2489
|
-
.pushBytes(Uint8Array.of(txHashSelector)) // [ sig, pubKey, selector ]
|
|
2504
|
+
.pushBytes(Uint8Array.of(txHashSelector & 0xff, txHashSelector >> 8)) // [ sig, pubKey, selector ]
|
|
2490
2505
|
.op(OP_TXHASH) // [ sig, pubKey, txHash ]
|
|
2491
2506
|
.op(OP_SWAP) // [ sig, txHash, pubKey ]
|
|
2492
2507
|
.op(OP_CHECKSIGFROMSTACK) // [ 1 | 0 ]
|
|
@@ -2998,9 +3013,13 @@ function parsePartialFillScriptPQ(script, network = 'xna-test') {
|
|
|
2998
3013
|
throw new Error(`parse-pq: pubKeyCommitment must be 32 bytes, got ${pubKeyCommitment.length}`);
|
|
2999
3014
|
}
|
|
3000
3015
|
expectByte(c, OP_EQUALVERIFY, 'OP_EQUALVERIFY (cancel)');
|
|
3001
|
-
const
|
|
3002
|
-
if (
|
|
3003
|
-
throw new Error(`parse-pq: txHashSelector
|
|
3016
|
+
const selectorBytes = readPush(c, 'txHashSelector');
|
|
3017
|
+
if (selectorBytes.length !== 2) {
|
|
3018
|
+
throw new Error(`parse-pq: txHashSelector must be a two-byte LE push, got ${selectorBytes.length} bytes`);
|
|
3019
|
+
}
|
|
3020
|
+
const txHashSelector = selectorBytes[0] | (selectorBytes[1] << 8);
|
|
3021
|
+
if (txHashSelector === 0 || txHashSelector > 0x1ff) {
|
|
3022
|
+
throw new Error(`parse-pq: txHashSelector 0x${txHashSelector.toString(16)} is rejected by OP_TXHASH`);
|
|
3004
3023
|
}
|
|
3005
3024
|
expectByte(c, OP_TXHASH, 'OP_TXHASH');
|
|
3006
3025
|
expectByte(c, OP_SWAP, 'OP_SWAP');
|