From a90e645ccda7d8d373783e161e6c6fc4430cb6d0 Mon Sep 17 00:00:00 2001 From: Marius van der Wijden Date: Mon, 28 Sep 2020 14:12:08 +0200 Subject: [PATCH] mobile: added constructor for big int (#21597) * mobile: added constructor for big int * mobile: tiny nitpick --- mobile/big.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mobile/big.go b/mobile/big.go index 86ea93245..c08bcf93f 100644 --- a/mobile/big.go +++ b/mobile/big.go @@ -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()