Alice has coloured coins (but no bearer tokens)
Bob has bearer tokens
Create a TX to send colour coins from Alice to Carol, with Bob paying the miners fee.
Bitcoin (bearer) change to go back to Bob
Colour coin change to go back to Alice
Here is my attempt:
Raw tx
01000000015c9aed0920c7ea31f867d1c2ead3d01a68b1c37929adfe54f363f340e08cd69400000 0006b483045022100b85cd1009a7d5efe8078c0fe2eb52ebbb6944b92ab655a988bf867dbcdac27 8002206c60f54f027586f6618f357b47c5240f5a24eb9917ba1a513d3e2d31fa700e06012102a34 dd7375accc0201e829eb28d40bafd0add18134b1ea30dff56ef79814e0124ffffffff0300000000 000000000c6a0a4f41010002a846e80700aa0a0000000000001976a914b7c2e22206fcd3eee3cbf a2fd423892355e5114488acaa0a0000000000001976a91467bac1ccbfab92c978a7549971a24f30 97038f9688ac00000000
{
try
{
//Apps private key
BitcoinSecret bearerKey = new BitcoinSecret(this.BearerKey);
BitcoinSecret assetOwnerKey = new BitcoinSecret(this.AssetOwnerKey);
TransactionBuilder txBuilder = new TransactionBuilder();
txBuilder
.AddKeys(bearerKey)
.AddCoins(bearer)
.AddKeys(assetOwnerKey)
.AddCoins(colored)
.SendAsset(toAddress, assetToSend)
//.SendAsset(agentAddress, agentFee)
//.SendAsset(AutarkyBitcoinAddress, autarkyFee)
.SetChange(AutarkyBitcoinAddress, ChangeType.Uncolored) //was from address
.SetChange(fromAddress, ChangeType.Colored)
.SendFees(this.MinersFee);
Transaction tx = txBuilder.BuildTransaction(true);
Boolean ok = txBuilder.Verify(tx);
if (ok == true)
{
#if DEBUG
String hex = tx.ToHex();
#endif
String response = NetworkClient.BroadCastTx(tx.ToHex());
return new BE.Models.NodeTransactionResponse() { status = "ok", data = response };
}
else
{
//TODO MAKE TX INVALID EXCEPTION
//return new Models.TransactionErrorResponse() { status = "Error", data = "The transaction is invalid" };
throw new Exception();
}
}
catch (Exception ex)
{
//return new Models.TransactionErrorResponse() { status = "Error", data = "The transaction is invalid. " + ex.Message };
throw ex;
}
}