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

Support Bitcoin Core v22 RPC for JSON export #6123

Merged
merged 3 commits into from Apr 4, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions core/src/main/java/bisq/core/dao/node/full/RpcService.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@
import bisq.common.UserThread;
import bisq.common.config.Config;
import bisq.common.handlers.ResultHandler;
import bisq.common.util.Hex;
import bisq.common.util.Utilities;

import org.bitcoinj.core.Utils;
import org.bitcoinj.script.Script;

import com.google.inject.Inject;

Expand Down Expand Up @@ -75,7 +77,7 @@ public class RpcService {
private static final int ACTIVATE_HARD_FORK_2_HEIGHT_MAINNET = 680300;
private static final int ACTIVATE_HARD_FORK_2_HEIGHT_TESTNET = 1943000;
private static final int ACTIVATE_HARD_FORK_2_HEIGHT_REGTEST = 1;
private static final Range<Integer> SUPPORTED_NODE_VERSION_RANGE = Range.closedOpen(180000, 210100);
private static final Range<Integer> SUPPORTED_NODE_VERSION_RANGE = Range.closedOpen(180000, 220100);

private final String rpcUser;
private final String rpcPassword;
Expand Down Expand Up @@ -350,9 +352,14 @@ private static RawTx getTxFromRawTransaction(RawDtoTransaction rawDtoTx,
}
}
}
// We don't support raw MS which are the only case where scriptPubKey.getAddresses()>1
String address = scriptPubKey.getAddresses() != null &&
scriptPubKey.getAddresses().size() == 1 ? scriptPubKey.getAddresses().get(0) : null;
String address = null;
try {
address = new Script(Hex.decode(scriptPubKey.getHex()))
.getToAddress(Config.baseCurrencyNetworkParameters()).toString();
} catch (Exception ex) {
// certain scripts e.g. OP_RETURN do not resolve to an address
// in that case do not provide an address to the RawTxOutput
}
PubKeyScript pubKeyScript = new PubKeyScript(scriptPubKey);
return new RawTxOutput(rawDtoTxOutput.getN(),
BigDecimal.valueOf(rawDtoTxOutput.getValue()).movePointRight(8).longValueExact(),
Expand Down