Skip to content

Commit

Permalink
bitcoind: Remove the 'wait until blocks mined' functionality
Browse files Browse the repository at this point in the history
The implementation is wrong.
  • Loading branch information
alvasw committed Sep 3, 2024
1 parent 81e059e commit 7681bbf
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 111 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.CountDownLatch;

public class BitcoindRegtestSetup
extends AbstractRegtestSetup<MultiProcessCoordinator> {
Expand Down Expand Up @@ -88,10 +87,6 @@ public Optional<BitcoindListUnspentResponse.Entry> filterUtxosByAddress(
.findFirst();
}

public CountDownLatch waitUntilBlocksMined(List<String> blockHashes) {
return remoteBitcoind.waitUntilBlocksMined(blockHashes);
}

public static RpcConfig createRpcConfig(String hostname, int port) {
return RpcConfig.builder()
.hostname(hostname)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.CountDownLatch;

import static bisq.wallets.regtest.AbstractRegtestSetup.WALLET_PASSPHRASE;

Expand All @@ -49,28 +48,24 @@ public class RemoteBitcoind implements BisqProcess {
private final ZmqListeners zmqListeners = new ZmqListeners();
@Getter
private final BitcoindWallet minerWallet;
private final BitcoindRegtestBlockMiner blockMiner;
private final List<BitcoindWallet> loadedWallets = new ArrayList<>();
private ZmqConnection bitcoindZeroMq;

public RemoteBitcoind(RpcConfig rpcConfig) {
this.rpcConfig = rpcConfig;
this.daemon = createBitcoindDaemon();
this.minerWallet = new BitcoindWallet(daemon, rpcConfig, MINER_WALLET_NAME);
this.blockMiner = new BitcoindRegtestBlockMiner(daemon, minerWallet, zmqListeners);
}

@Override
public void start() throws InterruptedException {
blockMiner.start();
initializeZmqListeners();
initializeWallet(minerWallet);
mineInitialRegtestBlocks();
}

@Override
public void shutdown() {
blockMiner.shutdown();
bitcoindZeroMq.close();
loadedWallets.forEach(BitcoindWallet::shutdown);
}
Expand All @@ -81,8 +76,9 @@ public BitcoindWallet createAndInitializeNewWallet(String walletName) {
return bitcoindWallet;
}

public List<String> mineBlocks(int numberOfBlocks) throws InterruptedException {
return blockMiner.mineBlocks(numberOfBlocks);
public List<String> mineBlocks(int numberOfBlocks) {
String minerAddress = minerWallet.getNewAddress(AddressType.BECH32, "");
return daemon.generateToAddress(numberOfBlocks, minerAddress);
}

public String fundAddress(String address, double amount) throws InterruptedException {
Expand All @@ -104,10 +100,6 @@ public List<String> mineOneBlock() throws InterruptedException {
return mineBlocks(1);
}

public CountDownLatch waitUntilBlocksMined(List<String> blockHashes) {
return blockMiner.waitUntilBlocksMined(blockHashes);
}

private BitcoindDaemon createBitcoindDaemon() {
JsonRpcClient rpcClient = RpcClientFactory.createDaemonRpcClient(rpcConfig);
return new BitcoindDaemon(rpcClient);
Expand All @@ -127,7 +119,7 @@ private void initializeWallet(BitcoindWallet wallet) {
loadedWallets.add(wallet);
}

private void mineInitialRegtestBlocks() throws InterruptedException {
blockMiner.mineBlocks(101);
private void mineInitialRegtestBlocks() {
mineBlocks(101);
}
}

0 comments on commit 7681bbf

Please sign in to comment.