Bitcoin Forum
September 22, 2018, 11:52:11 PM *
News: ♦♦ New info! Bitcoin Core users absolutely must upgrade to previously-announced 0.16.3 [Torrent]. All Bitcoin users should temporarily trust confirmations slightly less. More info.
   Home   Help Search Donate Login Register  
Pages: [1]
Author Topic: Is this TX possible (Using NBitcoin c#)  (Read 1246 times)
Hero Member
Offline Offline

Activity: 765
Merit: 501

View Profile WWW
July 06, 2016, 12:18:41 AM

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

protected BE.Models.ITransactionBroadcastResponse Transfer(BitcoinAddress fromAddress, BitcoinAddress toAddress, BitcoinAddress agentAddress, IEnumerable<ICoin> bearer, ICoin colored, AssetMoney assetToSend, AssetMoney autarkyFee, AssetMoney agentFee)
//Apps private key
BitcoinSecret bearerKey = new BitcoinSecret(this.BearerKey);
                BitcoinSecret assetOwnerKey = new BitcoinSecret(this.AssetOwnerKey);

TransactionBuilder txBuilder = new TransactionBuilder();
.SendAsset(toAddress, assetToSend)
//.SendAsset(agentAddress, agentFee)
//.SendAsset(AutarkyBitcoinAddress, autarkyFee)
                    .SetChange(AutarkyBitcoinAddress, ChangeType.Uncolored) //was from address
                    .SetChange(fromAddress, ChangeType.Colored)

Transaction tx = txBuilder.BuildTransaction(true);
Boolean ok = txBuilder.Verify(tx);

if (ok == true)
                    String hex = tx.ToHex();
String response = NetworkClient.BroadCastTx(tx.ToHex());
return new BE.Models.NodeTransactionResponse() { status = "ok", data = response };
                    //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;
Pages: [1]
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!