BlockSearchJ is a simple Java library that allows to easily generate from a 12 word mnemonic phrase or entropy, the BIP44, BIP49 and BIP84 addresses and get the associated Bitcoin balance using the Blochain.info API. The library is only meant to access wallets and get their basic informations, NOT to manage transactions.
- BitcoinJ - for bitcoin algorithms
- Blockchain API - for Blockchain requests (Balance, Current BTC Price)
To get started, download BlockSearchJ's Jar file and add it to your Java Project Build Path.
Wallet myWallet = new Wallet("word word word word word word word word word word word word");
Wallet myWallet = new Wallet(new BigInteger("00"),2);
// Only meant for test purposes, doesn't generate a real Bitcoin wallet
Wallet myWallet = new Wallet();
String phrase = myWallet.getMnemonic().getPhrase() // Get wallet's 12 word mnemonic phrase
String entropy = myWallet.getMnemonic().getEntropy() // Get wallet's binary entropy
String seed = myWallet.getMnemonic().getSeed() // Get wallet's BIP39 seed
Key keys = myWallet.getMnemonic().getMasterKeys() // Get wallet's master keys (public and private)
String address;
myWallet.changeAddressFormat(AddressFormat.BIP84); // Change wallet's address format to BIP84
address = myWallet.getAddress() // Get wallet's BIP84 first address
myWallet.changeAddressFormat(AddressFormat.BIP49); // Change wallet's address format to BIP49
address = myWallet.getAddress() // Get wallet's BIP49 first address
myWallet.changeAddressFormat(AddressFormat.BIP44); // Change wallet's address format to BIP44
address = myWallet.getAddress() // Get wallet's BIP44 first address
double balance = myWallet.getBalance() // Get wallet's balance of the first address of the selected address format
// Get the public key of m/84'/0'/0'/0/1 and generate it's address
String publicKey = myWallet.getMnemonic().getMasterKeys().derivateKeys("m/84'/0'/0'/0/1").getPublicKey();
Algorithms.generateAddress(publicKey, AddressFormat.BIP84);
// Get the public key of the first BIP44 key (m/44'/0'/0'/0/0) and generate it's address
String publicKey = myWallet.getMnemonic().getMasterKeys().derivateFirstKey(AddressFormat.BIP44).getPublicKey();
Algorithms.generateAddress(publicKey, AddressFormat.BIP44);
double balance = Blockchain.getBalance("address") // Get the balance in BTC of an address
double balanceUsd = Blockchain.btcToCurrency(0.34, "usd") // Convert 0.34BTC to USD
double balanceCad = Blockchain.btcToCurrency(2, "cad") // Convert 2BTC to CAD