Ejemplo n.º 1
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);
        }
        public FederationGatewayFeature(
            ILoggerFactory loggerFactory,
            Signals signals,
            IDepositExtractor depositExtractor,
            IWithdrawalExtractor withdrawalExtractor,
            IWithdrawalReceiver withdrawalReceiver,
            IConnectionManager connectionManager,
            IFederationGatewaySettings federationGatewaySettings,
            IFullNode fullNode,
            IFederationWalletManager federationWalletManager,
            IFederationWalletSyncManager walletSyncManager,
            Network network,
            ConcurrentChain chain,
            INodeStats nodeStats,
            ICrossChainTransferStore crossChainTransferStore,
            IPartialTransactionRequester partialTransactionRequester,
            IFederationGatewayClient federationGatewayClient,
            MempoolManager mempoolManager,
            IMaturedBlocksSyncManager maturedBlocksSyncManager,
            IWithdrawalHistoryProvider withdrawalHistoryProvider)
        {
            this.loggerFactory             = loggerFactory;
            this.signals                   = signals;
            this.depositExtractor          = depositExtractor;
            this.withdrawalExtractor       = withdrawalExtractor;
            this.withdrawalReceiver        = withdrawalReceiver;
            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.federationGatewayClient     = federationGatewayClient;
            this.mempoolManager            = mempoolManager;
            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);
        }
Ejemplo n.º 3
0
        private void GetWithdrawalHistory(IWithdrawalHistoryProvider provider, WithdrawalHistoryContext context)
        {
            if (context == null)
            {
                return;
            }

            var r = AsyncContext.Run(() => provider.GetWithdrawalHistoryAsync(context));

            foreach (var historyEntry in r)
            {
                Trace.WriteLine($"{historyEntry.CreatedTimeUtc} {historyEntry.WithdrawalStatus} {historyEntry.WithdrawalRemoteId} {historyEntry.Price.Display}");
            }

            // Assert.IsTrue(r);
        }
Ejemplo n.º 4
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,
            MempoolCleaner mempoolCleaner,
            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.mempoolCleaner            = mempoolCleaner;
            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, this.GetType().Name);
            nodeStats.RegisterStats(this.AddInlineStats, StatsType.Inline, this.GetType().Name, 800);
        }
 public FederationWalletController(
     ILoggerFactory loggerFactory,
     IFederationWalletManager walletManager,
     IFederationWalletSyncManager walletSyncManager,
     IConnectionManager connectionManager,
     Network network,
     ChainIndexer chainIndexer,
     IDateTimeProvider dateTimeProvider,
     IWithdrawalHistoryProvider withdrawalHistoryProvider)
 {
     this.walletManager             = walletManager;
     this.walletSyncManager         = walletSyncManager;
     this.connectionManager         = connectionManager;
     this.withdrawalHistoryProvider = withdrawalHistoryProvider;
     this.coinType     = (CoinType)network.Consensus.CoinType;
     this.chainIndexer = chainIndexer;
     this.logger       = loggerFactory.CreateLogger(this.GetType().FullName);
 }
Ejemplo n.º 6
0
        public FederationGatewayFeature(
            ILoggerFactory loggerFactory,
            IConnectionManager connectionManager,
            IFederationGatewaySettings federationGatewaySettings,
            IFullNode fullNode,
            IFederationWalletManager federationWalletManager,
            IFederationWalletSyncManager walletSyncManager,
            Network network,
            ChainIndexer chainIndexer,
            INodeStats nodeStats,
            ICrossChainTransferStore crossChainTransferStore,
            IPartialTransactionRequester partialTransactionRequester,
            ISignedMultisigTransactionBroadcaster signedBroadcaster,
            IMaturedBlocksSyncManager maturedBlocksSyncManager,
            IWithdrawalHistoryProvider withdrawalHistoryProvider)
        {
            this.loggerFactory             = loggerFactory;
            this.connectionManager         = connectionManager;
            this.federationGatewaySettings = federationGatewaySettings;
            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.logger = loggerFactory.CreateLogger("Impleum.Bitcoin.FullNode");

            // 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);
        }
        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);

            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
            {
                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());
            });
        }