Git Product home page Git Product logo

merkle-bitcoin's Introduction

merkle-bitcoin

Bitcoin-style merkle root generation.

Usage

npm install merkle-bitcoin
var merkle = require('merkle-bitcoin');

Examples

Even number of transactions

// Generate the merkle root for block #80000
var hashes = [
  "c06fbab289f723c6261d3030ddb6be121f7d2508d77862bb1e484f5cd7f92b25",
  "5a4ebf66822b0b2d56bd9dc64ece0bc38ee7844a23ff1d7320a88c5fdb2ad3e2"
];

merkle(hashes, function (err, merkleTree) {
  console.log(merkleTree.root);
  // 8fb300e3fdb6f30a4c67233b997f99fdd518b968b9a3fd65857bfe78b2600719 
});

Odd number of transactions

// Generate the merkle root for block #50001
var hashes = [
    "e1882d41800d96d0fddc196cd8d3f0b45d65b030c652d97eaba79a1174e64d58",
    "7940cdde4d713e171849efc6bd89939185be270266c94e92369e3877ad89455a",
    "f84761459a00c6df3176ae5d94c99e69f25100d09548e5686bd0c354bb8cc60a"
];

merkle(hashes, function (err, merkleTree) {
  console.log(merkleTree.root);
  // ee3a2d2b895cafacff526d06a55b55e049cf84a9735e4a63f7fd08f96d0f4649 
});

merkle-bitcoin's People

Contributors

dirtyharrydev avatar

Watchers

James Cloos avatar DeckerSU avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.