mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-24 14:50:50 +01:00
Add Tests Add Index, XPub to payment data Add Note on local ETH node Fix Sync Summary and Race Condition
41 lines
1.2 KiB
C#
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
|