Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serialization/Deserialization of Transaction object resets fee to 1000. #362

Open
egieseke opened this issue Aug 17, 2022 · 3 comments
Open
Labels
bug Something isn't working good first issue Good for newcomers Team Lamprey

Comments

@egieseke
Copy link
Contributor

Subject of the issue

Fix Transaction Java serialization to preserve the fee value. In group transactions, fees can be paid by a single party in the transaction, so it is important to be able to specify a 0 transaction fee for other parties.

Your environment

Java SDK v 1.14.0

Steps to reproduce

  1. Set the Transaction fee to 0.
  2. Serialize and deserialize the transaction.
  3. Note that the transaction fee is 1000, rather than 0.

Expected behavior

The transaction fee should remain what was set.

Actual behavior

The transaction fee is reset to 1000 after serialization/deserialization, the set value is lost.

@egieseke egieseke added the new-bug Bug report that needs triage label Aug 17, 2022
@winder
Copy link
Contributor

winder commented Aug 18, 2022

Could you provide a code sample?

@winder
Copy link
Contributor

winder commented Sep 22, 2022

Here's an example showing the failure:

        @Test
        public void TxnZeroFeeEncodeDecode() throws Exception {
            Transaction tx = Transaction.PaymentTransactionBuilder()
                    .sender(DEFAULT_ACCOUNT.getAddress())
                    .flatFee(0)
                    .firstValid(1)
                    .lastValid(10)
                    .amount(1)
                    .genesisHash(new Digest())
                    .receiver(DEFAULT_ACCOUNT.getAddress())
                    .build();

            assertThat(tx.fee).isEqualTo(0);

            String encoded2 = Encoder.encodeToJson(tx);
            Transaction jsonTxn = Encoder.decodeFromJson(encoded2, Transaction.class);
            assertThat(jsonTxn.fee).isEqualTo(0);

            byte[] encoded = Encoder.encodeToMsgPack(tx);
            Transaction msgpTxn = Encoder.decodeFromMsgPack(encoded, Transaction.class);
            assertThat(msgpTxn.fee).isEqualTo(0);
        }

@algoanne algoanne added bug Something isn't working and removed new-bug Bug report that needs triage labels May 8, 2023
@winder winder added the good first issue Good for newcomers label May 23, 2023
@FabioRagno
Copy link

This might solve the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers Team Lamprey
Projects
None yet
Development

No branches or pull requests

4 participants