Skip to content

Commit 8f39b51

Browse files
Support for BIP49 YPUB/UPUB
1 parent 9c8503c commit 8f39b51

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/hdnode.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ HDNode.fromBase58 = function (string, networks) {
6464
if (Array.isArray(networks)) {
6565
network = networks.filter(function (x) {
6666
return version === x.bip32.private ||
67-
version === x.bip32.public
67+
version === x.bip32.public ||
68+
version === x.bip49.private ||
69+
version === x.bip49.public
6870
}).pop()
6971

7072
if (!network) throw new Error('Unknown network version')
@@ -75,7 +77,9 @@ HDNode.fromBase58 = function (string, networks) {
7577
}
7678

7779
if (version !== network.bip32.private &&
78-
version !== network.bip32.public) throw new Error('Invalid network version')
80+
version !== network.bip32.public &&
81+
version !== network.bip49.private &&
82+
version !== network.bip49.public) throw new Error('Invalid network version')
7983

8084
// 1 byte: depth: 0x00 for master nodes, 0x01 for level-1 descendants, ...
8185
var depth = buffer[4]

src/networks.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ module.exports = {
99
public: 0x0488b21e,
1010
private: 0x0488ade4
1111
},
12+
bip49: {
13+
public: 0x049D7CB2,
14+
private: 0x049D7878
15+
},
1216
pubKeyHash: 0x00,
1317
scriptHash: 0x05,
1418
wif: 0x80
@@ -20,6 +24,10 @@ module.exports = {
2024
public: 0x043587cf,
2125
private: 0x04358394
2226
},
27+
bip49: {
28+
public: 0x044A5262,
29+
private: 0x044A4E28
30+
},
2331
pubKeyHash: 0x6f,
2432
scriptHash: 0xc4,
2533
wif: 0xef

0 commit comments

Comments
 (0)