GithubHelp home page GithubHelp logo

tokyoben / counterjs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from visvirial/counterjs

0.0 1.0 1.0 96 KB

Counterparty Node.js and JavaScript library.

License: MIT License

JavaScript 100.00%

counterjs's Introduction

CounterJS

Build Status Coverage Status

A pure and easy-to-use Counterparty Node.js (JavaScript) library.

Features

  • Can generate or parse Counterparty messages without interaction with a Counterparty server (counterparty-lib and/or blockparty)
  • Can generate or decode bitcoin transactions with Counterparty messages embedded
  • No specific bitcoin library (e.g. Bitcore and BitcoinJS) dependency. You can use any bitcoin library you prefer
  • [WIP] Browser support

Install

With NPM

$ npm install counterjs

From Source

$ git clone https://github.com/fressets/CounterJS
$ cd CounterJS
$ npm install

For browsers

In the source code directory, run

$ gulp browser

Then browserified JS file dist/counterjs.js and minified dist/counterjs.min.js will be created.

Load one of the files above in your HTML.

<script type="text/javascript" src="__JS_DIR__/counterjs.min.js"></script>

Then, you can require('counterjs') to load the module.

var xcp = require('counterjs');

// Do the stuff!!!

Basic Usage

We will show a code for generating private key (WIF) and address associated with a given mnemonic (passphrase) as an example.

Please refer to the /sample directory for more advanced usage.

Node.js

// Load CounterJS module.
var xcp = require('counterjs');

// Inputs.
// Mnemonic code (passphrase).
var mnemonic = 'blood honor rude click strength plain stare movie grab long hardly tease';
// Address index.
var index = 0;

// Compute a private key (WIF format).
var wif = xcp.util.mnemonicToPrivateKey(mnemonic, index, 'mainnet');
// Compute an address (using BitcoinJS).
var address = require('bitcoinjs-lib').ECPair.fromWIF(wif).getAddress();
// ...or you can use Bitcore instead.
//var address = new require('bitcore-lib').PrivateKey(wif).toAddress().toString();

// Print the results.
console.log('WIF: ' + wif);
console.log('address: ' + address);

Browser

Under preparation.

API Reference

xcp.Message

[WIP]

xcp.util

[WIP]

Miscellaneous

Running Tests

To run all tests, run

$ mocha

If you want to run a specific test, run

$ mocha ./test/FILE.js

Replace FILE.js with a test file you want to run.

Gulp Tasks

jshint

It will run jshint. Please run this task before you make a pull request and check if your code passes the jshint check.

Design Guideline

  • Input to / output from any API call should not depend on any other libraries - e.g. do not return bitcore.PrivateKey instance, return a WIF string or a 256-bit BitInteger instead
  • Write a readable code rather than fast code

counterjs's People

Contributors

visvirial avatar tokyoben avatar

Watchers

 avatar

Forkers

akloboucnik

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.