public static StObject FromParser(BinaryParser parser, int? hint = null) { var so = new StObject(); // hint, is how many bytes to parse if (hint != null) { // end hint hint = parser.Pos() + hint; } while (!parser.End(hint)) { var field = parser.ReadField(); if (field == Field.ObjectEndMarker) { break; } var sizeHint = field.IsVlEncoded ? parser.ReadVlLength() : (int?) null; var st = field.FromParser(parser, sizeHint); if (st == null) { throw new InvalidOperationException("Parsed " + field + " as null"); } so.Fields[field] = st; } return so; }
public static AmountValue FromParser(BinaryParser parser) { AmountValue value; var mantissa = parser.Read(8); var b1 = mantissa[0]; var b2 = mantissa[1]; var isIou = (b1 & 0x80) != 0; var isPositive = (b1 & 0x40) != 0; var sign = isPositive ? 1 : -1; if (isIou) { mantissa[0] = 0; var exponent = ((b1 & 0x3F) << 2) + ((b2 & 0xff) >> 6) - 97; mantissa[1] &= 0x3F; value = new IouValue(mantissa, sign, exponent); } else { mantissa[0] &= 0x3F; value = new NativeValue(mantissa, sign); } return value; }
public static Amount FromParser(BinaryParser parser, int? hint=null) { var value = AmountValue.FromParser(parser); if (!value.IsIou) return new Amount(value); var curr = Currency.FromParser(parser); var issuer = AccountId.FromParser(parser); return new Amount(value, curr, issuer); }
public static Hash160 FromParser(BinaryParser parser, int? hint = null) { return new Hash160(parser.Read(20)); }
public static Blob FromParser(BinaryParser parser, int? hint=null) { Debug.Assert(hint != null, "hint != null"); return parser.Read((int) hint); }
public StReader(BinaryParser parser) { _parser = parser; }
public new static AccountId FromParser(BinaryParser parser, int? hint=null) { return new AccountId(parser.Read(20)); }
public new static Currency FromParser(BinaryParser parser, int? hint = null) { return new Currency(parser.Read(20)); }
public static Hash128 FromParser(BinaryParser parser, int? hint=null) { return new Hash128(parser.Read(16)); }
public static Hash256 FromParser(BinaryParser parser, int? hint = null) { return new Hash256(parser.Read(32)); }