HashEngineering started aa copy/paste find/replace Android Wallet app creation service. Currently we limit out work to previously made wallets by fixing bugs and maintaining the code and providing user support.
While we don't create android apps from scratch, we understand the C++ source code that defines the parameters that uniquely identify each coin. These parameters include the hash functions, coin generation rules, the network protocols and ports, difficulty retargets, transaction fees, genesis block information, DNS seeds, checkpoints and even where to get data from the block explorers and exchanges. This information is moved into a slightly modified Bitcoin Wallet / Bitcoin Java Library source code that allows for easy porting of a proven wallet to a new coin.
HashEngineering was created when there was a need to fix the digitalcoin android wallet to be compatible with the V0.2 and V1.0 forks. We were further inspired when the digitalcoin android wallet developer announced that the standalone android app (it doesn’t require an online wallet) would no longer be maintained. Therefore we decided to fork the Bitcoin Wallet (v3.22) and BitCoin Java Library (v0.11) to digitalcoin in such a way that the java source code could more easily be ported to other coins while requiring a minimal amount of changes. A few lines of code were taken from the Litecoin Wallet (no longer available on Google Play) for the scrypt hash functions.
Currently the Bitcoin Client source and the Bitcoin Android Wallet source have the coin defining parameters sprinkled through out many C++ or Java files [Similar to the actual Bitcoin QT Client]. Our modification contains a Java class called
CoinDefinition where all of these parameters are stored in one place.
public class CoinDefinition {
public static final String coinName = "digitalcoin";
public static final String coinTicker = "DGC";
public static final String coinURIScheme = "digitalcoin";
public static final String cryptsyMarketId = "26";
The modifications to the Bitcoin Wallet code include sections such as this one that refer to the
CoinDefinition:
public class MainNetParams extends NetworkParameters {
public MainNetParams() {
super();
interval = INTERVAL;
targetTimespan = TARGET_TIMESPAN;
proofOfWorkLimit = CoinDefinition.proofOfWorkLimit;
acceptableAddressCodes = new int[] { CoinDefinition.AddressHeader/*,0*/ };
dumpedPrivateKeyHeader = 128 + CoinDefinition.AddressHeader;
addressHeader = CoinDefinition.AddressHeader;
port = CoinDefinition.Port;
packetMagic = CoinDefinition.PacketMagic;
genesisBlock.setDifficultyTarget(CoinDefinition.genesisBlockDifficultyTarget);
After this there is still a lot of Find/Replacing of the coin names that must be done to finish the port. Since we began, we determined that we can reduce the amount of find/replacing by leaving all the bitcoin references in the code for page names, classes and methods. Only the text needs to be changed and the graphics need to be updated.
What about Proof of Stake Coins?Proof of Stake coins will require more code to be added to the Bitcoin Java Library (which now as been done by two independent developers). Currently, the Android Bitcoin Wallet is setup as SPV - Simplified Payment Verification. The App does not download the entire blockchain with all data on every block like the standard desktop client. This is good for a mobile device, where bandwidth is at a premium. Certainly no one would want to download the entire blockchain of Bitcoin to their phone (140 GB). The Bitcoin android app only downloads the block headers (80 bytes) and then queries the other peers for other information on transactions.
The block header contains several types of data, but for this discussion the important data is the difficulty. The Android Wallet will verify the difficulty of each block as each header is downloaded from the network. Most coin forks have to do with difficulty code changes so this is an important thing to check.
A proof of work coin only has 1 type of difficulty per block, which is for the proof of work hash function. The problem with Proof of Stake coins is that a block may be a Proof of stake block or a Proof of Work block. Unfortunately, the block header does not contain the information to determine if the block is POS or POW. More information is needed and that is the first transaction of the block. The Bitcoin Java Library can be switched to a mode that downloads the full block information. There will be other code needed to check what kind of block it is (POS, POW). Other code will check to make sure the difficulty is correct for each block. Additionally, other information is required to verify the coin staking. This prevents the wallet from being a lightweight wallet.
Fortunately, some are working to get around the above issues. One is for
Peercoin. It works in a similar way as the Bitcoin Wallet, but it does not verify blocks or block headers in the app, but submits requests to verify to a centralized server using a getvalidhashes API in an ABE based block explorer. To date we have not been able to get this solution to work for other coins. We don't do servers and rely on the others to do that and they have yet to deliver.
http://www.peercointalk.org/index.php?topic=1751.15 (links for source are here).
Additionally a developer has created a
Blackcoin Wallet, which uses a "Full Pruned" blockchain storage method.
Java Library Source -
https://github.com/janko33bd/bitcoinj/tree/blackcoinjWallet Source -
https://bitbucket.org/janko33/bitcoin-wallet-4.16Coinomi can also be forked for support a POS coin, but that does require electrum servers.
Looking at the APK file for the source code:1. One can use a Java Decompiler such as: http://jd.benow.ca/#jd-gui-overview to open the .apk file.
2. Most of the code is in the classes.dex file. That can be opened by first extracting it using a Archive file viewer such as 7Zip () and then using this tool to convert it to a .jar file (
https://code.google.com/p/dex2jar/downloads/detail?name=dex2jar-0.0.9.15.zip&can=2&q=). Then use the java decompiler from step 1 to look at it.