Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
9e80d9be
Commit
9e80d9be
authored
Jul 16, 2017
by
Jim McDonald
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
common: Address.Hex() outputs EIP55-compliant string
parent
0ff35e17
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
1 deletion
+23
-1
types.go
common/types.go
+23
-1
No files found.
common/types.go
View file @
9e80d9be
...
@@ -24,6 +24,7 @@ import (
...
@@ -24,6 +24,7 @@ import (
"reflect"
"reflect"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/crypto/sha3"
)
)
const
(
const
(
...
@@ -163,7 +164,28 @@ func (a Address) Str() string { return string(a[:]) }
...
@@ -163,7 +164,28 @@ func (a Address) Str() string { return string(a[:]) }
func
(
a
Address
)
Bytes
()
[]
byte
{
return
a
[
:
]
}
func
(
a
Address
)
Bytes
()
[]
byte
{
return
a
[
:
]
}
func
(
a
Address
)
Big
()
*
big
.
Int
{
return
new
(
big
.
Int
)
.
SetBytes
(
a
[
:
])
}
func
(
a
Address
)
Big
()
*
big
.
Int
{
return
new
(
big
.
Int
)
.
SetBytes
(
a
[
:
])
}
func
(
a
Address
)
Hash
()
Hash
{
return
BytesToHash
(
a
[
:
])
}
func
(
a
Address
)
Hash
()
Hash
{
return
BytesToHash
(
a
[
:
])
}
func
(
a
Address
)
Hex
()
string
{
return
hexutil
.
Encode
(
a
[
:
])
}
// Hex returns an EIP55-compliant hex string representation of the address.
func
(
a
Address
)
Hex
()
string
{
unchecksummed
:=
hex
.
EncodeToString
(
a
[
:
])
sha
:=
sha3
.
NewKeccak256
()
sha
.
Write
([]
byte
(
unchecksummed
))
hash
:=
sha
.
Sum
(
nil
)
result
:=
[]
byte
(
unchecksummed
)
for
i
:=
0
;
i
<
len
(
result
);
i
++
{
hashByte
:=
hash
[
i
/
2
]
if
i
%
2
==
0
{
hashByte
=
hashByte
>>
4
}
else
{
hashByte
&=
0xf
}
if
result
[
i
]
>
'9'
&&
hashByte
>
7
{
result
[
i
]
-=
32
}
}
return
"0x"
+
string
(
result
)
}
// String implements the stringer interface and is used also by the logger.
// String implements the stringer interface and is used also by the logger.
func
(
a
Address
)
String
()
string
{
func
(
a
Address
)
String
()
string
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment