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

bitcoin-proof

v2.0.0

Published

Merkle proof for a Bitcoin transaction

Downloads

31

Readme

bitcoin-proof

NPM Package Build Status js-standard-style Dependency status

Merkle proof for a Bitcoin transaction.

Install

npm install bitcoin-proof

API


#####getProof(String[] txIds, Number txIndex) -> {txId: String, txIndex: Number, sibling: String[]}

Computes the Merkle proof of a given transaction.

  • txIds - array of transaction hashes (as hex string)
  • txIndex - index of which transaction to compute a Merkle proof for

Returns an object with the following keys:

  • txId - transaction hash that the Merkle proof is computed for
  • txIndex - index of txId among txIds
  • sibling - sibling hashes of txId which comprise the Merkle proof

#####getTxMerkle({txId: String, txIndex: Number, sibling: String[]}) -> String

Computes the Merkle root of a given proof.

  • proof - an object of the form returned by getProof

Returns the Merkle root as a hex string.


#####getMerkleRoot(String[] txIds) -> String

Computes the Merkle root of a set of transactions.

  • txIds - array of transaction hashes (as hex string)

Returns the Merkle root as a hex string.

Usage

var btcProof = require('bitcoin-proof');

var BLOCK_100K_TRANSACTIONS = [
  '8c14f0db3df150123e6f3dbbf30f8b955a8249b62ac1d1ff16284aefa3d06d87',
  'fff2525b8931402dd09222c50775608f75787bd2b87e56995a7bdd30f79702c4',
  '6359f0868171b1d194cbee1af2f16ea598ae8fad666d9b012c8ed2b79a236ec4',
  'e9a66845e05d5abc0ad04ec80f774a7e585c6e8db975962d069a522137b80c1d'
];

var proofOfFirstTx = btcProof.getProof(BLOCK_100K_TRANSACTIONS, 0);
// {
//   txId: '8c14f0db3df150123e6f3dbbf30f8b955a8249b62ac1d1ff16284aefa3d06d87',
//   txIndex: 0,
//   sibling: [
//     'fff2525b8931402dd09222c50775608f75787bd2b87e56995a7bdd30f79702c4',
//     '8e30899078ca1813be036a073bbf80b86cdddde1c96e9e9c99e9e3782df4ae49'
//   ]
// }

var proofOfLastTx = btcProof.getProof(BLOCK_100K_TRANSACTIONS, 3);
// {
//   txId: 'e9a66845e05d5abc0ad04ec80f774a7e585c6e8db975962d069a522137b80c1d',
//   txIndex: 0,
//   sibling: [
//     '6359f0868171b1d194cbee1af2f16ea598ae8fad666d9b012c8ed2b79a236ec4',
//     'ccdafb73d8dcd0173d5d5c3c9a0770d0b3953db889dab99ef05b1907518cb815'
//   ]
// }

License

MIT