Skip to content

bitcoin-fp/bitcoin-KAT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bitcoin-KAT

JavaScript Style Guide License: MIT

Using the code to construct Keys, Addresses and Transactions.

Install

npm install bitcoin-KAT

Usage

var bitcoin = require('bitcoin-KAT')

Keys

Generate keys randomly

bitcoin.keys()

Generate keys with given private key

bitcoin.keys(privateKey) //privateKey: private key hex

Generate keys for Testnet

bitcoin.keys_testnet()

Address

Generate an address

bitcoin.address(publicKey) //publicKey: public key hex

Generate an address for Testnet

bitcoin.address_testnet(publicKey)

Transaction

Generate a transaction rawdata, take a look at this transaction for example. Currently support P2PKH only.

var payment = [
  {
    from: 'n4j1MtzGZpivsqbvrcAqPV4GS74B3kS7qG', //payer's address
    to: 'mwCwTceJvYV27KXBc3NJZys6CjsgsoeHmf', //payee's address
    value: 0.64, //payment amount in BTC
    prevHash: '0e512b5ab9220e473928b0c2728aaa74ec66a1cc827caa29a744eb508d15f850', //the UTXO refers to previous tx's hash
    prevIndex: 0 //the index of UTXO refers to previous tx's output
  }
]
bitcoin.transaction(privateKey, payment) //privateKey: private key in WIF

Test

Run npm test

Reference

Mastering Bitcoin, O'Reilly Media

About

Bitcoin Keys, Addresses and Transactions generator

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published