1- var wally = require ( '../wally' ) ;
2- var test = require ( 'tape' ) ;
3- const EC_PUBLIC_KEY_LEN = 33 ;
4- var seed = Buffer . from ( '00000000000000000000000000000000' , 'hex' ) ;
1+ const wally = require ( '../wally' ) ;
2+ const test = require ( 'tape' ) ;
3+ const seed = Buffer . from ( '00000000000000000000000000000000' , 'hex' ) ;
54
65test ( 'BIP32 from seed + derivation' , function ( t ) {
76 t . plan ( 6 ) ;
8- wally . bip32_key_from_seed ( Buffer . from ( seed ) , 0x0488ADE4 , 0 ) . then ( function ( s ) {
9- wally . wally_base58_from_bytes ( s , 1 ) . then ( function ( s ) {
7+
8+ wally . bip32_key_from_seed ( Buffer . from ( seed ) , wally . BIP32_VER_MAIN_PRIVATE , wally . BIP32_FLAG_KEY_PRIVATE ) . then ( function ( s ) {
9+ wally . wally_base58_from_bytes ( s , wally . BASE58_FLAG_CHECKSUM ) . then ( function ( s ) {
1010 t . equal (
1111 s ,
1212 ( 'xprv9s21ZrQH143K2JbpEjGU94NcdKSASB7LuXvJCTsxuENcGN1nVG7Q' +
@@ -15,8 +15,8 @@ test('BIP32 from seed + derivation', function(t) {
1515 ) ;
1616 } ) ;
1717
18- wally . bip32_pubkey_from_parent ( s , 1 , 0 ) . then ( function ( pub ) {
19- wally . wally_base58_from_bytes ( pub , 1 ) . then ( function ( s ) {
18+ wally . bip32_pubkey_from_parent ( s , 1 , wally . BIP32_FLAG_KEY_PRIVATE ) . then ( function ( pub ) {
19+ wally . wally_base58_from_bytes ( pub , wally . BASE58_FLAG_CHECKSUM ) . then ( function ( s ) {
2020 t . equal (
2121 s ,
2222 ( 'xpub683nVy7Tt7baCKuqho7X5C7TGuskZAa4wQ5YEue2BxtYB6upN4Yg' +
@@ -36,8 +36,8 @@ test('BIP32 from seed + derivation', function(t) {
3636 } ) ;
3737 } )
3838
39- wally . bip32_privkey_from_parent ( s , 0 , 0 ) . then ( function ( xpriv_0_0 ) {
40- wally . wally_base58_from_bytes ( xpriv_0_0 , 1 ) . then ( function ( base58_xpriv ) {
39+ wally . bip32_privkey_from_parent ( s , 0 , wally . BIP32_FLAG_KEY_PRIVATE ) . then ( function ( xpriv_0_0 ) {
40+ wally . wally_base58_from_bytes ( xpriv_0_0 , wally . BASE58_FLAG_CHECKSUM ) . then ( function ( base58_xpriv ) {
4141 t . equal (
4242 base58_xpriv ,
4343 'xprv9u4S6Taa3k3GxnaHfWzboKwLPPPHpDyDHdLGqDArBejguBuv6GkerLy6MtAeFfo9RDfZy22FWEc1ExEShuRGZJpgVgeVu5KZ5obWbV2R3D2' ,
@@ -46,17 +46,17 @@ test('BIP32 from seed + derivation', function(t) {
4646 } ) ;
4747 } ) ;
4848
49- wally . bip32_pubkey_from_parent ( s , 0 , 0 ) . then ( function ( xpub_0_0 ) {
50- wally . wally_base58_from_bytes ( xpub_0_0 , 1 ) . then ( function ( base58_xpub ) {
49+ wally . bip32_pubkey_from_parent ( s , 0 , wally . BIP32_FLAG_KEY_PRIVATE ) . then ( function ( xpub_0_0 ) {
50+ wally . wally_base58_from_bytes ( xpub_0_0 , wally . BASE58_FLAG_CHECKSUM ) . then ( function ( base58_xpub ) {
5151 t . equal (
5252 base58_xpub ,
5353 'xpub683nVy7Tt7baBGekmYXcATt4wRDnDgh4erFsdbaTjzGfmzF4dp4uQ9HaDCdvSqctrsbxZey5wozKyyy2J3zhDDHU3UhW4uCFQp6bESv8ewQ' ,
5454 'xpub M/0/0'
5555 ) ;
5656 } ) ;
5757
58- wally . bip32_pubkey_from_parent ( xpub_0_0 , 1 , 1 ) . then ( function ( xpub_0_0_1 ) {
59- wally . wally_base58_from_bytes ( xpub_0_0_1 , 1 ) . then ( function ( base58_xpub ) {
58+ wally . bip32_pubkey_from_parent ( xpub_0_0 , 1 , wally . BIP32_FLAG_KEY_PUBLIC ) . then ( function ( xpub_0_0_1 ) {
59+ wally . wally_base58_from_bytes ( xpub_0_0_1 , wally . BASE58_FLAG_CHECKSUM ) . then ( function ( base58_xpub ) {
6060 t . equal (
6161 base58_xpub ,
6262 'xpub6An6e2ai6kSDnnxJ3876JwfeigdQu9YNudcP7ayT828xDFzFQkP9oBoBNdvj7xDrDQd9TQDpzkLhM5L71rFDTmxMuzSvXwZKnLx56Es6MEg' ,
@@ -71,15 +71,15 @@ test('BIP32 from seed + derivation', function(t) {
7171test ( 'BIP32 from seed to address' , function ( t ) {
7272 t . plan ( 1 ) ;
7373
74- wally . bip32_key_from_seed ( seed , 0x0488ADE4 , 0 ) . then ( function ( s ) {
75- return wally . bip32_pubkey_from_parent ( s , 0 , 1 ) ;
74+ wally . bip32_key_from_seed ( seed , wally . BIP32_VER_MAIN_PRIVATE , wally . BIP32_FLAG_KEY_PRIVATE ) . then ( function ( s ) {
75+ return wally . bip32_pubkey_from_parent ( s , 0 , wally . BIP32_FLAG_KEY_PUBLIC ) ;
7676 } ) . then ( ( xpubkey ) => {
7777 return wally . bip32_key_get_pub_key ( xpubkey ) ;
7878 } ) . then ( ( pubkey ) => {
7979 return wally . wally_hash160 ( pubkey ) ;
8080 } ) . then ( ( script ) => {
8181 const prefix = Buffer . from ( 'eb' , 'hex' ) ;
82- return wally . wally_base58_from_bytes ( Buffer . concat ( [ prefix , script ] ) , 1 ) ;
82+ return wally . wally_base58_from_bytes ( Buffer . concat ( [ prefix , script ] ) , wally . BASE58_FLAG_CHECKSUM ) ;
8383 } ) . then ( ( address ) => {
8484 t . equal (
8585 address ,
0 commit comments