Skip to content

Instantly share code, notes, and snippets.

@abeldantas
Created February 26, 2019 18:35
Show Gist options
  • Save abeldantas/8cca29e9a536cbe00d37f274aca1a33a to your computer and use it in GitHub Desktop.
Save abeldantas/8cca29e9a536cbe00d37f274aca1a33a to your computer and use it in GitHub Desktop.
Transaction CreateUtxoSpendTxn( string rawUtxo, byte[][] msg )
{
var utxo = JsonConvert.DeserializeObject<UTXO>( rawUtxo );
Debug.Log( rawUtxo );
var coin = new Coin( new uint256( utxo.TxId), (uint)utxo.OutputIndex, utxo.Satoshis, bitcoinSecret.ScriptPubKey );
var txnBuilder = NBitcoin.Altcoins.BCash.Instance.Mainnet.CreateTransactionBuilder();
return txnBuilder
.AddCoins( coin )
.AddKeys( bitcoinSecret )
.Send( TxNullDataTemplate.Instance.GenerateScriptPubKey( msg ), Money.Zero )
.SendFees( new Money(utxo.Satoshis, MoneyUnit.Satoshi ) )
.BuildTransaction( true );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment