-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreateBchWalletSingle.js
More file actions
36 lines (25 loc) · 868 Bytes
/
createBchWalletSingle.js
File metadata and controls
36 lines (25 loc) · 868 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
createBchWalletSingle.js
A script to create a new BCH wallet (12-word mnemonic and address)
Inputs:
None
Outputs:
1) Randomly generated BCH wallet with mnemonic and address
*/
//Import Bitbox
let BITBOX = require("bitbox-sdk").BITBOX;
let bitbox = new BITBOX();
let mnemonic = bitbox.Mnemonic.generate();
// root seed buffer
let rootSeed = bitbox.Mnemonic.toSeed(mnemonic);
// master HDNode
let masterHDNode = bitbox.HDNode.fromSeed(rootSeed, "bitcoincash");
// HDNode of BIP44 account
let account = bitbox.HDNode.derivePath(masterHDNode, "m/44'/145'/0'");
// derive the first external change address HDNode which is going to spend utxo
let change = bitbox.HDNode.derivePath(account, "0/0");
// get the cash address
let cashAddress = bitbox.HDNode.toCashAddress(change);
console.log(`Seed and Address:`);
console.log(mnemonic);
console.log(cashAddress);