Coder Social home page Coder Social logo

litecoinj's Introduction

GitHub Build Status GitLab Build Status Coverage Status

Visit our IRC channel

Welcome to bitcoinj

The bitcoinj library is a Java implementation of the Bitcoin protocol, which allows it to maintain a wallet and send/receive transactions without needing a local copy of Bitcoin Core. It comes with full documentation and some example apps showing how to use it.

Technologies

  • Java 8+ (needs Java 8 API or Android 8.0 API, compiles to Java 8 bytecode) and Gradle 4.4+ for the core module

  • Java 11+ and Gradle 4.4+ for tools, wallettool and examples

  • Java 11+ and Gradle 4.10+ for the JavaFX-based wallettemplate

  • Gradle - for building the project

  • Google Protocol Buffers - for use with serialization and hardware communications

Getting started

To get started, it is best to have the latest JDK and Gradle installed. The HEAD of the master branch contains the latest development code and various production releases are provided on feature branches.

Building from the command line

Official builds are currently using JDK 11. Our GitHub Actions build and test with JDK 11 and JDK 17.

To perform a full build (including JavaDocs and unit/integration tests) use JDK 11+.

gradle clean build

If you are using Gradle 4.10 or later, the build will automatically include the JavaFX-based wallettemplate module. The outputs are under the build directory.

To perform a full build without unit/integration tests use:

gradle clean assemble

Building from an IDE

Alternatively, just import the project using your IDE. IntelliJ has Gradle integration built-in and has a free Community Edition. Simply use File | New | Project from Existing Sources and locate the build.gradle in the root of the cloned project source tree.

Building and Using the Wallet Tool

The bitcoinj wallettool subproject includes a command-line Wallet Tool (wallet-tool) that can be used to create and manage bitcoinj-based wallets (both the HD keychain and SPV blockchain state.) Using wallet-tool on Bitcoin’s test net is a great way to learn about Bitcoin and bitcoinj.

To build an executable shell script that runs the command-line Wallet Tool, use:

gradle bitcoinj-wallettool:installDist

You can now run the wallet-tool without parameters to get help on its operation:

./wallettool/build/install/wallet-tool/bin/wallet-tool

To create a test net wallet file in ~/bitcoinj/bitcoinj-test.wallet, you would use:

mkdir ~/bitcoinj
./wallettool/build/install/wallet-tool/bin/wallet-tool --net=TESTNET --wallet=$HOME/bitcoinj/bitcoinj-test.wallet create

To sync the newly created wallet in ~/bitcoinj/bitcoinj-test.wallet with the test net, you would use:

./wallettool/build/install/wallet-tool/bin/wallet-tool --net=TESTNET --wallet=$HOME/bitcoinj/bitcoinj-test.wallet sync

To dump the state of the wallet in ~/bitcoinj/bitcoinj-test.wallet with the test net, you would use:

./wallettool/build/install/wallet-tool/bin/wallet-tool --net=TESTNET --wallet=$HOME/bitcoinj/bitcoinj-test.wallet dump
Note
These instructions are for macOS/Linux, for Windows use the wallettool/build/install/wallet-tool/bin/wallet-tool.bat batch file with the equivalent Windows command-line commands and options.

Example applications

These are found in the examples module.

Where next?

Now you are ready to follow the tutorial.

Testing a SNAPSHOT build

Building apps with official releases of bitcoinj is covered in the tutorial.

If you want to develop or test your app with a Jitpack-powered build of the latest master or release-0.15 branch of bitcoinj follow the dynamically-generated instructions for that branch by following the correct link.

litecoinj's People

Contributors

amichair avatar c-otto avatar cyberzac avatar devrandom avatar devrandom1 avatar erasmospunk avatar haraldh avatar hashengineering avatar jarlfr avatar johnzweng avatar kirill-vlasov avatar kmels avatar kparmar1 avatar ksedgwic avatar matthewleon avatar mikehearn avatar mjjbell avatar mruddy avatar msgilligan avatar mswiggs avatar natzei avatar oscarguindzberg avatar peterdettman avatar pvyhnal-generalbytes avatar rustin-bot avatar schildbach avatar thebluematt avatar troggy avatar w-shackleton avatar wlk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

litecoinj's Issues

Incomplete Method

Please complete this, this program is invaluable to crypto currency and will revolutionize cryptocurrency usage. I believe LegacyAddress.fromKey is an incomplete method the outPutScriptType is added as a parameter but is not updated across the application. Please do this if you can. It will be of great help.

Tutorial Please

If it is not too much work could someone link a video tutorial or a readme tutorial on how to get this working.

deserializing error

I am trying to develop a wallet application using liteconj library.
When the wallet starts syncing it immediately throws the below error.

2023-01-16 14:34:15.134  WARN 9940 --- [ioClientManager] org.bitcoinj.core.BitcoinSerializer      : No support for deserializing message with name alert
2023-01-16 14:34:15.134  INFO 9940 --- [eerGroup Thread] org.bitcoinj.core.PeerGroup              : Waiting 1000 ms before next connect attempt to [77.120.122.116]:9333
2023-01-16 14:34:15.134  WARN 9940 --- [ioClientManager] org.bitcoinj.core.PeerSocketHandler      : [176.126.167.10]:9333 - 

org.bitcoinj.core.ProtocolException: Error deserializing message 5c0100000015f7675900000000ffffff7f00000000ffffff7ffeffff7f0000000000ffffff7f00ffffff7f002f555247454e543a20416c657274206b657920636f6d70726f6d697365642c2075706772616465207265717569726564004630440220405f7e7572b176f3316d4e12deab75ad4ff978844f7a7bcd5ed06f6aa094eb6602207880fcc07d0a78e0f46f188d115e04ed4ad48980ea3572cb0e0cb97921048095

	at org.bitcoinj.core.BitcoinSerializer.deserializePayload(BitcoinSerializer.java:212) ~[litecoinj-0.2.jar:na]
	at org.bitcoinj.core.BitcoinSerializer.deserialize(BitcoinSerializer.java:173) ~[litecoinj-0.2.jar:na]
	at org.bitcoinj.core.PeerSocketHandler.receiveBytes(PeerSocketHandler.java:157) ~[litecoinj-0.2.jar:na]
	at org.bitcoinj.net.ConnectionHandler.handleKey(ConnectionHandler.java:238) ~[litecoinj-0.2.jar:na]
	at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:86) ~[litecoinj-0.2.jar:na]
	at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122) ~[litecoinj-0.2.jar:na]
	at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:65) ~[guava-30.0-android.jar:na]
	at com.google.common.util.concurrent.Callables$4.run(Callables.java:119) ~[guava-30.0-android.jar:na]
	at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:50) ~[litecoinj-0.2.jar:na]
	at java.base/java.lang.Thread.run(Thread.java:829) ~[na:na]
Caused by: java.lang.IllegalStateException: Length field has not been set in constructor for UnknownMessage after parse.
	at com.google.common.base.Preconditions.checkState(Preconditions.java:592) ~[guava-30.0-android.jar:na]
	at org.bitcoinj.core.Message.<init>(Message.java:93) ~[litecoinj-0.2.jar:na]
	at org.bitcoinj.core.Message.<init>(Message.java:101) ~[litecoinj-0.2.jar:na]
	at org.bitcoinj.core.EmptyMessage.<init>(EmptyMessage.java:41) ~[litecoinj-0.2.jar:na]
	at org.bitcoinj.core.UnknownMessage.<init>(UnknownMessage.java:28) ~[litecoinj-0.2.jar:na]
	at org.bitcoinj.core.BitcoinSerializer.makeMessage(BitcoinSerializer.java:260) ~[litecoinj-0.2.jar:na]
	at org.bitcoinj.core.BitcoinSerializer.deserializePayload(BitcoinSerializer.java:210) ~[litecoinj-0.2.jar:na]
	... 9 common frames omitted

error Context does not match implicit network params

hi when I use your library with bitcoinJ for create lite coin and bitcoin wallet together, I have error error Context does not match implicit network params and Duplicate class org.bitcoin.NativeSecp256k1 found in modules bitcoinj-core-0.16.2 (org.bitcoinj:bitcoinj-core:0.16.2) and litecoinj-0.3.0 (com.github.pokkst:litecoinj:0.3.0)
. how to fix that ?
my example:

