Skip to content

Commit

Permalink
mobile: added constructor for big int (ethereum#21597)
Browse files Browse the repository at this point in the history
* mobile: added constructor for big int

* mobile: tiny nitpick
  • Loading branch information
MariusVanDerWijden authored and enriquefynn committed Feb 15, 2021
1 parent f4610a0 commit 32be0a9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions mobile/big.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ func NewBigInt(x int64) *BigInt {
return &BigInt{big.NewInt(x)}
}

// NewBigIntFromString allocates and returns a new BigInt set to x
// interpreted in the provided base.
func NewBigIntFromString(x string, base int) *BigInt {
b, success := new(big.Int).SetString(x, base)
if !success {
return nil
}
return &BigInt{b}
}

// GetBytes returns the absolute value of x as a big-endian byte slice.
func (bi *BigInt) GetBytes() []byte {
return bi.bigint.Bytes()
Expand Down

0 comments on commit 32be0a9

Please sign in to comment.