コード例 #1
0
        public FederationWalletSyncManager(ILoggerFactory loggerFactory, IFederationWalletManager walletManager, ConcurrentChain chain,
                                           Network network, IBlockStore blockStore, StoreSettings storeSettings, INodeLifetime nodeLifetime)
        {
            Guard.NotNull(loggerFactory, nameof(loggerFactory));
            Guard.NotNull(walletManager, nameof(walletManager));
            Guard.NotNull(chain, nameof(chain));
            Guard.NotNull(network, nameof(network));
            Guard.NotNull(blockStore, nameof(blockStore));
            Guard.NotNull(storeSettings, nameof(storeSettings));
            Guard.NotNull(nodeLifetime, nameof(nodeLifetime));

            this.walletManager = walletManager;
            this.chain         = chain;
            this.blockStore    = blockStore;
            this.coinType      = (CoinType)network.Consensus.CoinType;
            this.storeSettings = storeSettings;
            this.nodeLifetime  = nodeLifetime;
            this.logger        = loggerFactory.CreateLogger(this.GetType().FullName);
        }
コード例 #2
0
 public FederationGatewayController(
     ILoggerFactory loggerFactory,
     Network network,
     ILeaderProvider leaderProvider,
     IMaturedBlocksProvider maturedBlocksProvider,
     ILeaderReceiver leaderReceiver,
     IFederationGatewaySettings federationGatewaySettings,
     IFederationWalletManager federationWalletManager,
     FederationManager federationManager = null)
 {
     this.logger                    = loggerFactory.CreateLogger(this.GetType().FullName);
     this.network                   = network;
     this.leaderProvider            = leaderProvider;
     this.maturedBlocksProvider     = maturedBlocksProvider;
     this.leaderReceiver            = leaderReceiver;
     this.federationGatewaySettings = federationGatewaySettings;
     this.federationWalletManager   = federationWalletManager;
     this.federationManager         = federationManager;
 }
コード例 #3
0
        public SignedMultisigTransactionBroadcaster(
            ILoggerFactory loggerFactory,
            MempoolManager mempoolManager,
            IBroadcasterManager broadcasterManager,
            IInitialBlockDownloadState ibdState,
            IFederationWalletManager federationWalletManager,
            ISignals signals,
            ICrossChainTransferStore crossChainTransferStore = null)
        {
            Guard.NotNull(loggerFactory, nameof(loggerFactory));
            this.mempoolManager          = Guard.NotNull(mempoolManager, nameof(mempoolManager));
            this.broadcasterManager      = Guard.NotNull(broadcasterManager, nameof(broadcasterManager));
            this.ibdState                = Guard.NotNull(ibdState, nameof(ibdState));
            this.federationWalletManager = Guard.NotNull(federationWalletManager, nameof(federationWalletManager));
            this.signals = Guard.NotNull(signals, nameof(signals));
            this.store   = crossChainTransferStore;

            this.logger = loggerFactory.CreateLogger(this.GetType().FullName);
        }
コード例 #4
0
        // TODO: Could put a dictionary by OutPoint.

        public InputConsolidator(IFederationWalletTransactionHandler transactionHandler,
                                 IFederationWalletManager walletManager,
                                 IBroadcasterManager broadcasterManager,
                                 IFederatedPegSettings settings,
                                 ILoggerFactory loggerFactory,
                                 ISignals signals,
                                 IAsyncProvider asyncProvider,
                                 Network network)
        {
            this.transactionHandler = transactionHandler;
            this.walletManager      = walletManager;
            this.broadcasterManager = broadcasterManager;
            this.network            = network;
            this.settings           = settings;
            this.logger             = loggerFactory.CreateLogger(this.GetType().FullName);
            this.asyncProvider      = asyncProvider;
            this.blockQueue         = asyncProvider.CreateAndRunAsyncDelegateDequeuer <ChainedHeaderBlock>($"{nameof(InputConsolidator)}-{nameof(this.blockQueue)}", this.ProcessBlockInternal);
            signals.Subscribe <WalletNeedsConsolidation>(this.StartConsolidation);
        }
