Skip to content

Commit f39b968

Browse files
committed
Use bip32_key_get_pub_key & bip32_key_get_priv_key instead of slice
1 parent e8c5745 commit f39b968

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/wrap_js/makewrappers/wrap.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ def __init__(self, arguments, out_size=None, wally_name=None, nodejs_append_allo
146146
('bip32_key_get_priv_key', F([
147147
'bip32_in', 'out_bytes_fixedsized'
148148
], out_size='32')),
149+
('bip32_key_get_pub_key', F([
150+
'bip32_in', 'out_bytes_fixedsized'
151+
], out_size='33')),
149152

150153
('wally_ec_public_key_from_private_key', F([
151154
'const_bytes[key]', 'out_bytes_fixedsized'

src/wrap_js/test/test_bip32.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ test('BIP32 from seed + derivation', function(t) {
2626
});
2727
});
2828

29-
wally.wally_ec_public_key_from_private_key(s.slice(46, 78)).then(function(master_pubkey) {
30-
t.equal(
31-
Buffer.from(master_pubkey).toString('hex'),
32-
'02be99138b48b430a8ee40bf8b56c8ebc584c363774010a9bfe549a87126e61746',
33-
'M/0'
34-
);
35-
});
29+
wally.bip32_key_get_priv_key(s).then(function(privkey) {
30+
wally.wally_ec_public_key_from_private_key(privkey).then(function(master_pubkey) {
31+
t.equal(
32+
Buffer.from(master_pubkey).toString('hex'),
33+
'02be99138b48b430a8ee40bf8b56c8ebc584c363774010a9bfe549a87126e61746',
34+
'M/0'
35+
);
36+
});
37+
})
3638

3739
wally.bip32_privkey_from_parent(s, 0, 0).then(function (xpriv_0_0) {
3840
wally.wally_base58_from_bytes(xpriv_0_0, 1).then(function (base58_xpriv) {
@@ -72,7 +74,8 @@ test('BIP32 from seed to address', function(t) {
7274
wally.bip32_key_from_seed(seed, 0x0488ADE4, 0).then(function(s) {
7375
return wally.bip32_pubkey_from_parent(s, 0, 1);
7476
}).then((xpubkey) => {
75-
const pubkey = xpubkey.slice(45, 78);
77+
return wally.bip32_key_get_pub_key(xpubkey);
78+
}).then((pubkey) => {
7679
return wally.wally_hash160(pubkey);
7780
}).then((script) => {
7881
const prefix = Buffer.from('eb', 'hex');

0 commit comments

Comments
 (0)