Ejemplo n.º 1
0
        /// <summary>
        ///     Creates a Uint256 from a byte hash.
        /// </summary>
        /// <param name="hash"></param>
        /// <returns>A Uint256</returns>
        private static sdkxdr.Uint256 CreateUint256(byte[] hash)
        {
            if (hash.Length != 32)
            {
                throw new ArgumentException("hash must be 32 bytes long");
            }

            sdkxdr.Uint256 value = new sdkxdr.Uint256();
            value.InnerValue = hash;
            return(value);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Create <code>preAuthTx</code> <see cref="sdkxdr.SignerKey" /> from
        ///     a transaction hash.
        /// </summary>
        /// <param name="hash"></param>
        /// <returns>sdkxdr.SignerKey</returns>
        public static sdkxdr.SignerKey PreAuthTx(byte[] hash)
        {
            if (hash == null)
            {
                throw new ArgumentNullException(nameof(hash), "hash cannot be null");
            }

            sdkxdr.SignerKey signerKey = new sdkxdr.SignerKey();
            sdkxdr.Uint256   value     = CreateUint256(hash);

            signerKey.Discriminant =
                sdkxdr.SignerKeyType.Create(sdkxdr.SignerKeyType.SignerKeyTypeEnum.SIGNER_KEY_TYPE_PRE_AUTH_TX);
            signerKey.PreAuthTx = value;

            return(signerKey);
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Create <code>preAuthTx</code> <see cref="sdkxdr.SignerKey" /> from
        ///     a <see cref="sdkxdr.Transaction" /> hash.
        /// </summary>
        /// <param name="tx"></param>
        /// <returns>sdkxdr.SignerKey</returns>
        public static sdkxdr.SignerKey PreAuthTx(Transaction tx)
        {
            if (tx == null)
            {
                throw new ArgumentNullException(nameof(tx), "tx cannot be null");
            }

            sdkxdr.SignerKey signerKey = new sdkxdr.SignerKey();
            sdkxdr.Uint256   value     = CreateUint256(tx.Hash());

            signerKey.Discriminant =
                sdkxdr.SignerKeyType.Create(sdkxdr.SignerKeyType.SignerKeyTypeEnum.SIGNER_KEY_TYPE_PRE_AUTH_TX);
            signerKey.PreAuthTx = value;

            return(signerKey);
        }