btcpayserver/BTCPayServer/Payments/Bitcoin/BitcoinLikeOnChainPaymentMethod.cs
Andrew Camilleri 79b034b505
GreenField: Add properties to Store API (#1573)
* GreenField: Add properties to Store API

* Update StoreBaseData.cs

* fix api

* fix swagger
2020-05-24 04:13:18 +09:00

68 lines
2.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BTCPayServer.Client.Models;
using BTCPayServer.Services.Invoices;
using BTCPayServer.Services.Wallets;
using NBitcoin;
using NBXplorer.JsonConverters;
using Newtonsoft.Json;
namespace BTCPayServer.Payments.Bitcoin
{
public class BitcoinLikeOnChainPaymentMethod : IPaymentMethodDetails
{
public PaymentType GetPaymentType() => PaymentTypes.BTCLike;
public string GetPaymentDestination()
{
return DepositAddress;
}
public decimal GetNextNetworkFee()
{
return NextNetworkFee.ToDecimal(MoneyUnit.BTC);
}
public decimal GetFeeRate()
{
return FeeRate.SatoshiPerByte;
}
public void SetPaymentDestination(string newPaymentDestination)
{
DepositAddress = newPaymentDestination;
}
public NetworkFeeMode NetworkFeeMode { get; set; }
FeeRate _NetworkFeeRate;
[JsonConverter(typeof(NBitcoin.JsonConverters.FeeRateJsonConverter))]
public FeeRate NetworkFeeRate
{
get
{
// Some old invoices don't have this field set, so we fallback on FeeRate
return _NetworkFeeRate ?? FeeRate;
}
set
{
_NetworkFeeRate = value;
}
}
public bool PayjoinEnabled { get; set; }
// Those properties are JsonIgnore because their data is inside CryptoData class for legacy reason
[JsonIgnore]
public FeeRate FeeRate { get; set; }
[JsonIgnore]
public Money NextNetworkFee { get; set; }
[JsonIgnore]
public String DepositAddress { get; set; }
public BitcoinAddress GetDepositAddress(Network network)
{
return string.IsNullOrEmpty(DepositAddress) ? null : BitcoinAddress.Create(DepositAddress, network);
}
///////////////////////////////////////////////////////////////////////////////////////
}
}