Esempio n. 1
0
        public bool Validate(Timestamp timestamp, out IList <string> errors)
        {
            errors = new List <string>();

            if (timestamp == null)
            {
                return(false);
            }

            var proof = _timestampService.GetProof(timestamp);

            if (proof == null)
            {
                errors.Add("No proof for timestamp was found");
                return(false);
            }

            if (string.IsNullOrEmpty(proof.Address))
            {
                errors.Add("No address was found");
                return(false);
            }

            if (proof.Confirmations < 1)
            {
                errors.Add("No confirmations on blockchain.");
                return(false);
            }

            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// Get a package
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }


            Package = await mediator.Send(new GetPackageCommand { DatabaseID = (int)id });

            if (Package == null)
            {
                return(NotFound());
            }

            if (string.IsNullOrEmpty(Package.Scopes))
            {
                Package.Scopes = "Global";
            }

            var count = 0;

            foreach (var timestamp in Package.Timestamps)
            {
                if (timestamp.Proof == null || string.IsNullOrEmpty(timestamp.Proof.Address))
                {
                    timestamp.Proof = _timestampService.GetProof(timestamp);
                }

                if (count++ > 3) // Minimize attack vector off having to many timestamps to check
                {
                    break;
                }
            }

            //var query = _trustDBService.DBContext.ClaimPackageRelationships.Where(p => p.PackageID == id).Include(p => p.Claim).OrderBy(p => p.Claim.Created).Select(p => p.Claim);
            //Claims = await PaginatedList<Claim>.CreateAsync(query, 1, 0); // PageSize = 0 is unlimited

            return(Page());
        }