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); }
public override void Deserialize(BinaryReader reader) { base.Deserialize(reader); BlockUIndex = reader.ReadInt64(); BlockHash = reader.ReadString(); Result = (APIResultCodes)reader.ReadInt32(); AuthSign = JsonConvert.DeserializeObject <AuthorizationSignature>(reader.ReadString()); }
protected AuthorizationSignature Sign <T>(DagSystem sys, T tblock) { if (!(tblock is Block)) { throw new System.Exception("APIResultCodes.InvalidBlockType"); } var block = tblock as Block; // sign with the authorizer key AuthorizationSignature authSignature = new AuthorizationSignature { Key = sys.PosWallet.AccountId, Signature = Signatures.GetSignature(sys.PosWallet.PrivateKey, block.Hash, sys.PosWallet.AccountId) }; return(authSignature); }