mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 22:26:42 +00:00
added ChecksumAddress according to https://github.com/ethereum/EIPs/issues/55
This commit is contained in:
parent
dbaed09e19
commit
416f46ac99
2 changed files with 1 additions and 5 deletions
|
|
@ -350,7 +350,6 @@ func zeroBytes(bytes []byte) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// for input read: https://github.com/ethereum/EIPs/issues/55
|
// for input read: https://github.com/ethereum/EIPs/issues/55
|
||||||
// modelled after the JavaScript function toChecksumAddress()
|
// modelled after the JavaScript function toChecksumAddress()
|
||||||
// Convert address into checksummed address
|
// Convert address into checksummed address
|
||||||
|
|
@ -374,4 +373,3 @@ func ChecksumAddress(a common.Address) string {
|
||||||
func ChecksumAddressHex(s string) string {
|
func ChecksumAddressHex(s string) string {
|
||||||
return ChecksumAddress(common.HexToAddress(strings.Replace(strings.ToLower(s), "0x", "", 1)))
|
return ChecksumAddress(common.HexToAddress(strings.Replace(strings.ToLower(s), "0x", "", 1)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,9 +24,9 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"math/big"
|
"math/big"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/crypto/secp256k1"
|
"github.com/ethereum/go-ethereum/crypto/secp256k1"
|
||||||
|
|
@ -249,7 +249,6 @@ func TestPythonIntegration(t *testing.T) {
|
||||||
fmt.Printf("msg: %x, privkey: %x sig: %x\n", msg1, k1, sig1)
|
fmt.Printf("msg: %x, privkey: %x sig: %x\n", msg1, k1, sig1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func TestChecksumAddress(t *testing.T) {
|
func TestChecksumAddress(t *testing.T) {
|
||||||
// 4 groups of tests:
|
// 4 groups of tests:
|
||||||
// All caps
|
// All caps
|
||||||
|
|
@ -386,4 +385,3 @@ func TestChecksumAddressHex(t *testing.T) {
|
||||||
}
|
}
|
||||||
fmt.Printf("Passed %d tests and failed %d tests out of %d.\n", passed, failed, passed+failed)
|
fmt.Printf("Passed %d tests and failed %d tests out of %d.\n", passed, failed, passed+failed)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue