From 7cb61b03993797c55eca6f87dbe21b6576b82a4b Mon Sep 17 00:00:00 2001 From: Sean Gilligan Date: Thu, 4 May 2023 10:53:54 -0700 Subject: [PATCH] Transaction: use stream in method `getOutputSum()` --- core/src/main/java/org/bitcoinj/core/Transaction.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/org/bitcoinj/core/Transaction.java b/core/src/main/java/org/bitcoinj/core/Transaction.java index 4883f5cf2..c85c58dea 100644 --- a/core/src/main/java/org/bitcoinj/core/Transaction.java +++ b/core/src/main/java/org/bitcoinj/core/Transaction.java @@ -500,13 +500,9 @@ public class Transaction extends BaseMessage { * @return the sum of the outputs regardless of who owns them. */ public Coin getOutputSum() { - Coin totalOut = Coin.ZERO; - - for (TransactionOutput output: outputs) { - totalOut = totalOut.add(output.getValue()); - } - - return totalOut; + return outputs.stream() + .map(TransactionOutput::getValue) + .reduce(Coin.ZERO, Coin::add); } /**