combining bitcoinj with bitcoinj cash

189 views
Skip to first unread message

Bobby_Bouche

unread,
May 5, 2018, 5:53:31 PM5/5/18
to bitcoinj

I currently have a java project already near completion using just bitcoinj to deal with bitcoin.

I went through the code for cash and i see that its nearly a perfect mirror.

So my question is this. How can i distinguish between bitcoinj and bitcoinjcash in terms of retrieving wallet balances, sending/receiving payments, etc..

Andreas Schildbach

unread,
May 5, 2018, 6:53:39 PM5/5/18
to bitc...@googlegroups.com
Bitcoinj doesn't support BCH. I guess you'll need to import both
libraries; bitcoincashj should be in its own namespace.
> --
> You received this message because you are subscribed to the Google
> Groups "bitcoinj" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to bitcoinj+u...@googlegroups.com
> <mailto:bitcoinj+u...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.


Bobby_Bouche

unread,
May 5, 2018, 6:56:14 PM5/5/18
to bitcoinj
https://github.com/bitcoinj-cash/bitcoinj 

the bitcoinj cash version.

its nearly an exact copy, but i dont know how to get the 2 blocks to sync in unision on 1 program. Do you have experience with this?

Carlos López-Camey

unread,
May 6, 2018, 3:57:56 AM5/6/18
to bitc...@googlegroups.com
Hi Bobby,

For the time being, if you want to support BTC, tBTC, BCH and tBTC, see: https://github.com/Stash-Crypto/bitcoincashj, which we are using for Stash Wallet.!
Cheers





--
You received this message because you are subscribed to the Google Groups "bitcoinj" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bitcoinj+unsubscribe@googlegroups.com.

Bobby_Bouche

unread,
May 6, 2018, 7:14:33 AM5/6/18
to bitcoinj
so how do you instantiate the different addresses? And is there one with litecoin and dash? Can you provide the setup for the walletkit and the blockchain sync issues?


On Sunday, May 6, 2018 at 3:57:56 AM UTC-4, Carlos López-Camey wrote:
Hi Bobby,

For the time being, if you want to support BTC, tBTC, BCH and tBTC, see: https://github.com/Stash-Crypto/bitcoincashj, which we are using for Stash Wallet.!
Cheers




2018-05-05 16:56 GMT-06:00 Bobby_Bouche <syng...@gmail.com>:
https://github.com/bitcoinj-cash/bitcoinj 

the bitcoinj cash version.

its nearly an exact copy, but i dont know how to get the 2 blocks to sync in unision on 1 program. Do you have experience with this?

--
You received this message because you are subscribed to the Google Groups "bitcoinj" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bitcoinj+u...@googlegroups.com.

Carlos López-Camey

unread,
May 6, 2018, 11:35:35 AM5/6/18
to bitc...@googlegroups.com
El dom., 6 de may. de 2018 5:14 AM, Bobby_Bouche <syng...@gmail.com> escribió:
so how do you instantiate the different addresses?

Look in BIP47AppKit#isValidAdress for the logic of that. Every instance uses a different class.

And is there one with litecoin and dash?

2 months ago I used Github API to find a unique list of bitcoinj fork names: 

Most are updated many years ago but you may find dashj from HashEngineering very attractive.

> u provide the setup for the walletkit and the blockchain sync issues?

Give BIP47AppKit a try. You can take the code from the first cell here and run it in minutes: https://blog.stashwalletapp.com/bip47-bitcoinj/

- Carlos. 

Bobby_Bouche

unread,
May 6, 2018, 12:38:50 PM5/6/18
to bitcoinj
I grabbed stash-crypto, but i still see nothing that would show how to deal with bitcoin cash addresses, its protocol for listenable events and other basic things.

What sets bitcoin and bitcoin cash different in this code wise?

I looked at your bip for payment codes, looks interesting but doesnt it have to be both ways? Perhaps ill throw it as an option. But my main focus is getting bitcoin cash and bitcoin to be in the same program.l

Carlos López-Camey

unread,
May 6, 2018, 12:59:50 PM5/6/18
to bitcoinj
It's not very different because an address is just a representation of a public key and they use the same type for public key.


