Skip to content

Instantly share code, notes, and snippets.

@nopara73
Created Jun 7, 2017
Embed
What would you like to do?
BuildProofOfTumbleBitConceptTransactions
private static void BuildProofOfTumbleBitConceptTransactions()
{
uint256 txIdToSpend = _qBitClient.GetBalance(_fundingAddress, unspentOnly: false).Result.Operations.First().TransactionId;
Transaction txToSpend = _qBitClient.GetTransaction(txIdToSpend).Result.Transaction;
var tOfferExtKey = _seed.ExtKey.Derive(1, false);
var tOfferDestination = tOfferExtKey.ScriptPubKey.GetDestinationAddress(_network); // mk1soVb7Se1t99v7APGqiXofr2pKVS7hN5
var tFulfillExtKey = _seed.ExtKey.Derive(2, false);
var tFulfillDestination = tFulfillExtKey.ScriptPubKey.GetDestinationAddress(_network); // n4mey3skuXQna149vUaanuAPyEDiunsryT
var fee = new Money(0.001m, MoneyUnit.BTC);
var builder = new TransactionBuilder();
var tOffer = builder
.AddCoins(txToSpend)
.AddKeys(_fundingExtKey)
.SendFees(fee)
.Send(tOfferDestination, txToSpend.Outputs.First().Value - fee)
.BuildTransaction(sign: true);
var errors = builder.Check(tOffer);
if (errors.Count() != 0)
{
ReportErrors(txName: nameof(tOffer), errors: errors);
}
else
{
ReportTransaction(txName: nameof(tOffer), transaction: tOffer);
}
builder = new TransactionBuilder();
var tFulfill = builder
.AddCoins(tOffer)
.AddKeys(tOfferExtKey)
.SendFees(fee)
.Send(tFulfillDestination, tOffer.Outputs.First().Value - fee)
.BuildTransaction(sign: true);
errors = builder.Check(tFulfill);
if (errors.Count() != 0)
{
ReportErrors(txName: nameof(tFulfill), errors: errors);
}
else
{
ReportTransaction(txName: nameof(tFulfill), transaction: tOffer);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment