This guide explains in detail how to support CoinSpark assets in your wallet.

Before getting started on modifying your wallet’s code, please work through the steps below:

This guide is written for lightweight bitcoin wallets, which do not store the entire blockchain on the user’s computer. However there is no problem implementing CoinSpark in a full bitcoin wallet. The main difference will be that the asynchronous fetching of genesis transactions can be performed instantly, since the block containing the genesis can be retrieved locally rather than from the network.

First Steps

In order to ensure your wallet is able to receive and safely transact in CoinSpark assets, start with the following modifications:

  • When a transaction has change to go back to the user, always use the last transaction output for that change. This is vital because CoinSpark assets in a transaction’s inputs always flow to the last output by default, if there is no transfer metadata specifying otherwise.
  • Ensure that every transaction has some change. Even if unspent transaction outputs can be found which exactly match the amount to be sent to a different address, an additional input must be added to the bitcoin transaction, to ensure that there is some change. The amount of change can be as low as bitcoin’s anti-dust threshold, which is 546 satoshis as of Bitcoin Core 0.9 (less than 0.3 US cents at $500 per bitcoin). It is not possible to spend all of the bitcoin in a CoinSpark wallet without also spending all of the CoinSpark assets.
  • In the location where your wallet displays a bitcoin receiving address, display the equivalent CoinSpark address alongside. The CoinSpark library makes it easy to calculate CoinSpark addresses from bitcoin addresses.

At this point you will be able to experiment with creating a new CoinSpark asset and sending it to your wallet.

Next Steps

You should now read and implement each of the sections below:

If you have any questions, please don’t hesitate to be in touch.

Next: Data Model »