Skip to content

Commit 704d5e4

Browse files
committed
test: Add BIP86 test case for Taproot address derivation
1 parent 5f71529 commit 704d5e4

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/bip86.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//https://github.com/bitcoin/bips/blob/master/bip-0086.mediawiki#user-content-Address_derivation
2+
3+
import * as ecc from '@bitcoinerlab/secp256k1';
4+
import { networks } from 'bitcoinjs-lib';
5+
import { DescriptorsFactory, scriptExpressions } from '../dist/';
6+
import { mnemonicToSeedSync } from 'bip39';
7+
const { trBIP32 } = scriptExpressions;
8+
const { Output, BIP32 } = DescriptorsFactory(ecc);
9+
const network = networks.bitcoin;
10+
const masterNode = BIP32.fromSeed(
11+
mnemonicToSeedSync(
12+
'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about'
13+
),
14+
network
15+
);
16+
describe('BIP86', () => {
17+
test('BIP86', () => {
18+
const descriptor = trBIP32({
19+
masterNode,
20+
network,
21+
account: 0,
22+
change: 0,
23+
index: 0
24+
});
25+
const output = new Output({ descriptor, network });
26+
console.log(output.getAddress());
27+
});
28+
});

0 commit comments

Comments
 (0)