mirror of
https://github.com/embarklabs/ethereumjs-wallet.git
synced 2025-02-17 21:06:39 +00:00
Introduce '.getChecksumAddressString()'
This commit is contained in:
parent
3c09bc2527
commit
de11ded5df
16
index.js
16
index.js
@ -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 || {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user