CoinSpark is designed to require minimal modifications to the existing user interface of your wallet. However two changes are required to ensure compatibility with the protocol.

Getting a CoinSpark address

This was already covered in the First Steps section, but is included here for completeness.

In any location where the user can obtain their bitcoin address, provide them with the equivalent CoinSpark address alongside. The CoinSpark library makes it easy to calculate CoinSpark addresses from bitcoin addresses.

Sending regular bitcoin

First, when sending a regular bitcoin transaction, you should allow users to enter a CoinSpark address for the recipient as well as a regular bitcoin address. It is easy to decode CoinSpark addresses using the CoinSpark library, and you can simply ignore the address flags for bitcoin transactions. If the CoinSpark address encodes a non-zero payment reference, you should encode that payment reference as CoinSpark metadata and then embed that metadata in an additional OP_RETURN output for the outgoing transaction.

Second, recall from the First Steps section that every transaction must send some change back to the user, in order to ensure that their CoinSpark assets are preserved. By extension, it is not possible to spend all of the bitcoin in a CoinSpark wallet without also spending all of the CoinSpark assets, so some bitcoin must be kept back. Because of the cost of migrating CoinSpark assets, we recommend that CoinSpark wallets maintain a minimum bitcoin balance which is calculated as follows:

  1. Count the total number of unspent transaction outputs which this wallet can spend.
  2. Divide this number by 5, then round up to the nearest integer. This gives an upper limit on the number of KB required to send out a migration transaction.
  3. Multiply this number of KB by 11,000 satoshis (5.5 US cents at $500 per bitcoin). This is the number of satoshis that will be required for the migration transaction, with a little room to spare. It covers both the transaction fee and the anti-dust threshold for the transaction output.

Because of this restriction, you will need to display an error message to the user if they attempt to leave too little bitcoin in their wallet. It should give them the choice of either keeping back at least the required number of satoshis, or alternatively migrating all of their bitcoin and CoinSpark assets to another wallet.

« Previous: Asynchronous Tasks Next: Interface Additions »