Transaction: use stream in method getOutputSum()

This commit is contained in:
Sean Gilligan 2023-05-04 10:53:54 -07:00 committed by Andreas Schildbach
parent 9de77cdd67
commit 7cb61b0399

View File

@ -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);
}
/**