I'm trying to add a simple time bounds with the Java SDK to settle a transaction happening at a certain time.

Code used :

Instant unlockDate = Instant.now().plusSeconds(60 * 2);
    TimeBounds timeBounds = new TimeBounds(unlockDate.getEpochSecond(), 0);
Transaction transaction = new Transaction.Builder(sourceAccount)
      .addOperation(new PaymentOperation.Builder(destination,
          new AssetTypeCreditAlphaNum12("xxx", issuer), amount).build())
      .addTimeBounds(timeBounds)
      .addMemo(Memo.text("Memo")).build();
  transaction.sign(distributor);

But I get this error :

Exception in thread "main" java.lang.IllegalArgumentException: minTime must be >= maxTime

It seems you can't set the maxTime to 0 anymore.

Is there a workaround?

up vote 6 down vote accepted

Thanks for catching this. It's a bug in Java SDK, please upgrade to 0.3.1 and it should be fixed.

  • The error is not happening anymore now, thanks. However, if I enter a minTime which is the same as the maxTime like this : Instant unlockDate = Instant.now().plusSeconds(60 * 2); TimeBounds timeBounds = new TimeBounds(unlockDate.getEpochSecond(), unlockDate.getEpochSecond()); I will get the the message error : minTime must be >= maxTime. Shouldn't it be "minTime must be > maxTime" ? – Brice Faller Aug 10 at 15:57
  • 1
    You are right but you should never set time bound to so short interval. Ledgers close on average every 2-5 seconds so it's possible that your transaction will miss it's chance to be included in a ledger. – Bartek Nowotarski Aug 10 at 17:14

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.