val params = MainNetParams.get()
val seed = DeterministicSeed(mnemonic, null, "", System.currentTimeMillis() / 1000)
val wallet = Wallet.fromSeed(params, seed, Script.ScriptType.P2WPKH)

// with your dependency
val params1 =MainNetParams.get()
val seed1 = DeterministicSeed(mnemonic, null, "", System.currentTimeMillis() / 1000)
val wallet1 = Wallet.fromSeed(params1, seed1, Script.ScriptType.P2WPKH)

here I receive this error.

IllegalStateException: Length field has not been set in constructor for UnknownMessage after parse.

anyone else seeing below stacktrace when constructing WalletAppKit using org.litecoin.test (TestNet3Params) and have a proper workaround (that doesn't involve a try/catch hack)?

the exception does not cause application to crash, but rather is thrown over and over- ad infinitum. strangely at one point, the below exception stopped for several hours- then reappeared.

it appears to be specifically recurring about failed de-serialization of this message (and nothing else):

5c0100000015f7675900000000ffffff7f00000000ffffff7ffeffff7f0000000000ffffff7f00ffffff7f002f555247454e543a20416c657274206b657920636f6d70726f6d697365642c2075706772616465207265717569726564004630440220405f7e7572b176f3316d4e12deab75ad4ff978844f7a7bcd5ed06f6aa094eb6602207880fcc07d0a78e0f46f188d115e04ed4ad48980ea3572cb0e0cb97921048095

the critical parts of the stacktrace are:
org.litecoinj.core.BitcoinSerializer : No support for deserializing message with name alert
and
java.lang.IllegalStateException: Length field has not been set in constructor for UnknownMessage after parse.

here's the full stacktrace:

2021-05-04 09:16:13.007  INFO 43756 --- [ioClientManager] org.litecoinj.core.Peer                  : Peer{[104.237.131.138]:19335, version=70015, subVer=/LitecoinCore:0.18.1/, services=1037 (NETWORK, BLOOM, WITNESS, NETWORK_LIMITED), time=2021-05-04 09:16:12, height=1886649}
2021-05-04 09:16:13.010  INFO 43756 --- [ioClientManager] org.litecoinj.core.PeerGroup             : Peer{[104.237.131.138]:19335, version=70015, subVer=/LitecoinCore:0.18.1/, services=1037 (NETWORK, BLOOM, WITNESS, NETWORK_LIMITED), time=2021-05-04 09:16:12, height=1886649}: New peer      (1 connected, 5 pending, 6 max)
2021-05-04 09:16:13.010  INFO 43756 --- [ioClientManager] org.litecoinj.core.Peer                  : Peer{[104.237.131.138]:19335, version=70015, subVer=/LitecoinCore:0.18.1/, services=1037 (NETWORK, BLOOM, WITNESS, NETWORK_LIMITED), time=2021-05-04 09:16:12, height=1886649}: Sending Bloom filter and querying mempool
2021-05-04 09:16:13.012  WARN 43756 --- [ioClientManager] org.litecoinj.core.BitcoinSerializer     : No support for deserializing message with name alert
2021-05-04 09:16:13.018  WARN 43756 --- [ioClientManager] org.litecoinj.core.PeerSocketHandler     : [104.237.131.138]:19335 - 

org.litecoinj.core.ProtocolException: Error deserializing message 5c0100000015f7675900000000ffffff7f00000000ffffff7ffeffff7f0000000000ffffff7f00ffffff7f002f555247454e543a20416c657274206b657920636f6d70726f6d697365642c2075706772616465207265717569726564004630440220405f7e7572b176f3316d4e12deab75ad4ff978844f7a7bcd5ed06f6aa094eb6602207880fcc07d0a78e0f46f188d115e04ed4ad48980ea3572cb0e0cb97921048095

	at org.litecoinj.core.BitcoinSerializer.deserializePayload(BitcoinSerializer.java:212) ~[litecoinj-core-0.2.jar:na]
	at org.litecoinj.core.BitcoinSerializer.deserialize(BitcoinSerializer.java:173) ~[litecoinj-core-0.2.jar:na]
	at org.litecoinj.core.PeerSocketHandler.receiveBytes(PeerSocketHandler.java:157) ~[litecoinj-core-0.2.jar:na]
	at org.litecoinj.net.ConnectionHandler.handleKey(ConnectionHandler.java:238) [litecoinj-core-0.2.jar:na]
	at org.litecoinj.net.NioClientManager.handleKey(NioClientManager.java:86) [litecoinj-core-0.2.jar:na]
	at org.litecoinj.net.NioClientManager.run(NioClientManager.java:122) [litecoinj-core-0.2.jar:na]
	at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66) [guava-30.1.1-jre.jar:na]
	at com.google.common.util.concurrent.Callables$4.run(Callables.java:117) [guava-30.1.1-jre.jar:na]
	at org.litecoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:50) [litecoinj-core-0.2.jar:na]
	at java.base/java.lang.Thread.run(Thread.java:844) [na:na]
