Developers have provided some insights into good methods for implementing features in your software. This tip was created by Come-from-Beyond.
For more information on the API calls referenced here, check our high-level API documentation.
1 One way to handle withdrawals
- Use this API call:
- This request will return a transaction ID and transaction bytes.
- Save both these values and periodically check that transaction is still in the blockchain.
- Due to possible transaction malleability issues, do not rely on transaction ID alone to verify a transaction has been sent.
- If the transaction becomes unknown or unconfirmed, you can rebroadcast it via
broadcastTransaction(Transaction bytes can be obtained using
- Once the transaction reaches 720 confirmations, it's safe.
2 Some very important things
- If a claim is made that a transaction was not sent, do not use sendMoney again without making sure that the original transaction wasn't modified.
- Blocks can become orphaned and transactions can be cancelled, so pay attention to the timestamp and deadline values of a transaction. Timestamp is measured in seconds since the genesis block (24th of Nov, 2013 12:00:00 UTC). The transaction deadline is measured in minutes.
- A transaction expires when
timestamp + deadline * 60 < current time. It can't be included into a block with a timestamp greater than
timestamp (of the transaction) + deadline * 60. The current time can be obtained with
- To make sure that you won't lose the transaction you should check that a user uses large deadline and doesn't try to cheat you by setting a timestamp too far in the past.
- Until a transaction gets 720 confirmations you should check to be sure it's still confirmed. If not (due to blockchain reorg), rebroadcast the transaction it to the network using
http://localhost:7876/nxt?requestType=broadcastTransaction&transactionBytes=f11234bd3a2fc19c2ba6b7c0d108deea9fcbafda5f544e4648c651ec4ed34ed2. Transaction bytes can be obtained via