utils/address-utils.js

Utility encryption related functions for KeyManager module.
Author:
  • Raul Aragonez (r.aragonez@topl.me)
Source:

Methods

(inner) createAssetCode(networkPrefix, address, shortName) → {string}

Source:
Parameters:
Name Type Description
networkPrefix string prefix of network where address will be used
address string address to be used to create asset code
shortName string name of assets, up to 8 bytes long latin-1 enconding
Returns:
Type:
string
return asset code

(inner) extractAddressesFromObj(obj) → {Array}

Parse obj to retrieve addresses from the following keys: ["recipients", "sender", "changeAddress", "consolidationAdddress", "addresses"]
Source:
Parameters:
Name Type Description
obj object json obj to retrieve addresses from
Returns:
Type:
Array
list of addresses found in object

(inner) generatePubKeyHashAddress(publicKey, networkPrefix) → {object}

Generate Hash Address using the Public Key and Network Prefix
Source:
Parameters:
Name Type Description
publicKey Buffer base58 buffer of public key
networkPrefix String prefix of network where address will be used
Returns:
Type:
object
result obj returned as json

(inner) getAddressNetwork(address) → {object}

Source:
Parameters:
Name Type Description
address string valid address to retrieve network prefix from
Returns:
Type:
object
obj with {success: , networkPrefix: "", error: ""}

(inner) getDecimalByNetwork(networkPrefix) → {String}

Source:
Parameters:
Name Type Description
networkPrefix String prefix of network to validate against
Returns:
Type:
String
hexadecimal value of network

(inner) getHexByNetwork(networkPrefix) → {hex}

Source:
Parameters:
Name Type Description
networkPrefix String prefix of network to validate against
Returns:
Type:
hex
hexadecimal value of network

(inner) getValidNetworksList(networkPrefix) → {object}

Source:
Parameters:
Name Type Description
networkPrefix String prefix of network to validate against
Returns:
Type:
object
json obj of valid networks

(inner) isValidAssetCode(assetCode) → {boolean}

Source:
Parameters:
Name Type Description
assetCode string string in latin1 encoding
Returns:
Type:
boolean
true if valid

(inner) isValidMetadata(metadata) → {boolean}

Source:
Parameters:
Name Type Description
metadata string string in latin1 encoding
Returns:
Type:
boolean
true if valid

(inner) isValidNetwork(networkPrefix) → {boolean}

Source:
Parameters:
Name Type Description
networkPrefix String prefix of network to validate against
Returns:
Type:
boolean
true if network is valid and is included in the valid networks obj

(inner) validateAddressesByNetwork(networkPrefix, addresses) → {object}

Check if addresses are valid by verifying: 1. verify the address is not null 2. verify the base58 is 38 bytes long 3. verify that it matches the network 4. verify that hash matches the last 4 bytes
Source:
Parameters:
Name Type Description
networkPrefix String prefix of network to validate against
addresses Array list of addresses to run validation against
Returns:
Type:
object
result obj returned as json