@neuraiproject/neurai-scripts 0.11.0 → 0.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/README.md CHANGED
@@ -724,6 +724,16 @@ consumable; callers import directly from the package root.
724
724
 
725
725
  ## Version notes
726
726
 
727
+ ### 0.12.0
728
+
729
+ - Requires `@neuraiproject/neurai-create-transaction` **0.10.0**, which follows the node's
730
+ NIP-014 encoding (Neurai DePIN-Test `d4ff4ef`, live on the testnet reset of 2026-11-05):
731
+ reference inputs are announced by flag `0x02` of the extended format, and a version 3
732
+ transaction without them has the plain layout. `assetAuthProposalHash` parses the
733
+ proposal's raw transaction with that codec; the proposal message itself is unchanged
734
+ (it already committed an empty reference list for a transaction without references).
735
+ Checked against a regtest node built from Neurai `7f1773e`.
736
+
727
737
  ### 0.11.0
728
738
 
729
739
  - P2AH custody (NIP-054 `OP_CHECKASSETAUTH`, slot `0xdf`): `opcodes.OP_CHECKASSETAUTH`,
@@ -192,6 +192,8 @@ var NeuraiScriptsBundle = (function (exports) {
192
192
  // AuthScript only. Stack contract: (c a b T 1 M G role_1 .. role_n n -- 1),
193
193
  // failing the script instead of pushing 0. See covenants/asset-auth.
194
194
  const OP_CHECKASSETAUTH = 0xdf;
195
+ // NIP-060: verify a compact P-256 signature over SHA-256(message).
196
+ const OP_CHECKSIG_P256 = 0xe0;
195
197
  // ---------- Expansion / NOPs ----------
196
198
  // Only the NOPs not aliased by DePIN-Test opcodes are exported as NOPs.
197
199
  // OP_NOP2 == OP_CHECKLOCKTIMEVERIFY (0xb1)
@@ -361,6 +363,7 @@ var NeuraiScriptsBundle = (function (exports) {
361
363
  OP_CHECKSIGFROMSTACK: OP_CHECKSIGFROMSTACK,
362
364
  OP_CHECKSIGVERIFY: OP_CHECKSIGVERIFY,
363
365
  OP_CHECKSIG_ED25519: OP_CHECKSIG_ED25519,
366
+ OP_CHECKSIG_P256: OP_CHECKSIG_P256,
364
367
  OP_CHECKTEMPLATEVERIFY: OP_CHECKTEMPLATEVERIFY,
365
368
  OP_CODESEPARATOR: OP_CODESEPARATOR,
366
369
  OP_DEPTH: OP_DEPTH,
@@ -1986,12 +1989,19 @@ var NeuraiScriptsBundle = (function (exports) {
1986
1989
  for (let i = 0; i < voutCount; i += 1)
1987
1990
  outputs.push(readOutput(reader));
1988
1991
  }
1989
- // NIP-014: vrefin sits between vout and witness, v3 only (even when empty).
1992
+ // NIP-014: reference inputs sit between vout and witness, announced by flag
1993
+ // 0x02. Without the flag a version 3 transaction reads as 1.0.7 reads it.
1990
1994
  const vrefin = [];
1991
- if (version === 3) {
1995
+ const hasRefInputs = (flags & 2) !== 0;
1996
+ if (hasRefInputs) {
1997
+ flags ^= 2;
1992
1998
  const refCount = reader.readCount(36, 'refinput');
1993
1999
  for (let i = 0; i < refCount; i += 1)
1994
2000
  vrefin.push(readOutpoint(reader));
2001
+ if (vrefin.length === 0) {
2002
+ // One encoding per transaction: the flag means some.
2003
+ throw new Error('Superfluous reference inputs record (flag 0x02 with no reference inputs)');
2004
+ }
1995
2005
  }
1996
2006
  if (flags & 1) {
1997
2007
  flags ^= 1;
@@ -2004,6 +2014,11 @@ var NeuraiScriptsBundle = (function (exports) {
2004
2014
  }
2005
2015
  input.witness = stack;
2006
2016
  }
2017
+ if (hasRefInputs && !inputs.some(inputHasWitness)) {
2018
+ // With reference inputs the witness flag means some witness; 1.0.7 reads
2019
+ // an empty witness record without them, and so does the node.
2020
+ throw new Error('Superfluous witness record (flag 0x01 with no witness data)');
2021
+ }
2007
2022
  }
2008
2023
  if (flags) {
2009
2024
  throw new Error(`Unknown transaction optional data (flags 0x${flags.toString(16)})`);
@@ -2014,6 +2029,9 @@ var NeuraiScriptsBundle = (function (exports) {
2014
2029
  }
2015
2030
  return { version, inputs, outputs, vrefin, locktime };
2016
2031
  }
2032
+ function inputHasWitness(input) {
2033
+ return (input.witness?.length ?? 0) > 0;
2034
+ }
2017
2035
 
2018
2036
  /**
2019
2037
  * Address helpers. Wraps `decodeAddress` from