htmlcoinjs-lib
v0.1.15
Published
An extend lib for bitcoinjs-lib, it supports two new network of althash and althash-testnet, and it can generate contract creating and sending transactions
Downloads
27
Readme
htmlcoinjs-lib
This is an extend library called htmlcoinjs-lib, it supports two networks; htmlcoin-mainnet and htmlcoin-testnet It can generate contracts and creating and send transactions
Installation
npm install htmlcoinjs-lib
Setup
Node.js
var htmlcoinjs = require('htmlcoinjs-lib')
New features
Network
https://en.bitcoin.it/wiki/List_of_address_prefixes
{
htmlcoin: {
messagePrefix: '\x15HTMLCOIN Signed Message:\n',
bech32: 'hc',
bip32: {
public: 0x1397c10d,
private: 0x1397BCF3
},
pubKeyHash: 0x29,
scriptHash: 0x64,
wif: 0xa9
},
htmlcoin_testnet: {
messagePrefix: '\x15HTMLCOIN Signed Message:\n',
bech32: 'tq',
bip32: {
public: 0x043587cf,
private: 0x04358394
},
pubKeyHash: 0x64,
scriptHash: 0x6e,
wif: 0xef
}
}
Utils
Utils.selectTxs
/**
* This is a function for selecting HTML utxos to build transactions
* the transaction object takes at least 3 fields, value(unit is 1e-8 HTML) , confirmations and isStake
*
* @param [transaction] unspentTransactions
* @param Number amount(unit: HTML)
* @param Number fee(unit: HTML)
* @returns [transaction]
*/
function selectTxs(unspentTransactions, amount, fee)
Utils.buildPubKeyHashTransaction
/**
* This is a helper function to build a pubkeyhash transaction
* the transaction object takes at least 5 fields, value(unit is 1e-8 HTML), confirmations, isStake, hash and pos
*
* @param bitcoinjs-lib.KeyPair keyPair
* @param String to
* @param Number amount(unit: HTML)
* @param Number fee(unit: HTML)
* @param [transaction] utxoList
* @returns String the built tx
*/
function buildPubKeyHashTransaction(keyPair, to, amount, fee, utxoList)
Utils.buildCreateContractTransaction
/**
* This is a helper function to build a create-contract transaction
* the transaction object takes at least 5 fields, value(unit is 1e-8 HTML), confirmations, isStake, hash and pos
*
* @param bitcoinjs-lib.KeyPair keyPair
* @param String code The contract byte code
* @param Number gasLimit
* @param Number gasPrice(unit: 1e-8 HTML/gas)
* @param Number fee(unit: HTML)
* @param [transaction] utxoList
* @returns String the built tx
*/
function buildCreateContractTransaction(keyPair, code, gasLimit, gasPrice, fee, utxoList)
Utils.buildSendToContractTransaction
/**
* This is a helper function to build a send-to-contract transaction
* the transaction object takes at least 5 fields, value(unit is 1e-8 HTML), confirmations, isStake, hash and pos
*
* @param bitcoinjs-lib.KeyPair keyPair
* @param String contractAddress The contract address
* @param String encodedData The encoded abi data
* @param Number gasLimit
* @param Number gasPrice(unit: 1e-8 HTML/gas)
* @param Number fee(unit: HTML)
* @param [transaction] utxoList
* @returns String the built tx
*/
function buildSendToContractTransaction(keyPair, contractAddress, encodedData, gasLimit, gasPrice, fee, utxoList)