Commit a17b5dd1 authored by Pieterjan Vanhoof's avatar Pieterjan Vanhoof Committed by GitHub

Merge pull request #53 from bokobza/feature/build-transaction

Fixed inserting the tx twice
parents 36cf64fb 821cc8c8
......@@ -491,7 +491,12 @@ namespace Breeze.Wallet
/// <param name="spendingTransactionIndex">The index of the output in the transaction being referenced, if this is a spending transaction.</param>
private void AddTransactionToWallet(uint256 transactionHash, uint time, int? index, Money amount, Script script, int? blockHeight = null, uint? blockTime = null, uint256 spendingTransactionId = null, int? spendingTransactionIndex = null)
{
// get the collection of transactions to add to.
this.keysLookup.TryGetValue(script, out ICollection<TransactionData> trans);
// if it's the first time we see this transaction
if (trans != null && trans.All(t => t.Id != transactionHash))
{
trans.Add(new TransactionData
{
Amount = amount,
......@@ -511,6 +516,15 @@ namespace Breeze.Wallet
transactions.Single(t => t.Index == spendingTransactionIndex).SpentInTransaction = transactionHash;
}
}
}
else if (trans.Any(t => t.Id == transactionHash && !t.Confirmed)) // if this is an unconfirmed transaction now received in a block
{
var foundTransaction = trans.Single(t => t.Id == transactionHash && !t.Confirmed);
if (blockHeight != null)
{
foundTransaction.Confirmed = true;
}
}
// notify a transaction has been found
this.TransactionFound?.Invoke(this, new TransactionFoundEventArgs(script, transactionHash));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment