Learn how to spend from a customized P2SH script utilizing bitcore-lib

0
76


I couldn’t discover anyplace on the internet about it. I used to be hopeless till I observed that I may, with out modifying the library.

First select an identical class in Bitcore-lib.

  • multisigscripthash (<== urged) or publickeyhash for P2SH outputs
  • multisig or publickey for naked script outputs (do not use these, these are nonstandard)

Then copy it to a brand new file in your venture reminiscent of this one**. Don’t use typescript lessons even when your venture is of type Typescript.

Then change require paths. Additionally require inherit from NPM. As within the boilerplates above, we have to inherit from Transaction.Enter

A operate reminiscent of “buildP2SHPushIn” within the instance ought to produce the redeemscript. Keep in mind, the final ingredient of P2SH redeem scripts is a push of the P2SH script.

And eventually use addInput as a substitute of the higher-level operate from so as to add inputs as proven right here**


**The examples are for Bitcoin Money, however they can be utilized the identical means in Bitcoin. Don’t copy from them, nonetheless!



Supply hyperlink

Leave a reply