コード例 #5
0
 public TestOnlyMaturedBlocksSyncManager(
     IAsyncProvider asyncProvider,
     ChainIndexer chainIndexer,
     ICrossChainTransferStore crossChainTransferStore,
     IFederationGatewayClient federationGatewayClient,
     IFederationWalletManager federationWalletManager,
     IInitialBlockDownloadState initialBlockDownloadState,
     INodeLifetime nodeLifetime)
     : base(
         asyncProvider,
         crossChainTransferStore,
         federationGatewayClient,
         federationWalletManager,
         initialBlockDownloadState,
         nodeLifetime,
         null,
         chainIndexer)
 {
 }
コード例 #6
0
        public SignedMultisigTransactionBroadcaster(
            IAsyncProvider asyncProvider,
            MempoolManager mempoolManager,
            IBroadcasterManager broadcasterManager,
            IInitialBlockDownloadState ibdState,
            IFederationWalletManager federationWalletManager,
            INodeLifetime nodeLifetime,
            ICrossChainTransferStore crossChainTransferStore = null)
        {
            this.asyncProvider           = asyncProvider;
            this.broadcasterManager      = Guard.NotNull(broadcasterManager, nameof(broadcasterManager));
            this.crossChainTransferStore = crossChainTransferStore;
            this.federationWalletManager = Guard.NotNull(federationWalletManager, nameof(federationWalletManager));
            this.mempoolManager          = Guard.NotNull(mempoolManager, nameof(mempoolManager));
            this.ibdState     = Guard.NotNull(ibdState, nameof(ibdState));
            this.nodeLifetime = nodeLifetime;

            this.logger = LogManager.GetCurrentClassLogger();
        }
コード例 #7
0
        public PartialTransactionsBehavior(
            IFederationWalletManager federationWalletManager,
            Network network,
            IFederatedPegSettings federatedPegSettings,
            ICrossChainTransferStore crossChainTransferStore,
            IInputConsolidator inputConsolidator)
        {
            Guard.NotNull(federationWalletManager, nameof(federationWalletManager));
            Guard.NotNull(network, nameof(network));
            Guard.NotNull(federatedPegSettings, nameof(federatedPegSettings));
            Guard.NotNull(crossChainTransferStore, nameof(crossChainTransferStore));

            this.logger = LogManager.GetCurrentClassLogger();
            this.federationWalletManager = federationWalletManager;
            this.network = network;
            this.federatedPegSettings    = federatedPegSettings;
            this.crossChainTransferStore = crossChainTransferStore;
            this.inputConsolidator       = inputConsolidator;
        }
コード例 #8
0
        public FederatedPegFeature(
            ILoggerFactory loggerFactory,
            IConnectionManager connectionManager,
            IFederatedPegSettings federatedPegSettings,
            IFullNode fullNode,
            IFederationWalletManager federationWalletManager,
            IFederationWalletSyncManager walletSyncManager,
            Network network,
            ChainIndexer chainIndexer,
            INodeStats nodeStats,
            ICrossChainTransferStore crossChainTransferStore,
            IPartialTransactionRequester partialTransactionRequester,
            ISignedMultisigTransactionBroadcaster signedBroadcaster,
            IMaturedBlocksSyncManager maturedBlocksSyncManager,
            IWithdrawalHistoryProvider withdrawalHistoryProvider,
            IInputConsolidator inputConsolidator,
            ICollateralChecker collateralChecker = null)
        {
            this.loggerFactory           = loggerFactory;
            this.connectionManager       = connectionManager;
            this.federatedPegSettings    = federatedPegSettings;
            this.fullNode                = fullNode;
            this.chainIndexer            = chainIndexer;
            this.federationWalletManager = federationWalletManager;
            this.walletSyncManager       = walletSyncManager;
            this.network = network;
            this.crossChainTransferStore     = crossChainTransferStore;
            this.partialTransactionRequester = partialTransactionRequester;
            this.maturedBlocksSyncManager    = maturedBlocksSyncManager;
            this.withdrawalHistoryProvider   = withdrawalHistoryProvider;
            this.signedBroadcaster           = signedBroadcaster;
            this.inputConsolidator           = inputConsolidator;

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

            // add our payload
            var payloadProvider = (PayloadProvider)this.fullNode.Services.ServiceProvider.GetService(typeof(PayloadProvider));

            payloadProvider.AddPayload(typeof(RequestPartialTransactionPayload));

            nodeStats.RegisterStats(this.AddComponentStats, StatsType.Component);
            nodeStats.RegisterStats(this.AddInlineStats, StatsType.Inline, 800);
        }
