mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-03-12 10:30:47 +01:00
Simplify code
This commit is contained in:
parent
d3dca7e808
commit
d44efce225
1 changed files with 16 additions and 20 deletions
|
@ -81,12 +81,13 @@ public class OnChainWalletReportProvider : ReportProvider
|
||||||
var walletId = new WalletId(store.Id, settings.Network.CryptoCode);
|
var walletId = new WalletId(store.Id, settings.Network.CryptoCode);
|
||||||
var command = new CommandDefinition(
|
var command = new CommandDefinition(
|
||||||
commandText:
|
commandText:
|
||||||
"SELECT r.tx_id, r.seen_at, t.blk_id, t.blk_height, r.balance_change, r.asset_id " +
|
"SELECT r.tx_id, r.seen_at, t.blk_id, t.blk_height, r.balance_change " +
|
||||||
"FROM get_wallets_recent(@wallet_id, @code, @interval, NULL, NULL) r " +
|
"FROM get_wallets_recent(@wallet_id, @code, @asset_id, @interval, NULL, NULL) r " +
|
||||||
"JOIN txs t USING (code, tx_id) " +
|
"JOIN txs t USING (code, tx_id) " +
|
||||||
"ORDER BY r.seen_at",
|
"ORDER BY r.seen_at",
|
||||||
parameters: new
|
parameters: new
|
||||||
{
|
{
|
||||||
|
asset_id = GetAssetId(settings.Network),
|
||||||
wallet_id = NBXplorer.Client.DBUtils.nbxv1_get_wallet_id(settings.Network.CryptoCode, settings.AccountDerivation.ToString()),
|
wallet_id = NBXplorer.Client.DBUtils.nbxv1_get_wallet_id(settings.Network.CryptoCode, settings.AccountDerivation.ToString()),
|
||||||
code = settings.Network.CryptoCode,
|
code = settings.Network.CryptoCode,
|
||||||
interval
|
interval
|
||||||
|
@ -99,24 +100,6 @@ public class OnChainWalletReportProvider : ReportProvider
|
||||||
var date = (DateTimeOffset)r.seen_at;
|
var date = (DateTimeOffset)r.seen_at;
|
||||||
if (date > queryContext.To)
|
if (date > queryContext.To)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
#if ALTCOINS
|
|
||||||
if (settings.Network is ElementsBTCPayNetwork elementsBTCPayNetwork)
|
|
||||||
{
|
|
||||||
var assetId = (string?)r.asset_id;
|
|
||||||
// if this is an asset scheme, check if the asset id is the same as the network asset id
|
|
||||||
if (elementsBTCPayNetwork.CryptoCode != elementsBTCPayNetwork.NetworkCryptoCode &&
|
|
||||||
assetId is not null && assetId != elementsBTCPayNetwork.AssetId?.ToString())
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else if (elementsBTCPayNetwork.CryptoCode == elementsBTCPayNetwork.NetworkCryptoCode &&
|
|
||||||
!(assetId is null || assetId == elementsBTCPayNetwork.AssetId?.ToString()))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
var values = queryContext.AddData();
|
var values = queryContext.AddData();
|
||||||
var balanceChange = Money.Satoshis((long)r.balance_change).ToDecimal(MoneyUnit.BTC);
|
var balanceChange = Money.Satoshis((long)r.balance_change).ToDecimal(MoneyUnit.BTC);
|
||||||
values.Add(date);
|
values.Add(date);
|
||||||
|
@ -141,4 +124,17 @@ public class OnChainWalletReportProvider : ReportProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string? GetAssetId(BTCPayNetwork network)
|
||||||
|
{
|
||||||
|
#if ALTCOINS
|
||||||
|
if (network is ElementsBTCPayNetwork elNetwork)
|
||||||
|
{
|
||||||
|
if (elNetwork.CryptoCode == elNetwork.NetworkCryptoCode)
|
||||||
|
return "";
|
||||||
|
return elNetwork.AssetId.ToString();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue