From 52b0d661e065e52380c797ebef9fc9e1da1ae11e Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Tue, 10 Sep 2019 14:19:36 +0300 Subject: [PATCH] vm: implement BigInt -> Boolean conversion --- pkg/vm/stack.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/vm/stack.go b/pkg/vm/stack.go index 17c6e8143..234d27dc0 100644 --- a/pkg/vm/stack.go +++ b/pkg/vm/stack.go @@ -63,6 +63,11 @@ func (e *Element) BigInt() *big.Int { switch t := e.value.(type) { case *BigIntegerItem: return t.value + case *BoolItem: + if t.value { + return big.NewInt(1) + } + return big.NewInt(0) default: b := t.Value().([]uint8) return new(big.Int).SetBytes(util.ArrayReverse(b))