@bsv/sdk 1.5.0 → 1.5.1
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/dist/cjs/package.json +1 -1
- package/dist/cjs/src/script/Script.js +21 -1
- package/dist/cjs/src/script/Script.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/src/script/Script.js +21 -1
- package/dist/esm/src/script/Script.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/types/src/script/Script.d.ts.map +1 -1
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/dist/umd/bundle.js +1 -1
- package/package.json +1 -1
- package/src/script/Script.ts +22 -1
package/package.json
CHANGED
package/src/script/Script.ts
CHANGED
|
@@ -125,10 +125,28 @@ export default class Script {
|
|
|
125
125
|
bin = [...bin]
|
|
126
126
|
const chunks: ScriptChunk[] = []
|
|
127
127
|
|
|
128
|
+
let inConditionalBlock: number = 0
|
|
129
|
+
|
|
128
130
|
const br = new Reader(bin)
|
|
129
131
|
while (!br.eof()) {
|
|
130
132
|
const op = br.readUInt8()
|
|
131
133
|
|
|
134
|
+
// if OP_RETURN and not in a conditional block, do not parse the rest of the data,
|
|
135
|
+
// rather just return the last chunk as data without prefixing with data length.
|
|
136
|
+
if (op === OP.OP_RETURN && inConditionalBlock === 0) {
|
|
137
|
+
chunks.push({
|
|
138
|
+
op,
|
|
139
|
+
data: br.read()
|
|
140
|
+
})
|
|
141
|
+
break
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (op === OP.OP_IF || op === OP.OP_NOTIF || op === OP.OP_VERIF || op === OP.OP_VERNOTIF) {
|
|
145
|
+
inConditionalBlock++
|
|
146
|
+
} else if (op === OP.OP_ENDIF) {
|
|
147
|
+
inConditionalBlock--
|
|
148
|
+
}
|
|
149
|
+
|
|
132
150
|
let len = 0
|
|
133
151
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
134
152
|
let data: number[] = []
|
|
@@ -225,7 +243,10 @@ export default class Script {
|
|
|
225
243
|
const chunk = this.chunks[i]
|
|
226
244
|
const op = chunk.op
|
|
227
245
|
writer.writeUInt8(op)
|
|
228
|
-
if (chunk.data != null) {
|
|
246
|
+
if (op === OP.OP_RETURN && chunk.data != null) { // special case for unformatted data
|
|
247
|
+
writer.write(chunk.data)
|
|
248
|
+
break
|
|
249
|
+
} else if (chunk.data != null) {
|
|
229
250
|
if (op < OP.OP_PUSHDATA1) {
|
|
230
251
|
writer.write(chunk.data)
|
|
231
252
|
} else if (op === OP.OP_PUSHDATA1) {
|