Ejemplo n.º 1
0
        protected void Sign <T>(ref T tblock)
        {
            if (!(tblock is TransactionBlock))
            {
                throw new System.ApplicationException("APIResultCodes.InvalidBlockType");
            }

            var block = tblock as TransactionBlock;

            // ServiceHash is excluded when calculating the block hash,
            // but it is included when creating/validating the authorization signature
            block.ServiceHash = _serviceAccount.GetLatestBlock().Hash;

            // sign with the authorizer key
            AuthorizationSignature authSignature = new AuthorizationSignature
            {
                Key       = _serviceAccount.AccountId,
                Signature = Signatures.GetSignature(_serviceAccount.PrivateKey, block.Hash + block.ServiceHash)
            };

            if (block.Authorizations == null)
            {
                block.Authorizations = new List <AuthorizationSignature>();
            }
            block.Authorizations.Add(authSignature);
        }