Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public double makeTxFees(Transaction tx) {
if (!this.isValidTx(tx)) {
return 0;
}
double inputValuesSum = tx.getInputs()
.parallelStream()
.map((x) -> new UTXO(x.prevTxHash, x.outputIndex))
.filter((x) -> this.utxoPool.contains(x))
.mapToDouble((x) -> this.utxoPool.getTxOutput(x).value)
.sum();
double outputValuesSum = tx.getOutputs()
.parallelStream()
.mapToDouble((x) -> x.value)
.sum();
return inputValuesSum - outputValuesSum;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.