Edit library to accept WIF of other versions
This commit is contained in:
parent
b80bd43313
commit
fcc5f3ce4e
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
*.tmp*
|
||||||
17
lib.js
17
lib.js
@ -1,4 +1,4 @@
|
|||||||
(function(GLOBAL) { //lib v1.2.2a
|
(function(GLOBAL) { //lib v1.2.3
|
||||||
'use strict';
|
'use strict';
|
||||||
/* Utility Libraries required for Standard operations
|
/* Utility Libraries required for Standard operations
|
||||||
* All credits for these codes belong to their respective creators, moderators and owners.
|
* All credits for these codes belong to their respective creators, moderators and owners.
|
||||||
@ -5016,12 +5016,12 @@
|
|||||||
*
|
*
|
||||||
* Returns the address as a base58-encoded string in the standardized format.
|
* Returns the address as a base58-encoded string in the standardized format.
|
||||||
*/
|
*/
|
||||||
Bitcoin.Address.prototype.toString = function() {
|
Bitcoin.Address.prototype.toString = function(version = null) {
|
||||||
// Get a copy of the hash
|
// Get a copy of the hash
|
||||||
var hash = this.hash.slice(0);
|
var hash = this.hash.slice(0);
|
||||||
|
|
||||||
// Version
|
// Version
|
||||||
hash.unshift(this.version);
|
hash.unshift(version !== null ? version : this.version);
|
||||||
var checksum = Crypto.SHA256(Crypto.SHA256(hash, {
|
var checksum = Crypto.SHA256(Crypto.SHA256(hash, {
|
||||||
asBytes: true
|
asBytes: true
|
||||||
}), {
|
}), {
|
||||||
@ -5130,7 +5130,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
var Q;
|
var Q;
|
||||||
if (pubkey instanceof ec.PointFp) {
|
if (pubkey instanceof EllipticCurve.PointFp) {
|
||||||
Q = pubkey;
|
Q = pubkey;
|
||||||
} else if (Bitcoin.Util.isArray(pubkey)) {
|
} else if (Bitcoin.Util.isArray(pubkey)) {
|
||||||
Q = EllipticCurve.PointFp.decodeFrom(ecparams.getCurve(), pubkey);
|
Q = EllipticCurve.PointFp.decodeFrom(ecparams.getCurve(), pubkey);
|
||||||
@ -5444,9 +5444,8 @@
|
|||||||
var bytes = null;
|
var bytes = null;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// This part is edited for FLO. FLO WIF are always compressed WIF. FLO WIF (private key) starts with R for mainnet and c for testnet.
|
// This part is edited for FLO. FLO WIF are always compressed WIF (length of 52).
|
||||||
if (((GLOBAL.cryptocoin == "FLO") && /^R[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{51}$/.test(input)) ||
|
if ((/^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{52}$/.test(input))) {
|
||||||
((GLOBAL.cryptocoin == "FLO_TEST") && /^c[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{51}$/.test(input))) {
|
|
||||||
bytes = ECKey.decodeCompressedWalletImportFormat(input);
|
bytes = ECKey.decodeCompressedWalletImportFormat(input);
|
||||||
this.compressed = true;
|
this.compressed = true;
|
||||||
} else if (ECKey.isHexFormat(input)) {
|
} else if (ECKey.isHexFormat(input)) {
|
||||||
@ -5673,9 +5672,11 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
var version = hash.shift();
|
var version = hash.shift();
|
||||||
|
/*
|
||||||
if (version != ECKey.privateKeyPrefix) {
|
if (version != ECKey.privateKeyPrefix) {
|
||||||
throw "Version " + version + " not supported!";
|
throw "Version " + version + " not supported!";
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
return hash;
|
return hash;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -5697,9 +5698,11 @@
|
|||||||
throw "Checksum validation failed!";
|
throw "Checksum validation failed!";
|
||||||
}
|
}
|
||||||
var version = hash.shift();
|
var version = hash.shift();
|
||||||
|
/*
|
||||||
if (version != ECKey.privateKeyPrefix) {
|
if (version != ECKey.privateKeyPrefix) {
|
||||||
throw "Version " + version + " not supported!";
|
throw "Version " + version + " not supported!";
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
hash.pop();
|
hash.pop();
|
||||||
return hash;
|
return hash;
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user