Commit bc225cb7 authored by Jeremy Bokobza's avatar Jeremy Bokobza

Change some collection types in the wallet object

parent cea9240b
...@@ -121,7 +121,7 @@ namespace Breeze.Wallet ...@@ -121,7 +121,7 @@ namespace Breeze.Wallet
/// The accounts used in the wallet. /// The accounts used in the wallet.
/// </summary> /// </summary>
[JsonProperty(PropertyName = "accounts")] [JsonProperty(PropertyName = "accounts")]
public IEnumerable<HdAccount> Accounts { get; set; } public ICollection<HdAccount> Accounts { get; set; }
/// <summary> /// <summary>
/// Gets the first account that contains no transaction. /// Gets the first account that contains no transaction.
...@@ -227,13 +227,13 @@ namespace Breeze.Wallet ...@@ -227,13 +227,13 @@ namespace Breeze.Wallet
/// The list of external addresses, typically used for receiving money. /// The list of external addresses, typically used for receiving money.
/// </summary> /// </summary>
[JsonProperty(PropertyName = "externalAddresses")] [JsonProperty(PropertyName = "externalAddresses")]
public IEnumerable<HdAddress> ExternalAddresses { get; set; } public ICollection<HdAddress> ExternalAddresses { get; set; }
/// <summary> /// <summary>
/// The list of internal addresses, typically used to receive change. /// The list of internal addresses, typically used to receive change.
/// </summary> /// </summary>
[JsonProperty(PropertyName = "internalAddresses")] [JsonProperty(PropertyName = "internalAddresses")]
public IEnumerable<HdAddress> InternalAddresses { get; set; } public ICollection<HdAddress> InternalAddresses { get; set; }
/// <summary> /// <summary>
/// Gets the type of coin this account is for. /// Gets the type of coin this account is for.
...@@ -374,7 +374,7 @@ namespace Breeze.Wallet ...@@ -374,7 +374,7 @@ namespace Breeze.Wallet
/// A list of transactions involving this address. /// A list of transactions involving this address.
/// </summary> /// </summary>
[JsonProperty(PropertyName = "transactions")] [JsonProperty(PropertyName = "transactions")]
public IEnumerable<TransactionData> Transactions { get; set; } public ICollection<TransactionData> Transactions { get; set; }
} }
/// <summary> /// <summary>
......
...@@ -289,14 +289,14 @@ namespace Breeze.Wallet ...@@ -289,14 +289,14 @@ namespace Breeze.Wallet
BitcoinPubKeyAddress address = this.GenerateAddress(account.ExtendedPubKey, i, isChange, network); BitcoinPubKeyAddress address = this.GenerateAddress(account.ExtendedPubKey, i, isChange, network);
// add address details // add address details
addresses = addresses.Concat(new[] {new HdAddress addresses.Add(new HdAddress
{ {
Index = i, Index = i,
HdPath = CreateBip44Path(account.GetCoinType(), account.Index, i, isChange), HdPath = CreateBip44Path(account.GetCoinType(), account.Index, i, isChange),
ScriptPubKey = address.ScriptPubKey, ScriptPubKey = address.ScriptPubKey,
Address = address.ToString(), Address = address.ToString(),
Transactions = new List<TransactionData>() Transactions = new List<TransactionData>()
}}); });
addressesCreated.Add(address.ToString()); addressesCreated.Add(address.ToString());
} }
...@@ -497,7 +497,7 @@ namespace Breeze.Wallet ...@@ -497,7 +497,7 @@ namespace Breeze.Wallet
{ {
// selects all the transactions we already have in the wallet // selects all the transactions we already have in the wallet
var txs = this.Wallets.SelectMany(w => w.GetAllTransactionsByCoinType(coinType)); var txs = this.Wallets.SelectMany(w => w.GetAllTransactionsByCoinType(coinType));
// add this transaction if it is not in the list // add this transaction if it is not in the list
if (txs.All(t => t.Id != transactionHash || t.Index != index)) if (txs.All(t => t.Id != transactionHash || t.Index != index))
{ {
...@@ -514,17 +514,14 @@ namespace Breeze.Wallet ...@@ -514,17 +514,14 @@ namespace Breeze.Wallet
var address = receivingAddress ?? changeAddress; var address = receivingAddress ?? changeAddress;
if (address != null) if (address != null)
{ {
address.Transactions = address.Transactions.Concat(new[] address.Transactions.Add(new TransactionData
{ {
new TransactionData Amount = amount,
{ BlockHeight = blockHeight,
Amount = amount, Confirmed = blockHeight.HasValue,
BlockHeight = blockHeight, Id = transactionHash,
Confirmed = blockHeight.HasValue, CreationTime = DateTimeOffset.FromUnixTimeMilliseconds(blockTime ?? time),
Id = transactionHash, Index = index
CreationTime = DateTimeOffset.FromUnixTimeMilliseconds(blockTime ?? time),
Index = index
}
}); });
// notify a transaction has been found // notify a transaction has been found
......
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