예제 #1
0
        internal DynamicTableEntity ToEntity()
        {
            DynamicTableEntity entity = new DynamicTableEntity();

            entity.ETag         = "*";
            entity.PartitionKey = PartitionKey;

            var locator = CreateBalanceLocator();

            entity.RowKey = BalanceId + "-" + locator.ToString(true);

            entity.Properties.Add("s", new EntityProperty(SeenUtc));
            Helper.SetEntityProperty(entity, "ss", Helper.SerializeList(SpentIndices.Select(e => new IntCompactVarInt(e))));

            Helper.SetEntityProperty(entity, "a", Helper.SerializeList(SpentOutpoints));
            if (SpentCoins != null)
            {
                Helper.SetEntityProperty(entity, "b", Helper.SerializeList(SpentCoins.Select(c => new Spendable(c.Outpoint, c.TxOut))));
            }
            Helper.SetEntityProperty(entity, "c", Helper.SerializeList(ReceivedCoins.Select(e => new IntCompactVarInt(e.Outpoint.N))));
            Helper.SetEntityProperty(entity, "d", Helper.SerializeList(ReceivedCoins.Select(e => e.TxOut)));
            var flags = (HasOpReturn ? "o" : "n") + (IsCoinbase ? "o" : "n");

            entity.Properties.AddOrReplace("e", new EntityProperty(flags));
            entity.Properties.AddOrReplace("f", new EntityProperty(Helper.Serialize(MatchedRules)));
            if (ColoredTransaction != null)
            {
                entity.Properties.AddOrReplace("g", new EntityProperty(ColoredTransaction.ToBytes()));
            }
            if (ScriptPubKey != null && !BalanceId.ContainsScript)
            {
                var bytes = ScriptPubKey.ToBytes(true);
                if (bytes.Length < 63000)
                {
                    entity.Properties.Add("h", new EntityProperty(bytes));
                }
            }
            if (CustomData != null)
            {
                Helper.SetEntityProperty(entity, "cu", Encoding.UTF8.GetBytes(CustomData));
            }
            return(entity);
        }
예제 #2
0
파일: Tracker.cs 프로젝트: zzms/NBitcoin
            internal JObject ToJson()
            {
                var obj = new JObject();

                if (BlockId != null)
                {
                    obj.Add("Height", Height);
                    obj.Add("BlockId", BlockId.ToString());
                    obj.Add("Proof", Encoders.Hex.EncodeData(this.Proof.ToBytes()));
                }
                obj.Add("AddedDate", AddedDate);
                obj.Add("UnconfirmedSeen", UnconfirmedSeen);
                obj.Add("Transaction", Encoders.Hex.EncodeData(this.Transaction.ToBytes()));
                if (this.ReceivedCoins != null)
                {
                    obj.Add("ReceivedCoins", new JArray(ReceivedCoins.Select(c => ToJson(c))));
                }
                if (this.SpentCoins != null)
                {
                    obj.Add("SpentCoins", new JArray(SpentCoins.Select(c => ToJson(c))));
                }
                return(obj);
            }