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

mockle

v1.0.1

Published

Mock TSC merkle proof generator

Downloads

10

Readme

mockle

Mock TSC merkle proof generator

Notes

This tool generates mocked (fake) SPV proofs in the JSON TSC format, and returns them as JavaScript objects. It does this by taking the given transaction or transaction ID (or by randomly generating a TXID), and then hashing it with randomly generated merkle branches to arrive at a random merkle root.

Needless to say, these proofs will not validate against the real chain of blocks, since the random merkle branches are not inputs to any real block's merkle root. This tool is useful for testing software that deals with the SPV ecosystem

Example Usage

const mockle = require('mockle')
// or
import mockle from 'mockle'

Generate a mock proof for a random TXID

const mockProof = mockle()

Generate a mock proof for a given txOrId, index and targetType

const mockProof = mockle({
  txOrId: '...',
  index: 1337,
  targetType: 'header'
})

API

Table of Contents

mockle

Generate a fake TSC-format merkle proof

Parameters

  • param Object All parameters are given in an object (optional, default {})

    • param.txOrId String A custom transaction or transaction ID to use for the proof, instead of randomly generating a TXID (optional, default "A random TXID")
    • param.targetType String A custom target type for the proof, either "hash", "header" or "merkleRoot" which is the default (optional, default "merkleRoot")
    • param.index Number A custom index in the block for the mock proof, by default it will be a random integer between 0 and 255. The larger the index, the larger your proof will be. Every doubling of the index value will add another node to the proof (optional, default "random between 0 and 255")

Returns Object the TSC format merkle proof given as a JavaScript object

License

The license for the code in this repository is the Open BSV License.