コード例 #9
0
        public FederationWalletControllerTests()
        {
            this.loggerFactory     = Substitute.For <ILoggerFactory>();
            this.walletManager     = Substitute.For <IFederationWalletManager>();
            this.walletSyncManager = Substitute.For <IFederationWalletSyncManager>();
            this.connectionManager = Substitute.For <IConnectionManager>();
            this.network           = new StraxTest();

            this.chainIndexer = new ChainIndexer(this.network);

            ChainedHeader tip = ChainedHeadersHelper.CreateConsecutiveHeaders(100, ChainedHeadersHelper.CreateGenesisChainedHeader(this.network), true, null, this.network).Last();

            this.chainIndexer.SetTip(tip);

            ICrossChainTransferStore crossChainTransferStore = Substitute.For <ICrossChainTransferStore>();

            crossChainTransferStore.GetCompletedWithdrawals(5).ReturnsForAnyArgs(new List <WithdrawalModel>()
            {
                new WithdrawalModel()
            });

            this.controller = new FederationWalletController(this.walletManager, this.walletSyncManager, this.connectionManager, this.network, this.chainIndexer, crossChainTransferStore);

            this.fedWallet = new FederationWallet
            {
                Network = this.network,
                LastBlockSyncedHeight = 999,
                CreationTime          = DateTimeOffset.Now
            };

            this.walletManager.GetWallet().Returns(this.fedWallet);

            var          federationWalletManager = (FederationWalletManager)FormatterServices.GetUninitializedObject(typeof(FederationWalletManager));
            PropertyInfo lockProp = typeof(LockProtected).GetProperty("lockObject", BindingFlags.NonPublic | BindingFlags.Instance);

            lockProp.SetValue(federationWalletManager, new object());
            federationWalletManager.Wallet = this.fedWallet;
            this.walletManager.GetSpendableAmount().Returns((x) =>
            {
                return(federationWalletManager.GetSpendableAmount());
            });
        }
コード例 #10
0
        public async Task FederationWalletIsSyncing_DelayRequiredAsync()
        {
            this.initialBlockDownloadState = Substitute.For <IInitialBlockDownloadState>();
            this.initialBlockDownloadState.IsInitialBlockDownload().Returns(false);

            // Create chain of 15 blocks
            var          testbase = new TestBase(this.network);
            List <Block> blocks   = new TestBase(this.network).CreateBlocks(15);

            testbase.AppendBlocksToChain(this.chainIndexer, blocks);

            this.federationWalletManager = Substitute.For <IFederationWalletManager>();
            this.federationWalletManager.WalletTipHeight.Returns(0);

            this.syncManager = new TestOnlyMaturedBlocksSyncManager(this.asyncProvider, this.chainIndexer, this.crossChainTransferStore, this.federationGatewayClient, this.federationWalletManager, this.initialBlockDownloadState, new NodeLifetime());

            bool delayRequired = await this.syncManager.ExposedSyncBatchOfBlocksAsync();

            Assert.True(delayRequired);
        }
コード例 #11
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)
            });
        }
コード例 #12
0
        public FederationWalletSyncManager(IFederationWalletManager walletManager, ChainIndexer chain, Network network,
                                           IBlockStore blockStore, StoreSettings storeSettings, INodeLifetime nodeLifetime, IAsyncProvider asyncProvider)
        {
            Guard.NotNull(walletManager, nameof(walletManager));
            Guard.NotNull(chain, nameof(chain));
            Guard.NotNull(network, nameof(network));
            Guard.NotNull(blockStore, nameof(blockStore));
            Guard.NotNull(storeSettings, nameof(storeSettings));
            Guard.NotNull(nodeLifetime, nameof(nodeLifetime));
            Guard.NotNull(asyncProvider, nameof(asyncProvider));

            this.federationWalletManager = walletManager;
            this.chain               = chain;
            this.blockStore          = blockStore;
            this.coinType            = (CoinType)network.Consensus.CoinType;
            this.storeSettings       = storeSettings;
            this.nodeLifetime        = nodeLifetime;
            this.asyncProvider       = asyncProvider;
            this.logger              = LogManager.GetCurrentClassLogger();
            this.blockQueueProcessor = new BlockQueueProcessor(this.asyncProvider, this.OnProcessBlockWrapperAsync, MaxQueueSize, nameof(FederationWalletSyncManager));
        }
