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