Skip to content

Instantly share code, notes, and snippets.

@slaykovsky
Created April 4, 2018 19:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slaykovsky/c975b6db57bd2385ea6d48e8942e3e4e to your computer and use it in GitHub Desktop.
Save slaykovsky/c975b6db57bd2385ea6d48e8942e3e4e to your computer and use it in GitHub Desktop.
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