示例#1
0
        private static async Task RunAsync(IConfigurationRoot configuration)
        {
            var bitGoClient = new BitGoClient(BitGoNetwork.Main);//, configuration["Token"]
            var user        = await bitGoClient.User.LoginAsync(Console.ReadLine(), Console.ReadLine(), Console.ReadLine());

            bitGoClient.SetAccessToken(user.AccessToken);
            await bitGoClient.User.UnlockAsync(Console.ReadLine());

            return;

            // var encrypted = bitGoClient.Encrypt(new NBitcoin.ExtKey().GetWif(NBitcoin.Network.Main).ToString(), "Asdfasdfasdf!!");
            // var decrypted = bitGoClient.Decrypt(encrypted, "Asdfasdfasdf!!");
            // Console.WriteLine(encrypted);
            // Console.WriteLine(decrypted);
            // return;
            // var user = await bitGoClient.User.LoginAsync(Console.ReadLine(), Console.ReadLine(), Console.ReadLine());
            // bitGoClient.SetAccessToken(user.AccessToken);
            // await bitGoClient.User.UnlockAsync(Console.ReadLine());
            // var session = await bitGoClient.Users.GetSessionAsync();
            // Console.WriteLine(session.Client);
            var keychains = await bitGoClient.Keychains.GetListAsync();

            // Console.WriteLine(wallets.Start);
            // Console.WriteLine(wallets.Count);
            // Console.WriteLine(wallets.Total);
            foreach (var k in keychains.Keychains)
            {
                // Console.WriteLine(k.ExtendedPublicKey);
                Console.WriteLine((await bitGoClient.Keychains.GetAsync(k.ExtendedPublicKey)).EncryptedExtendedPrivateKey);
            }
        }
示例#2
0
        public IBitGoApi GetByUser(string brokerId, string userId, string coinId, string newApiKey)
        {
            var bitGoUser = _bitgoUserReader.Get(
                BitGoUserNoSqlEntity.GeneratePartitionKey(brokerId),
                BitGoUserNoSqlEntity.GenerateRowKey(BitGoUserNoSqlEntity.TechSignerId,
                                                    coinId)) ??
                            _bitgoUserReader.Get(
                BitGoUserNoSqlEntity.GeneratePartitionKey(brokerId),
                BitGoUserNoSqlEntity.GenerateRowKey(BitGoUserNoSqlEntity.TechSignerId,
                                                    BitGoUserNoSqlEntity.DefaultCoin));

            var apiKeyEnc = bitGoUser?.User?.ApiKey;

            if (string.IsNullOrEmpty(apiKeyEnc) && string.IsNullOrEmpty(newApiKey))
            {
                _logger.LogError("Tech account is not configured, id = {techSignerName}",
                                 BitGoUserNoSqlEntity.TechSignerId);
                return(null);
            }

            lock (_clients)
            {
                if (!string.IsNullOrEmpty(apiKeyEnc) && _clients.TryGetValue(apiKeyEnc, out var api))
                {
                    return(api);
                }
            }

            var coin = _bitgoCointReader.Get(BitgoCoinEntity.GeneratePartitionKey(),
                                             BitgoCoinEntity.GenerateRowKey(coinId));

            if (coin == null)
            {
                _logger.LogError("Cannot fond bitgo coin id = {symbol}", coinId);
                return(null);
            }

            var apiKey = string.IsNullOrEmpty(apiKeyEnc) ? newApiKey : _encryptionService.Decrypt(apiKeyEnc);

            var client = new BitGoClient(
                apiKey, Program.Settings.BitgoExpressUrlMainNet,
                apiKey, Program.Settings.BitgoExpressUrlTestNet);

            lock (_clients)
            {
                _clients[apiKey] = coin.IsMainNet ? client.MainNet : client.TestNet;
                return(_clients[apiKey]);
            }
        }
 internal WalletAddressService(BitGoClient client) : base(client, "walletaddress")
 {
 }
示例#4
0
 internal PendingApprovalService(BitGoClient client) : base(client, "pendingapprovals")
 {
 }
示例#5
0
 internal TransactionService(BitGoClient client) : base(client, "tx")
 {
 }
示例#6
0
 internal WalletService(BitGoClient client) : base(client, "wallet")
 {
 }
示例#7
0
 internal WebhookService(BitGoClient client) : base(client, "webhooks")
 {
 }
示例#8
0
 internal UserService(BitGoClient client) : base(client, "user")
 {
 }
示例#9
0
 internal LabelService(BitGoClient client) : base(client, "labels")
 {
 }
示例#10
0
        protected override void Load(ContainerBuilder builder)
        {
            var myNoSqlClient = builder.CreateNoSqlClient(Program.ReloadedSettings(e => e.MyNoSqlReaderHostPort));

            builder
            .RegisterAssetsDictionaryClients(myNoSqlClient);

            builder
            .RegisterSpotChangeBalanceGatewayClient(Program.Settings.ChangeBalanceGatewayGrpcServiceUrl);

            var bitgoClient =
                new BitGoClient(
                    Program.Settings.BitgoAccessTokenMainNet, Program.Settings.BitgoExpressUrlMainNet,
                    Program.Settings.BitgoAccessTokenTestNet, Program.Settings.BitgoExpressUrlTestNet);

            builder
            .RegisterInstance(bitgoClient)
            .As <IBitGoClient>()
            .SingleInstance();

            builder.RegisterBitgoSettingsReader(myNoSqlClient);

            ServiceBusLogger = Program.LogFactory.CreateLogger(nameof(MyServiceBusTcpClient));

            var serviceBusClient = builder.RegisterMyServiceBusTcpClient(
                Program.ReloadedSettings(e => e.SpotServiceBusHostPort),
                Program.LogFactory);

            builder.RegisterSignalBitGoTransferSubscriber(serviceBusClient, "Bitgo-DepositDetector",
                                                          TopicQueueType.Permanent);

            builder.RegisterSignalCircleTransferSubscriber(serviceBusClient, "Bitgo-DepositDetector",
                                                           TopicQueueType.Permanent);

            builder.RegisterMyServiceBusPublisher <Deposit>(serviceBusClient, Deposit.TopicName, false);

            builder.RegisterMyServiceBusSubscriberSingle <FireblocksDepositSignal>(serviceBusClient, Topics.FireblocksDepositSignalTopic,
                                                                                   "Bitgo-DepositDetector",
                                                                                   TopicQueueType.Permanent);

            builder
            .RegisterType <SignalBitGoTransferJob>()
            .AutoActivate()
            .SingleInstance();
            builder
            .RegisterType <SignalCircleTransferJob>()
            .AutoActivate()
            .SingleInstance();

            builder
            .RegisterType <FireblocksSignalDepositJob>()
            .AutoActivate()
            .SingleInstance();

            builder
            .RegisterType <BitgoDepositTransferProcessService>()
            .As <IBitgoDepositTransferProcessService>();

            builder
            .RegisterType <CircleDepositTransferProcessService>()
            .As <ICircleDepositTransferProcessService>();

            builder
            .RegisterType <FireblocksDepositProcessingService>()
            .AsSelf();

            builder.RegisterBitgoSettingsWriter(Program.ReloadedSettings(e => e.MyNoSqlWriterUrl));

            builder.RegisterMyNoSqlWriter <DepositAddressEntity>(
                Program.ReloadedSettings(e => e.MyNoSqlWriterUrl), DepositAddressEntity.TableName, true);
            builder.RegisterMyNoSqlWriter <BlockchainDepositAddressEntity>(
                Program.ReloadedSettings(e => e.MyNoSqlWriterUrl), BlockchainDepositAddressEntity.TableName);

            builder
            .RegisterMyNoSqlWriter <GeneratedDepositAddressEntity>(Program.ReloadedSettings(e => e.MyNoSqlWriterUrl), GeneratedDepositAddressEntity.TableName, true);

            builder
            .RegisterType <DepositsProcessingJob>()
            .AutoActivate()
            .SingleInstance()
            .AsSelf();

            builder
            .RegisterType <BitGoDepositAddressesGenerationJob>()
            .AutoActivate()
            .SingleInstance()
            .AsSelf();

            builder
            .RegisterType <DepositAddressGeneratorService>()
            .SingleInstance()
            .AsSelf();

            builder.RegisterCirclePaymentsClient(Program.Settings.CircleSignerGrpcServiceUrl);
            builder.RegisterCircleWalletsClient(myNoSqlClient, Program.Settings.CircleWalletsGrpcServiceUrl);
            builder.RegisterCircleSettingsReader(myNoSqlClient);
            builder.RegisterCircleSettingsWriter(Program.ReloadedSettings(e => e.MyNoSqlWriterUrl));
            builder.RegisterCircleDepositAddressClient(Program.Settings.CircleSignerGrpcServiceUrl);
            builder.RegisterAssetPaymentSettingsClients(myNoSqlClient);
        }
示例#11
0
 internal BillingService(BitGoClient client) : base(client, "billing")
 {
 }
示例#12
0
 internal InstantService(BitGoClient client) : base(client, "instant")
 {
 }
示例#13
0
        protected override void Load(ContainerBuilder builder)
        {
            var myNoSqlClient = builder.CreateNoSqlClient(Program.ReloadedSettings(e => e.MyNoSqlReaderHostPort));

            builder
            .RegisterInstance(myNoSqlClient)
            .AsSelf()
            .SingleInstance();

            builder
            .RegisterAssetsDictionaryClients(myNoSqlClient);

            builder
            .RegisterSpotChangeBalanceGatewayClient(Program.Settings.ChangeBalanceGatewayGrpcServiceUrl);

            var bitgoClient =
                new BitGoClient(
                    Program.Settings.BitgoAccessTokenMainNet, Program.Settings.BitgoExpressUrlMainNet,
                    Program.Settings.BitgoAccessTokenTestNet, Program.Settings.BitgoExpressUrlTestNet);

            builder
            .RegisterInstance(bitgoClient)
            .As <IBitGoClient>()
            .SingleInstance();

            builder.RegisterBitgoSettingsReader(myNoSqlClient);
            builder.RegisterFeesClients(myNoSqlClient);

            builder.RegisterBitGoSignTransactionClient(Program.Settings.BitgoSignTransactionGrpcServiceUrl);

            ServiceBusLogger = Program.LogFactory.CreateLogger(nameof(MyServiceBusTcpClient));

            var serviceBusClient = builder.RegisterMyServiceBusTcpClient(
                Program.ReloadedSettings(e => e.SpotServiceBusHostPort),
                Program.LogFactory);

            serviceBusClient.Log.AddLogException(ex => ServiceBusLogger.LogInformation(ex, "Exception in MyServiceBusTcpClient"));
            serviceBusClient.Log.AddLogInfo(info => ServiceBusLogger.LogDebug($"MyServiceBusTcpClient[info]: {info}"));
            serviceBusClient.SocketLogs.AddLogInfo((context, msg) => ServiceBusLogger.LogInformation($"MyServiceBusTcpClient[Socket {context?.Id}|{context?.ContextName}|{context?.Inited}][Info] {msg}"));
            serviceBusClient.SocketLogs.AddLogException((context, exception) => ServiceBusLogger.LogInformation(exception, $"MyServiceBusTcpClient[Socket {context?.Id}|{context?.ContextName}|{context?.Inited}][Exception] {exception.Message}"));
            builder.RegisterInstance(serviceBusClient).AsSelf().SingleInstance();

            builder.RegisterMyServiceBusSubscriberSingle <WithdrawalVerifiedMessage>(serviceBusClient, WithdrawalVerifiedMessage.TopicName, "Bitgo-WithdrawalProcessor-Verification", TopicQueueType.Permanent);

            builder.RegisterSignalBitGoTransferSubscriber(serviceBusClient, "Bitgo-WithdrawalProcessor", TopicQueueType.Permanent);
            builder.RegisterSignalCircleTransferSubscriber(serviceBusClient, "Bitgo-WithdrawalProcessor", TopicQueueType.Permanent);
            builder.RegisterMyServiceBusPublisher <Withdrawal>(serviceBusClient, Withdrawal.TopicName, false);
            builder.RegisterVerificationCodesClient(Program.Settings.VerificationCodesGrpcUrl);
            //builder.RegisterBitgoDepositAddressClient(Program.Settings.BitgoDepositDetectorGrpcServiceUrl, myNoSqlClient);
            builder.RegisterMyServiceBusSubscriberSingle <FireblocksWithdrawalSignal>(serviceBusClient, Topics.FireblocksWithdrawalSignalTopic,
                                                                                      "Bitgo-WithdrawalProcessor",
                                                                                      TopicQueueType.Permanent);

            var factory = new DepositDetectorClientFactory(Program.Settings.BitgoDepositDetectorGrpcServiceUrl);

            builder.RegisterInstance(factory.GetDepositAddressService()).As <IDepositAddressService>();

            builder.RegisterClientWalletsClients(myNoSqlClient, Program.Settings.ClientWalletsGrpcServiceUrl);
            builder.RegisterAssetPaymentSettingsClients(myNoSqlClient);

            builder.RegisterCirclePaymentsClient(Program.Settings.CircleSignerGrpcServiceUrl);
            builder.RegisterCircleSettingsReader(myNoSqlClient);
            //builder.RegisterBlockchainWalletsClient(Program.Settings.BlockchainWalletsGrpcServiceUrl, myNoSqlClient);

            builder.RegisterIndexPricesClient(myNoSqlClient);

            BlockchainWalletsClientFactory blockchainWalletsClientFactory = new BlockchainWalletsClientFactory(Program.Settings.BlockchainWalletsGrpcServiceUrl);
            var walletService = blockchainWalletsClientFactory.GetWalletService();

            builder.RegisterInstance(walletService).As <IWalletService>().SingleInstance();

            builder.RegisterFireblocksSignerClient(Program.Settings.FireblocksSignerGrpcServiceUrl);

            builder.RegisterInstance(new FireblocksWithdrawalNoteService());

            builder
            .RegisterType <SignalCircleTransferJob>()
            .AutoActivate()
            .SingleInstance();

            builder
            .RegisterType <SignalFireblocksTransferJob>()
            .AutoActivate()
            .SingleInstance();

            builder
            .RegisterType <WithdrawalProcessingJob>()
            .AutoActivate()
            .SingleInstance()
            .AsSelf();

            builder
            .RegisterType <CryptoWithdrawalService>()
            .AutoActivate()
            .SingleInstance()
            .AsSelf();
        }
示例#14
0
 internal KeychainService(BitGoClient client) : base(client, "keychain")
 {
 }
示例#15
0
 internal MarketService(BitGoClient client) : base(client, "market")
 {
 }
示例#16
0
 internal WalletItemService(BitGoClient client, WalletService walletService, string id) : base(client, $"wallet/{id}")
 {
     _walletService = walletService;
     _id            = id;
 }