btcpayserver/BTCPayServer/Services/Altcoins/Ethereum/Payments/EthereumSupportedPaymentMethod.cs
XPayServer de755ac0bb Add Ethereum & ERC20 Support
Add Tests
Add Index, XPub to payment data
Add Note on local ETH node
Fix Sync Summary and Race Condition
2020-09-09 08:19:10 +02:00

41 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