public byte[] Encode()
        {
            if (Signed && Signature == null)
            {
                throw new Exception("Missing payload signature for signed transaction.");
            }

            var list = new List <byte>();

            // 4 is the TRANSACTION_VERSION constant and it is 7 bits long, the highest bit 1 for signed transaction, 0 for unsigned.
            list.Add((byte)(Constants.EXTRINSIC_VERSION | (Signed ? 0x80 : 0)));

            // 32 bytes
            list.AddRange(Account.PublicKey);

            // key type ed = 00 and sr = FF
            list.Add(Account.KeyTypeByte);

            list.AddRange(Signature);

            list.AddRange(Era.Encode());

            list.AddRange(Nonce.Encode());

            list.AddRange(Tip.Encode());

            list.AddRange(Method.Encode());

            return(Utils.SizePrefixedByteArray(list));;
        }
Exemplo n.º 2
0
        public byte[] GetExtra()
        {
            var bytes = new List <byte>();

            // CheckMortality
            bytes.AddRange(_mortality.Encode());

            // CheckNonce
            bytes.AddRange(_nonce.Encode());

            // ChargeTransactionPayment
            bytes.AddRange(_chargeTransactionPayment.Encode());

            return(bytes.ToArray());
        }