コード例 #1
0
        public static SignData Unpack(System.IO.Stream stream)
        {
            SignData signData = new SignData();

            //read addressScript
            var buflenaddressScript = new byte[2];
            stream.Read(buflenaddressScript, 0, 2);
            UInt16 lenaddressScript = BitConverter.ToUInt16(buflenaddressScript, 0);
            signData.addressScript = new byte[lenaddressScript];
            stream.Read(signData.addressScript, 0, lenaddressScript);
            //read signScript
            var buflensignScript = new byte[2];
            stream.Read(buflensignScript, 0, 2);
            UInt16 lensignScript = BitConverter.ToUInt16(buflensignScript, 0);
            signData.signScript = new byte[lensignScript];
            stream.Read(signData.signScript, 0, lensignScript);

            var pcount = stream.ReadByte();
            for (var i = 0; i < pcount; i++)
            {
                var keylen = stream.ReadByte();
                var keybuf = new byte[keylen];
                stream.Read(keybuf, 0, keylen);
                var key = System.Text.Encoding.UTF8.GetString(keybuf);
                var datalenbuf = new byte[4];
                stream.Read(datalenbuf, 0, 4);
                var datalen = BitConverter.ToUInt32(datalenbuf, 0);
                var value = new byte[datalen];
                stream.Read(value, 0, (int)datalen);
                signData.extData[key] = value;
            }

            return signData;
        }
コード例 #2
0
 public static SignData FromRaw(byte[] data)
 {
     using (System.IO.MemoryStream ms = new System.IO.MemoryStream(data))
     {
         return SignData.Unpack(ms);
     }
 }
コード例 #3
0
        public static NetMessage CreateSendMsg(byte[] tasksrcdata, SignData signdata)
        {
            var msg = Allpet.DB.SDK.NetMessage.Create("_db.write");

            msg.Params["taskdata"] = tasksrcdata;
            msg.Params["signdata"] = signdata.ToBytes();
            return(msg);
        }
コード例 #4
0
 public static SignData Sign(byte[] prikey, byte[] srcdata)
 {
     var pubkey = ThinNeo.Helper_NEO.GetPublicKey_FromPrivateKey(prikey);
     SignData sdata = new SignData();
     sdata.addressScript = ThinNeo.Helper_NEO.GetAddressScript_FromPublicKey(pubkey);
     var signdata = ThinNeo.Helper_NEO.Sign(srcdata, prikey);
     sdata.signScript = MakePushScript(signdata);
     return sdata;
 }
コード例 #5
0
        public static message Post_write(this WebsocketBase socket, byte[] tasksrcdata, SignData signdata)
        {
            var msg     = CreateSendMsg(tasksrcdata, signdata);
            var msgrecv = socket.PostMsg(msg);
            var s       = PraseRecvMsg(msgrecv);

            return(s);
        }