Exemple #1
0
        public byte[] SigningHash(string delegateFor = "")
        {
            byte[] encode = RlpCode.Encode(Transaction.UnsignedRlpDefinition(), this.Body);
            byte[] hash   = Blake2b.CalculateHash(encode);

            if (delegateFor.Length != 0)
            {
                if (SimpleWallet.IsValidAddress(delegateFor))
                {
                    MemoryStream stream = new MemoryStream();
                    stream.Append(hash);
                    stream.Append(delegateFor.ToBytes());
                    return(Blake2b.CalculateHash(stream.ToArray()));
                }
                else
                {
                    throw new ArgumentException("delegateFor expected address");
                }
            }
            return(hash);
        }
Exemple #2
0
 public byte[] Encode()
 {
     this.TrimReserved();
     if (this.Signature != null && this.Signature.Length != 0)
     {
         var transaction = new {
             ChainTag     = this.Body.ChainTag,
             BlockRef     = this.Body.BlockRef,
             Expiration   = this.Body.Expiration,
             Clauses      = this.Body.Clauses,
             GasPriceCoef = this.Body.GasPriceCoef,
             Gas          = this.Body.Gas,
             DependsOn    = this.Body.DependsOn,
             Nonce        = this.Body.Nonce,
             Reserved     = this.Body.Reserved,
             Signature    = this.Signature
         };
         return(RlpCode.Encode(Transaction.SignedRlpDefinition(), transaction));
     }
     else
     {
         return(RlpCode.Encode(Transaction.UnsignedRlpDefinition(), this.Body));
     }
 }