From 7f46410f1b8366fc3f9d5c0463156262ba292abe Mon Sep 17 00:00:00 2001 From: Akshay Date: Tue, 8 Mar 2022 11:52:22 +0100 Subject: [PATCH 1/4] Update api version to 1.0.3 --- plugin.properties | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 plugin.properties diff --git a/plugin.properties b/plugin.properties deleted file mode 100644 index fda6225..0000000 --- a/plugin.properties +++ /dev/null @@ -1,5 +0,0 @@ -plugin.id=bitcoin-plugin -plugin.class=blockchains.iaas.uni.stuttgart.plugin.bitcoin.BitcoinPlugin -plugin.version=1.0.0 -plugin.provider= -plugin.dependencies= \ No newline at end of file From d3807d89054c345bf9cc34b9a698377171a681b7 Mon Sep 17 00:00:00 2001 From: Akshay Date: Tue, 8 Mar 2022 11:53:01 +0100 Subject: [PATCH 2/4] Update api version to 1.0.3 --- pom.xml | 29 ++++++++++++++++++- .../de/plugin/bitcoin/BitcoinPlugin.java | 6 ++-- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 2dcc823..3cc5a7f 100644 --- a/pom.xml +++ b/pom.xml @@ -24,6 +24,33 @@ + + + + org.apache.maven.plugins + maven-jar-plugin + + + + true + true + + + blockchains.iaas.uni.stuttgart.de.plugin.bitcoin.BitcoinPlugin + bitcoin-plugin + 1.0.0 + 1.0.0 + + Bitcoin plugin + Akshay Patel + Apache License 2.0 + + + + + + + org.pf4j @@ -33,7 +60,7 @@ com.github.TIHBS blockchain-access-layer-api - 1.0.2 + 1.0.3 com.neemre.btcd-cli4j diff --git a/src/main/java/blockchains/iaas/uni/stuttgart/de/plugin/bitcoin/BitcoinPlugin.java b/src/main/java/blockchains/iaas/uni/stuttgart/de/plugin/bitcoin/BitcoinPlugin.java index d926981..493a996 100644 --- a/src/main/java/blockchains/iaas/uni/stuttgart/de/plugin/bitcoin/BitcoinPlugin.java +++ b/src/main/java/blockchains/iaas/uni/stuttgart/de/plugin/bitcoin/BitcoinPlugin.java @@ -11,7 +11,7 @@ package blockchains.iaas.uni.stuttgart.de.plugin.bitcoin; -import blockchains.iaas.uni.stuttgart.de.api.IAdapterExtenstion; +import blockchains.iaas.uni.stuttgart.de.api.IAdapterExtension; import blockchains.iaas.uni.stuttgart.de.api.interfaces.BlockchainAdapter; import blockchains.iaas.uni.stuttgart.de.api.utils.PoWConfidenceCalculator; import com.neemre.btcdcli4j.core.BitcoindException; @@ -52,10 +52,10 @@ public void stop() { } @Extension - public static class BitcoinPluginImpl implements IAdapterExtenstion { + public static class BitcoinPluginImpl implements IAdapterExtension { @Override - public BlockchainAdapter getAdapter(Map parameters) { + public BlockchainAdapter getAdapter(Map parameters) { // TODO: Create blockchains.iaas.uni.stuttgart.demo.BitcoinConnectionProfile object from parameters BitcoinConnectionProfile gateway = new BitcoinConnectionProfile(); final PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(); From b9259f53ad941a78087a0496ee2021cd40a69f4c Mon Sep 17 00:00:00 2001 From: Akshay Date: Fri, 11 Mar 2022 12:34:05 +0100 Subject: [PATCH 3/4] Update api version to 1.0.7 --- pom.xml | 2 +- .../de/plugin/bitcoin/BitcoinPlugin.java | 21 +++++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 3cc5a7f..258596f 100644 --- a/pom.xml +++ b/pom.xml @@ -60,7 +60,7 @@ com.github.TIHBS blockchain-access-layer-api - 1.0.3 + 1.0.7 com.neemre.btcd-cli4j diff --git a/src/main/java/blockchains/iaas/uni/stuttgart/de/plugin/bitcoin/BitcoinPlugin.java b/src/main/java/blockchains/iaas/uni/stuttgart/de/plugin/bitcoin/BitcoinPlugin.java index 493a996..fc6a2c8 100644 --- a/src/main/java/blockchains/iaas/uni/stuttgart/de/plugin/bitcoin/BitcoinPlugin.java +++ b/src/main/java/blockchains/iaas/uni/stuttgart/de/plugin/bitcoin/BitcoinPlugin.java @@ -12,6 +12,7 @@ package blockchains.iaas.uni.stuttgart.de.plugin.bitcoin; import blockchains.iaas.uni.stuttgart.de.api.IAdapterExtension; +import blockchains.iaas.uni.stuttgart.de.api.connectionprofiles.AbstractConnectionProfile; import blockchains.iaas.uni.stuttgart.de.api.interfaces.BlockchainAdapter; import blockchains.iaas.uni.stuttgart.de.api.utils.PoWConfidenceCalculator; import com.neemre.btcdcli4j.core.BitcoindException; @@ -55,9 +56,8 @@ public void stop() { public static class BitcoinPluginImpl implements IAdapterExtension { @Override - public BlockchainAdapter getAdapter(Map parameters) { - // TODO: Create blockchains.iaas.uni.stuttgart.demo.BitcoinConnectionProfile object from parameters - BitcoinConnectionProfile gateway = new BitcoinConnectionProfile(); + public BlockchainAdapter getAdapter(AbstractConnectionProfile abstractConnectionProfile) { + BitcoinConnectionProfile gateway = (BitcoinConnectionProfile) abstractConnectionProfile; final PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(); final CloseableHttpClient httpProvider = HttpClients.custom().setConnectionManager(connManager).build(); @@ -69,14 +69,23 @@ public BlockchainAdapter getAdapter(Map parameters) { cCalc.setAdversaryRatio(gateway.getAdversaryVotingRatio()); result.setConfidenceCalculator(cCalc); return result; - } catch (BitcoindException e) { - e.printStackTrace(); - } catch (CommunicationException e) { + } catch (BitcoindException | CommunicationException e) { e.printStackTrace(); } return null; } + + @Override + public Class getConnectionProfileClass() { + return BitcoinConnectionProfile.class; + } + + @Override + public String getConnectionProfileNamedType() { + return "bitcoin"; + } + @Override public String getBlockChainId() { return "bitcoin"; From 4e2a403a8c41034e35739fccb232ad41890be749 Mon Sep 17 00:00:00 2001 From: Akshay Date: Fri, 11 Mar 2022 12:49:20 +0100 Subject: [PATCH 4/4] Update README.md --- README.md | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 54c74dd..d5474dc 100644 --- a/README.md +++ b/README.md @@ -1 +1,32 @@ -# blockchain-access-layer-bitcoin-plugin \ No newline at end of file +# blockchain-access-layer-bitcoin-plugin + +**Notice:** the build requires a library (btcd-cli4j) to communicate with the Bitcoin Core +node. [The used library](https://github.com/pythonmax/btcd-cli4j) is forked from +an [unmaintained library](http://btcd-cli4j.neemre.com) to fix some issues resulting from changes in the recent versions +of the Bitcoin Core node. However, the used library is not available in a public Maven repository, so we had to provide +a local Maven repository which includes the required binaries. This repository is found [here](local-maven-repo). + +### Running a Local Bitcoin Core Node + +A Bitcoin Core node (or _bitcoind_ node) is used to access the Bitcoin network. For development purposes, it is advised +not to connect to the main Bitcoin network, but rather to one of the testnets. +(another, more difficult option would be to run a local private Bitcoin network). In order to connect a _bitcoind_ node +to [testnet3](https://en.bitcoin.it/wiki/Testnet) (one of Bitcoin's testnets), you can follow these steps: + +1. [Install bitcoind](https://bitcoin.org/en/download): + this differs depending on your operating system. For the installation instructions on Ubuntu you can + follow [these steps](https://gist.github.com/rjmacarthy/b56497a81a6497bfabb1). +2. Configure _bitcoind_: This can be done by editing and using the [`bitcoin.conf`](app/src/main/resources/bitcoin.conf) + file when starting the bicoind daemon. The configuration allows external rpc-based communication with the node, and + instructs it to communicate with the testnet rather than the mainnet. Furthermore, it orders the node to build an + index on the blockchain that allows querying even historic transactions. Finally, it instructs the node to send + notifications to the BAL when it detects a new block or a transaction addressed to one of the Bitcoin wallet's + addresses. Syncing the whole testnet blockchain (which is done once only) takes about 1-4 hours (depending on the + hardware, the speed of the network connection, and the availability of peers). +3. Start the pre-configured _bitcoind_ node with the following command:```bitcoind -daemon``` +4. Test connection: you can test your connection to a running _bitcoind_ node using the following command + (make sure to install bitcoin-cli (shipped with _bitcoind_) on the computer where you run this command): + +``` +bitcoin-cli -getinfo -rpcconnect= -rpcport= -rpcuser= -rpcpassword= +``` \ No newline at end of file