File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -239,6 +239,8 @@ However, production code will look more like this:
239
239
RECEIVE, CHANGE
240
240
async fromSeed(seedBytes, opts) // depth-0 hdkey (Wallet)
241
241
async fromXKey(xprv||xpub, opts) // depth-4 hdkey (XKey)
242
+ async toPublic(xKey)
243
+ async wipePrivateData(xKey)
242
244
async toWif(privBytes, opts)
243
245
async toAddr(pubBytes, opts)
244
246
async toXPrv(xprvKey, opts)
@@ -415,6 +417,22 @@ let xkey = await DashHd.fromXKey(xprvOrXPub, options);
415
417
}
416
418
```
417
419
420
+ ### `toPublic(xkey)`
421
+
422
+ Creates a copy of the HD Key with `privateKey` set to `null`.
423
+
424
+ ```js
425
+ let xpubKey = await DashHd.toPublic(xprvKey);
426
+ ```
427
+
428
+ ### `wipePrivateData(xkey)`
429
+
430
+ Performs an in-place secure erase of the private key memory.
431
+
432
+ ```js
433
+ await DashHd.wipePrivateData(xprvKey);
434
+ ```
435
+
418
436
### `toWif(privBytes, opts)`
419
437
420
438
Wrapper around `DashKeys.encodeKey(keyBytes, options)` to Base58Check-encode a
Original file line number Diff line number Diff line change 14
14
* @prop {HDToXKeyBytes } toXPubBytes
15
15
* @prop {HDUtils } utils
16
16
* @prop {HDWipePrivates } wipePrivateData - randomizes private key buffer in-place
17
+ * @prop {HDToPublic } toPublic - returns public key
17
18
* @prop {Number } HARDENED_OFFSET - 0x80000000
18
19
* @prop {HDVersions } MAINNET - 'xprv' & 'xpub'
19
20
* @prop {HDVersions } TESTNET - 'tprv' & 'tpub'
@@ -651,6 +652,12 @@ var DashHd = ("object" === typeof module && exports) || {};
651
652
return hdkey ;
652
653
} ;
653
654
655
+ DashHd . toPublic = function ( _hdkey ) {
656
+ let hdkey = Object . assign ( { } , _hdkey ) ;
657
+ hdkey . privateKey = null ;
658
+ return hdkey ;
659
+ } ;
660
+
654
661
DashHd . wipePrivateData = function ( hdkey ) {
655
662
if ( hdkey . privateKey ) {
656
663
Utils . secureErase ( hdkey . privateKey ) ;
@@ -908,6 +915,12 @@ if ("object" === typeof module) {
908
915
* @param {Uint8Array } buf
909
916
*/
910
917
918
+ /**
919
+ * @callback HDToPublic
920
+ * @param {HDKey } hdkey
921
+ * @returns {HDKey }
922
+ */
923
+
911
924
/**
912
925
* @callback HDWipePrivates
913
926
* @param {HDKey } hdkey
You can’t perform that action at this time.
0 commit comments