forked from bitpay/bitcore
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Armory.js
65 lines (49 loc) · 2.01 KB
/
Armory.js
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
var Armory = require('../lib/Armory');
var Address = require('../lib/Address');
// Initial public key can be retrieved from paper backup
var PublicX = '9df5 23e7 18b9 1f59 a790 2d46 999f 9357 ccf8 7208 24d4 3076 4516 b809 f7ab ce4e';
var PublicY = '66ba 5d21 4682 0dae 401d 9506 8437 2516 79f9 0c56 4186 cc50 07df c6d0 6989 1ff4';
var pubkey = '04' + PublicX.split(' ').join('') + PublicY.split(' ').join('');
// Chain code can be generated by entering paper backup
// on brainwallet.org/#chains or by using Armory.fromSeed() below
var chaincode = '84ac14bc4b388b33da099a0b4ee3b507284d99e1476639e36e5ca5e6af86481e';
var armory = new Armory(chaincode, pubkey);
console.log('Deriving public keys for');
console.log('------------------------');
console.log('Chain code: %s', chaincode);
console.log('Public key: %s', pubkey);
console.log('');
for (var i = 0; i < 5; i++) {
console.log(Address.fromPubKey(armory.pubkey).as('base58'));
armory = armory.next();
}
// Derive first public key and chain code from seed
var seed = [
'aagh hjfj sihk ietj giik wwai awtd uodh hnji',
'soss uaku egod utai itos fijj ihgi jhau jtoo'
];
console.log('');
console.log('');
console.log('Deriving public keys for');
console.log('------------------------');
console.log('Seed: %s', seed.join(' '));
console.log('');
// skip first public key
var a = Armory.fromSeed(seed.join('\n')).next();
for (var i = 0; i < 5; i++) {
console.log(Address.fromPubKey(a.pubkey).as('base58'));
a = a.next();
}
var mpk = '045a09a3286873a72f164476bde9d1d8e5c2bc044e35aa47eb6e798e325a86417f7c35b61d9905053533e0b4f2a26eca0330aadf21c638969e45aaace50e4c0c8784ac14bc4b388b33da099a0b4ee3b507284d99e1476639e36e5ca5e6af86481e';
console.log('');
console.log('');
console.log('Deriving public keys for');
console.log('------------------------');
console.log('Master Public Key: %s', mpk);
console.log('');
// skip first public key
var b = Armory.fromMasterPublicKey(mpk).next();
for (var i = 0; i < 5; i++) {
console.log(Address.fromPubKey(b.pubkey).as('base58'));
b = b.next();
}