A CoinSpark address is just a bitcoin address containing additional information.

CoinSpark addresses start with the prefix s rather than a 1 or 3, for example sYDagjBGQXqpAKQ6EFDhs6igLiwdEwKoF66xN. Each CoinSpark address encodes three pieces of information regarding the destination of a payment:

  • bitcoinAddress – the receiving wallet’s regular bitcoin address.
  • addressFlags – flags representing which CoinSpark features (if any) that wallet supports.
  • paymentRef – an optional payment reference to allow the sender to be identified.

The purpose of the flags is to ensure that, when a CoinSpark transaction is sent, the receiving wallet supports all of the features required by the sending wallet. For example, if CoinSpark assets were sent to a regular bitcoin wallet, the assets would not be detected, and would likely be sent on unintentionally to someone else as part of a subsequent transaction. CoinSpark prevents this by requiring the receiving wallet to ‘prove’ its support for the protocol in a special CoinSpark address.

You can easily create and decode CoinSpark addresses using the appropriate CoinSpark library for your programming language.

Creating a CoinSpark address

C/C++

CoinSparkAddress address;
char addressString[64];
size_t addressStringLen;

strcpy(address.bitcoinAddress, "171uUzpjQyWFufu3DPcECrET9kTqKmccUt");
address.addressFlags=COINSPARK_ADDRESS_FLAG_ASSETS | COINSPARK_ADDRESS_FLAG_PAYMENT_REFS |
    COINSPARK_ADDRESS_FLAG_TEXT_MESSAGES | COINSPARK_ADDRESS_FLAG_FILE_MESSAGES;
address.paymentRef=0; // or any unsigned 52-bit integer up to COINSPARK_PAYMENT_REF_MAX

addressStringLen=CoinSparkAddressEncode(&address, addressString, sizeof(addressString));

if (addressStringLen)
    printf("CoinSpark address: %s\n", addressString);
else
    printf("CoinSpark address encode failed!\n");

Java

CoinSparkAddress address=new CoinSparkAddress();

address.setBitcoinAddress("171uUzpjQyWFufu3DPcECrET9kTqKmccUt");
address.setAddressFlags(CoinSparkAddress.COINSPARK_ADDRESS_FLAG_ASSETS |
    CoinSparkAddress.COINSPARK_ADDRESS_FLAG_PAYMENT_REFS |
    CoinSparkAddress.COINSPARK_ADDRESS_FLAG_TEXT_MESSAGES |
    CoinSparkAddress.COINSPARK_ADDRESS_FLAG_FILE_MESSAGES);
address.setPaymentRef(new CoinSparkPaymentRef(0)); // or any unsigned 52-bit integer up to CoinSparkPaymentRef.COINSPARK_PAYMENT_REF_MAX

String addressString=address.encode();

if (addressString!=null)
    System.out.println("CoinSpark address: "+addressString);
else
    System.out.println("CoinSpark address encode failed!");

Javascript

var address=new CoinSparkAddress();

address.bitcoinAddress="171uUzpjQyWFufu3DPcECrET9kTqKmccUt";
address.addressFlags=COINSPARK_ADDRESS_FLAG_ASSETS | COINSPARK_ADDRESS_FLAG_PAYMENT_REFS |
    COINSPARK_ADDRESS_FLAG_TEXT_MESSAGES | COINSPARK_ADDRESS_FLAG_FILE_MESSAGES;
address.paymentRef.ref=0; // or any unsigned 52-bit integer up to COINSPARK_PAYMENT_REF_MAX

var addressString=address.encode();

if (addressString)
    console.log("CoinSpark address: "+addressString);
else
    console.log("CoinSpark address encode failed!");

PHP

$address=new CoinSparkAddress();

$address->bitcoinAddress="171uUzpjQyWFufu3DPcECrET9kTqKmccUt";
$address->addressFlags=COINSPARK_ADDRESS_FLAG_ASSETS | COINSPARK_ADDRESS_FLAG_PAYMENT_REFS |
    COINSPARK_ADDRESS_FLAG_TEXT_MESSAGES | COINSPARK_ADDRESS_FLAG_FILE_MESSAGES;
$address->paymentRef->ref=0; // or any unsigned 52-bit integer up to COINSPARK_PAYMENT_REF_MAX

$addressString=$address->encode();

if (isset($addressString))
    echo "CoinSpark address: ".$addressString."\n";
else
    echo "CoinSpark address encode failed!";

Python

address=CoinSparkAddress()

address.bitcoinAddress="171uUzpjQyWFufu3DPcECrET9kTqKmccUt"
address.addressFlags=(COINSPARK_ADDRESS_FLAG_ASSETS | COINSPARK_ADDRESS_FLAG_PAYMENT_REFS |
    COINSPARK_ADDRESS_FLAG_TEXT_MESSAGES | COINSPARK_ADDRESS_FLAG_FILE_MESSAGES)
address.paymentRef.ref=0 # or any unsigned 52-bit integer up to COINSPARK_PAYMENT_REF_MAX

addressString=address.encode()

if not addressString is None:
    print("CoinSpark address: "+addressString)
else:
    print("CoinSpark address encode failed!")

Ruby

address=CoinSparkAddress.new

address.bitcoinAddress="171uUzpjQyWFufu3DPcECrET9kTqKmccUt"
address.addressFlags=(COINSPARK_ADDRESS_FLAG_ASSETS | COINSPARK_ADDRESS_FLAG_PAYMENT_REFS |
    COINSPARK_ADDRESS_FLAG_TEXT_MESSAGES | COINSPARK_ADDRESS_FLAG_FILE_MESSAGES)
address.paymentRef.ref=0 # or any unsigned 52-bit integer up to COINSPARK_PAYMENT_REF_MAX

addressString=address.encode

if addressString!=nil
    puts("CoinSpark address: "+addressString)
else
    puts("CoinSpark address encode failed!")
end

Decoding a CoinSpark address

C/C++

char addressString[]="sYDagjBGQXqpAKQ6EFDhs6igLiwdEwKoF66xN";
CoinSparkAddress address;
char debugString[1024];

if (CoinSparkAddressDecode(&address, addressString, strlen(addressString)) {
    printf("Bitcoin address: %s\n", address.bitcoinAddress);
    printf("Address flags: %d\n", address.addressFlags);
    printf("Payment reference: %ld\n", address.paymentRef);

    CoinSparkAddressToString(&address, debugString, sizeof(debugString));
    printf(debugString);

} else
    printf("CoinSpark address decode failed!\n");

Java

CoinSparkAddress address=new CoinSparkAddress();

if (address.decode("sYDagjBGQXqpAKQ6EFDhs6igLiwdEwKoF66xN")) {
    System.out.println("Bitcoin address: "+address.getBitcoinAddress());
    System.out.println("Address flags: "+address.getAddressFlags());
    System.out.println("Payment reference: "+address.getPaymentRef().getRef());

    System.out.print(address.toString());

} else
    System.out.println("CoinSpark address decode failed!");

Javascript

var address=new CoinSparkAddress();

if (address.decode("sYDagjBGQXqpAKQ6EFDhs6igLiwdEwKoF66xN")) {
    console.log("Bitcoin address: "+address.bitcoinAddress);
    console.log("Address flags: "+address.addressFlags);
    console.log("Payment reference: "+address.paymentRef.ref);

    console.log(address.toString());

} else
    console.log("CoinSpark address decode failed!");

PHP

$address=new CoinSparkAddress();

if ($address->decode("sYDagjBGQXqpAKQ6EFDhs6igLiwdEwKoF66xN")) {
    echo "Bitcoin address: ".$address->bitcoinAddress."\n";
    echo "Address flags: ".$address->addressFlags."\n";
    echo "Payment reference: ".$address->paymentRef->ref."\n";

    echo $address->toString();

} else
    echo "CoinSpark address decode failed!";

Python

address=CoinSparkAddress()

if address.decode("sYDagjBGQXqpAKQ6EFDhs6igLiwdEwKoF66xN"):
    print("Bitcoin address: "+address.bitcoinAddress)
    print("Address flags: "+str(address.addressFlags))
    print("Payment reference: "+str(address.paymentRef.ref))

    sys.stdout.write(address.toString())

else:
    print("CoinSpark address decode failed!")

Ruby

address=CoinSparkAddress.new

if address.decode("sYDagjBGQXqpAKQ6EFDhs6igLiwdEwKoF66xN")
    puts("Bitcoin address: "+address.bitcoinAddress)
    puts("Address flags: "+address.addressFlags.to_s)
    puts("Payment reference: "+address.paymentRef.ref.to_s)

    print(address.toString)
else
    puts("CoinSpark address decode failed!")
end