@alexbosworth/blockchain 4.7.1 → 4.7.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/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -100,15 +100,20 @@ const tests = [
|
|
|
100
100
|
args: {
|
|
101
101
|
transaction: '010000000002010000000000000000000000000000000000000000000000000000000000000000ffffffff00ffffffff010100000000000000000101510000' + '0000',
|
|
102
102
|
},
|
|
103
|
-
description: 'A
|
|
104
|
-
error: '
|
|
103
|
+
description: 'A zero marker with unknown flag is legacy and has extra data',
|
|
104
|
+
error: 'UnexpectedDataAfterTransactionToGetComponentsOf',
|
|
105
105
|
},
|
|
106
106
|
{
|
|
107
107
|
args: {
|
|
108
108
|
transaction: '0100000000' + '02' + '01000000000000000151' + '020000000000000000' + '00000000',
|
|
109
109
|
},
|
|
110
|
-
description: 'A zero
|
|
111
|
-
|
|
110
|
+
description: 'A zero inputs tx with a non-witness flag byte is parsed as legacy',
|
|
111
|
+
expected: {
|
|
112
|
+
inputs: [],
|
|
113
|
+
locktime: 0,
|
|
114
|
+
outputs: [{script: '51', tokens: 1}, {script: '', tokens: 2}],
|
|
115
|
+
version: 1,
|
|
116
|
+
},
|
|
112
117
|
},
|
|
113
118
|
{
|
|
114
119
|
args: {
|
|
@@ -17,7 +17,6 @@ const minByteLengthInput = 41;
|
|
|
17
17
|
const minByteLengthOutput = 9;
|
|
18
18
|
const times = n => [...Array(n).keys()];
|
|
19
19
|
const witnessFlagValue = 1;
|
|
20
|
-
const zeroFlagValue = 0;
|
|
21
20
|
|
|
22
21
|
/** Parse a raw transaction out of a buffer at a specific offset start
|
|
23
22
|
|
|
@@ -87,14 +86,8 @@ module.exports = args => {
|
|
|
87
86
|
// The presence of the marker and flag indicates SegWit tx encoding
|
|
88
87
|
const isSegWit = !marker && flag === witnessFlagValue;
|
|
89
88
|
|
|
90
|
-
//
|
|
91
|
-
//
|
|
92
|
-
// count. Any other flag value following a zero marker is unknown data.
|
|
93
|
-
if (!marker && !isSegWit && flag !== zeroFlagValue) {
|
|
94
|
-
throw new Error('UnexpectedWitnessFlagByteValueInTransaction');
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// When tx isn't SegWit though, the bytes are not marker and flag
|
|
89
|
+
// When tx isn't SegWit though, the bytes are not marker and flag: a zero
|
|
90
|
+
// marker without the witness flag is a legacy tx with an empty inputs count
|
|
98
91
|
offset += isSegWit ? byteCountMarkerFlag : byteCountNoMarkerFlag;
|
|
99
92
|
|
|
100
93
|
const inputsCount = decodeCompactInt(args.buffer, offset);
|