1

If someone sends me lumens, what happens if the transaction neither succeed nor fails? How can I determine whether I will receive lumens or not when the transaction is pending?

From the getting started guide:

IMPORTANT It’s possible that you will not receive a response from Horizon server due to a bug, network conditions, etc. In such situation it’s impossible to determine the status of your transaction. That’s why you should always save a built transaction (or transaction encoded in XDR format) in a variable or a database and resubmit it if you don’t know it’s status. If the transaction has already been successfully applied to the ledger, Horizon will simply return the saved result and not attempt to submit the transaction again. Only in cases where a transaction’s status is unknown (and thus will have a chance of being included into a ledger) will a resubmission to the network occur.

2
  • Accoding to my understanding - If successful or unsuccessful it will give response -If pending two cases, 1- the transaction is submitted on stellar network means successful but response is not received then resubmitting the transaction to the network will give the same response which have to be received on first attempt. 2- tx is not submitted on stellar n/w than resubmitting the tx will do the require changes on stellar network . Nov 13, 2018 at 6:00
  • always save a built transaction (or transaction encoded in XDR format) in a variable or a database and resubmit it if you don’t know it’s status. Nov 13, 2018 at 6:01

2 Answers 2

1

If you use the SDK, you should look at your response and figure out if it errorred or not. If so, either it was a validation problem or something timed out. If it timed out, you should retry.

Have a look at my Kotlin wrapper for the java sdk. It provides an extension method to the java Server class that comes with the java sdk that does this in a sane way:

KotlinExtensions.kt

This is used from my KotlinWrapper class provides a convenient DSL for doing stellar stuff on top of this.

If it comes back successful, that means the transaction has been committed to a ledger that is now part of the stellar block chain. The doTransaction method will throw an exception if it fails for whatever reason.

1

The section you quoted is relevant when sending a transaction, when receiving lumens you can periodically check your balance to see if new transactions have settled. Since transactions settle every 5 seconds, you'll know if a transaction has come through or not pretty quickly after it was attempted.

When sending a transaction, it's best practice to hold onto a transaction until you're sure that the network has accepted it. Transactions are idempotent due to the sequence number, so if you're ever unsure if a transaction has been successfully submitted, re-submitting the transaction envelope will never result in a duplicate.

  • Build and sign transaction (producing a Transaction Envelope XDR string)
  • Submit XDR to the network
  • ???
  • Re-submit XDR because of uncertain transaction status

Only 1 transaction will have an effect on the network because of the guarantees provided around transactions.

Your Answer

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

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