Closed kevinejohn closed 4 years ago
This issue is reproducible.
var bsv = require("bsv");
var script = new bsv.Script("4e");
Invalid script buffer: can't parse valid script from given buffer 4e
When parsing the script, a buffer reader will attempt to read data which does not exist, resulting in a ranger error being thrown. This exception is caught and rethrown as the above invalid script buffer.
If the intent is to have the caller place bsv scripting calls within a try catch, it should be documented so that developers are aware that there could be exceptions which propagate up the call stack.
Returning null, similar to the fix for bitcoinjs-lib, could also be an option but that would require existing applications to check for a null script.
Closing due to imminent release of bsv 2.0. Please let me know if you still have this issue.
I believe the bitcore ASM format is fundamentally broken and may not be able to resolve this issue ever - you may need to use one of the other formats. There are 3 string formats in the new library.
When parsing this transaction's (https://whatsonchain.com/tx/ebc9fa1196a59e192352d76c0f6e73167046b9d37b8302b6bb6968dfd279b767) output scripts bsv throws this error:
Looks like this was fixed for bitcoinjs-lib: https://github.com/bitcoinjs/bitcoinjs-lib/pull/375