1

Hoping for a simple scenario following This thread:

1) Creating wallets from master accounts

2) Funding the escrow wallet

3) Giving the lock - in time bound period

4) Releasing the amount locked in escrow to destination

First 2 steps are fine, but as soon as I define lock -in time bounds in step 3, the Transaction is done immediately, transferring the funds to destination.

Ideally, I was hoping that the amount should be locked in Escrow account, and on further transaction, it should then release it to destination.

This is what I did to configure 3 accounts namely source, escrow and destination :

  const account = new StellarSdk.Account(escrow.publicKey(), sequence)
       const transaction = new StellarSdk.TransactionBuilder(account,{
        fee: StellarSdk.BASE_FEE
      })
       .addOperation(Stellar.Operation.setOptions({
        masterWeight: 2, 
        lowThreshold: 2,
        medThreshold: 2, 
        highThreshold: 2,
        signer: {
          ed25519PublicKey: dest.publicKey(),
          weight: 1
      }

       }))
       .addOperation(Stellar.Operation.setOptions({
        medThreshold: 3,
        signer: {
          ed25519PublicKey: source.publicKey(),
          weight: 1
      }
       }))

       .setTimeout(10000)
       .build()

       transaction.sign(StellarSdk.Keypair.fromSecret(escrow.secret()))
       return server.submitTransaction(transaction) 

And then this transaction to serve lock in period and amount should be locked :

const transaction = new StellarSdk.TransactionBuilder(account,{ 
      timebounds: { minTime: time -20 ,
                   maxTime: time + 200 },
      fee:StellarSdk.BASE_FEE }) 
      .addOperation(
       Stellar.Operation.payment({
        destination: dest.publicKey(),
        asset: StellarSdk.Asset.native(),
        amount:  amt

       })
       )
       .addOperation(Stellar.Operation.setOptions({
        signer: { ed25519PublicKey: dest.publicKey(), weight: 0 }

       })
       )
       .addOperation(Stellar.Operation.setOptions({
        masterWeight: 1, // revert to original state
        lowThreshold: 0,
        medThreshold: 0,
        highThreshold: 0,
        signer: { ed25519PublicKey: source.publicKey(), weight: 0 }

       }))
       .build()

       transaction.sign(StellarSdk.Keypair.fromSecret(escrow.secret()),  
       StellarSdk.Keypair.fromSecret(dest.secret()))
       return server.submitTransaction(transaction)

But as soon as this Tx is submitted, the funds are immediately transferred to destination account. What I am missing ?

  • Have not drilled into your code yet, but why timebounds: { minTime: time -20 , maxTime: time + 200 }? The time range suggests your transaction is valid already when you make the function call, and so the funds are readily, immediately transferred. Do you mean some fixed time instead of a variable one? – cesarm Mar 26 at 9:52
  • @cesarm Thanks for your response. Basically I configured the time range so that starting from now to 200 sec in future the transaction should remain invalid. But from your comment it looks like it's just the opposite ? – rohan sethi Mar 26 at 10:06
  • 1
    for time=1553652000 (2am of today), your expression yields a range of 1553652000-20 to 1553652000+200. That means your transaction is only valid from 1:59:40am to 2:03:20am. So...seems you may want some range like { minTime: time +200 , maxTime: time + 2000 } – cesarm Mar 27 at 1:57
  • 1
    yeah, it's opposite. timebounds define the range where a transaction is valid. – sui Mar 27 at 9:33
  • @cesarm Please post your comment as an answer so that it can be accepted – rohan sethi Mar 27 at 9:39
1

For example, when time=1553652000 (2am of 2019-03-27), your expression yields a range of 1553652000-20 to 1553652000+200.

That means your transaction is only valid from 1:59:40am to 2:03:20am.

So...seems you may want some range like { minTime: time +200 , maxTime: time + 2000 } for your transaction to work in the future, instead of the immediate current moment.

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.