@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 +10 -0
- package/dist/NeuraiScripts.global.js +20 -2
- package/dist/NeuraiScripts.global.js.map +1 -1
- package/dist/browser.js +20 -2
- package/dist/browser.js.map +1 -1
- package/dist/core/opcodes.d.ts +1 -0
- package/dist/index.cjs +20 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -0
- package/dist/index.js +20 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/browser.js
CHANGED
|
@@ -189,6 +189,8 @@ const OP_CHECKSIGADD = 0xde;
|
|
|
189
189
|
// AuthScript only. Stack contract: (c a b T 1 M G role_1 .. role_n n -- 1),
|
|
190
190
|
// failing the script instead of pushing 0. See covenants/asset-auth.
|
|
191
191
|
const OP_CHECKASSETAUTH = 0xdf;
|
|
192
|
+
// NIP-060: verify a compact P-256 signature over SHA-256(message).
|
|
193
|
+
const OP_CHECKSIG_P256 = 0xe0;
|
|
192
194
|
// ---------- Expansion / NOPs ----------
|
|
193
195
|
// Only the NOPs not aliased by DePIN-Test opcodes are exported as NOPs.
|
|
194
196
|
// OP_NOP2 == OP_CHECKLOCKTIMEVERIFY (0xb1)
|
|
@@ -358,6 +360,7 @@ var opcodes = /*#__PURE__*/Object.freeze({
|
|
|
358
360
|
OP_CHECKSIGFROMSTACK: OP_CHECKSIGFROMSTACK,
|
|
359
361
|
OP_CHECKSIGVERIFY: OP_CHECKSIGVERIFY,
|
|
360
362
|
OP_CHECKSIG_ED25519: OP_CHECKSIG_ED25519,
|
|
363
|
+
OP_CHECKSIG_P256: OP_CHECKSIG_P256,
|
|
361
364
|
OP_CHECKTEMPLATEVERIFY: OP_CHECKTEMPLATEVERIFY,
|
|
362
365
|
OP_CODESEPARATOR: OP_CODESEPARATOR,
|
|
363
366
|
OP_DEPTH: OP_DEPTH,
|
|
@@ -1983,12 +1986,19 @@ function parseTransaction(hex) {
|
|
|
1983
1986
|
for (let i = 0; i < voutCount; i += 1)
|
|
1984
1987
|
outputs.push(readOutput(reader));
|
|
1985
1988
|
}
|
|
1986
|
-
// NIP-014:
|
|
1989
|
+
// NIP-014: reference inputs sit between vout and witness, announced by flag
|
|
1990
|
+
// 0x02. Without the flag a version 3 transaction reads as 1.0.7 reads it.
|
|
1987
1991
|
const vrefin = [];
|
|
1988
|
-
|
|
1992
|
+
const hasRefInputs = (flags & 2) !== 0;
|
|
1993
|
+
if (hasRefInputs) {
|
|
1994
|
+
flags ^= 2;
|
|
1989
1995
|
const refCount = reader.readCount(36, 'refinput');
|
|
1990
1996
|
for (let i = 0; i < refCount; i += 1)
|
|
1991
1997
|
vrefin.push(readOutpoint(reader));
|
|
1998
|
+
if (vrefin.length === 0) {
|
|
1999
|
+
// One encoding per transaction: the flag means some.
|
|
2000
|
+
throw new Error('Superfluous reference inputs record (flag 0x02 with no reference inputs)');
|
|
2001
|
+
}
|
|
1992
2002
|
}
|
|
1993
2003
|
if (flags & 1) {
|
|
1994
2004
|
flags ^= 1;
|
|
@@ -2001,6 +2011,11 @@ function parseTransaction(hex) {
|
|
|
2001
2011
|
}
|
|
2002
2012
|
input.witness = stack;
|
|
2003
2013
|
}
|
|
2014
|
+
if (hasRefInputs && !inputs.some(inputHasWitness)) {
|
|
2015
|
+
// With reference inputs the witness flag means some witness; 1.0.7 reads
|
|
2016
|
+
// an empty witness record without them, and so does the node.
|
|
2017
|
+
throw new Error('Superfluous witness record (flag 0x01 with no witness data)');
|
|
2018
|
+
}
|
|
2004
2019
|
}
|
|
2005
2020
|
if (flags) {
|
|
2006
2021
|
throw new Error(`Unknown transaction optional data (flags 0x${flags.toString(16)})`);
|
|
@@ -2011,6 +2026,9 @@ function parseTransaction(hex) {
|
|
|
2011
2026
|
}
|
|
2012
2027
|
return { version, inputs, outputs, vrefin, locktime };
|
|
2013
2028
|
}
|
|
2029
|
+
function inputHasWitness(input) {
|
|
2030
|
+
return (input.witness?.length ?? 0) > 0;
|
|
2031
|
+
}
|
|
2014
2032
|
|
|
2015
2033
|
/**
|
|
2016
2034
|
* Address helpers. Wraps `decodeAddress` from
|