# new Address(address, testOnlyopt) → {module:dcp/wallet.Address|boolean}
Class which represents an Ethereum address (public key); used in DCP for public mentions of things like proof of user identity, bank account numbers, etc.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
address |
string | object | The address we want to represent. If the passed address is a string, it should be (but is not required to be) in checksum format; a leading 0x is not required. If the address is an object, we coerce the object with toString(16) before working with it (BigNumber and similar objects are expected to "just work") note - An address which arrives as an all-uppercase string and no leading 0x will not have its checksum validated. This is to ease debugging against MySQL database copy-and-paste and should have a negligible real-world impact. |
|
testOnly |
boolean |
<optional> |
when true, return true only when the privateKey argument could be used to construct without throwing |
when the address is invalid, fails checksum, etc.
when the address is a number; eg a programmer typed in a hexadecimal literal.
instance of Address whose value is a checksummed string of hex
digits with leading 0x or a boolean corresponding to the result of the testOnly
flag.
Methods
# ct(privateKey) → {boolean}
Corresponds-To method. Determines if this Address corresponds to the passed private key.
Parameters:
Name | Type | Description |
---|---|---|
privateKey |
string | object | An instance of PrivateKey or a value suitable for the PrivateKey constructor |
- See:
true when this address corresponds to the passed privateKey
# eq(address2) → {boolean}
Equality comparsion.
Parameters:
Name | Type | Description |
---|---|---|
address2 |
string | object | The address we want to compare. May be used as an argument to the Address() constructor. |
true if address2 represents the same eth address as this instance; false otherwise.
# toBuffer() → {Buffer|ArrayBuffer}
buffer (node: Buffer, browser: ArrayBuffer) of the address.
# verifySignature(messageBody, signature) → {boolean}
Verifies that an ethereum signature for the message came from this address.
Parameters:
Name | Type | Description |
---|---|---|
messageBody |
any | The message that the signature was created from. It will be stringified via JSON.stringify. |
signature |
object | string | The signature to compare against the address and messageBody. If it is a string, it will be coerced to an object via JSON.parse. |
true when this address matches the address that signed the message