bitcoinjs/bitcoinjs-lib

toASM throws TypeError: Cannot read properties of null (reading 'map')

O2rki opened this issue · 4 comments

Happens when decompile returns a null object, then toASM tries to map.

bitcoinjs-lib/src/script.js

Lines 158 to 162 in 6396fb4

if (chunksIsBuffer(chunks)) {
chunks = decompile(chunks);
}
return chunks
.map(chunk => {

Do I have to check myself (in my code) if decompile returns a null before calling toASM?.

We can optimize decomplie return value to avoid type error.

But you should check your logic why get incorrect chunks to exec toASM?

I was debugging the lib. Incorrect chunks may get there for whatever reason.

OK, we will fix it.