From d5d0479671979ad7e5c64a7eac3ed13d7a8888c7 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Mon, 16 Mar 2020 18:43:02 +0300 Subject: [PATCH] core: verify results of issue transaction It shouldn't try to issue more tokens than there is available. --- pkg/core/blockchain.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index 85a439d67..e5a7a5519 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -1660,6 +1660,13 @@ func (bc *Blockchain) verifyResults(t *transaction.Transaction, results []*trans if r.AssetID == UtilityTokenID() { return errors.New("issue tx issues utility tokens") } + asset, err := bc.dao.GetAssetState(r.AssetID) + if asset == nil || err != nil { + return errors.New("invalid asset in issue tx") + } + if asset.Available < r.Amount { + return errors.New("trying to issue more than available") + } } break default: