@onekeyfe/kaspa-core-lib 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +1 -0
- package/lib/address.js +9 -14
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -84,6 +84,7 @@ declare module '@onekeyfe/kaspa-core-lib' {
|
|
|
84
84
|
export class Script {
|
|
85
85
|
constructor(script ? : Script);
|
|
86
86
|
static buildPublicKeyHashIn(publicKey: PublicKey, signature: Signature, sigtype): Script;
|
|
87
|
+
static buildPublicKeyIn(signature: Signature, sigtype): Script;
|
|
87
88
|
static empty(): Script;
|
|
88
89
|
inspect():string;
|
|
89
90
|
toBuffer():Buffer;
|
package/lib/address.js
CHANGED
|
@@ -403,6 +403,8 @@ Address._transformString = function(data, network, type) {
|
|
|
403
403
|
if (typeof(data) !== 'string') {
|
|
404
404
|
throw new TypeError('data parameter supplied is not a string.');
|
|
405
405
|
}
|
|
406
|
+
|
|
407
|
+
data = data.trim();
|
|
406
408
|
if (data.length < 34){
|
|
407
409
|
throw new Error('Invalid address');
|
|
408
410
|
}
|
|
@@ -411,27 +413,20 @@ Address._transformString = function(data, network, type) {
|
|
|
411
413
|
throw new TypeError('address string is too long');
|
|
412
414
|
}
|
|
413
415
|
|
|
414
|
-
data = data.trim();
|
|
415
416
|
var networkObj = Networks.get(network);
|
|
416
417
|
|
|
417
418
|
if (network && !networkObj) {
|
|
418
419
|
throw new TypeError('Unknown network');
|
|
419
420
|
}
|
|
420
421
|
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
throw new TypeError('Address has mismatched network type.');
|
|
425
|
-
}
|
|
426
|
-
if (!info.type || (type && type !== info.type)) {
|
|
427
|
-
throw new TypeError('Address has mismatched type.');
|
|
428
|
-
}
|
|
429
|
-
return info;
|
|
430
|
-
} else {
|
|
431
|
-
var addressBuffer = Base58Check.decode(data);
|
|
432
|
-
// Legacy addr
|
|
433
|
-
return Address._transformBuffer(addressBuffer, network, type);
|
|
422
|
+
var info = decodeCashAddress(data);
|
|
423
|
+
if (!info.network || (networkObj && networkObj.name !== info.network.name)) {
|
|
424
|
+
throw new TypeError('Address has mismatched network type.');
|
|
434
425
|
}
|
|
426
|
+
if (!info.type || (type && type !== info.type)) {
|
|
427
|
+
throw new TypeError('Address has mismatched type.');
|
|
428
|
+
}
|
|
429
|
+
return info;
|
|
435
430
|
};
|
|
436
431
|
|
|
437
432
|
|