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

Changed Testnet fee address, NodeAndExplorerDataSourceImpl: Add optional checkTransaction call #176

Merged
merged 3 commits into from
Jul 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class Parameters {
* This is part of Ergo protocol and cannot be changed.
*/
public static final int MinerRewardDelay_Mainnet = 720;
public static final int MinerRewardDelay_Testnet = 72;
public static final int MinerRewardDelay_Testnet = 720;

/**
* One Erg is 10^9 NanoErg
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ public class NodeAndExplorerDataSourceImpl implements BlockchainDataSource {
// cached to avoid multiple fetches, these values won't change while this class lives
private BlockchainParameters blockchainParameters;

/**
* set to true to make {@link #sendTransaction(SignedTransaction)} call node's checkTransaction
* endpoint before actually sending the transaction
*/
public boolean performCheckBeforeSend = false;

public NodeAndExplorerDataSourceImpl(ApiClient nodeClient, @Nullable ExplorerApiClient explorerClient) {

OkHttpClient ok = nodeClient.getOkBuilder().build();
Expand Down Expand Up @@ -165,6 +171,14 @@ public String sendTransaction(SignedTransaction tx) {
.inputs(inputsData)
.outputs(outputsData);

if (performCheckBeforeSend) {
String txId = executeCall(nodeTransactionsApi.checkTransaction(txData)).replace("\"", "");
if (!txData.getId().equals(txId)) {
throw new IllegalStateException("checkTransaction returned tx id " + txId +
", expected was " + txData.getId());
}
}

return executeCall(nodeTransactionsApi.sendTransaction(txData));
}

Expand Down