Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

regtest: Apply bitcoin binary Gradle plugin #2759

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,16 @@ public BitcoindDaemon(JsonRpcClient rpcClient) {
}

public void createOrLoadWallet(String walletName, Optional<String> passphrase) {
createOrLoadWallet(walletName, passphrase, true, false, false);
}

public void createOrLoadLegacyWallet(String walletName, Optional<String> passphrase) {
createOrLoadWallet(walletName, passphrase, false, false, false);
createOrLoadWallet(walletName, passphrase, false, false);
}

public void createOrLoadWatchOnlyWallet(String walletName) {
createOrLoadWallet(walletName, Optional.empty(), true, true, true);
createOrLoadWallet(walletName, Optional.empty(), true, true);
}

private void createOrLoadWallet(String walletName, Optional<String> passphrase, boolean descriptors, boolean disablePrivateKeys, boolean blank) {
private void createOrLoadWallet(String walletName, Optional<String> passphrase, boolean disablePrivateKeys, boolean blank) {
try {
createWallet(walletName, passphrase.orElse(""), descriptors, disablePrivateKeys, blank);
createWallet(walletName, passphrase.orElse(""), disablePrivateKeys, blank);
} catch (RpcCallFailureException e) {
if (doesWalletExist(e)) {
List<String> loadedWallets = listWallets();
Expand Down Expand Up @@ -117,7 +113,11 @@ private static List<String> listWalletsWithRpcClient(JsonRpcClient rpcClient) {
}

public String sendRawTransaction(String hexString) {
var request = new BitcoindSendRawTransactionRpcCall.Request(hexString);
return sendRawTransaction(hexString, null);
}

public String sendRawTransaction(String hexString, String maxBurnAmount) {
var request = new BitcoindSendRawTransactionRpcCall.Request(hexString, maxBurnAmount);
var rpcCall = new BitcoindSendRawTransactionRpcCall(request);
return rpcClient.call(rpcCall).getResult();
}
Expand Down Expand Up @@ -147,10 +147,9 @@ private boolean doesWalletExist(RpcCallFailureException e) {
return e.getMessage().contains("Database already exists.");
}

private void createWallet(String walletName, String passphrase, boolean descriptors, boolean disablePrivateKeys, boolean blank) {
private void createWallet(String walletName, String passphrase, boolean disablePrivateKeys, boolean blank) {
var request = BitcoindCreateWalletRpcCall.Request.builder()
.walletName(walletName)
.descriptors(descriptors)
.disablePrivateKeys(disablePrivateKeys)
.blank(blank)
.passphrase(passphrase)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public static class Request {
private String passphrase;
@Json(name = "avoid_reuse")
private Boolean avoidReuse;
private boolean descriptors;
}

public BitcoindCreateWalletRpcCall(Request request) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ public class BitcoindSendRawTransactionRpcCall extends DaemonRpcCall<BitcoindSen
public static final class Request {
@Json(name = "hexstring")
private final String hexString;
@Json(name = "maxburnamount")
private final String maxBurnAmount;

public Request(String hexString) {
public Request(String hexString, String maxBurnAmount) {
this.hexString = hexString;
this.maxBurnAmount = maxBurnAmount;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package bisq.wallets.bitcoind.rpc.responses;

import com.squareup.moshi.Json;
import lombok.Getter;

import java.util.List;
Expand All @@ -29,4 +30,6 @@ public class BitcoindDescriptor {
private boolean internal;
private List<Integer> range;
private Integer next;
@Json(name = "next_index")
private Integer nextIndex;
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,7 @@ public static class Result {
private BitcoindGetMineBalancesResponse mine;
@Json(name = "watchonly")
private BitcoindGetMineBalancesResponse watchOnly;
@Json(name = "lastprocessedblock")
private BitcoindGetLastProcessedBlockBalancesResponse lastProcessedBlock;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package bisq.wallets.bitcoind.rpc.responses;

import lombok.Getter;

@Getter
public class BitcoindGetLastProcessedBlockBalancesResponse {
private String hash;
long height;
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public class BitcoindListTransactionsResponse extends JsonRpcResponse<List<Bitco
public static class Entry implements TransactionInfo {
private boolean involvesWatchonly;
private String address;
@Json(name = "parent_descs")
private List<String> parentDescs;
private String category;
private double amount;
private String label;
Expand All @@ -46,6 +48,8 @@ public static class Entry implements TransactionInfo {
private int blocktime;
@Json(name = "txid")
private String txId;
@Json(name = "wtxid")
private String wtxId;
private String[] walletconflicts;
private int time;
private int timereceived;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ public class BitcoindWalletProcessPsbtResponse extends JsonRpcResponse<BitcoindW
public static class Result {
private String psbt;
private boolean complete;
private String hex;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@
import bisq.wallets.json_rpc.JsonRpcResponse;
import lombok.Getter;

import java.util.Collections;
import java.util.List;

public class BitcoindWarningResponse extends JsonRpcResponse<BitcoindWarningResponse.Result> {
@Getter
public static class Result {
protected String warning;
protected List<String> warnings = Collections.emptyList();

public boolean hasWarning() {
return !warning.isEmpty();
return !warnings.isEmpty();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public ElementsdDaemon(JsonRpcClient rpcClient) {
}

public void createOrLoadWallet(String walletName, Optional<String> passphrase) {
bitcoindDaemon.createOrLoadLegacyWallet(walletName, passphrase);
throw new UnsupportedOperationException("Bitcoin Core 25.0 removed legacy wallet support.");
}

public ElementsdDecodeRawTransactionResponse decodeRawTransaction(String txInHex) {
Expand Down
13 changes: 13 additions & 0 deletions wallets/regtest/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
plugins {
id("bisq.java-library")
id("bisq.gradle.bitcoin_core.BitcoinCorePlugin")
}

bitcoin_core {
version.set("27.1")
}

sourceSets {
main {
resources {
srcDir(layout.buildDirectory.file("generated/src/main/resources"))
}
}
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public List<String> mineOneBlock() throws InterruptedException {
return mineBlocks(1);
}

public List<String> mineBlocks(int numberOfBlocks) throws InterruptedException {
public List<String> mineBlocks(int numberOfBlocks) {
return remoteBitcoind.mineBlocks(numberOfBlocks);
}

Expand Down
Loading