If you search the code for `getUseForkId()` you will find some "ifs" for the protocol implementation, like special transactiom signing (for replay protection) or connecting to the right nodes. But there are not so many differences, as you said both projects look like a mirror

Bobby_Bouche

unread,
May 6, 2018, 1:20:28 PM5/6/18
to bitcoinj
I got bitcoinj-cash-0.14 and tried searching for "getUseForkId()" but found nothing...Im using intellij

Carlos López-Camey

unread,
May 6, 2018, 1:38:18 PM5/6/18
to bitc...@googlegroups.com
If you are using Linux or cygwin, try grep:

```
find $PATH_TO_BITCOINJ_SOURCE -type f |grep java$ |xargs grep getUseForkId
```

You should find getUseForkId.

--
You received this message because you are subscribed to the Google Groups "bitcoinj" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bitcoinj+unsubscribe@googlegroups.com.

Bobby_Bouche

unread,
May 6, 2018, 2:12:32 PM5/6/18
to bitcoinj
im using only windows .....:S sorry. It appears intellij doesnt have a global search button.

Do you know the directory for this?
To unsubscribe from this group and stop receiving emails from it, send an email to bitcoinj+u...@googlegroups.com.

Carlos López-Camey

unread,
May 6, 2018, 2:15:28 PM5/6/18
to bitc...@googlegroups.com
Sure man, normally you can CTRL + SHIFT + F for global search in intellij no?


To unsubscribe from this group and stop receiving emails from it, send an email to bitcoinj+unsubscribe@googlegroups.com.

Bobby_Bouche

unread,
May 6, 2018, 4:08:14 PM5/6/18
to bitcoinj
That is embarassing, i was only doing ctrl+F.

Moving on. So i went through the code but im still not quite understanding how it distinguishes between bitcoin and bitcoincash.

I got Wallet.java, SendRequest.java and TransactionSigner.java opened.

Jimmy Morales

unread,
May 7, 2018, 2:09:40 AM5/7/18
to bitcoinj
What distinguishes between bitcoin and bitcoincash are the Network Parameters classes. Use BCCMainNetParams for bitcoincash, BCCTestNet3Params for testnet bitcoincash, MainNetParams for bitcoin and TestNet3Params for testnet bitcoin.

Bobby_Bouche

unread,
May 7, 2018, 8:28:32 AM5/7/18
to bitcoinj
package wallettemplate;

import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.kits.WalletAppKit;
import org.bitcoinj.params.TestNet3Params;
//import org.bitcoinj.params.BCCTestNet3Params;

import java.io.File;

public class TestHybrid {
//Bitcoin
public static NetworkParameters params = TestNet3Params.get();
public static WalletAppKit kit = new WalletAppKit(params, new File("."), "bitcoin");
//Bitcoin Cash
//public static NetworkParameters params1 = BCCTestNet3Params.get();
//public static WalletAppKit kit1 = new WalletAppKit(params1, new File("."), "bitcoincash");

public static void main(String[] args) {
kit.startAsync();
kit.awaitRunning();
System.out.println(kit.wallet().currentReceiveAddress().toString());
}
}

BCCTestNet3Params.get(); shows up in red. saying it cannot resolve.

are all the other bitcoinj forks work the same way such as this?

For example...litecoinj, dashj and other forks from here --> https://pastebin.com/UYW7gUtH

And also how would you merge these into 1 program since theya re from different modules. Im currently using Intellij.

Carlos López-Camey

unread,
May 7, 2018, 11:28:07 AM5/7/18
to bitc...@googlegroups.com
You can run "mvn clean install" command to get a .jar bundle file (bitcoincashj-core-0.14.7-bip47.3-bundled.jar in core/target) and then you can add this jar to IntellIJ 2018 in Project Structure -> Libraries.



To unsubscribe from this group and stop receiving emails from it, send an email to bitcoinj+unsubscribe@googlegroups.com.

Jimmy Morales

unread,
May 7, 2018, 3:45:25 PM5/7/18
to bitcoinj
Make sure you are on the release-0.14 branch

Bobby_Bouche

unread,
May 7, 2018, 4:58:44 PM5/7/18
to bitcoinj
Where are you guys doing mvn clean install? In command prompt? Under build? I cant seem to find the jar...

Carlos López-Camey

