You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
451 B

  1. package common
  2. import (
  3. "math/big"
  4. ethCommon "github.com/ethereum/go-ethereum/common"
  5. )
  6. // SwapEndianness swaps the order of the bytes in the slice.
  7. func SwapEndianness(b []byte) []byte {
  8. o := make([]byte, len(b))
  9. for i := range b {
  10. o[len(b)-1-i] = b[i]
  11. }
  12. return o
  13. }
  14. // EthAddrToBigInt returns a *big.Int from a given ethereum common.Address.
  15. func EthAddrToBigInt(a ethCommon.Address) *big.Int {
  16. return new(big.Int).SetBytes(a.Bytes())
  17. }