public ChannelManagerReadArgs(IKeysInterface keysInterface, IBroadcaster broadcaster, IFeeEstimator feeEstimator, ILogger logger, IChainWatchInterface chainWatchInterface, NBitcoin.Network n, ManyChannelMonitor manyChannelMonitor) { _keysInterface = keysInterface ?? throw new ArgumentNullException(nameof(keysInterface)); _broadcaster = broadcaster ?? throw new ArgumentNullException(nameof(broadcaster)); _feeEstimator = feeEstimator ?? throw new ArgumentNullException(nameof(feeEstimator)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _chainWatchInterface = chainWatchInterface ?? throw new ArgumentNullException(nameof(chainWatchInterface)); _n = n; ManyChannelMonitor = manyChannelMonitor ?? throw new ArgumentNullException(nameof(manyChannelMonitor)); }
public KeysInterfaceDelegatesHolder(IKeysInterface keysInterface) { _keysInterface = keysInterface ?? throw new ArgumentNullException(nameof(keysInterface)); _getNodeSecret = (ref byte nodeSecretPtr) => { var b = _keysInterface.GetNodeSecret().ToBytes(); Debug.Assert(b.Length == 32); Unsafe.CopyBlock(ref nodeSecretPtr, ref b[0], 32); }; _getDestinationScript = (ref byte scriptPtr, ref UIntPtr scriptLen) => { var b = _keysInterface.GetDestinationScript().ToBytes(); if (b.Length > 512) { throw new InvalidDataException($"Currently, binary length of the script must not be longer than 512. It was {b.Length}"); } unsafe { Unsafe.Write(Unsafe.AsPointer(ref scriptLen), (UIntPtr)b.Length); } Unsafe.CopyBlock(ref scriptPtr, ref b[0], (uint)b.Length); }; _getShutdownKey = (ref byte ptr) => { var pk = _keysInterface.GetShutdownKey(); if (!pk.IsCompressed) { pk = pk.Compress(); } var b = pk.ToBytes(); Unsafe.CopyBlock(ref ptr, ref b[0], 33); }; _getChannelKeys = (byte inbound, ulong satoshis, ref byte channelKeysPtr) => { var channelKeysBytes = _keysInterface.GetChannelKeys(inbound == 1, satoshis).ToBytes(); Debug.Assert(channelKeysBytes.Length == 216); Unsafe.CopyBlock(ref channelKeysPtr, ref channelKeysBytes[0], 216); }; _getOnionRand = (ref byte sec, ref byte seed) => { var t = _keysInterface.GetOnionRand(); var(secretBytes, seedBytes) = (t.Item1.ToBytes(), t.Item2.ToBytes()); Unsafe.CopyBlock(ref sec, ref secretBytes[0], 32); Unsafe.CopyBlock(ref seed, ref seedBytes[0], 32); }; _getChannelId = (ref byte id) => { var b = _keysInterface.GetChannelId().ToBytes(false); Unsafe.CopyBlock(ref id, ref b[0], 32); }; }
public static ChannelManager Create( NBitcoin.Network nbitcoinNetwork, IUserConfigProvider config, IChainWatchInterface chainWatchInterface, IKeysInterface keysInterface, ILogger logger, IBroadcaster broadcaster, IFeeEstimator feeEstimator, ulong currentBlockHeight ) { var c = config.GetUserConfig(); return(Create(nbitcoinNetwork, in c, chainWatchInterface, keysInterface, logger, broadcaster, feeEstimator, currentBlockHeight)); }
public static PeerManager Create( Span <byte> seed, NBitcoin.Network nbitcoinNetwork, IUserConfigProvider config, IChainWatchInterface chainWatchInterface, IKeysInterface keysInterface, IBroadcaster broadcaster, ILogger logger, IFeeEstimator feeEstimator, uint currentBlockHeight, int tickIntervalMSec = 30000 ) { var c = config.GetUserConfig(); return(Create(seed, nbitcoinNetwork, in c, chainWatchInterface, keysInterface, broadcaster, logger, feeEstimator, currentBlockHeight, tickIntervalMSec)); }