/// <summary> /// 反序列化交易中额外的数据 /// </summary> /// <param name="reader">数据来源</param> protected override void DeserializeExclusiveData(BinaryReader reader) { AssetType = (AssetType)reader.ReadByte(); if (!Enum.IsDefined(typeof(AssetType), AssetType) || AssetType == AssetType.CreditFlag || AssetType == AssetType.DutyFlag) { throw new FormatException(); } Name = reader.ReadVarString(); Amount = reader.ReadSerializable <Fixed8>(); if (Amount == Fixed8.Zero || Amount < -Fixed8.Satoshi) { throw new FormatException(); } if (AssetType == AssetType.Share && Amount <= Fixed8.Zero) { throw new FormatException(); } if (AssetType == AssetType.Invoice && Amount != -Fixed8.Satoshi) { throw new FormatException(); } Precision = reader.ReadByte(); if (Precision > 8) { throw new FormatException(); } Issuer = ECPoint.DeserializeFrom(reader, ECCurve.Secp256r1); Admin = reader.ReadSerializable <UInt160>(); }
public override void Deserialize(BinaryReader reader) { byte version = reader.ReadByte(); if (version > StateVersion) { throw new FormatException(); } Hash = reader.ReadSerializable <UInt160>(); Name = reader.ReadVarString(); Owner = ECPoint.DeserializeFrom(reader, ECCurve.Secp256r1); Type = (AppChainType)reader.ReadByte(); Timestamp = reader.ReadUInt32(); LastModified = version >= 1 ? reader.ReadUInt32() : Timestamp; SeedList = new string[reader.ReadVarInt()]; for (int i = 0; i < SeedList.Length; i++) { SeedList[i] = reader.ReadVarString(); } StandbyValidators = new ECPoint[reader.ReadVarInt()]; for (int i = 0; i < StandbyValidators.Length; i++) { StandbyValidators[i] = ECPoint.DeserializeFrom(reader, ECCurve.Secp256r1); } }
public override void Deserialize(BinaryReader reader) { base.Deserialize(reader); PublicKey = ECPoint.DeserializeFrom(reader, ECCurve.Secp256r1); Registered = reader.ReadBoolean(); Votes = reader.ReadSerializable <Fixed8>(); }
/// <summary> /// 序列化交易中的额外数据 /// </summary> /// <param name="reader">数据来源</param> protected override void DeserializeExclusiveData(BinaryReader reader) { if (Version != 0) { throw new FormatException(); } PublicKey = ECPoint.DeserializeFrom(reader, ECCurve.Secp256r1); }
void ISerializable.Deserialize(BinaryReader reader) { if (reader.ReadByte() != StateVersion) { throw new FormatException(); } PublicKey = ECPoint.DeserializeFrom(reader, ECCurve.Secp256r1); }
/// <summary> /// 反序列化交易中额外的数据 /// </summary> /// <param name="reader">数据来源</param> protected override void DeserializeExclusiveData(BinaryReader reader) { AssetType = (AssetType)reader.ReadByte(); Name = reader.ReadVarString(1024); Amount = reader.ReadSerializable <Fixed8>(); Precision = reader.ReadByte(); Issuer = ECPoint.DeserializeFrom(reader, ECCurve.Secp256r1); Admin = reader.ReadSerializable <UInt160>(); }
public override void Deserialize(BinaryReader reader) { this.m = (int)reader.ReadVarInt(); this.publicKeys = new ECPoint[reader.ReadVarInt()]; for (int i = 0; i < publicKeys.Length; i++) { publicKeys[i] = ECPoint.DeserializeFrom(reader, ECCurve.Secp256r1); } base.RedeemScript = CreateMultiSigRedeemScript(m, publicKeys); base.PublicKeyHash = reader.ReadSerializable <UInt160>(); }
/// <summary> /// 反序列化交易中额外的数据 /// </summary> /// <param name="reader">数据来源</param> protected override void DeserializeExclusiveData(BinaryReader reader) { AssetType = (AssetType)reader.ReadByte(); Name = reader.ReadVarString(1024); Amount = reader.ReadSerializable <Fixed8>(); Precision = reader.ReadByte(); Owner = ECPoint.DeserializeFrom(reader, ECCurve.Secp256r1); if (Owner.IsInfinity && AssetType != AssetType.SystemShare && AssetType != AssetType.SystemCoin) { throw new FormatException(); } Admin = reader.ReadSerializable <UInt160>(); }
void ISignable.DeserializeUnsigned(BinaryReader reader) { PrevHash = reader.ReadSerializable <UInt256>(); Miner = ECPoint.DeserializeFrom(reader, ECCurve.Secp256r1); NoncePieces.Clear(); int count = (int)reader.ReadVarInt(); for (int i = 0; i < count; i++) { ECPoint key = ECPoint.DeserializeFrom(reader, ECCurve.Secp256r1); byte[] value = reader.ReadBytes((int)reader.ReadVarInt()); NoncePieces.Add(key, value); } MerkleRoot = reader.ReadSerializable <UInt256>(); }
public static AssetRegistration Unserialize(BinaryReader reader) { var reg = new AssetRegistration(); reg.type = (AssetType)reader.ReadByte(); reg.name = reader.ReadVarString(); reg.amount = reader.ReadFixed(); reg.precision = reader.ReadByte(); reg.owner = ECPoint.DeserializeFrom(reader, ECCurve.Secp256r1); if (reg.owner.IsInfinity && reg.type != AssetType.GoverningToken && reg.type != AssetType.UtilityToken) { throw new FormatException(); } reg.admin = new UInt160(reader.ReadBytes(20)); return(reg); }
public override void Deserialize(BinaryReader reader) { byte version = reader.ReadByte(); if (version > StateVersion) { throw new FormatException(); } AssetId = reader.ReadSerializable <UInt160>(); Name = reader.ReadVarString(); Symbol = reader.ReadVarString(); TotalSupply = reader.ReadSerializable <Fixed8>(); Decimals = reader.ReadByte(); Owner = ECPoint.DeserializeFrom(reader, ECCurve.Secp256r1); Admin = reader.ReadSerializable <UInt160>(); BlockIndex = reader.ReadUInt32(); IsFrozen = reader.ReadBoolean(); }
public override void Deserialize(BinaryReader reader) { base.Deserialize(reader); AssetId = reader.ReadSerializable <UInt256>(); AssetType = (AssetType)reader.ReadByte(); Name = reader.ReadVarString(); Amount = reader.ReadSerializable <Fixed8>(); Available = reader.ReadSerializable <Fixed8>(); Precision = reader.ReadByte(); reader.ReadByte(); //FeeMode Fee = reader.ReadSerializable <Fixed8>(); //Fee FeeAddress = reader.ReadSerializable <UInt160>(); Owner = ECPoint.DeserializeFrom(reader, ECCurve.Secp256r1); Admin = reader.ReadSerializable <UInt160>(); Issuer = reader.ReadSerializable <UInt160>(); Expiration = reader.ReadUInt32(); IsFrozen = reader.ReadBoolean(); }
/// <summary> /// 反序列化交易中额外的数据 /// </summary> /// <param name="reader">数据来源</param> protected override void DeserializeExclusiveData(BinaryReader reader) { TR.Enter(); if (Version != 0) { throw new FormatException(); } AssetType = (AssetType)reader.ReadByte(); Name = reader.ReadVarString(1024); Amount = reader.ReadSerializable <Fixed8>(); Precision = reader.ReadByte(); Owner = ECPoint.DeserializeFrom(reader, ECCurve.Secp256r1); if (Owner.IsInfinity && AssetType != AssetType.GoverningToken && AssetType != AssetType.UtilityToken) { throw new FormatException(); } Admin = reader.ReadSerializable <UInt160>(); TR.Exit(); }
public override void Deserialize(BinaryReader reader) { base.Deserialize(reader); ScriptHash = reader.ReadSerializable <UInt160>(); IsFrozen = reader.ReadBoolean(); Votes = new ECPoint[reader.ReadVarInt()]; for (int i = 0; i < Votes.Length; i++) { Votes[i] = ECPoint.DeserializeFrom(reader, ECCurve.Secp256r1); } int count = (int)reader.ReadVarInt(); Balances = new Dictionary <UInt256, Fixed8>(count); for (int i = 0; i < count; i++) { UInt256 assetId = reader.ReadSerializable <UInt256>(); Fixed8 value = reader.ReadSerializable <Fixed8>(); Balances.Add(assetId, value); } }
void ISerializable.Deserialize(BinaryReader reader) { if (reader.ReadByte() != StateVersion) { throw new FormatException(); } AssetId = reader.ReadSerializable <UInt256>(); AssetType = (AssetType)reader.ReadByte(); Name = reader.ReadVarString(); Amount = reader.ReadSerializable <Fixed8>(); Available = reader.ReadSerializable <Fixed8>(); Precision = reader.ReadByte(); reader.ReadByte(); //FeeMode Fee = reader.ReadSerializable <Fixed8>(); //Fee FeeAddress = reader.ReadSerializable <UInt160>(); Owner = ECPoint.DeserializeFrom(reader, ECCurve.Secp256r1); Admin = reader.ReadSerializable <UInt160>(); Issuer = reader.ReadSerializable <UInt160>(); Expiration = reader.ReadUInt32(); IsFrozen = reader.ReadBoolean(); }
public override void Deserialize(BinaryReader reader) { base.Deserialize(reader); Hash = reader.ReadSerializable <UInt160>(); Name = reader.ReadVarString(); Owner = ECPoint.DeserializeFrom(reader, ECCurve.Secp256r1); Timestamp = reader.ReadUInt32(); TcpPort = reader.ReadInt32(); WsPort = reader.ReadInt32(); SeedList = new string[reader.ReadVarInt()]; for (int i = 0; i < SeedList.Length; i++) { SeedList[i] = reader.ReadVarString(); } StandbyValidators = new ECPoint[reader.ReadVarInt()]; for (int i = 0; i < StandbyValidators.Length; i++) { StandbyValidators[i] = ECPoint.DeserializeFrom(reader, ECCurve.Secp256r1); } int count = (int)reader.ReadVarInt(); }
void ISignable.DeserializeUnsigned(BinaryReader reader) { PrevHash = reader.ReadSerializable <UInt256>(); Miner = ECPoint.DeserializeFrom(reader, ECCurve.Secp256r1); IV = reader.ReadBytes(16); NoncePieces.Clear(); int count = (int)reader.ReadVarInt(); for (int i = 0; i < count; i++) { ECPoint key = ECPoint.DeserializeFrom(reader, ECCurve.Secp256r1); if (key == Miner) { throw new FormatException(); } byte[] value = reader.ReadBytes((int)reader.ReadVarInt()); NoncePieces.Add(key, value); } NonceHash = reader.ReadSerializable <UInt256>(); TransactionHashes = reader.ReadSerializableArray <UInt256>(); }
void ISerializable.Deserialize(BinaryReader reader) { if (reader.ReadByte() != StateVersion) { throw new FormatException(); } ScriptHash = reader.ReadSerializable <UInt160>(); IsFrozen = reader.ReadBoolean(); Votes = new ECPoint[reader.ReadVarInt()]; for (int i = 0; i < Votes.Length; i++) { Votes[i] = ECPoint.DeserializeFrom(reader, ECCurve.Secp256r1); } int count = (int)reader.ReadVarInt(); Balances = new Dictionary <UInt256, Fixed8>(count); for (int i = 0; i < count; i++) { UInt256 assetId = reader.ReadSerializable <UInt256>(); Fixed8 value = reader.ReadSerializable <Fixed8>(); Balances.Add(assetId, value); } }
protected override void DeserializeExclusiveData(BinaryReader reader) { this.AssetType = (AssetType)reader.ReadByte(); if (!Enum.IsDefined(typeof(AssetType), AssetType)) { throw new FormatException(); } this.Name = reader.ReadVarString(); this.Amount = reader.ReadSerializable <Fixed8>(); if (Amount == Fixed8.Zero || Amount < -Fixed8.Satoshi) { throw new FormatException(); } if (AssetType == AssetType.Share && Amount <= Fixed8.Zero) { throw new FormatException(); } if (AssetType == AssetType.Currency && Amount != -Fixed8.Satoshi) { throw new FormatException(); } this.Issuer = ECPoint.DeserializeFrom(reader, ECCurve.Secp256r1); this.Admin = reader.ReadSerializable <UInt160>(); }
public override void Deserialize(BinaryReader reader) { this.publicKey = ECPoint.DeserializeFrom(reader, ECCurve.Secp256r1); base.RedeemScript = CreateSignatureRedeemScript(publicKey); base.PublicKeyHash = publicKey.EncodePoint(true).ToScriptHash(); }
/// <summary> /// 序列化交易中的额外数据 /// </summary> /// <param name="reader">数据来源</param> protected override void DeserializeExclusiveData(BinaryReader reader) { PublicKey = ECPoint.DeserializeFrom(reader, ECCurve.Secp256r1); }
public override void Deserialize(BinaryReader reader) { base.Deserialize(reader); PublicKey = ECPoint.DeserializeFrom(reader, ECCurve.Secp256r1); }