dont validate amounts coming from binary parser

This commit is contained in:
Matthew Fettig
2018-06-06 16:44:20 -05:00
parent cda8197ee6
commit b1eecd7e93

View File

@@ -72,11 +72,11 @@ const parsers = {
};
const Amount = makeClass({
Amount(value, currency, issuer) {
Amount(value, currency, issuer, validate = true) {
this.value = value || new Decimal('0');
this.currency = currency || Currency.XRP;
this.issuer = issuer || null;
this.assertValueIsValid();
validate && this.assertValueIsValid();
},
mixins: SerializedType,
statics: {
@@ -108,13 +108,13 @@ const Amount = makeClass({
// decimal.js won't accept e notation with hex
const value = new Decimal(`${sign}0x${bytesToHex(mantissa)}`)
.times('1e' + exponent);
return new this(value, currency, issuer);
return new this(value, currency, issuer, false);
}
mantissa[0] &= 0x3F;
const drops = new Decimal(`${sign}0x${bytesToHex(mantissa)}`);
const xrpValue = drops.dividedBy(DROPS_PER_XRP);
return new this(xrpValue, Currency.XRP);
return new this(xrpValue, Currency.XRP, null, false);
}
},
assertValueIsValid() {