4
4
/** @typedef {import('./base-x.types.js').DecodeUnsafe } BaseXDecodeUnsafe */
5
5
/** @typedef {import('./base-x.types.js').Encode } BaseXEncode */
6
6
/** @typedef {import('./base58check.types.js').Base58Check } Base58Check */
7
+ /** @typedef {import('./base58check.types.js').base58Check } Base58CheckInstance */
7
8
/** @typedef {import('./base58check.types.js').Checksum } Base58CheckChecksum */
8
9
/** @typedef {import('./base58check.types.js').Create } Base58CheckCreate */
9
10
/** @typedef {import('./base58check.types.js').Decode } Base58CheckDecode */
37
38
* @prop {WifToAddress } wifToAddr
38
39
* @prop {WifToPrivateKey } wifToPrivKey
39
40
* @prop {DashKeysUtils } utils
41
+ * @prop {EncodeKeyUint8Array } _encodeXKey
42
+ * @prop {Base58CheckInstance } _dash58check
40
43
*/
41
44
42
45
/**
@@ -456,7 +459,7 @@ var DashKeys = ("object" === typeof module && exports) || {};
456
459
457
460
/** @type {Base58CheckVerify } */
458
461
b58c . verify = async function ( b58Addr , opts ) {
459
- let bytes = bs58 . decode ( b58Addr , opts ) ;
462
+ let bytes = bs58 . decode ( b58Addr ) ;
460
463
let hex = Utils . bytesToHex ( bytes ) ;
461
464
return await b58c . verifyHex ( hex , opts ) ;
462
465
} ;
@@ -964,6 +967,8 @@ var DashKeys = ("object" === typeof module && exports) || {};
964
967
965
968
/** @type {AddressToPubKeyHash } */
966
969
_DashKeys . addrToPkh = async function ( address , opts ) {
970
+ /** @type {Base58CheckPubKeyHashParts } */
971
+ //@ts -ignore - address has pkh parts
967
972
let addrParts = await _DashKeys . decode ( address , opts ) ;
968
973
let shaRipeBytes = Utils . hexToBytes ( addrParts . pubKeyHash ) ;
969
974
@@ -972,6 +977,7 @@ var DashKeys = ("object" === typeof module && exports) || {};
972
977
973
978
/** @type {DecodeBase58Check } */
974
979
_DashKeys . decode = async function ( keyB58c , opts ) {
980
+ /* jshint maxcomplexity:35 */
975
981
let _opts = { } ;
976
982
if ( opts ?. version ) {
977
983
switch ( opts . version ) {
@@ -1039,7 +1045,7 @@ var DashKeys = ("object" === typeof module && exports) || {};
1039
1045
let check = await dash58check . checksum ( parts ) ;
1040
1046
let valid = parts . check === check ;
1041
1047
if ( ! valid ) {
1042
- if ( false !== opts . validate ) {
1048
+ if ( false !== opts ? .validate ) {
1043
1049
// to throw the inner error
1044
1050
await dash58check . verify ( keyB58c , _opts ) ;
1045
1051
}
@@ -1220,7 +1226,11 @@ var DashKeys = ("object" === typeof module && exports) || {};
1220
1226
/** @type {PublicKeyToAddress } */
1221
1227
_DashKeys . pubkeyToAddr = async function ( pubBytes , opts ) {
1222
1228
let shaRipeBytes = await _DashKeys . pubkeyToPkh ( pubBytes ) ;
1223
- let addr = await _DashKeys . pkhToAddr ( shaRipeBytes , opts ) ;
1229
+ let addr = await _DashKeys . pkhToAddr (
1230
+ shaRipeBytes ,
1231
+ //@ts -ignore - has version property
1232
+ opts ,
1233
+ ) ;
1224
1234
1225
1235
return addr ;
1226
1236
} ;
@@ -1276,6 +1286,7 @@ var DashKeys = ("object" === typeof module && exports) || {};
1276
1286
/**
1277
1287
* @callback PrivateKeyToWif
1278
1288
* @param {Uint8Array } privBytes
1289
+ * @param {EncodeKeyUint8ArrayOpts } [opts]
1279
1290
* @returns {Promise<String> } - wif
1280
1291
*/
1281
1292
@@ -1305,13 +1316,14 @@ if ("object" === typeof module) {
1305
1316
/**
1306
1317
* @callback AddressToPubKeyHash
1307
1318
* @param {String } addr - Base58Check encoded version + pkh + check
1319
+ * @param {DecodeOpts } [opts]
1308
1320
* @returns {Promise<Uint8Array> } - pkh bytes (no version or check, NOT Base58Check)
1309
1321
*/
1310
1322
1311
1323
/**
1312
1324
* @callback DecodeBase58Check
1313
1325
* @param {String } keyB58c - addr, wif, or xkey (xprv, xpub)
1314
- * @param {DecodeOpts } opts
1326
+ * @param {DecodeOpts } [ opts]
1315
1327
* @returns {Promise<Base58CheckParts> }
1316
1328
*/
1317
1329
0 commit comments