From 82feb7b831d8a84bd59ce66892f95bfc14f0eaaa Mon Sep 17 00:00:00 2001 From: Sean Gilligan Date: Tue, 5 Sep 2023 19:24:54 -0700 Subject: [PATCH] CoinSelection: add defensive copy in constructor --- core/src/main/java/org/bitcoinj/wallet/CoinSelection.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/bitcoinj/wallet/CoinSelection.java b/core/src/main/java/org/bitcoinj/wallet/CoinSelection.java index b82e53563..2d4ae7737 100644 --- a/core/src/main/java/org/bitcoinj/wallet/CoinSelection.java +++ b/core/src/main/java/org/bitcoinj/wallet/CoinSelection.java @@ -21,6 +21,7 @@ import org.bitcoinj.core.TransactionOutput; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.List; /** @@ -42,7 +43,7 @@ public class CoinSelection { public CoinSelection(List gathered) { this.valueGathered = sumOutputValues(gathered); - this.gathered = gathered; + this.gathered = Collections.unmodifiableList(new ArrayList<>(gathered)); } /**