Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wallet: support import of x/y/zpubkey (BIP49 and BIP84) #616

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
add test for key inherit purpose
  • Loading branch information
pinheadmz committed Nov 20, 2019
commit 2361ab17ec63f9c6a34c27cf9874479dedd8e73b
23 changes: 23 additions & 0 deletions test/wallet-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1478,6 +1478,29 @@ describe('Wallet', function() {
assert.strictEqual(recAddr, 'bc1qcr8te4kr609gcawutmrza0j4xv80jy8z306fyu');
});

it('should get x/y/zpub wallets by tx', async () => {
const xtx = new MTX();
xtx.addInput(dummyInput());
xtx.addOutput('1LqBGSKuX5yYUonjxT5qGfpUsXKYYWeabA', 50000);
const xrecWallet = await wdb.getWalletsByTX(xtx);
const xexpectedWallet = await wdb.get('xpubtest');
assert(xrecWallet.has(xexpectedWallet.wid));

const ytx = new MTX();
ytx.addInput(dummyInput());
ytx.addOutput('37VucYSaXLCAsxYyAPfbSi9eh4iEcbShgf', 50000);
const yrecWallet = await wdb.getWalletsByTX(ytx);
const yexpectedWallet = await wdb.get('ypubtest');
assert(yrecWallet.has(yexpectedWallet.wid));

const ztx = new MTX();
ztx.addInput(dummyInput());
ztx.addOutput('bc1qcr8te4kr609gcawutmrza0j4xv80jy8z306fyu', 50000);
const zrecWallet = await wdb.getWalletsByTX(ztx);
const zexpectedWallet = await wdb.get('zpubtest');
assert(zrecWallet.has(zexpectedWallet.wid));
});

// https://github.com/bitcoin/bips/blob/master/bip-0049.mediawiki#test-vectors
it('should create BIP49 wallet and addresses', async () => {
// test vectors provided for testnet only
Expand Down