From a5e2df69422ba2f318fdf14af048065897c7f6ef Mon Sep 17 00:00:00 2001 From: Anastasia Prasolova Date: Thu, 7 Feb 2019 14:44:51 +0300 Subject: [PATCH] small fix of utxo calculation on raw transaction build (#126) * small fixes * gofmt * fix in raw tx build * fixes after review --- pkg/rpc/txBuilder.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/rpc/txBuilder.go b/pkg/rpc/txBuilder.go index 1f4b001d8..1d7f4dc46 100644 --- a/pkg/rpc/txBuilder.go +++ b/pkg/rpc/txBuilder.go @@ -48,8 +48,10 @@ func CreateRawContractTransaction(params ContractTxParams) (*transaction.Transac tx.AddInput(&input) } - senderOutput = transaction.NewOutput(assetID, spent-amount, fromAddressHash) - tx.AddOutput(senderOutput) + if senderUnspent := spent - amount; senderUnspent > 0 { + senderOutput = transaction.NewOutput(assetID, senderUnspent, fromAddressHash) + tx.AddOutput(senderOutput) + } receiverOutput = transaction.NewOutput(assetID, amount, toAddressHash) tx.AddOutput(receiverOutput)