diff --git a/BTCPayServer.Common/BTCPayServer.Common.csproj b/BTCPayServer.Common/BTCPayServer.Common.csproj
index 0c5a12120..ffbddfe94 100644
--- a/BTCPayServer.Common/BTCPayServer.Common.csproj
+++ b/BTCPayServer.Common/BTCPayServer.Common.csproj
@@ -5,6 +5,6 @@
-
+
diff --git a/BTCPayServer/Controllers/WalletsController.cs b/BTCPayServer/Controllers/WalletsController.cs
index 48de86cb0..481d67364 100644
--- a/BTCPayServer/Controllers/WalletsController.cs
+++ b/BTCPayServer/Controllers/WalletsController.cs
@@ -252,7 +252,7 @@ namespace BTCPayServer.Controllers
vm.Id = tx.TransactionId.ToString();
vm.Link = string.Format(CultureInfo.InvariantCulture, paymentMethod.Network.BlockExplorerLink, vm.Id);
vm.Timestamp = tx.Timestamp;
- vm.Positive = tx.BalanceChange >= Money.Zero;
+ vm.Positive = tx.BalanceChange.GetValue(wallet.Network) >= Money.Zero;
vm.Balance = tx.BalanceChange.ToString();
vm.IsConfirmed = tx.Confirmations != 0;
@@ -912,7 +912,7 @@ namespace BTCPayServer.Controllers
}
else if (command == "prune")
{
- var result = await ExplorerClientProvider.GetExplorerClient(walletId.CryptoCode).PruneAsync(derivationScheme.AccountDerivation, cancellationToken);
+ var result = await ExplorerClientProvider.GetExplorerClient(walletId.CryptoCode).PruneAsync(derivationScheme.AccountDerivation, new PruneRequest(), cancellationToken);
if (result.TotalPruned == 0)
{
TempData[WellKnownTempData.SuccessMessage] = $"The wallet is already pruned";
diff --git a/BTCPayServer/Extensions/MoneyExtensions.cs b/BTCPayServer/Extensions/MoneyExtensions.cs
new file mode 100644
index 000000000..e800b9485
--- /dev/null
+++ b/BTCPayServer/Extensions/MoneyExtensions.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Linq;
+using NBitcoin;
+
+namespace BTCPayServer
+{
+ public static class MoneyExtensions
+ {
+ public static Money GetValue(this IMoney m, BTCPayNetwork network = null)
+ {
+ switch (m)
+ {
+ case Money money:
+ return money;
+ case MoneyBag mb:
+ return mb.Select(money => money.GetValue(network)).Sum();
+// case AssetMoney assetMoney:
+// if (network is ElementsBTCPayNetwork elementsBTCPayNetwork)
+// {
+// return elementsBTCPayNetwork.AssetId == assetMoney.AssetId
+// ? new Money(assetMoney.Quantity)
+// : Money.Zero;
+// }
+// throw new NotSupportedException("IMoney type not supported");
+ default:
+ throw new NotSupportedException("IMoney type not supported");
+ }
+ }
+ }
+}
diff --git a/BTCPayServer/Payments/Bitcoin/BitcoinLikePaymentData.cs b/BTCPayServer/Payments/Bitcoin/BitcoinLikePaymentData.cs
index 3ded51cbb..c742b8cb7 100644
--- a/BTCPayServer/Payments/Bitcoin/BitcoinLikePaymentData.cs
+++ b/BTCPayServer/Payments/Bitcoin/BitcoinLikePaymentData.cs
@@ -20,10 +20,10 @@ namespace BTCPayServer.Payments.Bitcoin
{
}
- public BitcoinLikePaymentData(Coin coin, bool rbf)
+ public BitcoinLikePaymentData(TxOut txout, OutPoint outpoint, bool rbf)
{
- Outpoint = coin.Outpoint;
- Output = coin.TxOut;
+ Outpoint = outpoint;
+ Output = txout;
ConfirmationCount = 0;
RBF = rbf;
}
diff --git a/BTCPayServer/Payments/Bitcoin/NBXplorerListener.cs b/BTCPayServer/Payments/Bitcoin/NBXplorerListener.cs
index e0bb76c3e..072fa983f 100644
--- a/BTCPayServer/Payments/Bitcoin/NBXplorerListener.cs
+++ b/BTCPayServer/Payments/Bitcoin/NBXplorerListener.cs
@@ -157,7 +157,7 @@ namespace BTCPayServer.Payments.Bitcoin
var invoice = (await _InvoiceRepository.GetInvoicesFromAddresses(new [] {key})).FirstOrDefault();
if (invoice != null)
{
- var paymentData = new BitcoinLikePaymentData(txCoin, evt.TransactionData.Transaction.RBF);
+ var paymentData = new BitcoinLikePaymentData(txCoin.TxOut, txCoin.Outpoint, evt.TransactionData.Transaction.RBF);
var alreadyExist = GetAllBitcoinPaymentData(invoice).Where(c => c.GetPaymentId() == paymentData.GetPaymentId()).Any();
if (!alreadyExist)
{
@@ -338,7 +338,7 @@ namespace BTCPayServer.Payments.Bitcoin
foreach (var coin in coins.Where(c => !alreadyAccounted.Contains(c.Coin.Outpoint)))
{
var transaction = await wallet.GetTransactionAsync(coin.Coin.Outpoint.Hash);
- var paymentData = new BitcoinLikePaymentData(coin.Coin, transaction.Transaction.RBF);
+ var paymentData = new BitcoinLikePaymentData(coin.Coin.TxOut, coin.Coin.Outpoint, transaction.Transaction.RBF);
var payment = await _InvoiceRepository.AddPayment(invoice.Id, coin.Timestamp, paymentData, network).ConfigureAwait(false);
alreadyAccounted.Add(coin.Coin.Outpoint);
if (payment != null)
diff --git a/BTCPayServer/Services/Wallets/BTCPayWallet.cs b/BTCPayServer/Services/Wallets/BTCPayWallet.cs
index c21ed79b8..d11800445 100644
--- a/BTCPayServer/Services/Wallets/BTCPayWallet.cs
+++ b/BTCPayServer/Services/Wallets/BTCPayWallet.cs
@@ -181,7 +181,7 @@ namespace BTCPayServer.Services.Wallets
public async Task GetBalance(DerivationStrategyBase derivationStrategy, CancellationToken cancellation = default(CancellationToken))
{
UTXOChanges changes = await GetUTXOChanges(derivationStrategy, cancellation);
- return changes.GetUnspentUTXOs().Select(c => c.Value).Sum();
+ return changes.GetUnspentUTXOs().Select(c => c.Value.GetValue(_Network)).Sum();
}
}
}