0.1.7 • Published 3 years ago
pegin v0.1.7
Pegin
TypeScript module to pegin Bitcoin into Liquid Bitcoin in the browser
Usage
Install from npm
npm install --save pegin
# or with yarn
yarn add peginUse in your JavaScript or TypeScript project, works in the browser!
import ElementsPegin from 'pegin';
const peginModule = new ElementsPegin(
await ElementsPegin.withGoElements(),
await ElementsPegin.withLibwally(),
// Optionals, defaults are dynfed is off, mainnet and hardcoded fedpeg script
ElementsPegin.withDynamicFederation(false),
ElementsPegin.withMainnet(),
ElementsPegin.withFederationScript('my_Fed_Peg_Script_XXXYYYXXX')
);
const address = await peginModule.getMainchainAddress(
'0014efcee7e291eb23654650b3eb950fca21d01ee37e' // Liquid script
);
console.log(address); // Bitcoin addressDevelopment
Compile wasm wrappers
git submodule update --init --recursiveBuild Go Elements and Libwally to WASM
make buildTest
npm testBuild the TS lib
npm run buildProject
- The Typescript lib entrypoint is
src/index.ts. resources/wallycore.jsis the compiled WebAssembly lib from LibwallyCore build usingresources/Dockerfile.libwally.resources/wasm_exec.jsis the WebAssembly runner for Golang.elements.wasmis compiled from wrappers inmain.gousingresources/Dockerfile.goelements.elements.jsis the JavasScript glue with the base64 encoded wasm file packaged in the npm module.
License
Distributed under the MIT License. See LICENSE for more information.