Skip to content

Commit ad2fca4

Browse files
authored
Wallet db to use sqlite (instead of litedbv4) (#272)
* sqlite data table and serialization code * Final table changes and fix tests to work * in memory store for tests * Fix some tests * Fix some more tests * fix minor history problem * Add wallet version for future upgrades * add comments in memory constructor * Act on review * Regenerate test data
1 parent ef16368 commit ad2fca4

32 files changed

Lines changed: 544 additions & 201 deletions

src/Features/Blockcore.Features.Wallet/Api/Controllers/WalletModelBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ public static WalletHistoryModel GetHistory(IWalletManager walletManager, Networ
325325

326326
// Sort and filter the history items.
327327
List<TransactionItemModel> itemsToInclude = transactionItems.OrderByDescending(t => t.Timestamp)
328-
.Where(x => String.IsNullOrEmpty(request.SearchQuery) || (x.Id.ToString() == request.SearchQuery || x.ToAddress == request.SearchQuery || x.Payments.Any(p => p.DestinationAddress == request.SearchQuery)))
328+
.Where(x => string.IsNullOrEmpty(request.SearchQuery) || (x.Id.ToString() == request.SearchQuery || x.ToAddress == request.SearchQuery || x.Payments.Any(p => p.DestinationAddress == request.SearchQuery)))
329329
.Skip(request.Skip ?? 0)
330330
.Take(request.Take ?? transactionItems.Count)
331331
.ToList();
@@ -350,4 +350,4 @@ private static TransactionItemModel FindSimilarReceivedTransactionOutput(List<Tr
350350
return existingTransaction;
351351
}
352352
}
353-
}
353+
}

src/Features/Blockcore.Features.Wallet/Blockcore.Features.Wallet.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
<ItemGroup>
2020
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.1.11" />
21+
<PackageReference Include="Dapper" Version="2.0.78" />
22+
<PackageReference Include="Microsoft.Data.Sqlite" Version="5.0.2" />
2123
<PackageReference Include="System.Reactive" Version="5.0.0" />
2224
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.1.11" />
2325
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.1.11" />

src/Features/Blockcore.Features.Wallet/Database/WalletData.cs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ public class WalletData
2525

2626
public HashHeightPair WalletTip { get; set; }
2727

28+
public int WalletVersion { get; set; }
29+
2830
public ICollection<uint256> BlockLocator { get; set; }
2931
}
3032

@@ -55,4 +57,59 @@ public class WalletHistoryPaymentData
5557
public Money Amount { get; set; }
5658
public bool? PayToSelf { get; set; }
5759
}
60+
61+
public class TransactionData
62+
{
63+
public TransactionData()
64+
{
65+
this.SpendingDetailsPayments = new List<PaymentDetails>();
66+
}
67+
68+
public OutPoint OutPoint { get; set; }
69+
70+
public string Address { get; set; }
71+
72+
public int AccountIndex { get; set; }
73+
74+
public uint256 Id { get; set; }
75+
76+
public Money Amount { get; set; }
77+
78+
public bool? IsCoinBase { get; set; }
79+
80+
public bool? IsCoinStake { get; set; }
81+
82+
public bool? IsColdCoinStake { get; set; }
83+
84+
public int IndexInTransaction { get; set; }
85+
86+
public int? BlockHeight { get; set; }
87+
88+
public uint256 BlockHash { get; set; }
89+
90+
public int? BlockIndex { get; set; }
91+
92+
public DateTimeOffset CreationTime { get; set; }
93+
94+
public PartialMerkleTree MerkleProof { get; set; }
95+
public string Hex { get; set; }
96+
97+
public Script ScriptPubKey { get; set; }
98+
99+
public bool? IsPropagated { get; set; }
100+
101+
public uint256 SpendingDetailsTransactionId { get; set; }
102+
103+
public ICollection<PaymentDetails> SpendingDetailsPayments { get; set; }
104+
105+
public int? SpendingDetailsBlockHeight { get; set; }
106+
107+
public int? SpendingDetailsBlockIndex { get; set; }
108+
109+
public bool? SpendingDetailsIsCoinStake { get; set; }
110+
111+
public DateTimeOffset? SpendingDetailsCreationTime { get; set; }
112+
113+
public string SpendingDetailsHex { get; set; }
114+
}
58115
}

0 commit comments

Comments
 (0)