mirror of https://github.com/lukechilds/vainjs.git
Luke Childs
6 years ago
1 changed files with 19 additions and 0 deletions
@ -1,6 +1,25 @@ |
|||
import test from 'ava'; |
|||
// For some reason AVA can't `import` bitcoin so `require` for now.
|
|||
// import bitcoin from 'bitcoinjs-lib';
|
|||
import Vain from '..'; |
|||
|
|||
const bitcoin = require('bitcoinjs-lib'); |
|||
|
|||
test('Vain is exported', t => { |
|||
t.not(Vain, undefined); |
|||
}); |
|||
|
|||
test('Vain derives a p2pkh vanity address', async t => { |
|||
const options = { |
|||
addressFormat: 'p2pkh', |
|||
prefix: 'A' |
|||
}; |
|||
const vain = new Vain(options); |
|||
const {address, wif} = await vain.start(); |
|||
|
|||
const keyPair = bitcoin.ECPair.fromWIF(wif); |
|||
const {address: wifAddress} = bitcoin.payments.p2pkh({pubkey: keyPair.publicKey}); |
|||
|
|||
t.true(address.startsWith(`1${options.prefix}`)); |
|||
t.is(address, wifAddress); |
|||
}); |
|||
|
Loading…
Reference in new issue