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?

  • Can you elaborate on what "doesn't work" means? – Paul Jun 15 '18 at 13:05
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();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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