Socket
Socket
Sign inDemoInstall

pegin

Package Overview
Dependencies
Maintainers
3
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pegin

TS package using wasm from go-elements and libwally-core


Version published
Weekly downloads
1
decreased by-91.67%
Maintainers
3
Weekly downloads
 
Created
Source

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 pegin

Use 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 address

Development

Compile wasm wrappers

git submodule update --init --recursive

Build Go Elements and Libwally to WASM

make build

Test

npm test

Build the TS lib

npm run build

Project

  • The Typescript lib entrypoint is src/index.ts.
  • resources/wallycore.js is the compiled WebAssembly lib from LibwallyCore build using resources/Dockerfile.libwally.
  • resources/wasm_exec.js is the WebAssembly runner for Golang.
  • elements.wasm is compiled from wrappers in main.go using resources/Dockerfile.goelements.
  • elements.js is 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.

FAQs

Package last updated on 07 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc