Skip to content

Commit

Permalink
pubkeyhex type (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
metachris committed Jul 7, 2022
1 parent aaa40fb commit c7452a0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions types/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@ package types

import (
"math/big"
"strings"
)

type PubkeyHex string

func NewPubkeyHex(pk string) PubkeyHex {
return PubkeyHex(strings.ToLower(pk))
}

func (n *U256Str) BigInt() *big.Int {
return new(big.Int).SetBytes(reverse(n[:]))
}
Expand All @@ -16,6 +23,10 @@ func (n *U256Str) Cmp(b *U256Str) int {
return _a.Cmp(_b)
}

func (p PublicKey) PubkeyHex() PubkeyHex {
return NewPubkeyHex(p.String())
}

// HexToAddress takes a hex string and returns an Address
func HexToAddress(s string) (ret Address, err error) {
err = ret.UnmarshalText([]byte(s))
Expand Down

0 comments on commit c7452a0

Please sign in to comment.