mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-02-23 14:40:40 +01:00
Transaction: replace Guava Lists.reversed()
with JDK equivalent
This commit is contained in:
parent
c5faecf3b6
commit
37a06b150f
1 changed files with 8 additions and 7 deletions
|
@ -18,7 +18,6 @@
|
|||
package org.bitcoinj.core;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.math.IntMath;
|
||||
import org.bitcoinj.base.Address;
|
||||
import org.bitcoinj.base.Coin;
|
||||
|
@ -1737,12 +1736,14 @@ public class Transaction extends ChildMessage {
|
|||
/** Loops the outputs of a coinbase transaction to locate the witness commitment. */
|
||||
public Sha256Hash findWitnessCommitment() {
|
||||
checkState(isCoinBase());
|
||||
for (TransactionOutput out : Lists.reverse(outputs)) {
|
||||
Script scriptPubKey = out.getScriptPubKey();
|
||||
if (ScriptPattern.isWitnessCommitment(scriptPubKey))
|
||||
return ScriptPattern.extractWitnessCommitmentHash(scriptPubKey);
|
||||
}
|
||||
return null;
|
||||
List<TransactionOutput> reversed = new ArrayList<>(outputs);
|
||||
Collections.reverse(reversed);
|
||||
return reversed.stream()
|
||||
.map(TransactionOutput::getScriptPubKey)
|
||||
.filter(ScriptPattern::isWitnessCommitment)
|
||||
.findFirst()
|
||||
.map(ScriptPattern::extractWitnessCommitmentHash)
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue