use of io.nuls.ledger.rpc.model.InputDto in project nuls by nuls-io.
the class TransactionResource method calTransactionValue.
/**
* 计算交易实际发生的金额
* Calculate the actual amount of the transaction.
*
* @param txDto
*/
private void calTransactionValue(TransactionDto txDto) {
if (txDto == null) {
return;
}
List<InputDto> inputDtoList = txDto.getInputs();
Set<String> inputAdressSet = new HashSet<>(inputDtoList.size());
for (InputDto inputDto : inputDtoList) {
inputAdressSet.add(inputDto.getAddress());
}
Na value = Na.ZERO;
List<OutputDto> outputDtoList = txDto.getOutputs();
for (OutputDto outputDto : outputDtoList) {
if (inputAdressSet.contains(outputDto.getAddress())) {
continue;
}
value = value.add(Na.valueOf(outputDto.getValue()));
}
txDto.setValue(value.getValue());
}