Exemple #1
0
        public JsonResult saveWalletID(string walletID)
        {
            var isValid = BlockApi.validateAddress(walletID);

            if (isValid == false)
            {
                return(Json("failed", JsonRequestBehavior.AllowGet));
            }
            string          transID    = Session["transID"].ToString();
            AzureConnection db         = new AzureConnection();
            trans_history   trans_data = db.trans_history.Where(a => a.id.ToString() == transID).FirstOrDefault();

            trans_data.buyerWallet = walletID;
            Session["buyerWallet"] = walletID;
            db.SaveChanges();
            return(Json("success", JsonRequestBehavior.AllowGet));
        }
Exemple #2
0
 /// <summary>
 ///   Creates a new instance of the <see cref="IpfsEngine"/> class.
 /// </summary>
 public IpfsEngine()
 {
     // Init the core api inteface.
     Bitswap    = new BitswapApi(this);
     Block      = new BlockApi(this);
     Config     = new ConfigApi(this);
     Dag        = new DagApi(this);
     Dht        = new DhtApi(this);
     FileSystem = new FileSystemApi(this);
     Generic    = new GenericApi(this);
     Key        = new KeyApi(this);
     Name       = new NameApi(this);
     Object     = new ObjectApi(this);
     Pin        = new PinApi(this);
     PubSub     = new PubSubApi(this);
     Swarm      = new SwarmApi(this);
 }
Exemple #3
0
        void Init()
        {
            // Init the core api inteface.
            Bitswap         = new BitswapApi(this);
            Block           = new BlockApi(this);
            BlockRepository = new BlockRepositoryApi(this);
            Bootstrap       = new BootstrapApi(this);
            Config          = new ConfigApi(this);
            Dag             = new DagApi(this);
            Dht             = new DhtApi(this);
            Dns             = new DnsApi(this);
            FileSystem      = new FileSystemApi(this);
            Generic         = new GenericApi(this);
            Key             = new KeyApi(this);
            Name            = new NameApi(this);
            Object          = new ObjectApi(this);
            Pin             = new PinApi(this);
            PubSub          = new PubSubApi(this);
            Stats           = new StatsApi(this);
            Swarm           = new SwarmApi(this);

            // Async properties
            LocalPeer = new AsyncLazy <Peer>(async() =>
            {
                log.Debug("Building local peer");
                var keyChain = await KeyChain().ConfigureAwait(false);
                log.Debug("Getting key info about self");
                var self      = await keyChain.FindKeyByNameAsync("self").ConfigureAwait(false);
                var localPeer = new Peer
                {
                    Id              = self.Id,
                    PublicKey       = await keyChain.GetPublicKeyAsync("self").ConfigureAwait(false),
                    ProtocolVersion = "ipfs/0.1.0"
                };
                var version            = typeof(IpfsEngine).GetTypeInfo().Assembly.GetName().Version;
                localPeer.AgentVersion = $"net-ipfs/{version.Major}.{version.Minor}.{version.Revision}";
                log.Debug("Built local peer");
                return(localPeer);
            });
            SwarmService = new AsyncLazy <Swarm>(async() =>
            {
                log.Debug("Building swarm service");
                if (Options.Swarm.PrivateNetworkKey == null)
                {
                    var path = Path.Combine(Options.Repository.Folder, "swarm.key");
                    if (File.Exists(path))
                    {
                        using (var x = File.OpenText(path))
                        {
                            Options.Swarm.PrivateNetworkKey = new PreSharedKey();
                            Options.Swarm.PrivateNetworkKey.Import(x);
                        }
                    }
                }
                var peer     = await LocalPeer.ConfigureAwait(false);
                var keyChain = await KeyChain().ConfigureAwait(false);
                var self     = await keyChain.GetPrivateKeyAsync("self").ConfigureAwait(false);
                var swarm    = new Swarm
                {
                    LocalPeer        = peer,
                    LocalPeerKey     = PeerTalk.Cryptography.Key.CreatePrivateKey(self),
                    NetworkProtector = Options.Swarm.PrivateNetworkKey == null
                        ? null
                        : new Psk1Protector {
                        Key = Options.Swarm.PrivateNetworkKey
                    }
                };
                if (Options.Swarm.PrivateNetworkKey != null)
                {
                    log.Debug($"Private network {Options.Swarm.PrivateNetworkKey.Fingerprint().ToHexString()}");
                }

                log.Debug("Built swarm service");
                return(swarm);
            });
            BitswapService = new AsyncLazy <BlockExchange.Bitswap>(async() =>
            {
                log.Debug("Building bitswap service");
                var bitswap = new BlockExchange.Bitswap
                {
                    Swarm        = await SwarmService.ConfigureAwait(false),
                    BlockService = Block
                };
                log.Debug("Built bitswap service");
                return(bitswap);
            });
            DhtService = new AsyncLazy <PeerTalk.Routing.Dht1>(async() =>
            {
                log.Debug("Building DHT service");
                var dht = new PeerTalk.Routing.Dht1
                {
                    Swarm = await SwarmService.ConfigureAwait(false)
                };
                dht.Swarm.Router = dht;
                log.Debug("Built DHT service");
                return(dht);
            });
            PubSubService = new AsyncLazy <PeerTalk.PubSub.NotificationService>(async() =>
            {
                log.Debug("Building PubSub service");
                var pubsub = new PeerTalk.PubSub.NotificationService
                {
                    LocalPeer = await LocalPeer.ConfigureAwait(false)
                };
                pubsub.Routers.Add(new PeerTalk.PubSub.FloodRouter
                {
                    Swarm = await SwarmService.ConfigureAwait(false)
                });
                log.Debug("Built PubSub service");
                return(pubsub);
            });
        }