コード例 #13
0
        public MaturedBlocksSyncManager(
            IAsyncProvider asyncProvider,
            ICrossChainTransferStore crossChainTransferStore,
            IFederationGatewayClient federationGatewayClient,
            IFederationWalletManager federationWalletManager,
            IInitialBlockDownloadState initialBlockDownloadState,
            INodeLifetime nodeLifetime,
            IConversionRequestRepository conversionRequestRepository,
            ChainIndexer chainIndexer)
        {
            this.asyncProvider = asyncProvider;
            this.chainIndexer  = chainIndexer;
            this.conversionRequestRepository = conversionRequestRepository;
            this.crossChainTransferStore     = crossChainTransferStore;
            this.federationGatewayClient     = federationGatewayClient;
            this.federationWalletManager     = federationWalletManager;
            this.initialBlockDownloadState   = initialBlockDownloadState;
            this.nodeLifetime = nodeLifetime;

            this.logger = LogManager.GetCurrentClassLogger();
        }
コード例 #14
0
        public PartialTransactionsBehavior(
            ILoggerFactory loggerFactory,
            IFederationWalletManager federationWalletManager,
            Network network,
            IFederationGatewaySettings federationGatewaySettings,
            ICrossChainTransferStore crossChainTransferStore)
        {
            Guard.NotNull(loggerFactory, nameof(loggerFactory));
            Guard.NotNull(federationWalletManager, nameof(federationWalletManager));
            Guard.NotNull(network, nameof(network));
            Guard.NotNull(federationGatewaySettings, nameof(federationGatewaySettings));
            Guard.NotNull(crossChainTransferStore, nameof(crossChainTransferStore));

            this.logger                    = loggerFactory.CreateLogger(this.GetType().FullName);
            this.loggerFactory             = loggerFactory;
            this.federationWalletManager   = federationWalletManager;
            this.network                   = network;
            this.federationGatewaySettings = federationGatewaySettings;
            this.crossChainTransferStore   = crossChainTransferStore;
            this.ipAddressComparer         = new IPAddressComparer();
        }
コード例 #15
0
        public PartialTransactionRequester(
            ICrossChainTransferStore crossChainTransferStore,
            IAsyncProvider asyncProvider,
            INodeLifetime nodeLifetime,
            IFederatedPegBroadcaster federatedPegBroadcaster,
            IInitialBlockDownloadState ibdState,
            IFederationWalletManager federationWalletManager,
            IInputConsolidator inputConsolidator)
        {
            Guard.NotNull(crossChainTransferStore, nameof(crossChainTransferStore));
            Guard.NotNull(asyncProvider, nameof(asyncProvider));
            Guard.NotNull(nodeLifetime, nameof(nodeLifetime));

            this.logger = LogManager.GetCurrentClassLogger();
            this.crossChainTransferStore = crossChainTransferStore;
            this.asyncProvider           = asyncProvider;
            this.nodeLifetime            = nodeLifetime;
            this.ibdState = ibdState;
            this.federatedPegBroadcaster = federatedPegBroadcaster;
            this.federationWalletManager = federationWalletManager;
            this.inputConsolidator       = inputConsolidator;
        }
        public PartialTransactionsBehavior(
            ILoggerFactory loggerFactory,
            IFederationWalletManager federationWalletManager,
            Network network,
            IFederatedPegSettings federatedPegSettings,
            ICrossChainTransferStore crossChainTransferStore,
            IInputConsolidator inputConsolidator)
        {
            Guard.NotNull(loggerFactory, nameof(loggerFactory));
            Guard.NotNull(federationWalletManager, nameof(federationWalletManager));
            Guard.NotNull(network, nameof(network));
            Guard.NotNull(federatedPegSettings, nameof(federatedPegSettings));
            Guard.NotNull(crossChainTransferStore, nameof(crossChainTransferStore));

            this.logger                  = loggerFactory.CreateLogger(this.GetType().FullName);
            this.loggerFactory           = loggerFactory;
            this.federationWalletManager = federationWalletManager;
            this.network                 = network;
            this.federatedPegSettings    = federatedPegSettings;
            this.crossChainTransferStore = crossChainTransferStore;
            this.inputConsolidator       = inputConsolidator;
        }
