Skip to content

Commit 8a1cbcc

Browse files
authored
Merge pull request #9 from Adamant-im/dev
v1.3.0
2 parents 45bab0d + 564cc83 commit 8a1cbcc

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

groups/doge.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
var bitcoin = require('bitcoinjs-lib');
2+
var coinNetworks = require('./coinNetworks');
3+
const doge = { }
4+
5+
/**
6+
* Generates a DOGE account from the passphrase specified.
7+
* @param {string} passphrase ADAMANT account passphrase
8+
* @returns {object} network info, keyPair, privateKey, privateKeyWIF
9+
*/
10+
11+
doge.keys = passphrase => {
12+
const network = coinNetworks.DOGE;
13+
const pwHash = bitcoin.crypto.sha256(Buffer.from(passphrase));
14+
const keyPair = bitcoin.ECPair.fromPrivateKey(pwHash, { network });
15+
16+
return {
17+
network,
18+
keyPair,
19+
address: bitcoin.payments.p2pkh({ pubkey: keyPair.publicKey, network }).address,
20+
// DOGE private key is a regular 256-bit key
21+
privateKey: keyPair.privateKey.toString('hex'), // regular 256-bit (32 bytes, 64 characters) private key
22+
privateKeyWIF: keyPair.toWIF() // Wallet Import Format (52 base58 characters)
23+
}
24+
25+
};
26+
27+
module.exports = doge;

index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const healthCheck = require('./helpers/healthCheck');
88
const eth = require('./groups/eth');
99
const dash = require('./groups/dash');
1010
const btc = require('./groups/btc');
11+
const doge = require('./groups/doge');
1112
const transactionFormer = require('./helpers/transactionFormer');
1213
const keys = require('./helpers/keys');
1314
const encryptor = require('./helpers/encryptor');
@@ -28,6 +29,7 @@ module.exports = (params, log) => {
2829
eth,
2930
dash,
3031
btc,
32+
doge,
3133
transactionFormer,
3234
keys,
3335
encryptor,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "adamant-api",
3-
"version": "1.2.0",
3+
"version": "1.3.0",
44
"description": "REST API for ADAMANT Blockchain",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)