Update cloud.js
Added ethereum address handling for decodeID function
This commit is contained in:
parent
6a57aa1273
commit
36d15bd7f8
10
src/cloud.js
10
src/cloud.js
@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
function K_Bucket(masterID, nodeList) {
|
function K_Bucket(masterID, nodeList) {
|
||||||
|
|
||||||
const decodeID = function(floID) {
|
const decodeID = function (floID) {
|
||||||
|
if (floID.startsWith("0x") || floID.length === '40')
|
||||||
|
floID = proxyID(floID);
|
||||||
let k = bitjs.Base58.decode(floID);
|
let k = bitjs.Base58.decode(floID);
|
||||||
k.shift();
|
k.shift();
|
||||||
k.splice(-4, 4);
|
k.splice(-4, 4);
|
||||||
@ -110,7 +112,7 @@ function proxyID(address) {
|
|||||||
});
|
});
|
||||||
hash[0] != checksum[0] || hash[1] != checksum[1] || hash[2] != checksum[2] || hash[3] != checksum[3] ?
|
hash[0] != checksum[0] || hash[1] != checksum[1] || hash[2] != checksum[2] || hash[3] != checksum[3] ?
|
||||||
bytes = undefined : bytes.shift();
|
bytes = undefined : bytes.shift();
|
||||||
} else if (address.length == 42 || address.length == 62) { //bech encoding
|
} else if (!address.startsWith("0x") && (address.length == 42 || address.length == 62)) { //bech encoding
|
||||||
if (typeof coinjs !== 'function')
|
if (typeof coinjs !== 'function')
|
||||||
throw "library missing (lib_btc.js)";
|
throw "library missing (lib_btc.js)";
|
||||||
let decode = coinjs.bech32_decode(address);
|
let decode = coinjs.bech32_decode(address);
|
||||||
@ -125,8 +127,8 @@ function proxyID(address) {
|
|||||||
bytes = ripemd160(Crypto.SHA256(Crypto.util.hexToBytes(address), {
|
bytes = ripemd160(Crypto.SHA256(Crypto.util.hexToBytes(address), {
|
||||||
asBytes: true
|
asBytes: true
|
||||||
}));
|
}));
|
||||||
} else if ((address.length == 42 && address.startsWith("0x")) || (address.length == 40 && !address.startsWith("0x"))){ //Ethereum Address
|
} else if ((address.length == 42 && address.startsWith("0x")) || (address.length == 40 && !address.startsWith("0x"))) { //Ethereum Address
|
||||||
if (address.startsWith("0x")) { address = address.substring(2);}
|
if (address.startsWith("0x")) { address = address.substring(2); }
|
||||||
bytes = Crypto.util.hexToBytes(address);
|
bytes = Crypto.util.hexToBytes(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user