Doichain Support Module for Bitcore (based on Namecoin version)
bitcore-doichain
adds doichain support to bitcore for creating doichain name_*
transactions, private keys, and scripts in Node.js and web browsers.
Note: This is still experimental software. This module is not intended for use in production environments, or for use where real money is at stake, at this point.
See the main bitcore repo for more information.
Getting Started
npm install bitcore-doichain
yarn add bitcore-doichain
bower install bitcore-doichain
To create a doichain wallet (privateKey & publicKey) and register it at a doichain dApp (so you can retrieve UTXO's)
; const wallet = bitcoreconst url = bitcore+"/api/v1/importpubkey"bitcore
To get a Doichain Address from a Doichain PublicKey and request UTXO's (and balances)
;const addr = bitcoreconst amount = 005 //amount (in DOI) to send - amount determines the required amount of utxos to be used as inputsconst response = await bitcoreresponsebalanceAllUTXOs //balance of all UTXO's of this addressresponseamountUsedUTXOs //the amount of all used utxos which are required to fullfil the requested amountresponsechange //the change which results between the amount to spend and the amount of used UTXOsresponseutxos //the full unspent transactions with details in an array
To import a doichain WIF (from vanitygen, for example):
// return bitcore with namecoin commands overlayedvar bitcore = ;var privateKey = bitcorePrivateKey;var address = privateKey;console;// NAMEuWT2icj3ef8HWJwetZyZbXaZUJ5hFT
To create a name_new
transaction:
var bitcore = ;var tx = ; // utxo and nameNew output addrs need to have privKeys here// now we can broadcast out to the networkvar serialized = tx;
To create a name_firstupdate
transaction:
var tx = ;var serialized = tx;
To create a name_update
transaction:
var tx = ;var serialized = tx;
Details
bitcore-doichain
works by pulling in bitcore and then adding Namecoin-specific
version constants, name operation functions onto Transaction
, and patches
a few bitcore functions that do not allow for altcoin compatability (specifically
bitcore.Script.fromString
and Transaction.prototype._fromNonP2SH
). These will
hopefully by replaced by native Bitcore functions as I work to improve Bitcore's
altcoin compatability.
Contributing
Contributions are welcome! See CONTRIBUTING.md on the main bitcore repo for information about how to contribute.
License
Code released under the MIT license.
Written in 2015 by Brandon Robertz.