You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

3.0 KiB

BitcoinCash.js v0.1

Bitcoin Cash

Bitcoin Cash is the continuation of the Bitcoin project as peer-to-peer electronic cash for the Internet.

Bitcoin Cash uses a different SigHash for transaction signatures. The implementation in BitcoinCash.js has been tested agains the original Bitcoin Cash test vectors (see sighash.json in /test). Modifications in script evaluation have not yet been implemented.

To get started, just npm install --save bitcoincashjs or bower install bitcoincashjs.

Documentation Index

Addresses and Key Management

Payment Handling

Bitcoin Internals

Extra

Module Development

Modules

Some functionality is implemented as a module that can be installed separately:

Examples

Create and Save a Private Key

var privateKey = new bitcore.PrivateKey();

var exported = privateKey.toWIF();
// e.g. L3T1s1TYP9oyhHpXgkyLoJFGniEgkv2Jhi138d7R2yJ9F4QdDU2m
var imported = bitcore.PrivateKey.fromWIF(exported);
var hexa = privateKey.toString();
// e.g. 'b9de6e778fe92aa7edb69395556f843f1dce0448350112e14906efc2a80fa61a'

Create an Address

var address = privateKey.toAddress();

Create a Multisig Address

// Build a 2-of-3 address from public keys
var p2shAddress = new bitcore.Address([publicKey1, publicKey2, publicKey3], 2);

Request a Payment

var paymentInfo = {
  address: '1DNtTk4PUCGAdiNETAzQFWZiy2fCHtGnPx',
  amount: 120000 //satoshis
};
var uri = new bitcore.URI(paymentInfo).toString();

Create a Transaction

var transaction = new Transaction()
    .from(utxos)          // Feed information about what unspent outputs one can use
    .to(address, amount)  // Add an output with the given amount of satoshis
    .change(address)      // Sets up a change address where the rest of the funds will go
    .sign(privkeySet)     // Signs all the inputs it can

Connect to the Network

var peer = new Peer('5.9.85.34');

peer.on('inv', function(message) {
  // new inventory
});

peer.connect();