Bitcoin4J is a Bitcoin library for the Java Language licensed under the Apache License 2.0.
This library has been built in line with the ideals espoused by BitcoinSV, i.e. massive on-chain scaling, protocol stability and original-bitcoin-protocol implementation.
You can learn more about BitcoinSV by visiting :
- TwoStack Bitcoin Developer Guide
- TwoStack Youtube Channel
- Bitcoin Association Website
- BitcoinSV Wiki.
Binaries for the library are available on Maven Central.
implementation("org.twostack:bitcoin4j:1.6.6")
<dependency>
<groupId>org.twostack</groupId>
<artifactId>bitcoin4j</artifactId>
<version>1.6.6</version>
</dependency>
Several helper classes and APIs exist to make constructing Transactions more intuitive.
See the full example source code
As a native Java implementation, the library integrates well with other JVM languages, e.g. Kotlin.
val txBuilder: TransactionBuilder = TransactionBuilder()
val spendingTx: Transaction = txBuilder.spendFromTransaction(aliceFundingTx, 1, Transaction.NLOCKTIME_MAX_VALUE, unlockBuilder)
.spendTo(bobLockingBuilder, BigInteger.valueOf(10000))
.sendChangeTo(aliceAddress, aliceLockingBuilder)
.withFeePerKb(512)
.build(true)
- Unbounded Transaction Types (creating non-standard transactions)
- HD Key Derivation (BIP32)
- Mnemonic Seed Support (BIP39)
- Original Bitcoin Address format
- A built-in Bitcoin Script Interpreter
- Custom-Script Builder Interface to support novel locking/spending conditions within Script
- P2PKH Transaction Builder - Pay to Pubkey Hash standard Transactions
- P2MS Transaction Builder - Pay to Multisig. This is naked MultiSig (the proper way to do multisig).
- P2PK Transaction Builder - Pay to Public Key standard Transactions
- P2SH Transaction Builder - Pay to Script Hash. This should be considered deprecated. BitcoinSV Nodes support this for backwards compatibility only.
- P2PKHDataLockBuilder - This is something new. Create a spendable data output. Spendable using P2PKH Transaction.
- UnspendableDataLockBuilder - OP_RETURN-style Data builder. Prepends a Transaction Output Script with OP_FALSE OP_RETURN followed by a series of data pushes.
The following features represent forks away from the original Bitcoin Protocol.
This library lacks, and does not implement :
- Segregated Witness (Segwit) Transaction support (Bitcoin Core - BTC)
- Schnorr Transaction Signature support (Bitcoin Cash - BCH)
- Check Datasig (OP_CHECKDATASIG) (Bitcoin Cash - BCH)
- Taproot (Bitcoin Core - BTC)
This library is a fork of the BitcoinJ and BitcoinJ-Cash projects. Contributor acknowledgements have been preserved in the AUTHORS file.
You can reach the author at : stephan@twostack.org