コード例 #17
0
        public FederationWalletSyncManager(ILoggerFactory loggerFactory, IFederationWalletManager walletManager, ChainIndexer chain,
                                           Network network, IBlockStore blockStore, StoreSettings storeSettings, INodeLifetime nodeLifetime)
        {
            Guard.NotNull(loggerFactory, nameof(loggerFactory));
            Guard.NotNull(walletManager, nameof(walletManager));
            Guard.NotNull(chain, nameof(chain));
            Guard.NotNull(network, nameof(network));
            Guard.NotNull(blockStore, nameof(blockStore));
            Guard.NotNull(storeSettings, nameof(storeSettings));
            Guard.NotNull(nodeLifetime, nameof(nodeLifetime));

            this.walletManager = walletManager;
            this.chain         = chain;
            this.blockStore    = blockStore;
            this.coinType      = (CoinType)network.Consensus.CoinType;
            this.storeSettings = storeSettings;
            this.nodeLifetime  = nodeLifetime;
            this.logger        = loggerFactory.CreateLogger("Impleum.Bitcoin.FullNode");
            this.blocksQueue   = new AsyncQueue <Block>(this.OnProcessBlockAsync);

            this.blocksQueueSize = 0;
        }
コード例 #18
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)
            });
        }
コード例 #19
0
        public FederationWalletSyncManager(ILoggerFactory loggerFactory, IFederationWalletManager walletManager, ChainIndexer chain,
                                           Network network, IBlockStore blockStore, StoreSettings storeSettings, INodeLifetime nodeLifetime, IAsyncProvider asyncProvider)
        {
            Guard.NotNull(loggerFactory, nameof(loggerFactory));
            Guard.NotNull(walletManager, nameof(walletManager));
            Guard.NotNull(chain, nameof(chain));
            Guard.NotNull(network, nameof(network));
            Guard.NotNull(blockStore, nameof(blockStore));
            Guard.NotNull(storeSettings, nameof(storeSettings));
            Guard.NotNull(nodeLifetime, nameof(nodeLifetime));
            Guard.NotNull(asyncProvider, nameof(asyncProvider));

            this.walletManager       = walletManager;
            this.chain               = chain;
            this.blockStore          = blockStore;
            this.coinType            = (CoinType)network.Consensus.CoinType;
            this.storeSettings       = storeSettings;
            this.nodeLifetime        = nodeLifetime;
            this.asyncProvider       = asyncProvider;
            this.logger              = loggerFactory.CreateLogger("Impleum.Bitcoin.Fullnode");
            this.blockQueueProcessor = new BlockQueueProcessor(this.logger, this.asyncProvider, this.OnProcessBlockWrapperAsync, MaxQueueSize, nameof(FederationWalletSyncManager));
        }
コード例 #20
0
        /// <summary>
        /// Create the wallet manager and wallet transaction handler.
        /// </summary>
        /// <param name="dataFolder">The data folder.</param>
        protected void Init(DataFolder dataFolder)
        {
            this.dataFolder = dataFolder;

            // Create the wallet manager.
            this.federationWalletManager = new FederationWalletManager(
                this.loggerFactory,
                this.network,
                this.chain,
                dataFolder,
                this.walletFeePolicy,
                this.asyncLoopFactory,
                new NodeLifetime(),
                this.dateTimeProvider,
                this.federationGatewaySettings,
                this.withdrawalExtractor);

            // Starts and creates the wallet.
            this.federationWalletManager.Start();
            this.wallet = this.federationWalletManager.GetWallet();
            this.federationWalletTransactionHandler = new FederationWalletTransactionHandler(this.loggerFactory, this.federationWalletManager, this.walletFeePolicy, this.network);

            var storeSettings = (StoreSettings)FormatterServices.GetUninitializedObject(typeof(StoreSettings));

            this.federationWalletSyncManager = new FederationWalletSyncManager(this.loggerFactory, this.federationWalletManager, this.chain, this.network,
                                                                               this.blockRepository, storeSettings, Substitute.For <INodeLifetime>());

            this.federationWalletSyncManager.Start();

            // Set up the encrypted seed on the wallet.
            string encryptedSeed = this.extendedKey.PrivateKey.GetEncryptedBitcoinSecret(walletPassword, this.network).ToWif();

            this.wallet.EncryptedSeed = encryptedSeed;

            this.federationWalletManager.Secret = new WalletSecret()
            {
                WalletPassword = walletPassword
            };
        }
