-
Notifications
You must be signed in to change notification settings - Fork 35
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
examples required #21
Comments
Good point - some examples would be helpful. In the meantime, Here's a very simple example as a Groovy script:
If you have the |
thanks for the script |
You're welcome. If you modify it and use it for anything interesting that you can share -- let us know! |
I have written a little test for BitcoinExtendedClient. I could clean it up. It has some problems: calling client.getBlock fails depending on which block number is retrieved. The error message is: [main] ERROR org.consensusj.jsonrpc.RPCClient - JsonProcessingException: {} Here is the content of the file BitcoinExtendedClientTest.java: import java.io.FileOutputStream; import org.bitcoinj.core.Address; public class BitcoinExtendedClientTest {
} |
I have created a simpler test for BitcoinExtendedClient (that fails for a good reason - will create an issue for this). It connects to a server and iterates through the last 100 blocks and writes them to the log: import java.net.URI; import org.bitcoinj.core.Block; public class BitcoinExtendedClientTest2 {
} |
Just want to refresh this thread a bit to help someone working with bitcoinj 0.17-alpha3 and consensusj 0.7.0-alpha3. I've spent sometime on starting this up. Don't forget to tick Enable RPC Server checkbox if you are using bitcoin core or make appropriate setting in bitcoind. Config class import lombok.extern.slf4j.Slf4j;
import org.bitcoinj.params.TestNet3Params;
import org.consensusj.bitcoin.jsonrpc.BitcoinClient;
import org.consensusj.bitcoin.jsonrpc.RpcConfig;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
@Slf4j
@Configuration
public class BitcoinConfig {
@Bean
public BitcoinClient getClient() throws URISyntaxException, IOException {
URI uri = new URI("http://localhost:18332/");
RpcConfig config = new RpcConfig(TestNet3Params.get().network(), uri, "user", "password");
BitcoinClient client = new BitcoinClient(config);
log.info("Blocks count " + client.getBlockChainInfo().getBlocks());
return client;
}
} Part of pom.xml related to consensusj and bitcoinj <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<repositories>
<repository>
<id>gitlab-maven</id>
<url>https://gitlab.com/api/v4/projects/8482916/packages/maven</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>gitlab-maven</id>
<url>https://gitlab.com/api/v4/projects/8482916/packages/maven</url>
</repository>
<snapshotRepository>
<id>gitlab-maven</id>
<url>https://gitlab.com/api/v4/projects/8482916/packages/maven</url>
</snapshotRepository>
</distributionManagement>
<properties>
<java.version>21</java.version>
<bitcoinj-core.version>0.17-alpha3</bitcoinj-core.version>
<consensusj.version>0.7.0-alpha3</consensusj.version>
</properties>
<dependencies>
<!--https://gitlab.com/ConsensusJ/consensusj/-/packages/19200815-->
<dependency>
<groupId>com.msgilligan</groupId>
<artifactId>cj-btc-jsonrpc</artifactId>
<version>${consensusj.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.bitcoinj/bitcoinj-core -->
<dependency>
<groupId>org.bitcoinj</groupId>
<artifactId>bitcoinj-core</artifactId>
<version>${bitcoinj-core.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project> And this is bitcoind.conf
|
Hello
It would be great if you provided examples on how to use the Bitconj json rpc client
thanks!
The text was updated successfully, but these errors were encountered: