npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

junkcoinjs-lib

v0.0.5

Published

Fork of bitcoinjs-lib for JunkCoin

Downloads

648

Readme

JunkcoinJS (junkcoinjs-lib)

Github CI NPM code style: prettier

A JavaScript Junkcoin library for Node.js and browsers. Written in TypeScript, but committing the JS files to verify.

Released under the terms of the MIT LICENSE.

Acknowledgments

Special thanks to the developers of BitcoinJS and LuckycoinJS for their inspiration and contributions to the crypto ecosystem. JunkcoinJS builds upon their exceptional work to provide a dedicated solution for Junkcoin.

Should I use this in production?

If you are thinking of using the master branch of this library in production, stop. Master is not stable; it is our development branch, and only tagged releases may be classified as stable.

Can I trust this code?

Don't trust. Verify.

We recommend every user of this library and the junkcoinjs ecosystem audit and verify any underlying code for its validity and suitability, including reviewing any and all of your project's dependencies.

Mistakes and bugs happen, but with your help in resolving and reporting issues, together we can produce open source software that is:

  • Easy to audit and verify
  • Tested, with test coverage >95%
  • Advanced and feature rich
  • Standardized, using prettier and Node Buffers throughout
  • Friendly, with a strong and helpful community, ready to answer questions

Features

  • Junkcoin address generation and validation (Legacy addresses starting with '7' or 'L')
  • Transaction building and signing
  • Support for various payment types (P2PKH, P2SH, P2WPKH)
  • Full TypeScript support
  • Comprehensive test suite

Installation

npm install junkcoinjs-lib
# optionally, install key derivation libraries
npm install ecpair bip32

Running Tests

# Install dependencies
npm install

# Run the test suite
npm test

# Run tests with coverage report
npm run coverage

# Watch mode during development
npm run test:watch

Usage

Crypto is hard. Please note these important considerations:

  1. The random number generator is crucial for security
  2. We use the randombytes module by default
  3. This library uses tiny-secp256k1 with RFC6979
  4. Verify everything in your target environment

Best practices:

  • Don't reuse addresses
  • Don't share BIP32 extended public keys ('xpubs')
  • Don't use Math.random
  • Have users verify decoded transactions before broadcast
  • Don't generate mnemonics manually
  • Use TypeScript or similar for better type safety

Examples

Generate a random address

const junkcoinjs = require('junkcoinjs-lib');
const ECPair = require('ecpair');
const { junkcoin } = junkcoinjs.networks;

// Generate random key pair
const keyPair = ECPair.makeRandom({ network: junkcoin });

// Create P2PKH address
const { address } = junkcoinjs.payments.p2pkh({
  pubkey: Buffer.from(keyPair.publicKey),
  network: junkcoin,
});

Import via WIF

const keyPair = ECPair.fromWIF('YOUR_WIF_HERE', junkcoin);
const { address } = junkcoinjs.payments.p2pkh({
  pubkey: Buffer.from(keyPair.publicKey),
  network: junkcoin,
});

Create Multi-sig Address

const pubkeys = [
  Buffer.from(keyPair1.publicKey),
  Buffer.from(keyPair2.publicKey),
  Buffer.from(keyPair3.publicKey),
];

const { address } = junkcoinjs.payments.p2sh({
  redeem: junkcoinjs.payments.p2ms({
    m: 2,
    pubkeys,
    network: junkcoin,
  }),
  network: junkcoin,
});

Network Parameters

Junkcoin specific network parameters:

  • Message Prefix: '\u0018Junkcoin Signed Message:\n'
  • Bech32 Prefix: 'jkc'
  • Public Key Hash: 0x10
  • Script Hash: 0x05
  • WIF: 0x99
  • BIP32 Public: 0x0488b21e
  • BIP32 Private: 0x0488ade4

Browser

The recommended method is through browserify:

npm install junkcoinjs-lib browserify
npx browserify --standalone junkcoin - -o junkcoinjs-lib.js <<<"module.exports = require('junkcoinjs-lib');"

Import as ESM module:

<script type="module">import "/scripts/junkcoinjs-lib.js"</script>

Development

# Build the project
npm run build

# Run linter
npm run lint

# Format code
npm run format

Complementary Libraries

  • BIP21 - A BIP21 compatible URL encoding library
  • BIP38 - Passphrase-protected private keys
  • BIP39 - Mnemonic generation for deterministic keys
  • BIP32-Utils - A set of utilities for working with BIP32
  • Base58 - Base58 encoding/decoding
  • Bech32 - A Bech32 encoding library

Contributing

See CONTRIBUTING.md for details.

LICENSE

MIT