コード例 #21
0
        public FederatedPegFeature(
            IConnectionManager connectionManager,
            IFederatedPegSettings federatedPegSettings,
            IFullNode fullNode,
            IFederationWalletManager federationWalletManager,
            IFederationWalletSyncManager walletSyncManager,
            Network network,
            INodeStats nodeStats,
            ICrossChainTransferStore crossChainTransferStore,
            IPartialTransactionRequester partialTransactionRequester,
            MempoolCleaner mempoolCleaner,
            ISignedMultisigTransactionBroadcaster signedBroadcaster,
            IMaturedBlocksSyncManager maturedBlocksSyncManager,
            IInputConsolidator inputConsolidator,
            ICollateralChecker collateralChecker = null)
        {
            this.connectionManager       = connectionManager;
            this.federatedPegSettings    = federatedPegSettings;
            this.fullNode                = fullNode;
            this.federationWalletManager = federationWalletManager;
            this.walletSyncManager       = walletSyncManager;
            this.network = network;
            this.crossChainTransferStore     = crossChainTransferStore;
            this.partialTransactionRequester = partialTransactionRequester;
            this.mempoolCleaner           = mempoolCleaner;
            this.maturedBlocksSyncManager = maturedBlocksSyncManager;
            this.signedBroadcaster        = signedBroadcaster;
            this.inputConsolidator        = inputConsolidator;

            this.logger = LogManager.GetCurrentClassLogger();

            // add our payload
            var payloadProvider = (PayloadProvider)this.fullNode.Services.ServiceProvider.GetService(typeof(PayloadProvider));

            payloadProvider.AddPayload(typeof(RequestPartialTransactionPayload));

            nodeStats.RegisterStats(this.AddComponentStats, StatsType.Component, this.GetType().Name);
        }
コード例 #22
0
        public FederationGatewayFeature(
            ILoggerFactory loggerFactory,
            IConnectionManager connectionManager,
            IFederationGatewaySettings federationGatewaySettings,
            IFullNode fullNode,
            IFederationWalletManager federationWalletManager,
            IFederationWalletSyncManager walletSyncManager,
            Network network,
            ConcurrentChain chain,
            INodeStats nodeStats,
            ICrossChainTransferStore crossChainTransferStore,
            IPartialTransactionRequester partialTransactionRequester,
            IMaturedBlocksSyncManager maturedBlocksSyncManager,
            IWithdrawalHistoryProvider withdrawalHistoryProvider)
        {
            this.loggerFactory             = loggerFactory;
            this.connectionManager         = connectionManager;
            this.federationGatewaySettings = federationGatewaySettings;
            this.fullNode = fullNode;
            this.chain    = chain;
            this.federationWalletManager = federationWalletManager;
            this.walletSyncManager       = walletSyncManager;
            this.network = network;
            this.crossChainTransferStore     = crossChainTransferStore;
            this.partialTransactionRequester = partialTransactionRequester;
            this.maturedBlocksSyncManager    = maturedBlocksSyncManager;
            this.withdrawalHistoryProvider   = withdrawalHistoryProvider;

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

            // add our payload
            var payloadProvider = (PayloadProvider)this.fullNode.Services.ServiceProvider.GetService(typeof(PayloadProvider));

            payloadProvider.AddPayload(typeof(RequestPartialTransactionPayload));

            nodeStats.RegisterStats(this.AddComponentStats, StatsType.Component);
            nodeStats.RegisterStats(this.AddInlineStats, StatsType.Inline, 800);
        }
コード例 #23
0
        public PartialTransactionsBehavior(
            ILoggerFactory loggerFactory,
            IFederationWalletManager federationWalletManager,
            Network network,
            IFederatedPegSettings federatedPegSettings,
            ICrossChainTransferStore crossChainTransferStore,
            IInputConsolidator inputConsolidator)
        {
            Guard.NotNull(loggerFactory, nameof(loggerFactory));
            Guard.NotNull(federationWalletManager, nameof(federationWalletManager));
            Guard.NotNull(network, nameof(network));
            Guard.NotNull(federatedPegSettings, nameof(federatedPegSettings));
            Guard.NotNull(crossChainTransferStore, nameof(crossChainTransferStore));

            this.logger                  = loggerFactory.CreateLogger("Impleum.Bitcoin.Fullnode");
            this.loggerFactory           = loggerFactory;
            this.federationWalletManager = federationWalletManager;
            this.network                 = network;
            this.federatedPegSettings    = federatedPegSettings;
            this.crossChainTransferStore = crossChainTransferStore;
            this.ipAddressComparer       = new IPAddressComparer();
            this.inputConsolidator       = inputConsolidator;
        }
