@neuraiproject/neurai-scripts 0.11.0 → 0.12.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 +17 -2
- package/dist/NeuraiScripts.global.js.map +1 -1
- package/dist/browser.js +17 -2
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +17 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +17 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1983,12 +1983,19 @@ function parseTransaction(hex) {
|
|
|
1983
1983
|
for (let i = 0; i < voutCount; i += 1)
|
|
1984
1984
|
outputs.push(readOutput(reader));
|
|
1985
1985
|
}
|
|
1986
|
-
// NIP-014:
|
|
1986
|
+
// NIP-014: reference inputs sit between vout and witness, announced by flag
|
|
1987
|
+
// 0x02. Without the flag a version 3 transaction reads as 1.0.7 reads it.
|
|
1987
1988
|
const vrefin = [];
|
|
1988
|
-
|
|
1989
|
+
const hasRefInputs = (flags & 2) !== 0;
|
|
1990
|
+
if (hasRefInputs) {
|
|
1991
|
+
flags ^= 2;
|
|
1989
1992
|
const refCount = reader.readCount(36, 'refinput');
|
|
1990
1993
|
for (let i = 0; i < refCount; i += 1)
|
|
1991
1994
|
vrefin.push(readOutpoint(reader));
|
|
1995
|
+
if (vrefin.length === 0) {
|
|
1996
|
+
// One encoding per transaction: the flag means some.
|
|
1997
|
+
throw new Error('Superfluous reference inputs record (flag 0x02 with no reference inputs)');
|
|
1998
|
+
}
|
|
1992
1999
|
}
|
|
1993
2000
|
if (flags & 1) {
|
|
1994
2001
|
flags ^= 1;
|
|
@@ -2001,6 +2008,11 @@ function parseTransaction(hex) {
|
|
|
2001
2008
|
}
|
|
2002
2009
|
input.witness = stack;
|
|
2003
2010
|
}
|
|
2011
|
+
if (hasRefInputs && !inputs.some(inputHasWitness)) {
|
|
2012
|
+
// With reference inputs the witness flag means some witness; 1.0.7 reads
|
|
2013
|
+
// an empty witness record without them, and so does the node.
|
|
2014
|
+
throw new Error('Superfluous witness record (flag 0x01 with no witness data)');
|
|
2015
|
+
}
|
|
2004
2016
|
}
|
|
2005
2017
|
if (flags) {
|
|
2006
2018
|
throw new Error(`Unknown transaction optional data (flags 0x${flags.toString(16)})`);
|
|
@@ -2011,6 +2023,9 @@ function parseTransaction(hex) {
|
|
|
2011
2023
|
}
|
|
2012
2024
|
return { version, inputs, outputs, vrefin, locktime };
|
|
2013
2025
|
}
|
|
2026
|
+
function inputHasWitness(input) {
|
|
2027
|
+
return (input.witness?.length ?? 0) > 0;
|
|
2028
|
+
}
|
|
2014
2029
|
|
|
2015
2030
|
/**
|
|
2016
2031
|
* Address helpers. Wraps `decodeAddress` from
|