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')
|
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
|
// https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition
|
||||||
Wallet.prototype.toV3 = function (password, opts) {
|
Wallet.prototype.toV3 = function (password, opts) {
|
||||||
opts = opts || {}
|
opts = opts || {}
|
||||||
|
|
Loading…
Reference in New Issue