public LightWalletFeature(
            IWalletSyncManager walletSyncManager,
            IWalletManager walletManager,
            IConnectionManager connectionManager,
            ChainIndexer chainIndexer,
            NodeDeployments nodeDeployments,
            IAsyncLoopFactory asyncLoopFactory,
            INodeLifetime nodeLifetime,
            IWalletFeePolicy walletFeePolicy,
            BroadcasterBehavior broadcasterBehavior,
            ILoggerFactory loggerFactory,
            StoreSettings storeSettings,
            WalletSettings walletSettings,
            INodeStats nodeStats,
            IPruneBlockStoreService lightWalletBlockStoreService)
        {
            this.walletSyncManager   = walletSyncManager;
            this.walletManager       = walletManager;
            this.connectionManager   = connectionManager;
            this.chainIndexer        = chainIndexer;
            this.nodeDeployments     = nodeDeployments;
            this.asyncLoopFactory    = asyncLoopFactory;
            this.nodeLifetime        = nodeLifetime;
            this.walletFeePolicy     = walletFeePolicy;
            this.broadcasterBehavior = broadcasterBehavior;
            this.logger         = loggerFactory.CreateLogger(this.GetType().FullName);
            this.loggerFactory  = loggerFactory;
            this.storeSettings  = storeSettings;
            this.walletSettings = walletSettings;

            this.lightWalletBlockStoreService = lightWalletBlockStoreService;

            nodeStats.RegisterStats(this.AddInlineStats, StatsType.Inline);
            nodeStats.RegisterStats(this.AddComponentStats, StatsType.Component);
        }
 public ManualMultiSigTransactionBuilderTests()
 {
     this.network = new StraxTest();
     this.federatedPegSettings = Substitute.For <IFederatedPegSettings>();
     this.walletFeePolicy      = Substitute.For <IWalletFeePolicy>();
     this.multisigCoinSelector = Substitute.For <IMultisigCoinSelector>();
 }
