new script API

fixes https://github.com/bitpay/bitcore/issues/602