Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="trunkTransaction"></param>
        /// <param name="branchTransaction"></param>
        /// <param name="minWeightMagnitude"></param>
        /// <param name="trytes"></param>
        /// <returns></returns>
        public AttachToTangleResponse AttachToTangle(
            string trunkTransaction, string branchTransaction,
            int minWeightMagnitude, string[] trytes)
        {
            if (!InputValidator.IsHash(trunkTransaction))
            {
                throw new ArgumentException(Constants.INVALID_HASH_INPUT_ERROR);
            }

            if (!InputValidator.IsHash(branchTransaction))
            {
                throw new ArgumentException(Constants.INVALID_HASH_INPUT_ERROR);
            }

            if (!InputValidator.IsArrayOfRawTransactionTrytes(trytes))
            {
                throw new ArgumentException(Constants.INVALID_TRYTES_INPUT_ERROR);
            }

            var attachToTangleRequest =
                new AttachToTangleRequest(
                    trunkTransaction, branchTransaction, minWeightMagnitude, trytes);

            return(Request <AttachToTangleRequest, AttachToTangleResponse>(attachToTangleRequest));
        }
Esempio n. 2
0
        public async Task <APIResult <string[]> > AttachToTangle(string[] trytes,
                                                                 string trunkTransaction, string branchTransaction, CancellationToken cancellationToken)
        {
            InputValidator.CheckIfArrayOfTrytes(trytes);

            AttachToTangleRequest attachToTangleRequest = new AttachToTangleRequest(trunkTransaction, branchTransaction, trytes, MinWeightMagnitude);

            var response = await genericWebClient.RequestAsync <AttachToTangleResponse>(attachToTangleRequest, cancellationToken);

            return(response?.RePackage(r => r.Trytes) ?? new APIResult <string[]>(null, "Null response from API"));
        }
Esempio n. 3
0
        public async Task <string[]> AttachToTangle(string[] trytes,
                                                    string trunkTransaction, string branchTransaction, CancellationToken cancellationToken)
        {
            InputValidator.CheckIfArrayOfTrytes(trytes);

            AttachToTangleRequest attachToTangleRequest = new AttachToTangleRequest(
                trunkTransaction, branchTransaction,
                trytes, MinWeightMagnitude);
            var response = await genericClient.RequestAsync <AttachToTangleResponse>(attachToTangleRequest, cancellationToken);

            if (response == null)
            {
                throw new NullReferenceException(nameof(response));
            }

            return(response.Trytes);
        }