Hello everyone, I have an account is a distributor account, this account need 2 signs to perform a payment transaction, those accounts can sign the transaction built by the distributor account in any moment using the XDR of the transaction, but those accounts can't sign the transaction in the same moment, this represents some issues:
- one account can sign the transaction at any moment and sign other transactions generated by the distributor account but the sequence number represents a big problem because all the transactions generated had the same seqNum because the transactions haven't submitted to the stellar network.
- the other account need to sign any of these transactions but when he signs the firs transaction and submit it to the stellar network the seqNum for the distributor account change because the transaction was performed, so when he tries to sign other transactions the seqNum of all of them is bad
I am using the Stellar SDK from JS to decode an XDR of a transaction and trying to update its sequence number, but when I change the sequence number from the envelope decoded from the XDR and restore the transaction into an XDR again the signs in this transaction that I had before the change of the sequence number appear as an invalid sign
There is the code
const envelope = stellar.xdr.TransactionEnvelope.fromXDR("AAAAAErl3dE4jJLDDKvWpvshJLHl5utiGfEyEHBCo8UFKVXAAAABkAAAFEEAAABaAAAAAQAAAAAAAAAAAAAAAF6i720AAAABAAAAAAAAAAQAAAAAAAAAAQAAAAC2eDSpfu4Lmiy8NGKJTqDpENfalh8O6zFDI0qtaHb86wAAAAJNVEsyMAAAAAAAAAAAAAAAUugnJv7cJ3YljSkIlvYHBfHBAt6KePyNitG3TATdSE0AAAABKgXyAAAAAAAAAAABAAAAALZ4NKl+7guaLLw0YolOoOkQ19qWHw7rMUMjSq1odvzrAAAAAk1USzIwAAAAAAAAAAAAAABS6Ccm/twndiWNKQiW9gcF8cEC3op4/I2K0bdMBN1ITQAAAAEqBfIAAAAAAAAAAAEAAAAAtng0qX7uC5osvDRiiU6g6RDX2pYfDusxQyNKrWh2/OsAAAACTVRLMjAAAAAAAAAAAAAAAFLoJyb+3Cd2JY0pCJb2BwXxwQLeinj8jYrRt0wE3UhNAAAACVAvkAAAAAAAAAAAAQAAAAC2eDSpfu4Lmiy8NGKJTqDpENfalh8O6zFDI0qtaHb86wAAAAJNVEsyMAAAAAAAAAAAAAAAUugnJv7cJ3YljSkIlvYHBfHBAt6KePyNitG3TATdSE0AAAAKejWCAAAAAAAAAAABbuuL2gAAAEDbDUouMfhHQLiTxxFd2SldD5JtAkeb5IUXoZ4zfp2+9TvvONNKhG/5D7On/BjPOM9gWz5gzo82La6L+sdVKCMC", 'base64')
const transaction = new stellar.Transaction(envelope)
// sequence number that i try to update into the last transaction with an outdated XDR
var number = xdr.Hyper.fromString('22269405429851')
transaction.tx._attributes.seqNum = number
// Transaction updated with the new sequence number
console.log(transaction.tx._attributes.seqNum)
// Added a new sign to the transaction
const new_keypair = stellar.Keypair.fromSecret("NEW SIGN OF THE TRANSACTION")
transaction.sign(new_keypair)
// re-build the envelope to XDR
const txEnvelopeXDR = transaction.toEnvelope().toXDR('base64')
console.log(txEnvelopeXDR)
// console.log(transaction.sequence)
This is the XDR returned by this process: AAAAAErl3dE4jJLDDKvWpvshJLHl5utiGfEyEHBCo8UFKVXAAAABkAAAFEEAAABbAAAAAQAAAAAAAAAAAAAAAF6i720AAAABAAAAAAAAAAQAAAAAAAAAAQAAAAC2eDSpfu4Lmiy8NGKJTqDpENfalh8O6zFDI0qtaHb86wAAAAJNVEsyMAAAAAAAAAAAAAAAUugnJv7cJ3YljSkIlvYHBfHBAt6KePyNitG3TATdSE0AAAABKgXyAAAAAAAAAAABAAAAALZ4NKl+7guaLLw0YolOoOkQ19qWHw7rMUMjSq1odvzrAAAAAk1USzIwAAAAAAAAAAAAAABS6Ccm/twndiWNKQiW9gcF8cEC3op4/I2K0bdMBN1ITQAAAAEqBfIAAAAAAAAAAAEAAAAAtng0qX7uC5osvDRiiU6g6RDX2pYfDusxQyNKrWh2/OsAAAACTVRLMjAAAAAAAAAAAAAAAFLoJyb+3Cd2JY0pCJb2BwXxwQLeinj8jYrRt0wE3UhNAAAACVAvkAAAAAAAAAAAAQAAAAC2eDSpfu4Lmiy8NGKJTqDpENfalh8O6zFDI0qtaHb86wAAAAJNVEsyMAAAAAAAAAAAAAAAUugnJv7cJ3YljSkIlvYHBfHBAt6KePyNitG3TATdSE0AAAAKejWCAAAAAAAAAAACbuuL2gAAAEDbDUouMfhHQLiTxxFd2SldD5JtAkeb5IUXoZ4zfp2+9TvvONNKhG/5D7On/BjPOM9gWz5gzo82La6L+sdVKCMCaHb86wAAAEBGdL549c1NSt7IiwfnPU6h0jnmBl9Dssw330I1VC9RxW98nSWWlSeijRcAa0ScAg6cQPX3wbHJeZTa7C1sUtQI
What can I do to solve this problem with the sequence number?