Not really clear. By my question I ment why signtransaction() doesn't do it? Because as far as I know the short tx id is generated as a result of signing, but not as double hashing, correct me if I'm wrong.
According to the
electrum docs, the TX ID is returned after broadcasting the transaction.
But to generate the ID yourself, technically you simply take the signed transaction and double hash it:
tx_id = sha256(sha256(signed_tx))Look. The simple task I faced: I need to send btc from server and get tx id before it broadcasted, because in some reasons electrum broadcast() result return nothing and transaction appear in network with delay 1 or even 2 minutes later. Or even not appear! Client want to know tx id straight away after withdraw. So I don't need double spend (by this I actually mean send same value to the same address 2 times) and trying to figure out, how to prevent this. In case, when something goes wrong broadcast() also return nothing cause of delay. And what should we do? Send tx again? Or wait until it finally appear in network. That's the question.
Usually the transaction
should always appear on the network.
IMO, there is no reason to show the txID initally (before the TX has been broadcasted). But that's just a personal opinion.
To prevent paying out twice (that's not a double spend), simply wait for the TX to be accepted by the network. If it does not appear, rebroadcast the same transaction again.
Just don't create another transaction.
If you want to have full control, simply setup an own electrum server. Then you don't need to depend on an unknown electrum server to broadcast your TX to the network.