Added "xdc" prefix in address

This commit is contained in:
AnilChinchawale 2019-03-17 16:14:42 +05:30
parent f272b5d8cb
commit ed6533e092
4 changed files with 282 additions and 13666 deletions

View file

@ -1853,7 +1853,7 @@ func (bc *BlockChain) UpdateM1() error {
return err
}
//TODO: smart contract shouldn't return "0x0000000000000000000000000000000000000000"
if candidate.String() != "0x0000000000000000000000000000000000000000" {
if candidate.String() != "xdc0000000000000000000000000000000000000000" {
ms = append(ms, XDPoS.Masternode{Address: candidate, Stake: v})
}
}

View file

@ -537,7 +537,14 @@ func (args *FilterCriteria) UnmarshalJSON(data []byte) error {
return nil
}
func hasXDCPrefix(str string) bool {
return len(str) >= 3 && (str[0] == 'x' || str[0] == 'X') && (str[1] == 'd' || str[1] == 'D') && (str[2] == 'c' || str[2] == 'C')
}
func decodeAddress(s string) (common.Address, error) {
if hasXDCPrefix(s) {
s = "0x" + s[3:]
}
b, err := hexutil.Decode(s)
if err == nil && len(b) != common.AddressLength {
err = fmt.Errorf("hex has invalid length %d after decoding", len(b))

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long