small fix of utxo calculation on raw transaction build (#126)

* small fixes

* gofmt

* fix in raw tx build

* fixes after review
This commit is contained in:
Anastasia Prasolova 2019-02-07 14:44:51 +03:00 committed by fabwa
parent a058598ecc
commit a5e2df6942

View file

@ -48,8 +48,10 @@ func CreateRawContractTransaction(params ContractTxParams) (*transaction.Transac
tx.AddInput(&input) tx.AddInput(&input)
} }
senderOutput = transaction.NewOutput(assetID, spent-amount, fromAddressHash) if senderUnspent := spent - amount; senderUnspent > 0 {
senderOutput = transaction.NewOutput(assetID, senderUnspent, fromAddressHash)
tx.AddOutput(senderOutput) tx.AddOutput(senderOutput)
}
receiverOutput = transaction.NewOutput(assetID, amount, toAddressHash) receiverOutput = transaction.NewOutput(assetID, amount, toAddressHash)
tx.AddOutput(receiverOutput) tx.AddOutput(receiverOutput)