コード例 #24
0
        public WithdrawalTransactionBuilder(
            Network network,
            IFederationWalletManager federationWalletManager,
            IFederationWalletTransactionHandler federationWalletTransactionHandler,
            IFederatedPegSettings federatedPegSettings,
            ISignals signals,
            IRewardDistributionManager distributionManager = null)
        {
            this.logger  = LogManager.GetCurrentClassLogger();
            this.network = network;
            this.federationWalletManager            = federationWalletManager;
            this.federationWalletTransactionHandler = federationWalletTransactionHandler;
            this.federatedPegSettings = federatedPegSettings;
            this.signals             = signals;
            this.distributionManager = distributionManager;

            if (!this.federatedPegSettings.IsMainChain)
            {
                this.cirrusRewardDummyAddressScriptPubKey = BitcoinAddress.Create(this.network.CirrusRewardDummyAddress).ScriptPubKey;
            }

            this.previousDistributionHeight = 0;
        }
コード例 #25
0
        public FederationWalletControllerTests()
        {
            this.loggerFactory     = Substitute.For <ILoggerFactory>();
            this.walletManager     = Substitute.For <IFederationWalletManager>();
            this.walletSyncManager = Substitute.For <IFederationWalletSyncManager>();
            this.connectionManager = Substitute.For <IConnectionManager>();
            this.network           = new StratisTest();

            this.chainIndexer = new ChainIndexer(this.network);

            ChainedHeader tip = ChainedHeadersHelper.CreateConsecutiveHeaders(100, ChainedHeadersHelper.CreateGenesisChainedHeader(this.network), true, null, this.network).Last();

            this.chainIndexer.SetTip(tip);


            this.dateTimeProvider          = Substitute.For <IDateTimeProvider>();
            this.withdrawalHistoryProvider = Substitute.For <IWithdrawalHistoryProvider>();

            this.controller = new FederationWalletController(this.loggerFactory, this.walletManager, this.walletSyncManager,
                                                             this.connectionManager, this.network, this.chainIndexer, this.dateTimeProvider, this.withdrawalHistoryProvider);

            this.fedWallet         = new FederationWallet();
            this.fedWallet.Network = this.network;
            this.fedWallet.LastBlockSyncedHeight = 999;
            this.fedWallet.CreationTime          = DateTimeOffset.Now;

            this.walletManager.GetWallet().Returns(this.fedWallet);

            var          federationWalletManager = (FederationWalletManager)FormatterServices.GetUninitializedObject(typeof(FederationWalletManager));
            PropertyInfo lockProp = typeof(LockProtected).GetProperty("lockObject", BindingFlags.NonPublic | BindingFlags.Instance);

            lockProp.SetValue(federationWalletManager, new object());
            federationWalletManager.Wallet = this.fedWallet;
            this.walletManager.GetSpendableAmount().Returns((x) => {
                return(federationWalletManager.GetSpendableAmount());
            });
        }
コード例 #26
0
        public FederationGatewayFeature(
            ILoggerFactory loggerFactory,
            ICrossChainTransactionMonitor crossChainTransactionMonitor,
            Signals signals,
            IConnectionManager connectionManager,
            FederationGatewaySettings federationGatewaySettings,
            IFullNode fullNode,
            IFederationWalletManager federationWalletManager,
            IFederationWalletSyncManager walletSyncManager,
            Network network,
            ConcurrentChain chain,
            IMonitorChainSessionManager monitorChainSessionManager,
            ICounterChainSessionManager counterChainSessionManager,
            INodeStats nodeStats)
        {
            this.loggerFactory = loggerFactory;
            this.crossChainTransactionMonitor = crossChainTransactionMonitor;
            this.signals                   = signals;
            this.connectionManager         = connectionManager;
            this.federationGatewaySettings = federationGatewaySettings;
            this.fullNode                  = fullNode;
            this.chain = chain;
            this.federationWalletManager = federationWalletManager;
            this.walletSyncManager       = walletSyncManager;
            this.network = network;

            this.counterChainSessionManager = counterChainSessionManager;
            this.monitorChainSessionManager = monitorChainSessionManager;

            // add our payload
            var payloadProvider = (PayloadProvider)this.fullNode.Services.ServiceProvider.GetService(typeof(PayloadProvider));

            payloadProvider.AddPayload(typeof(RequestPartialTransactionPayload));

            nodeStats.RegisterStats(this.AddComponentStats, StatsType.Component);
            nodeStats.RegisterStats(this.AddInlineStats, StatsType.Inline, 800);
        }
