How to generate a dash address? How can I generate a simple dash address from a public key?

How many address formats are there in dash?
How many address formats are there in dash?


Dash seems to be pretty similar to bitcoin when it comes to address and transaction formats. You have your typical P2PK, P2PKH, P2SH. 

Here is how to generate a standard P2PKH address (and therefore also a P2PK address).

var bip39 = require('bip39');
var hdkey = require('hdkey');
var createHash = require('create-hash');
var bs58check = require('bs58check');

//const mnemonic = bip39.generateMnemonic(); //generates string
const mnemonic = 'thunder purchase pave tower lecture upgrade supreme half kid fitness tray shove'
const seed = bip39.mnemonicToSeed(mnemonic); //creates seed buffer
console.log('mnemonic: ' + mnemonic);

const root = hdkey.fromMasterSeed(seed);
const masterPrivateKey = root.privateKey.toString('hex');
//console.log('extended public key root:  ' + root.publicExtendedKey)

const addrnode = root.derive("m/44'/5'/0'/0/0");
console.log('addrnodePublicKey: '+ addrnode._publicKey.toString('hex'))
console.log('addernodePrivateKey: ' + addrnode._privateKey.toString('hex'))

const step1 = addrnode._publicKey;
const step2 = createHash('sha256').update(step1).digest();
const step3 = createHash('rmd160').update(step2).digest();

var step4 = Buffer.allocUnsafe(21);
step4.writeUInt8(0x4c, 0); 
step3.copy(step4, 1); //step4 now holds the extended RIPMD-160 result
const step9 = bs58check.encode(step4);
console.log('Base58Check: ' + step9); 


Notice the only difference between this and deriving a bitcoin address is the version bytes is not 0x00 but instead 0x4c &amp; the derivation path coin index of 5 instead of 0.