java-algorand-sdk icon indicating copy to clipboard operation
java-algorand-sdk copied to clipboard

TransactionId empty if SignedTransaction initialized by constructor @JsonCreator

Open Reguzzoni opened this issue 3 years ago • 2 comments

Problem

The SignedTransaction created by deserialization JSON (@JSONCreator) doesn't fill the attribute transactionId. https://github.com/algorand/java-algorand-sdk/blob/develop/src/main/java/com/algorand/algosdk/transaction/SignedTransaction.java#L80

So with Atomic Composer if I put a TxnSigner as a external request that works with deserialization of SignedTransaction, It will not work cause the transactionId is emtpy. https://github.com/algorand/java-algorand-sdk/blob/develop/src/main/java/com/algorand/algosdk/transaction/AtomicTransactionComposer.java#L188

Solution

We could add the transactionId into the constructor through@JSONCreator or other options proposed by barnji: instead of using the txid directly from signed transaction object, use signedtransaction.tx.getTxId() or w/e its called in the atc. it'd be redundant hashing possibly but safer in the case of a enc/dec stxn

Dependencies

No dependencies

Urgency

Low Urgency, easy to implement a workaround

Reguzzoni avatar Nov 15 '22 12:11 Reguzzoni

I'm not very familiar with the ATC, but from what you described I think another solution would be to call the get transaction ID function instead of assuming the field is filled in.

A small example program would help me understand the exact problem.

winder avatar May 23 '23 20:05 winder

This is probably because the txid is not part of the canonical representation. We exclude it during serialization and need to recompute it during deserialization.

winder avatar Jun 08 '23 16:06 winder