Skip to content

Repository files navigation

Build and Test CodeQL OpenSSF Scorecard

powpeg-redeemscript-parser

This library helps building and parsing the redeem script of the RSK powpeg.

Local usage

Run npm ci to install dependencies.

Run node sample/sample.js to get a full run of all the methods available in the library.

Details

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.

buildPowpegRedeemScript

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.

buildFlyoverRedeemScript

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.

isFlyoverRedeemScript

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.

removeFlyoverPrefix

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.

About

This library helps obtaining the redeem script of the Rootstcok PowPeg as well as generating its address

Resources

Security policy

Stars

0 stars

Watchers

7 watching

Forks

Releases

Used by

Contributors

Languages