mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-19 15:04:19 +01:00
update nbx + prep bitcoin payment data ctor change
This commit is contained in:
30
BTCPayServer/Extensions/MoneyExtensions.cs
Normal file
30
BTCPayServer/Extensions/MoneyExtensions.cs
Normal file
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user