Skip to content

Commit

Permalink
Test p2wpkh-p2sh address
Browse files Browse the repository at this point in the history
  • Loading branch information
lukechilds committed May 9, 2019
1 parent da3fd64 commit d23a138
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,20 @@ test('Vain derives a p2pkh vanity address', async t => {
t.true(address.startsWith(`1${options.prefix}`));
t.is(address, wifAddress);
});

test('Vain derives a p2wpkh-p2sh vanity address', async t => {
const options = {
addressFormat: 'p2wpkh-p2sh',
prefix: 'A'
};
const vain = new Vain(options);
const {address, wif} = await vain.start();

const keyPair = bitcoin.ECPair.fromWIF(wif);
const {address: wifAddress} = bitcoin.payments.p2sh({
redeem: bitcoin.payments.p2wpkh({pubkey: keyPair.publicKey})
});

t.true(address.startsWith(`3${options.prefix}`));
t.is(address, wifAddress);
});

0 comments on commit d23a138

Please sign in to comment.