From ac2df625bb6efe18bc113c00c1606861b6529c94 Mon Sep 17 00:00:00 2001 From: Luke Childs Date: Thu, 9 May 2019 07:58:08 +0700 Subject: [PATCH] Test p2pkh is default address format --- test/unit.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/unit.js b/test/unit.js index 5e14272..0e498b1 100644 --- a/test/unit.js +++ b/test/unit.js @@ -55,3 +55,17 @@ test('Vain derives a p2wpkh vanity address', async t => { t.true(address.startsWith(`bc1q${options.prefix}`)); t.is(address, wifAddress); }); + +test('Vain defaults to p2pkh if no address format is set', async t => { + const options = { + 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); +});