Introduce '.getChecksumAddressString()'

This commit is contained in:
Alex Beregszaszi 2016-03-08 19:47:55 +00:00
parent 3c09bc2527
commit de11ded5df
1 changed files with 16 additions and 0 deletions

View File

@ -41,6 +41,22 @@ Wallet.prototype.getAddressString = function () {
return '0x' + this.getAddress().toString('hex')
}
Wallet.prototype.getChecksumAddressString = function () {
var address = this.getAddress().toString('hex')
var hash = ethUtil.sha3(address).toString('hex')
var ret = '0x'
for (var i = 0; i < address.length; i++) {
if (parseInt(hash[i], 16) >= 8) {
ret += address[i].toUpperCase()
} else {
ret += address[i]
}
}
return ret
}
// https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition
Wallet.prototype.toV3 = function (password, opts) {
opts = opts || {}