コード例 #27
0
        public PartialTransactionRequester(
            ILoggerFactory loggerFactory,
            ICrossChainTransferStore crossChainTransferStore,
            IAsyncProvider asyncProvider,
            INodeLifetime nodeLifetime,
            IFederatedPegBroadcaster federatedPegBroadcaster,
            IInitialBlockDownloadState ibdState,
            IFederationWalletManager federationWalletManager,
            IInputConsolidator inputConsolidator)
        {
            Guard.NotNull(loggerFactory, nameof(loggerFactory));
            Guard.NotNull(crossChainTransferStore, nameof(crossChainTransferStore));
            Guard.NotNull(asyncProvider, nameof(asyncProvider));
            Guard.NotNull(nodeLifetime, nameof(nodeLifetime));

            this.logger = loggerFactory.CreateLogger(this.GetType().FullName);
            this.crossChainTransferStore = crossChainTransferStore;
            this.asyncProvider           = asyncProvider;
            this.nodeLifetime            = nodeLifetime;
            this.ibdState = ibdState;
            this.federatedPegBroadcaster = federatedPegBroadcaster;
            this.federationWalletManager = federationWalletManager;
            this.inputConsolidator       = inputConsolidator;
        }
        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)
            });
        }
コード例 #29
0
 public FederationGatewayController(
     IAsyncProvider asyncProvider,
     ChainIndexer chainIndexer,
     IConnectionManager connectionManager,
     ICrossChainTransferStore crossChainTransferStore,
     IMaturedBlocksProvider maturedBlocksProvider,
     Network network,
     IFederatedPegSettings federatedPegSettings,
     IFederationWalletManager federationWalletManager,
     IFullNode fullNode,
     IFederationManager federationManager = null)
 {
     this.asyncProvider           = asyncProvider;
     this.chainIndexer            = chainIndexer;
     this.connectionManager       = connectionManager;
     this.crossChainTransferStore = crossChainTransferStore;
     this.federatedPegSettings    = federatedPegSettings;
     this.federationWalletManager = federationWalletManager;
     this.federationManager       = federationManager;
     this.fullNode = fullNode;
     this.logger   = LogManager.GetCurrentClassLogger();
     this.maturedBlocksProvider = maturedBlocksProvider;
     this.network = network;
 }
コード例 #30
0
        public FederationWalletSyncManager(ILoggerFactory loggerFactory, IFederationWalletManager walletManager, ChainIndexer chain,
                                           Network network, IBlockStore blockStore, StoreSettings storeSettings, INodeLifetime nodeLifetime, IAsyncProvider asyncProvider)
        {
            Guard.NotNull(loggerFactory, nameof(loggerFactory));
            Guard.NotNull(walletManager, nameof(walletManager));
            Guard.NotNull(chain, nameof(chain));
            Guard.NotNull(network, nameof(network));
            Guard.NotNull(blockStore, nameof(blockStore));
            Guard.NotNull(storeSettings, nameof(storeSettings));
            Guard.NotNull(nodeLifetime, nameof(nodeLifetime));
            Guard.NotNull(asyncProvider, nameof(asyncProvider));

            this.walletManager = walletManager;
            this.chain         = chain;
            this.blockStore    = blockStore;
            this.coinType      = (CoinType)network.Consensus.CoinType;
            this.storeSettings = storeSettings;
            this.nodeLifetime  = nodeLifetime;
            this.asyncProvider = asyncProvider;
            this.logger        = loggerFactory.CreateLogger(this.GetType().FullName);
            this.blocksQueue   = asyncProvider.CreateAndRunAsyncDelegateDequeuer <Block>($"{nameof(FederationWalletSyncManager)}-{nameof(this.blocksQueue)}", this.OnProcessBlockAsync);

            this.blocksQueueSize = 0;
        }