unread,
May 7, 2018, 5:02:45 PM5/7/18
to bitc...@googlegroups.com
Sorry Bobby,
I meant `mvn clean package`
(Check out the README.md file too)
Run it inside the cloned repository.. or also check out the release tab in Github for source code downloading 

--
You received this message because you are subscribed to the Google Groups "bitcoinj" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bitcoinj+unsubscribe@googlegroups.com.

Bobby_Bouche

unread,
May 7, 2018, 5:22:13 PM5/7/18
to bitcoinj
i got the source code already. im just trying to build it in a jar format that i can add with my main bitcoin program to have both. But im having problems. im trying to use mvn but it says its not recognized. i checked paths and i have it installed.


On Monday, May 7, 2018 at 5:02:45 PM UTC-4, Carlos López-Camey wrote:
Sorry Bobby,
I meant `mvn clean package`
(Check out the README.md file too)
Run it inside the cloned repository.. or also check out the release tab in Github for source code downloading 
2018-05-07 14:58 GMT-06:00 Bobby_Bouche <syng...@gmail.com>:
Where are you guys doing mvn clean install? In command prompt? Under build? I cant seem to find the jar...


On Monday, May 7, 2018 at 3:45:25 PM UTC-4, Jimmy Morales wrote:
Make sure you are on the release-0.14 branch

--
You received this message because you are subscribed to the Google Groups "bitcoinj" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bitcoinj+u...@googlegroups.com.

Bobby_Bouche

unread,
May 7, 2018, 5:22:35 PM5/7/18
to bitcoinj
C:\Users\Syn\Desktop\Bitcoin Project\bitcoinj-cash-0.14>mvn clean package
'mvn' is not recognized as an internal or external command,
operable program or batch file.

Bobby_Bouche

unread,
May 8, 2018, 3:10:45 PM5/8/18
to bitcoinj
still unable to get this working. Is there another step i can try? to get mvn to compile

Bobby_Bouche

unread,
May 10, 2018, 5:03:36 PM5/10/18
to bitcoinj
directed it to the wrong directory lol....but still im getting an issue something with my compiler


Which compiler is it referring to.

Bobby_Bouche

unread,
May 19, 2018, 1:18:28 PM5/19/18
to bitcoinj
*bump*

Bobby_Bouche

