mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-24 22:58:28 +01:00
42 lines
1.2 KiB
C#
42 lines
1.2 KiB
C#
|
#if ALTCOINS
|
||
|
using System;
|
||
|
using BTCPayServer.Payments;
|
||
|
using NBitcoin;
|
||
|
using Nethereum.HdWallet;
|
||
|
|
||
|
namespace BTCPayServer.Services.Altcoins.Ethereum.Payments
|
||
|
{
|
||
|
public class EthereumSupportedPaymentMethod : ISupportedPaymentMethod
|
||
|
{
|
||
|
public string CryptoCode { get; set; }
|
||
|
public string Seed { get; set; }
|
||
|
public string Password { get; set; }
|
||
|
public string XPub { get; set; }
|
||
|
public PaymentMethodId PaymentId => new PaymentMethodId(CryptoCode, EthereumPaymentType.Instance);
|
||
|
public long CurrentIndex { get; set; }
|
||
|
public string KeyPath { get; set; }
|
||
|
|
||
|
public Func<int, string> GetWalletDerivator()
|
||
|
{
|
||
|
if (!string.IsNullOrEmpty(XPub))
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
return new PublicWallet(XPub).GetAddress;
|
||
|
}
|
||
|
catch (Exception)
|
||
|
{
|
||
|
return new PublicWallet(new BitcoinExtPubKey(XPub, Network.Main).ExtPubKey).GetAddress;
|
||
|
}
|
||
|
}
|
||
|
else if (!string.IsNullOrEmpty(XPub))
|
||
|
{
|
||
|
return i => new Wallet(Seed, Password, KeyPath).GetAccount(i).Address;
|
||
|
}
|
||
|
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
#endif
|