Esempio n. 1
0
        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;
        }
Esempio n. 2
0
 public static Hash160 FromParser(BinaryParser parser, int? hint = null)
 {
     return new Hash160(parser.Read(20));
 }
Esempio n. 3
0
 public static Blob FromParser(BinaryParser parser, int? hint=null)
 {
     Debug.Assert(hint != null, "hint != null");
     return parser.Read((int) hint);
 }
Esempio n. 4
0
 public new static AccountId FromParser(BinaryParser parser, int? hint=null)
 {
     return new AccountId(parser.Read(20));
 }
Esempio n. 5
0
 public new static Currency FromParser(BinaryParser parser, int? hint = null)
 {
     return new Currency(parser.Read(20));
 }
Esempio n. 6
0
 public static Hash128 FromParser(BinaryParser parser, int? hint=null)
 {
     return new Hash128(parser.Read(16));
 }
Esempio n. 7
0
 public static Hash256 FromParser(BinaryParser parser, int? hint = null)
 {
     return new Hash256(parser.Read(32));
 }