UTXOProvider: replace getParams() with network()

Since this only affects FullPrunedBlockStore, this change doesn't
need deprecation.
This commit is contained in:
Sean Gilligan 2023-03-30 18:40:00 -07:00 committed by Andreas Schildbach
parent 24e030ae74
commit 99f6860ceb
4 changed files with 15 additions and 6 deletions

View File

@ -16,6 +16,7 @@
package org.bitcoinj.core;
import org.bitcoinj.base.Network;
import org.bitcoinj.crypto.ECKey;
import org.bitcoinj.store.FullPrunedBlockStore;
@ -44,8 +45,8 @@ public interface UTXOProvider {
int getChainHeadHeight() throws UTXOProviderException;
/**
* The {@link NetworkParameters} of this provider.
* @return The network parameters.
* The {@link Network} of this provider.
* @return the network
*/
NetworkParameters getParams();
Network network();
}

View File

@ -16,6 +16,7 @@
package org.bitcoinj.store;
import org.bitcoinj.base.Network;
import org.bitcoinj.base.ScriptType;
import org.bitcoinj.base.Address;
import org.bitcoinj.crypto.ECKey;
@ -415,6 +416,11 @@ public class MemoryFullPrunedBlockStore implements FullPrunedBlockStore {
return params;
}
@Override
public Network network() {
return params.network();
}
@Override
public int getChainHeadHeight() throws UTXOProviderException {
try {

View File

@ -4744,7 +4744,7 @@ public class Wallet extends BaseTaggableObject
public void setUTXOProvider(@Nullable UTXOProvider provider) {
lock.lock();
try {
checkArgument(provider == null || provider.getParams().equals(params));
checkArgument(provider == null || provider.network() == params.network());
this.vUTXOProvider = provider;
} finally {
lock.unlock();

View File

@ -18,7 +18,9 @@ package org.bitcoinj.core;
import com.google.common.collect.Lists;
import org.bitcoinj.base.Address;
import org.bitcoinj.base.BitcoinNetwork;
import org.bitcoinj.base.Coin;
import org.bitcoinj.base.Network;
import org.bitcoinj.base.ScriptType;
import org.bitcoinj.base.Sha256Hash;
import org.bitcoinj.crypto.ECKey;
@ -74,8 +76,8 @@ public class TransactionInputTest {
ScriptBuilder.createOutputScript(a));
w.setUTXOProvider(new UTXOProvider() {
@Override
public NetworkParameters getParams() {
return TESTNET;
public Network network() {
return BitcoinNetwork.TESTNET;
}
@Override