internal static void AdvanceTip(DBConnection conn, HDWallet wallet, ChainedHeader newTip, uint256 prevTipHash) { uint256 lastBlockSyncedHash = newTip?.HashBlock ?? uint256.Zero; int lastBlockSyncedHeight = newTip?.Height ?? -1; string blockLocator = ""; if (newTip != null) { blockLocator = string.Join(",", newTip?.GetLocator().Blocks); } conn.Execute($@" UPDATE HDWallet SET LastBlockSyncedHash = ?, LastBlockSyncedHeight = ?, BlockLocator = ? WHERE LastBlockSyncedHash = ? { // Respect the wallet name if provided. ((wallet?.Name != null) ? $@" AND Name = {DBParameter.Create(wallet?.Name)}" : "")}", lastBlockSyncedHash.ToString(), lastBlockSyncedHeight, blockLocator, prevTipHash.ToString()); }
internal static string ObjectRow(PropertyInfo[] props, object obj) { var res = props.Select(p => p.GetValue(obj)).Select(prop => DBParameter.Create(prop)); var arr = string.Join(",", res); return($"({arr})"); }
internal static IEnumerable <HDTransactionData> GetAllTransactions(DBConnection conn, int walletId, int?accountIndex, int?addressType, int?addressIndex, int limit = int.MaxValue, HDTransactionData prev = null, bool descending = true) { string strWalletId = DBParameter.Create(walletId); string strAccountIndex = DBParameter.Create(accountIndex); string strAddressType = DBParameter.Create(addressType); string strAddressIndex = DBParameter.Create(addressIndex); string strLimit = DBParameter.Create(limit); string strPrevTime = DBParameter.Create(prev?.OutputTxTime); string strPrevIndex = DBParameter.Create(prev?.OutputIndex); return(conn.Query <HDTransactionData>($@" SELECT * FROM HDTransactionData WHERE WalletId = {strWalletId} {((accountIndex == null) ? $@" AND AccountIndex IN (SELECT AccountIndex FROM HDAccount WHERE WalletId = {strWalletId})" : $@" AND AccountIndex = {strAccountIndex}")} {((addressType == null) ? $@"
public override string ToString() { return(string.Join(", ", this.GetProperties().Select(p => $"{p.Name}={DBParameter.Create(p.GetValue(this))}"))); }