Class SecureKeyManager
- Namespace
- NLightning.Infrastructure.Bitcoin.Managers
- Assembly
- NLightning.Infrastructure.Bitcoin.dll
Manages a securely stored private key using protected memory allocation. This class ensures that the private key remains inaccessible from regular memory and is securely wiped when no longer needed.
public class SecureKeyManager : ISecureKeyManager, IDisposable
- Inheritance
-
SecureKeyManager
- Implements
- Inherited Members
Constructors
SecureKeyManager(byte[], BitcoinNetwork, string, uint)
Manages secure key operations for generating and managing cryptographic keys. Provides functionality to safely store, load, and derive secure keys protected in memory.
public SecureKeyManager(byte[] privateKey, BitcoinNetwork network, string filePath, uint heightOfBirth)
Parameters
privateKeybyte[]The private key to be managed.
networkBitcoinNetworkThe network associated with the private key.
filePathstringThe file path for storing the key data.
heightOfBirthuintBlock Height when the wallet was created
Properties
ChannelKeyPath
public BitcoinKeyPath ChannelKeyPath { get; }
Property Value
DepositP2TrKeyPath
public BitcoinKeyPath DepositP2TrKeyPath { get; }
Property Value
DepositP2WpkhKeyPath
public BitcoinKeyPath DepositP2WpkhKeyPath { get; }
Property Value
HeightOfBirth
public uint HeightOfBirth { get; init; }
Property Value
OutputChangeP2TrDescriptor
public string OutputChangeP2TrDescriptor { get; init; }
Property Value
OutputChangeP2WshDescriptor
public string OutputChangeP2WshDescriptor { get; init; }
Property Value
OutputChannelDescriptor
public string OutputChannelDescriptor { get; init; }
Property Value
OutputDepositP2TrDescriptor
public string OutputDepositP2TrDescriptor { get; init; }
Property Value
OutputDepositP2WshDescriptor
public string OutputDepositP2WshDescriptor { get; init; }
Property Value
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
~SecureKeyManager()
protected ~SecureKeyManager()
FromFilePath(string, BitcoinNetwork, string)
public static SecureKeyManager FromFilePath(string filePath, BitcoinNetwork expectedNetwork, string password)
Parameters
filePathstringexpectedNetworkBitcoinNetworkpasswordstring
Returns
FromMnemonic(string, string, BitcoinNetwork, string?, uint)
public static SecureKeyManager FromMnemonic(string mnemonic, string passphrase, BitcoinNetwork network, string? filePath = null, uint currentHeight = 0)
Parameters
mnemonicstringpassphrasestringnetworkBitcoinNetworkfilePathstringcurrentHeightuint
Returns
GetChannelKeyAtIndex(uint)
public ExtPrivKey GetChannelKeyAtIndex(uint index)
Parameters
indexuint
Returns
GetDepositP2TrKeyAtIndex(uint, bool)
public ExtPrivKey GetDepositP2TrKeyAtIndex(uint index, bool isChange)
Parameters
Returns
GetDepositP2WpkhKeyAtIndex(uint, bool)
public ExtPrivKey GetDepositP2WpkhKeyAtIndex(uint index, bool isChange)
Parameters
Returns
GetKeyFilePath(string)
Gets the path for the Key file
public static string GetKeyFilePath(string configPath)
Parameters
configPathstring
Returns
GetNextChannelKey(out uint)
public ExtPrivKey GetNextChannelKey(out uint index)
Parameters
indexuint
Returns
GetNodeKeyPair()
public CryptoKeyPair GetNodeKeyPair()
Returns
GetNodePubKey()
public CompactPubKey GetNodePubKey()
Returns
SaveToFile(string)
public void SaveToFile(string password)
Parameters
passwordstring
UpdateLastUsedChannelIndexOnFile()
public Task UpdateLastUsedChannelIndexOnFile()