Esempio n. 3
0
        /// <summary>
        /// Constructs the cold staking manager which is used by the cold staking controller.
        /// </summary>
        /// <param name="network">The network that the manager is running on.</param>
        /// <param name="chainIndexer">Thread safe class representing a chain of headers from genesis.</param>
        /// <param name="walletSettings">The wallet settings.</param>
        /// <param name="dataFolder">Contains path locations to folders and files on disk.</param>
        /// <param name="walletFeePolicy">The wallet fee policy.</param>
        /// <param name="asyncProvider">Factory for creating and also possibly starting application defined tasks inside async loop.</param>
        /// <param name="nodeLifeTime">Allows consumers to perform cleanup during a graceful shutdown.</param>
        /// <param name="scriptAddressReader">A reader for extracting an address from a <see cref="Script"/>.</param>
        /// <param name="loggerFactory">The logger factory to use to create the custom logger.</param>
        /// <param name="dateTimeProvider">Provider of time functions.</param>
        /// <param name="broadcasterManager">The broadcaster manager.</param>
        public ColdStakingManager(
            Network network,
            ChainIndexer chainIndexer,
            WalletSettings walletSettings,
            DataFolder dataFolder,
            IWalletFeePolicy walletFeePolicy,
            IAsyncProvider asyncProvider,
            INodeLifetime nodeLifeTime,
            IScriptAddressReader scriptAddressReader,
            ILoggerFactory loggerFactory,
            IDateTimeProvider dateTimeProvider,
            IBroadcasterManager broadcasterManager = null) : base(
                loggerFactory,
                network,
                chainIndexer,
                walletSettings,
                dataFolder,
                walletFeePolicy,
                asyncProvider,
                nodeLifeTime,
                dateTimeProvider,
                scriptAddressReader,
                broadcasterManager
                )
        {
            Guard.NotNull(loggerFactory, nameof(loggerFactory));
            Guard.NotNull(dateTimeProvider, nameof(dateTimeProvider));

            this.logger           = loggerFactory.CreateLogger("Impleum.Bitcoin.Fullnode");
            this.dateTimeProvider = dateTimeProvider;
        }
        /// <summary>
        /// Constructs the cold staking manager which is used by the cold staking controller.
        /// </summary>
        /// <param name="network">The network that the manager is running on.</param>
        /// <param name="chain">Thread safe class representing a chain of headers from genesis.</param>
        /// <param name="walletSettings">The wallet settings.</param>
        /// <param name="dataFolder">Contains path locations to folders and files on disk.</param>
        /// <param name="walletFeePolicy">The wallet fee policy.</param>
        /// <param name="asyncLoopFactory">Factory for creating and also possibly starting application defined tasks inside async loop.</param>
        /// <param name="nodeLifeTime">Allows consumers to perform cleanup during a graceful shutdown.</param>
        /// <param name="scriptAddressReader">A reader for extracting an address from a <see cref="Script"/>.</param>
        /// <param name="loggerFactory">The logger factory to use to create the custom logger.</param>
        /// <param name="dateTimeProvider">Provider of time functions.</param>
        /// <param name="broadcasterManager">The broadcaster manager.</param>
        public ColdStakingManager(
            Network network,
            ConcurrentChain chain,
            WalletSettings walletSettings,
            DataFolder dataFolder,
            IWalletFeePolicy walletFeePolicy,
            IAsyncLoopFactory asyncLoopFactory,
            INodeLifetime nodeLifeTime,
            IScriptAddressReader scriptAddressReader,
            ILoggerFactory loggerFactory,
            IDateTimeProvider dateTimeProvider,
            IBroadcasterManager broadcasterManager = null) : base(
                loggerFactory,
                network,
                chain,
                walletSettings,
                dataFolder,
                walletFeePolicy,
                asyncLoopFactory,
                nodeLifeTime,
                dateTimeProvider,
                scriptAddressReader,
                broadcasterManager
                )
        {
            Guard.NotNull(loggerFactory, nameof(loggerFactory));
            Guard.NotNull(dateTimeProvider, nameof(dateTimeProvider));

            this.logger           = loggerFactory.CreateLogger(this.GetType().FullName);
            this.dateTimeProvider = dateTimeProvider;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="LightWalletFeature"/> class.
 /// </summary>
 /// <param name="walletSyncManager">The synchronization manager for the wallet, tasked with keeping the wallet synced with the network.</param>
 /// <param name="walletManager">The wallet manager.</param>
 /// <param name="connectionManager">The connection manager.</param>
 /// <param name="chain">The chain of blocks.</param>
 /// <param name="nodeDeployments">The node deployments.</param>
 /// <param name="asyncLoopFactory">The asynchronous loop factory.</param>
 /// <param name="nodeLifetime">The node lifetime.</param>
 /// <param name="walletFeePolicy">The wallet fee policy.</param>
 /// <param name="broadcasterBehavior">The broadcaster behaviour.</param>
 /// <param name="loggerFactory">Factory to be used to create logger for the puller.</param>
 /// <param name="nodeSettings">The settings for the node.</param>
 /// <param name="walletSettings">The settings for the wallet.</param>
 public LightWalletFeature(
     IWalletSyncManager walletSyncManager,
     IWalletManager walletManager,
     IConnectionManager connectionManager,
     ConcurrentChain chain,
     NodeDeployments nodeDeployments,
     IAsyncLoopFactory asyncLoopFactory,
     INodeLifetime nodeLifetime,
     IWalletFeePolicy walletFeePolicy,
     BroadcasterBehavior broadcasterBehavior,
     ILoggerFactory loggerFactory,
     NodeSettings nodeSettings,
     WalletSettings walletSettings)
 {
     this.walletSyncManager   = walletSyncManager;
     this.walletManager       = walletManager;
     this.connectionManager   = connectionManager;
     this.chain               = chain;
     this.nodeDeployments     = nodeDeployments;
     this.asyncLoopFactory    = asyncLoopFactory;
     this.nodeLifetime        = nodeLifetime;
     this.walletFeePolicy     = walletFeePolicy;
     this.broadcasterBehavior = broadcasterBehavior;
     this.logger              = loggerFactory.CreateLogger(this.GetType().FullName);
     this.loggerFactory       = loggerFactory;
     this.nodeSettings        = nodeSettings;
     this.walletSettings      = walletSettings;
 }
Esempio n. 6
0
 public TumblingState(ILoggerFactory loggerFactory,
                      ConcurrentChain chain,
                      WalletManager walletManager,
                      IWatchOnlyWalletManager watchOnlyWalletManager,
                      Network network,
                      WalletTransactionHandler walletTransactionHandler,
                      WalletSyncManager walletSyncManager,
                      IWalletFeePolicy walletFeePolicy,
                      NodeSettings nodeSettings,
                      IBroadcasterManager broadcasterManager,
                      ConnectionManager connectionManager)
 {
     this.Logger                   = loggerFactory.CreateLogger(this.GetType().FullName);
     this.Chain                    = chain;
     this.WalletManager            = walletManager;
     this.WatchOnlyWalletManager   = watchOnlyWalletManager;
     this.CoinType                 = (CoinType)network.Consensus.CoinType;
     this.WalletTransactionHandler = walletTransactionHandler;
     this.WalletSyncManager        = walletSyncManager;
     this.TumblerNetwork           = network;
     this.WalletFeePolicy          = walletFeePolicy;
     this.NodeSettings             = nodeSettings;
     this.BroadcasterManager       = broadcasterManager;
     this.ConnectionManager        = connectionManager;
 }
Esempio n. 7
0
        public WalletManager(ILoggerFactory loggerFactory, IConnectionManager connectionManager, Network network, ConcurrentChain chain,
                             NodeSettings settings, DataFolder dataFolder, IWalletFeePolicy walletFeePolicy, IAsyncLoopFactory asyncLoopFactory,
                             INodeLifetime nodeLifetime, MempoolValidator mempoolValidator = null) // mempool does not exist in a light wallet
        {
            Guard.NotNull(loggerFactory, nameof(loggerFactory));
            Guard.NotNull(network, nameof(network));
            Guard.NotNull(chain, nameof(chain));
            Guard.NotNull(settings, nameof(settings));
            Guard.NotNull(dataFolder, nameof(dataFolder));
            Guard.NotNull(walletFeePolicy, nameof(walletFeePolicy));
            Guard.NotNull(asyncLoopFactory, nameof(asyncLoopFactory));
            Guard.NotNull(nodeLifetime, nameof(nodeLifetime));


            this.logger  = loggerFactory.CreateLogger(this.GetType().FullName);
            this.Wallets = new ConcurrentBag <Wallet>();

            this.connectionManager = connectionManager;
            this.network           = network;
            this.coinType          = (CoinType)network.Consensus.CoinType;
            this.chain             = chain;
            this.settings          = settings;
            this.dataFolder        = dataFolder;
            this.walletFeePolicy   = walletFeePolicy;
            this.mempoolValidator  = mempoolValidator;
            this.asyncLoopFactory  = asyncLoopFactory;
            this.nodeLifetime      = nodeLifetime;

            // register events
            this.TransactionFound += this.OnTransactionFound;
        }
        /// <summary>
        /// Initializes the cross-chain transfer tests.
        /// </summary>
        /// <param name="network">The network to run the tests for.</param>
        public CrossChainTestBase(Network network = null, Network counterChainNetwork = null)
        {
            this.network             = network ?? FederatedPegNetwork.NetworksSelector.Regtest();
            this.counterChainNetwork = counterChainNetwork ?? Networks.Stratis.Regtest();
            this.federatedPegOptions = new FederatedPegOptions(counterChainNetwork);

            NetworkRegistration.Register(this.network);

            this.loggerFactory = Substitute.For <ILoggerFactory>();
            this.nodeLifetime  = new NodeLifetime();
            this.logger        = Substitute.For <ILogger>();
            this.signals       = Substitute.For <ISignals>();
            this.asyncProvider = new AsyncProvider(this.loggerFactory, this.signals, this.nodeLifetime);
            this.loggerFactory.CreateLogger(null).ReturnsForAnyArgs(this.logger);
            this.dateTimeProvider                   = DateTimeProvider.Default;
            this.opReturnDataReader                 = new OpReturnDataReader(this.loggerFactory, this.federatedPegOptions);
            this.blockRepository                    = Substitute.For <IBlockRepository>();
            this.fullNode                           = Substitute.For <IFullNode>();
            this.withdrawalTransactionBuilder       = Substitute.For <IWithdrawalTransactionBuilder>();
            this.federationWalletManager            = Substitute.For <IFederationWalletManager>();
            this.federationWalletSyncManager        = Substitute.For <IFederationWalletSyncManager>();
            this.FederationWalletTransactionHandler = Substitute.For <IFederationWalletTransactionHandler>();
            this.walletFeePolicy                    = Substitute.For <IWalletFeePolicy>();
            this.connectionManager                  = Substitute.For <IConnectionManager>();
            this.dBreezeSerializer                  = new DBreezeSerializer(this.network.Consensus.ConsensusFactory);
            this.ibdState                           = Substitute.For <IInitialBlockDownloadState>();
            this.wallet = null;
            this.federationGatewaySettings = Substitute.For <IFederationGatewaySettings>();
            this.ChainIndexer = new ChainIndexer(this.network);

            this.federationGatewaySettings.TransactionFee.Returns(new Money(0.01m, MoneyUnit.BTC));

            // Generate the keys used by the federation members for our tests.
            this.federationKeys = new[]
            {
                "ensure feel swift crucial bridge charge cloud tell hobby twenty people mandate",
                "quiz sunset vote alley draw turkey hill scrap lumber game differ fiction",
                "exchange rent bronze pole post hurry oppose drama eternal voice client state"
            }.Select(m => HdOperations.GetExtendedKey(m)).ToArray();

            SetExtendedKey(0);

            this.fundingTransactions = new List <Transaction>();

            this.blockDict = new Dictionary <uint256, Block>();
            this.blockDict[this.network.GenesisHash] = this.network.GetGenesis();

            this.blockRepository.GetBlocks(Arg.Any <List <uint256> >()).ReturnsForAnyArgs((x) =>
            {
                var hashes = x.ArgAt <List <uint256> >(0);
                var blocks = new List <Block>();
                for (int i = 0; i < hashes.Count; i++)
                {
                    blocks.Add(this.blockDict.TryGetValue(hashes[i], out Block block) ? block : null);
                }

                return(blocks);
            });
        }
 public SmartContractWalletTransactionHandler(
     ILoggerFactory loggerFactory,
     IWalletManager walletManager,
     IWalletFeePolicy walletFeePolicy,
     Network network,
     StandardTransactionPolicy transactionPolicy) :
     base(loggerFactory, walletManager, walletFeePolicy, network, transactionPolicy)
 {
 }
 public SmartContractWalletTransactionHandler(
     ILoggerFactory loggerFactory,
     IWalletManager walletManager,
     IWalletFeePolicy walletFeePolicy,
     Network network,
     StandardTransactionPolicy transactionPolicy,
     IReserveUtxoService utxoReservedService) :
     base(loggerFactory, walletManager, walletFeePolicy, network, transactionPolicy, utxoReservedService)
 {
 }
Esempio n. 11
0
 public ColdStakingWalletService(
     ILoggerFactory loggerFactory, IWalletManager walletManager,
     IConsensusManager consensusManager, IWalletTransactionHandler walletTransactionHandler,
     IWalletSyncManager walletSyncManager, IConnectionManager connectionManager,
     Network network, ChainIndexer chainIndexer, IBroadcasterManager broadcasterManager,
     IDateTimeProvider dateTimeProvider, IUtxoIndexer utxoIndexer,
     IWalletFeePolicy walletFeePolicy, NodeSettings nodeSettings)
     : base(loggerFactory, walletManager, consensusManager, walletTransactionHandler, walletSyncManager, connectionManager, network, chainIndexer, broadcasterManager, dateTimeProvider, utxoIndexer, walletFeePolicy, nodeSettings)
 {
 }
Esempio n. 12
0
 public WalletTransactionHandler(
     ILoggerFactory loggerFactory,
     IWalletManager walletManager,
     IWalletFeePolicy walletFeePolicy,
     Network network)
 {
     this.walletManager   = walletManager;
     this.walletFeePolicy = walletFeePolicy;
     this.coinType        = (CoinType)network.Consensus.CoinType;
     this.logger          = loggerFactory.CreateLogger(this.GetType().FullName);
 }
Esempio n. 13
0
 public FedMultiSigManualWithdrawalTransactionBuilder(
     Network network,
     IFederatedPegSettings federatedPegSettings,
     IWalletFeePolicy walletFeePolicy,
     IMultisigCoinSelector multisigCoinSelector)
 {
     this.network = network;
     this.federatedPegSettings = federatedPegSettings;
     this.walletFeePolicy      = walletFeePolicy;
     this.multisigCoinSelector = multisigCoinSelector;
 }
 public LightWalletFeature(IWalletSyncManager walletSyncManager, IWalletManager walletManager, IConnectionManager connectionManager,
                           ConcurrentChain chain, NodeDeployments nodeDeployments, IAsyncLoopFactory asyncLoopFactory, INodeLifetime nodeLifetime, IWalletFeePolicy walletFeePolicy)
 {
     this.walletSyncManager = walletSyncManager;
     this.walletManager     = walletManager;
     this.connectionManager = connectionManager;
     this.chain             = chain;
     this.nodeDeployments   = nodeDeployments;
     this.asyncLoopFactory  = asyncLoopFactory;
     this.nodeLifetime      = nodeLifetime;
     this.walletFeePolicy   = walletFeePolicy;
 }
        public WalletTransactionHandler(
            ILoggerFactory loggerFactory,
            IWalletManager walletManager,
            IWalletFeePolicy walletFeePolicy,
            Network network,
            StandardTransactionPolicy transactionPolicy)
        {
            this.network         = network;
            this.walletManager   = walletManager;
            this.walletFeePolicy = walletFeePolicy;
            this.logger          = loggerFactory.CreateLogger("Impleum.Bitcoin.Fullnode");

            this.TransactionPolicy = transactionPolicy;
        }
        public WalletTransactionHandler(
            ILoggerFactory loggerFactory,
            IWalletManager walletManager,
            IWalletFeePolicy walletFeePolicy,
            Network network,
            StandardTransactionPolicy transactionPolicy)
        {
            this.network         = network;
            this.walletManager   = walletManager;
            this.walletFeePolicy = walletFeePolicy;
            this.logger          = loggerFactory.CreateLogger(GetType().FullName);

            this.TransactionPolicy = transactionPolicy;
        }
 public WalletTransactionHandler(
     ILoggerFactory loggerFactory,
     IWalletManager walletManager,
     IWalletFeePolicy walletFeePolicy,
     Network network,
     StandardTransactionPolicy transactionPolicy,
     IReserveUtxoService reservedUtxoService)
 {
     this.network            = network;
     this.walletManager      = walletManager;
     this.walletFeePolicy    = walletFeePolicy;
     this.logger             = loggerFactory.CreateLogger(this.GetType().FullName);
     this.TransactionPolicy  = transactionPolicy;
     this.reserveUtxoService = reservedUtxoService;
 }
 public WalletTransactionHandler(
     ILoggerFactory loggerFactory,
     IWalletManager walletManager,
     IWalletFeePolicy walletFeePolicy,
     Network network)
 {
     this.Network         = network;
     this.walletManager   = walletManager;
     this.walletFeePolicy = walletFeePolicy;
     this.coinType        = (CoinType)network.Consensus.CoinType;
     this.logger          = loggerFactory.CreateLogger(this.GetType().FullName);
     this.privateKeyCache = new MemoryCache(new MemoryCacheOptions()
     {
         ExpirationScanFrequency = new TimeSpan(0, 1, 0)
     });
 }
Esempio n. 19
0
 public WalletTransactionHandler(
     ILoggerFactory loggerFactory,
     IWalletManager walletManager,
     IWalletFeePolicy walletFeePolicy,
     Network network,
     StandardTransactionPolicy transactionPolicy)
 {
     this.network         = network;
     this.walletManager   = walletManager;
     this.walletFeePolicy = walletFeePolicy;
     this.logger          = loggerFactory.CreateLogger(this.GetType().FullName);
     this.privateKeyCache = new MemoryCache(new MemoryCacheOptions()
     {
         ExpirationScanFrequency = new TimeSpan(0, 1, 0)
     });
     this.TransactionPolicy = transactionPolicy;
 }
        public FederationWalletManager(
            ILoggerFactory loggerFactory,
            Network network,
            ChainIndexer chainIndexer,
            DataFolder dataFolder,
            IWalletFeePolicy walletFeePolicy,
            IAsyncLoopFactory asyncLoopFactory,
            INodeLifetime nodeLifetime,
            IDateTimeProvider dateTimeProvider,
            IFederationGatewaySettings federationGatewaySettings,
            IWithdrawalExtractor withdrawalExtractor,
            IBroadcasterManager broadcasterManager = null) // no need to know about transactions the node broadcasted
        {
            Guard.NotNull(loggerFactory, nameof(loggerFactory));
            Guard.NotNull(network, nameof(network));
            Guard.NotNull(chainIndexer, nameof(chainIndexer));
            Guard.NotNull(dataFolder, nameof(dataFolder));
            Guard.NotNull(walletFeePolicy, nameof(walletFeePolicy));
            Guard.NotNull(asyncLoopFactory, nameof(asyncLoopFactory));
            Guard.NotNull(nodeLifetime, nameof(nodeLifetime));
            Guard.NotNull(federationGatewaySettings, nameof(federationGatewaySettings));
            Guard.NotNull(withdrawalExtractor, nameof(withdrawalExtractor));

            this.lockObject = new object();

            this.logger = loggerFactory.CreateLogger(this.GetType().FullName);

            this.network                   = network;
            this.coinType                  = (CoinType)network.Consensus.CoinType;
            this.chainIndexer              = chainIndexer;
            this.asyncLoopFactory          = asyncLoopFactory;
            this.nodeLifetime              = nodeLifetime;
            this.fileStorage               = new FileStorage <FederationWallet>(dataFolder.WalletPath);
            this.broadcasterManager        = broadcasterManager;
            this.dateTimeProvider          = dateTimeProvider;
            this.federationGatewaySettings = federationGatewaySettings;
            this.withdrawalExtractor       = withdrawalExtractor;
            this.outpointLookup            = new Dictionary <OutPoint, TransactionData>();
            this.isFederationActive        = false;

            // register events
            if (this.broadcasterManager != null)
            {
                this.broadcasterManager.TransactionStateChanged += this.BroadcasterManager_TransactionStateChanged;
            }
        }
Esempio n. 21
0
        public FederationWalletTransactionHandler(
            ILoggerFactory loggerFactory,
            IFederationWalletManager walletManager,
            IWalletFeePolicy walletFeePolicy,
            Network network)
        {
            Guard.NotNull(loggerFactory, nameof(loggerFactory));
            Guard.NotNull(walletManager, nameof(walletManager));
            Guard.NotNull(walletFeePolicy, nameof(walletFeePolicy));
            Guard.NotNull(network, nameof(network));

            this.walletManager   = walletManager;
            this.walletFeePolicy = walletFeePolicy;
            this.network         = network;
            this.logger          = loggerFactory.CreateLogger(this.GetType().FullName);
            this.privateKeyCache = new MemoryCache(new MemoryCacheOptions()
            {
                ExpirationScanFrequency = new TimeSpan(0, 1, 0)
            });
        }
        public ColdStakingController(
            ILoggerFactory loggerFactory,
            IWalletManager walletManager,
            IWalletTransactionHandler walletTransactionHandler,
            IWalletFeePolicy walletFeePolicy,
            IBroadcasterManager broadcasterManager)
        {
            Guard.NotNull(loggerFactory, nameof(loggerFactory));
            Guard.NotNull(walletManager, nameof(walletManager));
            Guard.NotNull(walletTransactionHandler, nameof(walletTransactionHandler));
            Guard.NotNull(walletFeePolicy, nameof(walletFeePolicy));
            Guard.NotNull(broadcasterManager, nameof(broadcasterManager));

            this.ColdStakingManager = walletManager as ColdStakingManager;
            Guard.NotNull(this.ColdStakingManager, nameof(this.ColdStakingManager));

            this.logger = loggerFactory.CreateLogger(this.GetType().FullName);
            this.walletTransactionHandler = walletTransactionHandler;
            this.walletFeePolicy          = walletFeePolicy;
            this.broadcasterManager       = broadcasterManager;
        }
Esempio n. 23
0
        public FederationWalletTransactionHandler(
            IFederationWalletManager walletManager,
            IWalletFeePolicy walletFeePolicy,
            Network network,
            IFederatedPegSettings settings)
        {
            Guard.NotNull(walletManager, nameof(walletManager));
            Guard.NotNull(walletFeePolicy, nameof(walletFeePolicy));
            Guard.NotNull(network, nameof(network));
            Guard.NotNull(settings, nameof(settings));

            this.walletManager   = walletManager;
            this.walletFeePolicy = walletFeePolicy;
            this.network         = network;
            this.settings        = settings;

            this.logger          = LogManager.GetCurrentClassLogger();
            this.privateKeyCache = new MemoryCache(new MemoryCacheOptions()
            {
                ExpirationScanFrequency = new TimeSpan(0, 1, 0)
            });
        }
        public WalletTransactionHandler(
            ILoggerFactory loggerFactory,
            IWalletManager walletManager,
            IWalletFeePolicy walletFeePolicy,
            Network network,
            StandardTransactionPolicy transactionPolicy)
        {
            this.network         = network;
            this.walletManager   = walletManager;
            this.walletFeePolicy = walletFeePolicy;
            this.logger          = loggerFactory.CreateLogger(this.GetType().FullName);
            this.privateKeyCache = new MemoryCache(new MemoryCacheOptions()
            {
                ExpirationScanFrequency = new TimeSpan(0, 1, 0)
            });
            this.TransactionPolicy = transactionPolicy;

            foreach (var wallet in this.walletManager.WalletsToUnlock)
            {
                this.UnlockWallet(wallet.Account, wallet.Password, wallet.Timeout);
            }
        }
        public FederationWalletManager(
            ILoggerFactory loggerFactory,
            Network network,
            ChainIndexer chainIndexer,
            DataFolder dataFolder,
            IWalletFeePolicy walletFeePolicy,
            IAsyncProvider asyncProvider,
            INodeLifetime nodeLifetime,
            IDateTimeProvider dateTimeProvider,
            IFederationGatewaySettings federationGatewaySettings,
            IWithdrawalExtractor withdrawalExtractor)
        {
            Guard.NotNull(loggerFactory, nameof(loggerFactory));
            Guard.NotNull(network, nameof(network));
            Guard.NotNull(chainIndexer, nameof(chainIndexer));
            Guard.NotNull(dataFolder, nameof(dataFolder));
            Guard.NotNull(walletFeePolicy, nameof(walletFeePolicy));
            Guard.NotNull(asyncProvider, nameof(asyncProvider));
            Guard.NotNull(nodeLifetime, nameof(nodeLifetime));
            Guard.NotNull(federationGatewaySettings, nameof(federationGatewaySettings));
            Guard.NotNull(withdrawalExtractor, nameof(withdrawalExtractor));

            this.lockObject = new object();

            this.logger = loggerFactory.CreateLogger(this.GetType().FullName);

            this.network                   = network;
            this.coinType                  = (CoinType)network.Consensus.CoinType;
            this.chainIndexer              = chainIndexer;
            this.asyncProvider             = asyncProvider;
            this.nodeLifetime              = nodeLifetime;
            this.fileStorage               = new FileStorage <FederationWallet>(dataFolder.WalletPath);
            this.dateTimeProvider          = dateTimeProvider;
            this.federationGatewaySettings = federationGatewaySettings;
            this.withdrawalExtractor       = withdrawalExtractor;
            this.outpointLookup            = new Dictionary <OutPoint, TransactionData>();
            this.isFederationActive        = false;
        }
        public FederationWalletTransactionHandler(
            ILoggerFactory loggerFactory,
            IFederationWalletManager walletManager,
            IWalletFeePolicy walletFeePolicy,
            Network network,
            IFederatedPegSettings settings)
        {
            Guard.NotNull(loggerFactory, nameof(loggerFactory));
            Guard.NotNull(walletManager, nameof(walletManager));
            Guard.NotNull(walletFeePolicy, nameof(walletFeePolicy));
            Guard.NotNull(network, nameof(network));
            Guard.NotNull(settings, nameof(settings));

            this.walletManager   = walletManager;
            this.walletFeePolicy = walletFeePolicy;
            this.network         = network;
            this.settings        = settings;

            this.logger          = loggerFactory.CreateLogger("Impleum.Bitcoin.Fullnode");
            this.privateKeyCache = new MemoryCache(new MemoryCacheOptions()
            {
                ExpirationScanFrequency = new TimeSpan(0, 1, 0)
            });
        }
Esempio n. 27
0
 public FullNodeFeeService(IWalletFeePolicy walletFeePolicy)
 {
     WalletFeePolicy = walletFeePolicy ?? throw new ArgumentNullException(nameof(walletFeePolicy));
 }
Esempio n. 28
0
        public TumbleBitManager(
            ILoggerFactory loggerFactory,
            NodeSettings nodeSettings,
            IWalletManager walletManager,
            IWatchOnlyWalletManager watchOnlyWalletManager,
            ConcurrentChain chain,
            Network network,
            Signals signals,
            IWalletTransactionHandler walletTransactionHandler,
            IWalletSyncManager walletSyncManager,
            IWalletFeePolicy walletFeePolicy,
            IBroadcasterManager broadcasterManager,
            FullNode fullNode,
            ConfigurationOptionWrapper <string> registrationStoreDirectory)
        {
            this.walletManager            = walletManager as WalletManager;
            this.watchOnlyWalletManager   = watchOnlyWalletManager;
            this.walletSyncManager        = walletSyncManager as WalletSyncManager;
            this.walletTransactionHandler = walletTransactionHandler as WalletTransactionHandler;
            this.chain              = chain;
            this.signals            = signals;
            this.network            = network;
            this.nodeSettings       = nodeSettings;
            this.loggerFactory      = loggerFactory;
            this.logger             = loggerFactory.CreateLogger(this.GetType().FullName);
            this.walletFeePolicy    = walletFeePolicy;
            this.broadcasterManager = broadcasterManager;
            this.fullNode           = fullNode;

            if (registrationStoreDirectory.Value != null)
            {
                this.registrationStore = new RegistrationStore(registrationStoreDirectory.Value);
            }
            else
            {
                this.registrationStore = new RegistrationStore(this.nodeSettings.DataDir);
            }

            this.tumblingState = new TumblingState(
                this.loggerFactory,
                this.chain,
                this.walletManager,
                this.watchOnlyWalletManager,
                this.network,
                this.walletTransactionHandler,
                this.walletSyncManager,
                this.walletFeePolicy,
                this.nodeSettings,
                this.broadcasterManager);

            // Load saved state e.g. previously selected server
            if (File.Exists(this.tumblingState.GetStateFilePath()))
            {
                try
                {
                    this.tumblingState.LoadStateFromMemory();
                }
                catch (NullReferenceException)
                {
                    // The file appears to get corrupted sometimes, not clear why
                    // May be if the node is not shut down correctly
                }
            }

            this.tumblingState.Save();

            // Remove the progress file from previous session as it is now stale
            ProgressInfo.RemoveProgressFile();
        }
Esempio n. 29
0
 public DeStreamWalletManager(ILoggerFactory loggerFactory, Network network, ConcurrentChain chain, NodeSettings settings, WalletSettings walletSettings,
                              DataFolder dataFolder, IWalletFeePolicy walletFeePolicy, IAsyncLoopFactory asyncLoopFactory, INodeLifetime nodeLifetime, IDateTimeProvider dateTimeProvider,
                              IBroadcasterManager broadcasterManager = null) :
     base(loggerFactory, network, chain, settings, walletSettings, dataFolder, walletFeePolicy, asyncLoopFactory, nodeLifetime, dateTimeProvider, broadcasterManager)
 {
 }
Esempio n. 30
0
        public TumbleBitManager(
            ILoggerFactory loggerFactory,
            NodeSettings nodeSettings,
            IWalletManager walletManager,
            IWatchOnlyWalletManager watchOnlyWalletManager,
            ConcurrentChain chain,
            Network network,
            Signals signals,
            IWalletTransactionHandler walletTransactionHandler,
            IWalletSyncManager walletSyncManager,
            IWalletFeePolicy walletFeePolicy,
            IBroadcasterManager broadcasterManager,
            FullNode fullNode,
            ConfigurationOptionWrapper <string>[] configurationOptions)
        {
            this.walletManager            = walletManager as WalletManager;
            this.watchOnlyWalletManager   = watchOnlyWalletManager;
            this.walletSyncManager        = walletSyncManager as WalletSyncManager;
            this.walletTransactionHandler = walletTransactionHandler as WalletTransactionHandler;
            this.chain              = chain;
            this.signals            = signals;
            this.network            = network;
            this.nodeSettings       = nodeSettings;
            this.loggerFactory      = loggerFactory;
            this.logger             = loggerFactory.CreateLogger(this.GetType().FullName);
            this.walletFeePolicy    = walletFeePolicy;
            this.broadcasterManager = broadcasterManager;
            this.connectionManager  = fullNode.ConnectionManager as ConnectionManager;
            this.fullNode           = fullNode;

            foreach (var option in configurationOptions)
            {
                if (option.Name.Equals("RegistrationStoreDirectory"))
                {
                    if (option.Value != null)
                    {
                        this.registrationStore = new RegistrationStore(option.Value);
                    }
                    else
                    {
                        this.registrationStore = new RegistrationStore(this.nodeSettings.DataDir);
                    }
                }

                if (option.Name.Equals("MasterNodeUri"))
                {
                    if (option.Value != null)
                    {
                        this.TumblerAddress = option.Value;
                    }
                }
            }

            this.tumblingState = new TumblingState(
                this.loggerFactory,
                this.chain,
                this.walletManager,
                this.watchOnlyWalletManager,
                this.network,
                this.walletTransactionHandler,
                this.walletSyncManager,
                this.walletFeePolicy,
                this.nodeSettings,
                this.broadcasterManager,
                this.connectionManager);

            // Load saved state e.g. previously selected server
            if (File.Exists(this.tumblingState.GetStateFilePath()))
            {
                try
                {
                    this.tumblingState.LoadStateFromMemory();
                }
                catch (NullReferenceException)
                {
                    // The file appears to get corrupted sometimes, not clear why
                    // May be if the node is not shut down correctly
                }
            }

            this.tumblingState.Save();

            // If there was a server address saved, that means we were previously
            // connected to it, and should try to reconnect to it by default when
            // the connect method is invoked by the UI
            if ((this.TumblerAddress == null) && (this.tumblingState.TumblerUri != null))
            {
                this.TumblerAddress = this.tumblingState.TumblerUri.ToString();
            }

            // Remove the progress file from previous session as it is now stale
            ProgressInfo.RemoveProgressFile();
        }