Commit 090e6c33 authored by Jeremy Bokobza's avatar Jeremy Bokobza

Fixed problem happening when user paid to himself

parent 365152b5
......@@ -229,16 +229,19 @@ namespace Breeze.Wallet.Controllers
{
item.Type = TransactionItemType.Send;
item.Amount = Money.Zero;
item.Payments = new List<PaymentDetailModel>();
foreach (var payment in transaction.Payments)
if (transaction.Payments != null)
{
item.Payments.Add(new PaymentDetailModel
item.Payments = new List<PaymentDetailModel>();
foreach (var payment in transaction.Payments)
{
DestinationAddress = payment.DestinationAddress,
Amount = payment.Amount
});
item.Amount += payment.Amount;
item.Payments.Add(new PaymentDetailModel
{
DestinationAddress = payment.DestinationAddress,
Amount = payment.Amount
});
item.Amount += payment.Amount;
}
}
var changeAddress = addresses.Single(a => a.IsChangeAddress() && a.Transactions.Any(t => t.Id == transaction.Id));
......
......@@ -477,10 +477,11 @@ namespace Breeze.Wallet
TransactionData tTx = this.keysLookup.Values.SelectMany(v => v.Transactions).Single(trackedTx => trackedTx.Id == input.PrevOut.Hash && trackedTx.Index == input.PrevOut.N);
// find the script this input references
var keyToSpend = this.keysLookup.Single(v => v.Value.Transactions.Contains(tTx)).Key;
// get the details of the outputs paid out
IEnumerable<TxOut> paidoutto = transaction.Outputs.Where(o => !this.keysLookup.Keys.Contains(o.ScriptPubKey));
var keyToSpend = this.keysLookup.Single(v => v.Value.Transactions.Contains(tTx)).Key;
// get the details of the outputs paid out.
// We first include the keys we don't hold and then we include the keys we do hold but that are for receiving addresses (which would mean the user paid itself).
IEnumerable<TxOut> paidoutto = transaction.Outputs.Where(o => !this.keysLookup.Keys.Contains(o.ScriptPubKey) || (this.keysLookup.ContainsKey(o.ScriptPubKey) && !this.keysLookup[o.ScriptPubKey].IsChangeAddress()));
AddTransactionToWallet(transaction.GetHash(), transaction.Time, null, -tTx.Amount, keyToSpend, blockHeight, blockTime, tTx.Id, tTx.Index, paidoutto);
}
......
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