Commit 821cc8c8 authored by Jeremy Bokobza's avatar Jeremy Bokobza

Fixed inserting the tx twice

parent 3c3778b8
...@@ -491,7 +491,12 @@ namespace Breeze.Wallet ...@@ -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> /// <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) 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); 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 trans.Add(new TransactionData
{ {
Amount = amount, Amount = amount,
...@@ -511,6 +516,15 @@ namespace Breeze.Wallet ...@@ -511,6 +516,15 @@ namespace Breeze.Wallet
transactions.Single(t => t.Index == spendingTransactionIndex).SpentInTransaction = transactionHash; 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 // notify a transaction has been found
this.TransactionFound?.Invoke(this, new TransactionFoundEventArgs(script, transactionHash)); 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