2

I am trying to create 2-Party Multisignature Escrow Account with Time Lock & Recovery as in this ref:https://www.stellar.org/developers/guides/walkthroughs/stellar-smart-contracts.html

Now, I stuck at creating the time bound as in Transaction 3: Unlock and Transaction 4: Recovery

I had tried many possibilities for examples: addTimeBounds, addTime, TimeBounds, but none of them worked. I also looked here: https://stellar.github.io/java-stellar-sdk/org/stellar/sdk/TimeBounds.html And it still doesn't work.

Can anyone give me the example of code how I actually setup time bound?

1
  • Can you elaborate on what "doesn't work" means?
    – Paul
    Commented Jun 15, 2018 at 13:05

1 Answer 1

3

Time bounds are part of the transaction itself, and are added in the Java SDK using the addTimeBounds method.

https://stellar.github.io/java-stellar-sdk/org/stellar/sdk/Transaction.Builder.html#addTimeBounds-org.stellar.sdk.TimeBounds-

Here's an example for transaction 3:

SetOptionsOperation setOptionsOperation = new SetOptionsOperation.Builder()
      .setMasterKeyWeight(0)
      .setLowThreshold(1)
      .setMediumThreshold(1)
      .setHighThreshold(1)
      .build();

// set up the unlock date (there are lots of ways to do this)
Instant unlockDate = Instant.now().plusSeconds(60 * 120); // 2 hours from now
TimeBounds timeBounds = new TimeBounds(unlockDate.getEpochSecond(), 0);

// build the transaction and add the time bounds
Transaction transaction = new Transaction.Builder(sourceAccount)
     .addOperation(setOptionsOperation)
     .addTimeBounds(timeBounds)
     .build();
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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