This library helps building and parsing the redeem script of the RSK powpeg.
Run npm ci to install dependencies.
Run node sample/sample.js to get a full run of all the methods available in the library.
The library offers methods to build each type of redeemscript available for the RSK powpeg, as well as to detect and remove the Flyover prefix from a redeemscript.
function buildPowpegRedeemScript(powpegBtcPublicKeys: Array<string|Buffer>, emergencyBtcPublicKeys: Array<string|Buffer>, csvValue: number): Buffer;Generates the powpeg (P2SH-P2WSH ERP) redeemscript. This method takes the parameterized powpegBtcPublicKeys, the emergency multisig public keys, and the delay value to generate the redeemscript.
function buildFlyoverRedeemScript(powpegRedeemScript: Buffer, derivationArgsHash: string): Buffer;Generates a Flyover redeemscript. This method expects a derivation arguments hash that represents the flyover protocol operation. With this it generates a prefix that is then joined with the regular powpeg redeemscript.
function isFlyoverRedeemScript(redeemScript: Buffer): boolean;Returns whether the redeemscript is a flyover redeemscript, i.e. a powpeg redeemscript prefixed with OP_PUSHBYTES_32 <derivationHash> OP_DROP.
function removeFlyoverPrefix(redeemScript: Buffer): Buffer;Removes the flyover prefix from a flyover redeemscript, returning the underlying powpeg redeemscript. Throws if the redeemscript is not a flyover redeemscript.
For any comments or suggestions, feel free to contribute or reach out at our Discord server.