Skip to content

Commit

Permalink
[Wallet] Re-implement some tests and add coldstake filter (#555)
Browse files Browse the repository at this point in the history
* WIP

* Single SQL query

* Refactor

* WIP

* Tests still need to be fixed

* Self review

* Self review

* Fixing tests and review changes

* Fix Test

* Fix Test

* busy with test

* WIP

* SQL changes based on review

* Update WalletHistoryIntegrationTests.cs

* Fix test

* Fix Tests

* Review fixes

* Re-include test

* Add coldstake filter

* Update HDTransactionData.cs
  • Loading branch information
fassadlr committed May 14, 2021
1 parent 7cad332 commit 56944b6
Show file tree
Hide file tree
Showing 5 changed files with 284 additions and 304 deletions.
2 changes: 2 additions & 0 deletions src/Stratis.Bitcoin.Features.Wallet/FlatHistory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public FlattenedHistoryItem()

public string ReceiveAddress { get; set; }

public string RedeemScript { get; set; }

/// <summary>
/// The height of the block in which this transaction was confirmed.
/// </summary>
Expand Down
27 changes: 1 addition & 26 deletions src/Stratis.Bitcoin.Features.Wallet/WalletManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -881,33 +881,8 @@ protected AccountHistory GetHistoryForAccount(HdAccount account, int limit, int

lock (this.lockObject)
{
static bool coldStakeUtxoFilter(TransactionData d) => d.IsColdCoinStake == null || d.IsColdCoinStake == false;

if (searchQuery != null && uint256.TryParse(searchQuery, out uint256 _))
{
// TODO coldStakeUtxoFilter
accountHistory = this.WalletRepository.GetHistory(account, limit, offset, searchQuery);

var result = accountHistory.History.FirstOrDefault();
if (result != null && result.Type == (int)TransactionItemType.Send)
{
var payments = this.WalletRepository.GetPaymentDetails(account.AccountRoot.Wallet.Name, result.Id);
var grouped = payments.GroupBy(p => p.DestinationScriptPubKey);

foreach (var group in grouped)
{
result.Payments.Add(new FlattenedHistoryItemPayment() { Amount = group.First().Amount, DestinationAddress = group.First().DestinationAddress, IsChange = group.First().IsChange });
}
}
}
else
{
// TODO coldStakeUtxoFilter
accountHistory = this.WalletRepository.GetHistory(account, limit, offset);
}
return this.WalletRepository.GetHistory(account, limit, offset, searchQuery);
}

return accountHistory;
}

/// <inheritdoc />
Expand Down
Loading

0 comments on commit 56944b6

Please sign in to comment.