@@ -100,13 +100,19 @@ var DashHd = ("object" === typeof module && exports) || {};
100
100
101
101
/**
102
102
* @param {Uint8Array } keyBytes
103
- * TODO - pass tprv
103
+ * @param {Object } opts
104
+ * @param {Number } [opts.version]
104
105
*/
105
- Utils . encodeXPrv = async function ( keyBytes ) {
106
+ Utils . encodeXPrv = async function ( keyBytes , opts ) {
106
107
//@ts -ignore - wth?
107
108
let DashKeys = window . DashKeys || require ( "dashkeys" ) ;
109
+ let version = "xprv" ;
110
+ if ( opts ?. version ) {
111
+ version = opts ?. version . toString ( 16 ) ;
112
+ version = version . padStart ( 8 , "0" ) ;
113
+ }
108
114
//@ts -ignore
109
- return await DashKeys . encodeKey ( keyBytes , { version : "xprv" } ) ;
115
+ return await DashKeys . encodeKey ( keyBytes , { version } ) ;
110
116
} ;
111
117
112
118
/**
@@ -514,7 +520,7 @@ var DashHd = ("object" === typeof module && exports) || {};
514
520
} ;
515
521
516
522
DashHd . fromXKey = async function ( xkey , opts ) {
517
- // version(4) + depth(1) + fingerprint(4) + index(4) + chain(32) + key(33 )
523
+ // version(4) + depth(1) + fingerprint(4) + index(4) + chain(32) + key(1 + 32 )
518
524
let versions = opts ?. versions ?? DashHd . MAINNET ;
519
525
let normalizePublicKey = opts ?. normalizePublicKey ?? false ;
520
526
let bip32 = opts ?. bip32 ?? false ;
@@ -606,7 +612,7 @@ var DashHd = ("object" === typeof module && exports) || {};
606
612
* @param {Uint8Array } keyBytes
607
613
*/
608
614
function serialize ( hdkey , keyBytes ) {
609
- // version(4) + depth(1) + fingerprint(4) + index(4) + chain(32) + key(33 )
615
+ // version(4) + depth(1) + fingerprint(4) + index(4) + chain(32) + key(1 + 32 )
610
616
let xkey = new Uint8Array ( XKEY_SIZE ) ;
611
617
let xkeyDv = new DataView ( xkey . buffer ) ;
612
618
0 commit comments