From a66b36c59c5d888b43c730f85321ddaabb8272a1 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Sat, 11 Feb 2023 14:28:10 +0200 Subject: [PATCH] cormorant: switch bitcoind client from named to array parameters to support btc-rpc-proxy --- .../sparrow/net/cormorant/bitcoind/BitcoindClient.java | 2 +- .../net/cormorant/bitcoind/BitcoindClientService.java | 5 ++++- .../net/cormorant/electrum/ElectrumServerService.java | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/net/cormorant/bitcoind/BitcoindClient.java b/src/main/java/com/sparrowwallet/sparrow/net/cormorant/bitcoind/BitcoindClient.java index 42daefd1..37d5e1a5 100644 --- a/src/main/java/com/sparrowwallet/sparrow/net/cormorant/bitcoind/BitcoindClient.java +++ b/src/main/java/com/sparrowwallet/sparrow/net/cormorant/bitcoind/BitcoindClient.java @@ -444,7 +444,7 @@ public class BitcoindClient { private String getTransaction(String txid) { try { - return getBitcoindService().getTransaction(txid, false).get("hex").toString(); + return getBitcoindService().getTransaction(txid, true, false).get("hex").toString(); } catch(JsonRpcException e) { return getBitcoindService().getRawTransaction(txid, false).toString(); } diff --git a/src/main/java/com/sparrowwallet/sparrow/net/cormorant/bitcoind/BitcoindClientService.java b/src/main/java/com/sparrowwallet/sparrow/net/cormorant/bitcoind/BitcoindClientService.java index 8f978111..6be17652 100644 --- a/src/main/java/com/sparrowwallet/sparrow/net/cormorant/bitcoind/BitcoindClientService.java +++ b/src/main/java/com/sparrowwallet/sparrow/net/cormorant/bitcoind/BitcoindClientService.java @@ -1,5 +1,7 @@ package com.sparrowwallet.sparrow.net.cormorant.bitcoind; +import com.github.arteam.simplejsonrpc.client.JsonRpcParams; +import com.github.arteam.simplejsonrpc.client.ParamsType; import com.github.arteam.simplejsonrpc.core.annotation.JsonRpcMethod; import com.github.arteam.simplejsonrpc.core.annotation.JsonRpcOptional; import com.github.arteam.simplejsonrpc.core.annotation.JsonRpcParam; @@ -9,6 +11,7 @@ import java.util.List; import java.util.Map; @JsonRpcService +@JsonRpcParams(ParamsType.ARRAY) public interface BitcoindClientService { @JsonRpcMethod("uptime") long uptime(); @@ -44,7 +47,7 @@ public interface BitcoindClientService { Object getRawTransaction(@JsonRpcParam("txid") String txid, @JsonRpcParam("verbose") boolean verbose); @JsonRpcMethod("gettransaction") - Map getTransaction(@JsonRpcParam("txid") String txid, @JsonRpcParam("verbose") boolean verbose); + Map getTransaction(@JsonRpcParam("txid") String txid, @JsonRpcParam("include_watchonly") boolean includeWatchOnly, @JsonRpcParam("verbose") boolean verbose); @JsonRpcMethod("getmempoolentry") MempoolEntry getMempoolEntry(@JsonRpcParam("txid") String txid); diff --git a/src/main/java/com/sparrowwallet/sparrow/net/cormorant/electrum/ElectrumServerService.java b/src/main/java/com/sparrowwallet/sparrow/net/cormorant/electrum/ElectrumServerService.java index 465dc888..52fe1ef0 100644 --- a/src/main/java/com/sparrowwallet/sparrow/net/cormorant/electrum/ElectrumServerService.java +++ b/src/main/java/com/sparrowwallet/sparrow/net/cormorant/electrum/ElectrumServerService.java @@ -150,7 +150,7 @@ public class ElectrumServerService { return bitcoindClient.getBitcoindService().getRawTransaction(tx_hash, true); } catch(JsonRpcException e) { try { - Map txInfo = bitcoindClient.getBitcoindService().getTransaction(tx_hash, true); + Map txInfo = bitcoindClient.getBitcoindService().getTransaction(tx_hash, true, true); Object decoded = txInfo.get("decoded"); if(decoded instanceof Map) { Map decodedMap = (Map)decoded; @@ -172,7 +172,7 @@ public class ElectrumServerService { } } else { try { - return bitcoindClient.getBitcoindService().getTransaction(tx_hash, false).get("hex"); + return bitcoindClient.getBitcoindService().getTransaction(tx_hash, true, false).get("hex"); } catch(JsonRpcException e) { try { return bitcoindClient.getBitcoindService().getRawTransaction(tx_hash, false);