Exemple #4
0
        void Init()
        {
            // Init the core api inteface.
            Bitswap    = new BitswapApi(this);
            Block      = new BlockApi(this);
            Bootstrap  = new BootstrapApi(this);
            Config     = new ConfigApi(this);
            Dag        = new DagApi(this);
            Dht        = new DhtApi(this);
            Dns        = new DnsApi(this);
            FileSystem = new FileSystemApi(this);
            Generic    = new GenericApi(this);
            Key        = new KeyApi(this);
            Name       = new NameApi(this);
            Object     = new ObjectApi(this);
            Pin        = new PinApi(this);
            PubSub     = new PubSubApi(this);
            Stats      = new StatsApi(this);
            Swarm      = new SwarmApi(this);

            // Async properties
            LocalPeer = new AsyncLazy <Peer>(async() =>
            {
                log.Debug("Building local peer");
                var keyChain = await KeyChain();
                log.Debug("Getting key info about self");
                var self                  = await keyChain.FindKeyByNameAsync("self");
                var localPeer             = new Peer();
                localPeer.Id              = self.Id;
                localPeer.PublicKey       = await keyChain.GetPublicKeyAsync("self");
                localPeer.ProtocolVersion = "ipfs/0.1.0";
                var version               = typeof(IpfsEngine).GetTypeInfo().Assembly.GetName().Version;
                localPeer.AgentVersion    = $"net-ipfs/{version.Major}.{version.Minor}.{version.Revision}";
                log.Debug("Built local peer");
                return(localPeer);
            });
            SwarmService = new AsyncLazy <Swarm>(async() =>
            {
                log.Debug("Building swarm service");
                var peer     = await LocalPeer;
                var keyChain = await KeyChain();
                var self     = await keyChain.GetPrivateKeyAsync("self");
                var swarm    = new Swarm
                {
                    LocalPeer    = peer,
                    LocalPeerKey = PeerTalk.Cryptography.Key.CreatePrivateKey(self)
                };
                log.Debug("Built swarm service");
                return(swarm);
            });
            BitswapService = new AsyncLazy <BlockExchange.Bitswap>(async() =>
            {
                log.Debug("Building bitswap service");
                var bitswap = new BlockExchange.Bitswap
                {
                    Swarm        = await SwarmService,
                    BlockService = Block
                };
                log.Debug("Built bitswap service");
                return(bitswap);
            });
            DhtService = new AsyncLazy <PeerTalk.Routing.Dht1>(async() =>
            {
                log.Debug("Building DHT service");
                var dht = new PeerTalk.Routing.Dht1
                {
                    Swarm = await SwarmService
                };
                dht.Swarm.Router = dht;
                log.Debug("Built DHT service");
                return(dht);
            });
        }
 public void Init()
 {
     instance = new BlockApi();
 }
Exemple #6
0
        public ActionResult sendEmailToOpp()
        {
            try
            {
                trans_history   data      = new trans_history();
                string          email     = Session["email"].ToString();
                AzureConnection db        = new AzureConnection();
                user_table      user_data = db.user_table.Where(a => a.email == email).FirstOrDefault();
                if (Session["user_type"].ToString() == "new_buyer" || Session["user_type"].ToString() == "old_buyer")
                {
                    data.buyer = user_data.id;
                    email      = Session["sellerEmail"].ToString();
                    user_table seller = db.user_table.Where(a => a.email == email).FirstOrDefault();
                    Session["sellerName"] = seller.username;
                    data.seller           = seller.id;
                }
                else
                {
                    data.seller = user_data.id;
                    email       = Session["buyerEmail"].ToString();
                    user_table buyer = db.user_table.Where(a => a.email == email).FirstOrDefault();
                    Session["buyerName"] = buyer.username;
                    data.buyer           = buyer.id;
                }

                data.btc         = double.Parse(Session["btc_amount"].ToString(), CultureInfo.InvariantCulture.NumberFormat);
                data.cash        = double.Parse(Session["cash"].ToString(), CultureInfo.InvariantCulture.NumberFormat);
                data.REFERENCE   = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 10).ToUpper();
                data.status      = "pending";
                data.holdBTC     = false;
                data.sentBTC     = false;
                data.sentCash    = false;
                data.recieveCash = false;
                data.holdAmount  = 0;
                data.holdWallet  = BlockApi.getNewAddressWithRandom();
                db.trans_history.Add(data);
                db.SaveChanges();
                Session["holdWallet"] = data.holdWallet;
                Session["transID"]    = data.id;
                var         fromEmail = new MailAddress(WebConfigurationManager.AppSettings.Get("siteEmail"), "Lyohai");
                MailAddress toEmail;
                var         fromEmailPassword = WebConfigurationManager.AppSettings.Get("EmailPassword");
                string      subject           = "TRUSTBTC to you";
                string      body;
                if (Session["user_type"].ToString() == "new_buyer" || Session["user_type"].ToString() == "old_buyer")
                {
                    string proceed_link = Request.Url.AbsoluteUri.Replace(Request.Url.PathAndQuery, "/Contract/proceed?" + "userID=" + data.seller + "&transID=" + data.id);
                    toEmail = new MailAddress(data.user_seller.email);
                    body    = "Dear " + Session["sellerName"] + "<br/><br/>" +
                              "One of our members," + Session["username"].ToString() + " will pay you " + "<b>$" + Session["cash"].ToString() + "</b>, if you agree to pay <b>" + Session["btc_amount"].ToString() + "BTC</b>.We will handle all process and secure a smooth transaction for you, in 3 very easy steps." + "<br/><br/>If you are interested to proceed with this transaction, please click the botton below.<br/><br/> <a href='" + proceed_link + "'>" + "Proceed </a>";
                }
                else
                {
                    toEmail = new MailAddress(data.user_buyer.email);
                    string proceed_link = Request.Url.AbsoluteUri.Replace(Request.Url.PathAndQuery, "/Contract/proceed?" + "userID=" + data.buyer + "&transID=" + data.id);
                    body = "Dear " + Session["buyerName"] + "<br/><br/>" +
                           "One of our members," + Session["username"].ToString() + " will pay you " + "<b>" + Session["btc_amount"].ToString() + "BTC</b>, if you agree to pay <b>$" + Session["cash"].ToString() + "</b>.We will handle all process and secure a smooth transaction for you, in 3 very easy steps." + "<br/><br/>If you are interested to proceed with this transaction, please click the botton below.<br/><br/> <a href='" + proceed_link + "'>" + "Proceed </a>";
                }

                var smtp = new SmtpClient
                {
                    Host                  = "smtp-mail.outlook.com",
                    Port                  = 587,
                    EnableSsl             = true,
                    DeliveryMethod        = SmtpDeliveryMethod.Network,
                    UseDefaultCredentials = false,
                    Credentials           = new NetworkCredential(fromEmail.Address, fromEmailPassword)
                };
                using (var message = new MailMessage(fromEmail, toEmail)
                {
                    Subject = subject,
                    Body = body,
                    IsBodyHtml = true
                })
                {
                    smtp.Send(message);
                }
                return(RedirectToAction("googleAuthPage", "Verify"));
            }
            catch
            {
                return(RedirectToAction("Index", "Home"));
            }
        }