Exemple #1
0
        public void sign(Core.Transaction tx, List <byte[]> privatekeys)
        {
            byte[] msg = null;
            tx.sigs = new List <Core.Sig> {
            };
            using (var ms = new System.IO.MemoryStream())
            {
                tx.SerializeUnsigned(ms);
                msg = ms.ToArray();

                for (int i = 0; i < privatekeys.Count; i++)
                {
                    byte[] signature = Helper.Sign(Helper.Sha256(Helper.Sha256(msg)), privatekeys[i]);

                    List <byte> bytes = new List <byte>();
                    bytes.AddRange(new byte[] { 0x01 });
                    bytes.AddRange(signature);

                    tx.sigs.Add(new Core.Sig());
                    tx.sigs[i].M       = 1;
                    tx.sigs[i].pubKeys = new List <byte[]> {
                        Helper.GetPublicKeyFromPrivateKey(privatekeys[i])
                    };
                    tx.sigs[i].sigData = new List <byte[]> {
                        bytes.ToArray()
                    };
                }
            }
        }
Exemple #2
0
        public NetworkResponse invokeTransaction(JObject action, List <byte[]> privatekeys, bool preExec)
        {
            Core.Transaction tx = Core.TransactionBuilder.MakeInvokeTransaction(action);
            sign(tx, privatekeys);
            NetworkResponse result = send(tx.toHexString(), preExec);

            return(result);
        }
Exemple #3
0
        //preExec = true, for check this transaction
        public NetworkResponse transfer(string name, string from, string to, long value, string payer, uint gasLimit, uint gasPrice, List <byte[]> privatekeys, bool preExec)
        {
            Core.Transaction tx = Core.TransactionBuilder.MakeTransferTransaction(name, from, to, value, payer, gasLimit, gasPrice);
            sign(tx, privatekeys);

            NetworkResponse result = send(tx.toHexString(), preExec);

            return(result);
        }