2018-02-19 11:06:08 +09:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using BTCPayServer.Services.Invoices;
|
|
|
|
|
using NBitcoin;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
|
|
|
|
namespace BTCPayServer.Payments.Bitcoin
|
|
|
|
|
{
|
2018-02-19 15:09:05 +09:00
|
|
|
|
public class BitcoinLikeOnChainPaymentMethod : IPaymentMethodDetails
|
2018-02-19 11:06:08 +09:00
|
|
|
|
{
|
|
|
|
|
public PaymentTypes GetPaymentType()
|
|
|
|
|
{
|
|
|
|
|
return PaymentTypes.BTCLike;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string GetPaymentDestination()
|
|
|
|
|
{
|
|
|
|
|
return DepositAddress?.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-19 18:54:21 +09:00
|
|
|
|
public decimal GetTxFee()
|
2018-02-19 11:06:08 +09:00
|
|
|
|
{
|
2018-02-19 18:54:21 +09:00
|
|
|
|
return TxFee.ToDecimal(MoneyUnit.BTC);
|
2018-02-19 11:06:08 +09:00
|
|
|
|
}
|
|
|
|
|
|
2018-02-20 12:45:04 +09:00
|
|
|
|
public void SetNoTxFee()
|
|
|
|
|
{
|
|
|
|
|
TxFee = Money.Zero;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2018-02-19 11:06:08 +09:00
|
|
|
|
public void SetPaymentDestination(string newPaymentDestination)
|
|
|
|
|
{
|
|
|
|
|
if (newPaymentDestination == null)
|
|
|
|
|
DepositAddress = null;
|
|
|
|
|
else
|
|
|
|
|
DepositAddress = BitcoinAddress.Create(newPaymentDestination, DepositAddress.Network);
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-19 11:31:34 +09:00
|
|
|
|
// Those properties are JsonIgnore because their data is inside CryptoData class for legacy reason
|
2018-02-19 11:06:08 +09:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
public FeeRate FeeRate { get; set; }
|
|
|
|
|
[JsonIgnore]
|
|
|
|
|
public Money TxFee { get; set; }
|
|
|
|
|
[JsonIgnore]
|
|
|
|
|
public BitcoinAddress DepositAddress { get; set; }
|
2018-02-19 11:31:34 +09:00
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////
|
2018-02-19 11:06:08 +09:00
|
|
|
|
}
|
|
|
|
|
}
|