unread,
May 19, 2018, 4:39:15 PM5/19/18
to bitcoinj
C:\Users\Syn\Desktop\Bitcoin Project\bitcoinj-cash-0.14>mvn clean package
[INFO] Scanning for projects...
[INFO] Inspecting build with total of 5 modules...
[INFO] Installing Nexus Staging features:
[INFO]   ... total of 5 executions of maven-deploy-plugin replaced with nexus-staging-maven-plugin
[WARNING] The project cash.bitcoinj:bitcoinj-parent:pom:0.14-SNAPSHOT uses prerequisites which is only intended for maven-plugin projects but not for non maven-plugin projects. For such purposes you should use the maven-enforcer-plugin. See https://maven.apache.org/e
nforcer/enforcer-rules/requireMavenVersion.html
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] bitcoinj Parent                                                    [pom]
[INFO] bitcoinj                                                           [jar]
[INFO] bitcoincashj Examples                                              [jar]
[INFO] bitcoincashj Tools                                                 [jar]
[INFO] bitcoinj.cash Wallet-Template                                      [jar]
[INFO]
[INFO] -------------------< cash.bitcoinj:bitcoinj-parent >--------------------
[INFO] Building bitcoinj Parent 0.14-SNAPSHOT                             [1/5]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.6.1:clean (default-clean) @ bitcoinj-parent ---
[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ bitcoinj-parent ---
[INFO]
[INFO] --------------------< cash.bitcoinj:bitcoinj-core >---------------------
[INFO] Building bitcoinj 0.14-SNAPSHOT                                    [2/5]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.6.1:clean (default-clean) @ bitcoinj-core ---
[INFO] Deleting C:\Users\Syn\Desktop\Bitcoin Project\bitcoinj-cash-0.14\core\target
[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ bitcoinj-core ---
[INFO]
[INFO] --- jacoco-maven-plugin:0.7.5.201505241946:prepare-agent (pre-unit-test) @ bitcoinj-core ---
[INFO] surefireArgLine set to "-javaagent:C:\\Users\\Syn\\.m2\\repository\\org\\jacoco\\org.jacoco.agent\\0.7.5.201505241946\\org.jacoco.agent-0.7.5.201505241946-runtime.jar=destfile=C:\\Users\\Syn\\Desktop\\Bitcoin Project\\bitcoinj-cash-0.14\\core\\target\\coverage
-reports\\jacoco.exec,excludes=**/Protos*.class:org/bitcoinj/jni/*:org/bitcoin/*"
[INFO]
[INFO] --- maven-resources-plugin:2.7:resources (default-resources) @ bitcoinj-core ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 4 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ bitcoinj-core ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 289 source files to C:\Users\Syn\Desktop\Bitcoin Project\bitcoinj-cash-0.14\core\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] bitcoinj Parent 0.14-SNAPSHOT ...................... SUCCESS [  1.888 s]
[INFO] bitcoinj ........................................... FAILURE [  6.848 s]
[INFO] bitcoincashj Examples .............................. SKIPPED
[INFO] bitcoincashj Tools ................................. SKIPPED
[INFO] bitcoinj.cash Wallet-Template 0.14-SNAPSHOT ........ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.979 s
[INFO] Finished at: 2018-05-19T16:37:23-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile (default-compile) on project bitcoinj-core: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[ERROR]
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :bitcoinj-core

This is the output error after running mvn clean package. 

Bobby_Bouche

unread,
May 21, 2018, 9:23:18 PM5/21/18
to bitcoinj
I was finally able to compile it it was a stupid mistake on my part. I went to core > target saw the snapshot, bundled and javadoc.

i still fail to understand how i can distinguish it by code the different blockchains?

Bobby_Bouche

unread,
May 29, 2018, 3:36:57 PM5/29/18
to bitcoinj
Bump.

How can i distinguish from bitcoin to bitcoin cash? They are a mirror to each other code wise.

Bobby_Bouche

unread,
Jun 3, 2018, 7:09:31 AM6/3/18
to bitcoinj
Bump

Bobby_Bouche

unread,
Jun 10, 2018, 12:30:16 PM6/10/18
to bitcoinj
Another Bump.

Carlos López-Camey

unread,
Jun 11, 2018, 11:34:52 AM6/11/18
to bitc...@googlegroups.com
Hi Bobby,
Sorry it took so long!

You may need two bitcoinj jars (or not) - I sent you earlier a repo link [1] where we try to avoid code duplication and use only one bitcoinj project to support the two, with IF conditionals in the code.
 
Depending on what you are trying to do with your code, you will need to change bits.  The most relevant change is your "NetworkParameters" instance that is passed as parameter to any Wallet, PeerGroup, Context, etc. 

If you look at our repo, there are NetworkParameter subclasses: 

BCCMainNetParams.java - for BCH
MainNetParams.java - for BTC
TestNet3Params.java - for tBTC 
BCCTestNet3Params.java.- for tBCH

So you just need to instantiate whichever you like for the network you want !

Now, if you want to use use two bitcoinjs, you are in trouble because the same package names are used:

org.bitcoinj.params.MainNetParams.java - for BTC
org.bitcoinj.params.MainNetParams.java - for BCH

And in a Java project you can not have one class name represent two different classes.



2018-06-10 10:30 GMT-06:00 Bobby_Bouche <syng...@gmail.com>:
Another Bump.

--
You received this message because you are subscribed to the Google Groups "bitcoinj" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bitcoinj+unsubscribe@googlegroups.com.

Bobby_Bouche

unread,
Jun 11, 2018, 12:32:58 PM6/11/18
to bitcoinj
I must have downloaded the wrong one.

When i was putting BCC params it wasn't recognizing. But now it works fine.

Now when i try to compile it using "mvn clean package" i get these errors.


I do have a side question though. I plan to add other cryptos such as ethereum, litecoin, monero and dash. Would it be feasible to fit all this in 1 java program? I know this is focused on bitcoin and bitcoin cash so any answer would be helpful.


Carlos López-Camey

unread,
Jun 11, 2018, 12:49:58 PM6/11/18
to bitc...@googlegroups.com
Oh yeah,
I forgot to mention: You need to be running on openjdk instead of oraclejdk..
The reason is that we used the spongy castle "provider" for BIP-47 and it needs to be signed by oracle before it can be used in their jdk !

Afaik, Litecoin and Dash have a bitcoinj fork implementation, so you could look at them. Ethereum and Monero are different beasts, and you will need to seek other options other than bitcoinj.


--
You received this message because you are subscribed to a topic in the Google Groups "bitcoinj" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/bitcoinj/VNw52fBIaY8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to bitcoinj+u...@googlegroups.com.

Bobby_Bouche

unread,
Jun 11, 2018, 5:31:13 PM6/11/18
to bitcoinj
Yea i am using openjdk...

Carlos López-Camey

unread,
Jun 11, 2018, 6:54:38 PM6/11/18
to bitc...@googlegroups.com
Are you sure? if you do in your terminal:
`echo %JAVA_PATH%`
you see openjdk in the output?

Also try to skip the tests like this:
`mvn clean package -DskipTests=true`

I hope this helps.


2018-06-11 15:31 GMT-06:00 Bobby_Bouche <syng...@gmail.com>:
Yea i am using openjdk...

--
You received this message because you are subscribed to the Google Groups "bitcoinj" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bitcoinj+unsubscribe@googlegroups.com.

Bobby_Bouche

unread,
Jun 11, 2018, 7:30:07 PM6/11/18
to bitcoinj
[INFO] bitcoincashj Parent 0.14.7-bip47.4 ................. SUCCESS [  1.020 s]
[INFO] bitcoincashj ....................................... FAILURE [05:24 min]
[INFO] bitcoincashj Examples .............................. SKIPPED
[INFO] bitcoincashj Tools 0.14.7-bip47.4 .................. SKIPPED


i ran mvn clean package -DskipTests=true

Also my PATH is

C:\Gradle\gradle-4.8\bin;C:\Program Files\apache-maven-3.5.3\bin;C:\Program Files\Java\jdk1.8.0_172\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;

Carlos López-Camey

unread,
Jun 11, 2018, 8:51:30 PM6/11/18
to bitc...@googlegroups.com
I think you are not using openjdk, otherwise the path would be explicit about it.

See http://openjdk.java.net/install/ !!


Bobby_Bouche

unread,
Jun 12, 2018, 8:43:08 AM6/12/18
to bitcoinj
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] bitcoincashj Parent 0.14.7-bip47.4 ................. SUCCESS [  0.907 s]
[INFO] bitcoincashj ....................................... FAILURE [05:00 min]
[INFO] bitcoincashj Examples .............................. SKIPPED
[INFO] bitcoincashj Tools 0.14.7-bip47.4 .................. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 05:03 min
[INFO] Finished at: 2018-06-12T08:40:49-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project bitcoincashj-core: There are test failures.
[ERROR]
[ERROR] Please refer to C:\Users\Syn\Desktop\Bitcoin Project\bitcoincashj-release-0.14\core\target\surefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :bitcoincashj-core

C:\Users\Syn\Desktop\Bitcoin Project\bitcoincashj-release-0.14>java -version
openjdk version "1.8.0_171-1-ojdkbuild"
OpenJDK Runtime Environment (build 1.8.0_171-1-ojdkbuild-b10)
OpenJDK 64-Bit Server VM (build 25.171-b10, mixed mode)

Bobby_Bouche

unread,
Jun 12, 2018, 8:44:07 AM6/12/18
to bitcoinj
this was ran with -DskipTests=true

Carlos López-Camey

unread,
Jun 12, 2018, 10:19:58 AM6/12/18
to bitc...@googlegroups.com
Hmm.. the log doesn't help me help you..
Cheers !!

Bobby_Bouche

unread,
Jun 12, 2018, 4:35:52 PM6/12/18
to bitcoinj
Hi Carlos. I was able to successfully add it to my project using the jar. thank you.

I do have a question. When i sync bitcoin then bitcoin-cash the peers cant be connected. It hangs. I know this because i have a progress bar to grab the % of the blockchain downloaded. 

[PeerGroup Thread] INFO org.bitcoinj.core.PeerGroup - Attempting connection to [158.69.119.35]:18333     (11 connected, 1 pending, 12 max)
[NioClientManager] INFO org.bitcoinj.net.NioClientManager - Connected to testnet-seed-abc.bitcoinforks.org/158.69.119.35:18333
[NioClientManager] INFO org.bitcoinj.core.Peer - Announcing to testnet-seed-abc.bitcoinforks.org/158.69.119.35:18333 as: /bitcoincashj:0.14.7-bip47.3/
[NioClientManager] INFO org.bitcoinj.core.Peer - [158.69.119.35]:18333: Got version=70015, subVer='/Bitcoin ABC:0.17.1(EB32.0)/', services=0x37, time=2018-06-12 16:12:13, blocks=1211030
[NioClientManager] INFO org.bitcoinj.core.PeerGroup - [158.69.119.35]:18333: New peer      (12 connected, 0 pending, 12 max)
[NioClientManager] WARN org.bitcoinj.core.Peer - [158.69.119.35]:18333: Received unhandled message: org.bitcoinj.core.listeners.SendHeadersMessage@4d9fc6a1
[NioClientManager] WARN org.bitcoinj.core.Peer - [158.69.119.35]:18333: Received unhandled message: org.bitcoinj.core.listeners.FeeFilterMessage@1f973cfa

I get these a lot. since my program requires it to be synced at 100% the program would only progress 10% of the time. The other times i either have to wait for a good 5 minutes or i just kill it.

Here is what deals with the sync. https://pastebin.com/bPJzTDmh

Also because i want to know if this happens next time these are the jar compile errors...https://pastebin.com/QZw3PZCK

Carlos López-Camey

unread,
Jun 14, 2018, 10:51:10 AM6/14/18
to bitc...@googlegroups.com
Hi Bobby,

I think you should call startBlockchainDownload() on the kit, after setting the download listener and it should go to 100%.

The 2 test failures in the other log are intermitent I think.. so you should try to replicate, but I don't think you need to run the tests (use -DskipTests=true ?).  

Carlos

--

Bobby_Bouche

unread,
Jun 14, 2018, 11:03:26 AM6/14/18
to bitcoinj
i dont see startBlockchainDownload() anywhere here.https://bitcoinj.github.io/javadoc/0.14.7/

Did you mean kit.startAsync(); ? Because its already there o.0?

This is what i got...

if(BTC){
DownloadProgressTracker BTCListener = new DownloadProgressTracker() {
@Override
public void progress(double pct, int blocksSoFar, Date date) {
System.out.println(BackEnd.strFormat("GOOD","BTC","GOOD","BlockChain "+(int)pct+"%"));
Diagnostic.BTCProgress = (int)pct;
}
@Override
public void doneDownload() {
System.out.println(BackEnd.strFormat("PASS","BTC","PASS","BlockChain Complete"));
System.out.println(BackEnd.strFormat("INFO","BTC","INFO","Address : "+BackEnd.gaddress(BTCkit)+" - "+BackEnd.gbal(BTCkit)));
Diagnostic.BTCProgress = 100;
}
};
BTCkit.setDownloadListener(BTCListener).setBlockingStartup(false);
BTCkit.startAsync();
BTCkit.awaitRunning();
}
if(BCH){
DownloadProgressTracker BCHListener = new DownloadProgressTracker() {
@Override
public void progress(double pct, int blocksSoFar, Date date) {
System.out.println(BackEnd.strFormat("GOOD","BCH","GOOD","BlockChain "+(int)pct+"%"));
Diagnostic.BCHProgress = (int)pct;
}
@Override
public void doneDownload() {
System.out.println(BackEnd.strFormat("PASS","BCH","PASS","BlockChain Complete"));
System.out.println(BackEnd.strFormat("INFO","BCH","INFO","Address : "+BackEnd.gaddress(BCHkit)+" - "+BackEnd.gbal(BCHkit)));
Diagnostic.BCHProgress = 100;
}
};
BCHkit.setDownloadListener(BCHListener).setBlockingStartup(false);
BCHkit.startAsync();
BCHkit.awaitRunning();
}
To unsubscribe from this group and stop receiving emails from it, send an email to bitcoinj+u...@googlegroups.com.

Carlos López-Camey

unread,
Jun 14, 2018, 2:32:01 PM6/14/18
to bitc...@googlegroups.com
Bobby, I followed your code and actually it's working.
Check it out:
Output Gif:


--
You received this message because you are subscribed to a topic in the Google Groups "bitcoinj" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/bitcoinj/VNw52fBIaY8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to bitcoinj+unsubscribe@googlegroups.com.
Message has been deleted

Bobby_Bouche

unread,
Jun 14, 2018, 8:29:31 PM6/14/18
to bitcoinj
dont know what happened to my last post.

Here is a video of me describing it ==> https://www.youtube.com/watch?v=RGsuCbw2uwo&feature=youtu.be

and the pastebin for the java ==> https://pastebin.com/Bg0jVfsC

Carlos López-Camey

unread,
Jun 14, 2018, 8:50:31 PM6/14/18
to bitc...@googlegroups.com
Hey Bobby,
These warnings can be normal and don't indicate total failure. They are saying that some peers rejected a connection attempt.
If you want to smooth/debug the process, I would say:
 - Add some "static" peer IPs for your BCH PeerGroup (see PeerGroup#addPeer). Look here: https://www.shodan.io/search?query=Bitcoin+ABC
 - Try bitcoinj-cash directly to see if these warning dissapear, if you report back that using bitcoinj-cash/bitcoinj fixes the  issue entirely I would be grateful.
Thanks
  Carlos

Bobby_Bouche

unread,
Jun 14, 2018, 11:52:44 PM6/14/18
to bitcoinj
Hi Carlos. So i tried just bitcoinj-cash and i had no issues. Sync was fine.

I went back to bitcoin hybrid and the issue persists.

When i delete the spvchain and force it to redownload the file it still doesnt always download the spvchain.

When it does at random times i get a negative percent for spvchain being downloaded.

Context.propagate(new Context(BCHparams));
DownloadProgressTracker BCHListener = new DownloadProgressTracker() {
@Override
public void progress(double pct, int blocksSoFar, Date date) {
System.out.println(BackEnd.strFormat("GOOD","BCH","GOOD","BlockChain "+(int)pct+"%"));
Diagnostic.BCHProgress = (int)pct;
}
@Override
public void doneDownload() {
System.out.println(BackEnd.strFormat("PASS","BCH","PASS","BlockChain Complete"));
System.out.println(BackEnd.strFormat("INFO","BCH","INFO","Address : "+BackEnd.gaddress(BCHkit)+" - "+BackEnd.gbal(BCHkit)));
Diagnostic.BCHProgress = 100;
}
};
BCHkit.setDownloadListener(BCHListener).setBlockingStartup(false).startAsync().awaitRunning();

output is here...

[23:49:03][BCH] : BlockChain -16%
[23:49:03][BCH] : BlockChain -15%
[23:49:03][BCH] : BlockChain -14%
[23:49:04][BCH] : BlockChain -13%
[23:49:04][BCH] : BlockChain -12%
[23:49:04][BCH] : BlockChain -11%

Carlos López-Camey

unread,
Jun 15, 2018, 10:58:49 AM6/15/18
to bitc...@googlegroups.com
Hey man, thanks... this is something we need to look at asap...  so we just noted it. Will message you back !

Bobby_Bouche

unread,
Jun 15, 2018, 12:09:31 PM6/15/18
to bitcoinj
Looking forward to it.

Bobby_Bouche

unread,
Jun 16, 2018, 10:37:48 AM6/16/18
to bitcoinj
Curious....got some sort of ETA on a response?

Carlos López-Camey

unread,
Jun 17, 2018, 2:58:12 AM6/17/18
to bitc...@googlegroups.com
Ok, I couldn't replicate the issue alone in our hybrid repo. I saw the WARN messages happen in 3 different bitcoinj jar bundles and I believe it happens when there is a reattempt to connect to a peer that has a stablished a connection with our IP before.

I am syncing all WalletAppKits in under one minute (from scratch) in 3 different programs.. so i think it's not a bug. 


To run it, just read the comments in the top of each java file

Good luck!!


2018-06-16 8:37 GMT-06:00 Bobby_Bouche <syng...@gmail.com>:
Curious....got some sort of ETA on a response?

--
You received this message because you are subscribed to the Google Groups "bitcoinj" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bitcoinj+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages