moneybutton / bsv

Bitcoin SV javascript library
Other
204 stars 105 forks source link

Check for non spendable #211

Closed calvogenerico closed 3 years ago

calvogenerico commented 3 years ago

This PR fixes the bug where the tx builder cannot build transactions that sends 0 sats to non spendable outputs that include OP_FALSE after the OP_RETURN.

The first approach to solve this was changing the method Script#isOpReturn to stop checking if every chunk if the script after the OP_RETURN is push data. That is still some desirable change for the future, but some members of the community pointed out that changing that method changes behavior in a few other methods.

To avoid breaking changes, then, I created this alternative solution. Instead of changing an existing method I created a new one and modified txBuilder to use this new method.

I also added new tests for Script#isOpReturn to have the behavior well explained in the code.

Lastly there is are some tests for the new code and the new cases contemplated.