Caused by: java.lang.IllegalStateException: Length field has not been set in constructor for UnknownMessage after parse.
	at com.google.common.base.Preconditions.checkState(Preconditions.java:591) ~[guava-30.1.1-jre.jar:na]
	at org.litecoinj.core.Message.<init>(Message.java:93) ~[litecoinj-core-0.2.jar:na]
	at org.litecoinj.core.Message.<init>(Message.java:101) ~[litecoinj-core-0.2.jar:na]
	at org.litecoinj.core.EmptyMessage.<init>(EmptyMessage.java:41) ~[litecoinj-core-0.2.jar:na]
	at org.litecoinj.core.UnknownMessage.<init>(UnknownMessage.java:28) ~[litecoinj-core-0.2.jar:na]
	at org.litecoinj.core.BitcoinSerializer.makeMessage(BitcoinSerializer.java:260) ~[litecoinj-core-0.2.jar:na]
	at org.litecoinj.core.BitcoinSerializer.deserializePayload(BitcoinSerializer.java:210) ~[litecoinj-core-0.2.jar:na]
	... 9 common frames omitted

2021-05-04 09:16:13.019  INFO 43756 --- [ioClientManager] org.litecoinj.core.PeerGroup             : [104.237.131.138]:19335: Peer died      (0 connected, 5 pending, 6 max)
2021-05-04 09:16:13.019  INFO 43756 --- [eerGroup Thread] org.litecoinj.core.PeerGroup             : Waiting 1000 ms before next connect attempt to [195.201.246.33]:19335
2021-05-04 09:16:13.021  WARN 43756 --- [ioClientManager] org.litecoinj.net.ConnectionHandler      : Error handling SelectionKey: java.lang.IllegalStateException 

java.lang.IllegalStateException: null
	at com.google.common.base.Preconditions.checkState(Preconditions.java:494) ~[guava-30.1.1-jre.jar:na]
	at org.litecoinj.net.ConnectionHandler.handleKey(ConnectionHandler.java:239) ~[litecoinj-core-0.2.jar:na]
	at org.litecoinj.net.NioClientManager.handleKey(NioClientManager.java:86) [litecoinj-core-0.2.jar:na]
	at org.litecoinj.net.NioClientManager.run(NioClientManager.java:122) [litecoinj-core-0.2.jar:na]
	at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66) [guava-30.1.1-jre.jar:na]
	at com.google.common.util.concurrent.Callables$4.run(Callables.java:117) [guava-30.1.1-jre.jar:na]
	at org.litecoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:50) [litecoinj-core-0.2.jar:na]
	at java.base/java.lang.Thread.run(Thread.java:844) [na:na]

TestNet dnsSeeds do not seem to exist

The TestNet3Params has 3 dns names hardcoded in for the dnsSeed array values (below). NONE of these 3 dns names even resolve anymore, let alone ping/work. If I use the MainNetParams everything works fine (albeit a good 30 minute first time load of Wallet/WalletKit to sync spv chain). If there are updated testnet config values, would be great if these were merged in. If LiteCoin testnet just not supported/working anymore, that would be nice to know as well.

    dnsSeeds = new String[] {
            "testnet-seed.litecointools.com",
            "seed-b.litecoin.loshan.co.uk",
            "dnsseed-testnet.thrasher.io"
    };

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.