Bitcoin
Segregated Witness – How to create and sign a segwit transaction using the npm package.
So I used this NPM package ( https://www.npmjs.com/package/bitcore-lib ) to create and sign Bitcoin legacy transactions locally and it worked fine for legacy. However, when I tried to do the same for a segwit address, I started getting this error when submitting that raw to the sendrawtransasction node method.
mandatory-script-verify-flag-failed (Witness requires empty scriptSig)
So I think the problem lies with this package because this payment structure is not what is required for SegWit transactions.
So my main question is, is there a javascript package that I can use to create and sign a transaction? The main payload I have is
receipentAddress, senderAddress, amount ( in satoshis ), and privateKey in WIF.
Any help or clues are highly appreciated.