@Override /** * We override seal method to recalculate holding at the state.data values */ public byte[] seal() { saveTrackingOriginsToState(); calculatePrepaidOriginDays(true); return super.seal(); }
@Override public boolean beforeUpdate(ImmutableEnvironment c) { boolean checkResult = false; // recalculate prepaid origins*days without saving to state calculatePrepaidOriginDays(false); // check that payment was not hacked checkResult = prepaidOriginDays == getStateData().getInt(PREPAID_OD_FIELD_NAME, 0); if(!checkResult) { addError(Errors.FAILED_CHECK, "Wrong [state.data." + PREPAID_OD_FIELD_NAME + "] value. " + "Should be sum of early paid U and paid U by current revision."); return checkResult; } // and call common follower check checkResult = additionallyFollowerCheck(c); return checkResult; }
@Override public boolean beforeCreate(ImmutableEnvironment c) { boolean checkResult = true; // recalculate prepaid origins*days without saving to state calculatePrepaidOriginDays(false); int paidU = getPaidU(); if(paidU == 0) { if(getPaidU(true) > 0) { addError(Errors.FAILED_CHECK, "Test payment is not allowed for follower contracts"); } checkResult = false; } else if(paidU < getMinPayment()) { addError(Errors.FAILED_CHECK, "Payment for follower contract is below minimum level of " + getMinPayment() + "U"); checkResult = false; } if(!checkResult) { addError(Errors.FAILED_CHECK, "Follower contract hasn't valid payment"); return checkResult; } // check that payment was not hacked checkResult = prepaidOriginDays == getStateData().getInt(PREPAID_OD_FIELD_NAME, 0); if(!checkResult) { addError(Errors.FAILED_CHECK, "Wrong [state.data." + PREPAID_OD_FIELD_NAME + "] value. " + "Should be sum of early paid U and paid U by current revision."); return checkResult; } // and call common follower check checkResult = additionallyFollowerCheck(c); return checkResult; }