Rust code / cardano-cli - change address / fees, not working as expected

I made a transaction using cardano-cli built from rust github.

I added 2 utxos (1ADA + 3ADA) as inputs, a change address, and an output for 2 ADA to an address.

You can see it here:

sick_puppy: ./cardano-cli transaction status 64SFC1
input-total: 4.000000
output-total: 2.000000
actual-fee: 2000000
fee: 0.175245
tx-bytes: 452
---
staging_id: 64SFC1
magic: 5452414e53414354494f4e5f5631
protocol_magic: 764824073
transaction:
  inputs:
    - transaction_id: 49b6a2bb6b8c68c95701cc3034dfae080d35ed143ab7ddc255456b41c3dda231
      index_in_transaction: 1
      expected_value: 1000000
    - transaction_id: 05e3cfa8681497daa671e91f614eebe4c257c4620c25ecccef8acddab91c7de6
      index_in_transaction: 1
      expected_value: 3000000
  outputs:
    - address: DdzFFzCqrhspknv7Ph59BP8bVXQg5X7aYhERr755LJjunTLwZsBu9NGh6nMS3Ynf9GwktoFocxy5BwUMXxza8ZKDAaTsmFxkUBVJuahS
      amount: 2000000
  changes:
    - address: Ae2tdPwUPEZ7ubYTmthXk5ns4N17crep1BNoJeD36CFrrfUk29bAAmsBP8T
  witnesses:
    - PkWitness:
        - f2e55906d8a7f60ccc0c0ac6bb3408f12dc130659ed75b9bb7c9c031a44948aaacf353e316a2d6273aa9c865f651c97fdc2c6abfe21f9e49b77912a44e1d9990
        - def1ed8f21827032a81bbfb29bff1a84b35c7d50dca95efa990535d25876f368d28373031f59d3b567dff55768ab2bc96c61e015b14d062bf128f1c9f181240e
    - PkWitness:
        - 60a6e277a0201f329004443d914a0a8276eeaabf7ef37868e08fc31f55c187746e4319d2429e126fa5c90eb287e594e2fc54867ac6f056db6277f01f2f504a25
        - eded3bf85350f41bcf1a5b785b46b4b8a2c2bf699f470bef366163e9e42063fadee5267fcb56777b3c1d992c0292afd54565cbd7000fbfce4fe3839630589401
  finalized: false

You can see that the fee should be 0.175, it also says “actual fee” is 2. I was not sure what would happen, so I singed and sent the transaction to mainnet, which processed it.

You can see it here: https://cardanoexplorer.com/tx/4113e3f0d34bf698f397b257da1213bed12537342fabf5a14c86f1afe8c46f47

As it says, the actual fee was 2. In other words, everything that did not go to the output address was considered a fee.

I would have thought, whatever was left after fee taken out, would be the “change” and would go to the change address. Yet it was not so…

So what is the point of the change address?

And how are we supposed to do it?

It’s a UTxO standard. “Fee” is just a sugar name for difference between sum inputs and sum outputs, and all of it becomes a reward (burned in this case). In this case fee is the calculated required minimum, but anyone is free to “donate” more fees at any time :slight_smile:

This looks weird tho, agree. Any change is usually set manually as outputs. I will need to look into CLI api more thoroughly

Hmm…interesting…I can try forwarding this over to IOHK too to see if they can have a review. Hopefully @vantuz-subhuman can crack this one, like always :wink:

1 Like

Thank you, Maki :wink:

@HisMajesty, there seem to be a little bug. Already found it in their code and reported. Let’s hope they fix it quickly :slight_smile: (https://github.com/input-output-hk/rust-cardano/issues/253)

Let’s all not forget that Prometheus (rust-cardano) and CLI are not officially finished yet, and still in active development, so some stuff may not work or actively change.

2 Likes

I do not think that there is an issue. It seems to me work as expected as it processes each of the inputs. But, I am going to check it.

UPDATE: Yep that part is OK, as it processes all inputs. Yep, (output_value - input_value - estimated_fee) seems misleading, but it’s not. Check the for loop which starts at line 184

What I can suspect is that if the user specifies the change address then it will add all the fees into the change address (probably IOHK’s burn address). I will have a look at the code in more detail as this change address vs. automatically generated multiple outputs (if there is no any change address is specified) can be a bit confusing for the users.
Also, it can lead to hijack the fee system if the users can specify their own change address, means all transaction fees can land on their specified address. But, if the change address currently derivated from the IOHK’s fee address, then that 's fine as it will be burnt. So, I need to dig a bit more into the code to fully understand, but currently do not have time to this.

So, it does not seem to be a BUG at all, but a normal behaviour (feature), it wil lbe a bug if the users can specify their own change address, which does not seem to me the case (but, as I mentioned, I need to dig a bit more to fully understand this)

Can you pls let me know what was the change address you added? That would be better if you could provide all commands you ran (you can remove or obfuscate all sensitive data from them).

Yeah, they have clarified it in the issue too, I misread the code :frowning_face: https://github.com/input-output-hk/rust-cardano/issues/253#issuecomment-420896426

But there’s no such thing as a “burn address”, tho :slight_smile: All fees for now just go nowhere. Which is exactly why they are “burned”. They just disappear.

No it shouldn’t be a bug, since there’s no such thing as “change” in UTxO, strictly speaking. All tx outputs have the same “rights” and are indistinguishable from the protocol POV. So user may specify any number of inputs and any number of outputs, and any of those outputs may be the “change” logically, or even multiple of them. “Change” is just a sugar word for an output that sends coins back to the same wallet (not necessarily the same address), that’s it )

Judging by this issue: https://github.com/input-output-hk/cardano-cli/issues/14, the separately specified “change” address is meant to be like a “syntax sugar” which is used in some specific way.

And the discussion continues: https://github.com/input-output-hk/rust-cardano/issues/253#issuecomment-420929134 :slight_smile:

Thanks @vantuz-subhuman Ruslan for being here so quickly!

tenor

1 Like

If it’s been sent to the network and executed, should this not read TRUE? or what does finalize mean? And what is the difference between finalize and sign?

cardano-cli transaction -h | egrep '(final|sign)'
    finalize        Finalize a staging transaction
    sign            Finalize a staging a transaction into a transaction ready to send to the blockchain network
1 Like

Thx, it makes sense. I have not checked that part of the code, therefore I just assumed that there is some change address, as it was applied in the command that @HisMajesty’s applied, but have not checked the transaction to be sure.

Yep, I know, I just thought that specified “change address” by @HisMajesty will be the output where the change goes (as he specified an output and a change address (means second output for change).

But, are you sure there is no some specified/generated address to burn? I would say there must be, as money cannot disappear from the system at all, what can I expect, that they have some automatically generated address (derivated from some wallet address) and they send the transaction fees there.

But, I have not checked this part of the protocol, but I will when I have some free time.

Thx, anyway.

There is no address, and coins DO disappear. This is the definition of “burning”. Strictly speaking, total supply of ADA coins is quite liquid in time, with new coins being added into supply as someone redeems their ICO certificate and as fees are disappearing.

From protocol POV there’s nothing wrong in disappearing coins, tho, think of it that way: a transaction is just an event that spends some UTxO and creates new UTxO. There’s absolutely nowhere in the protocol a validation that sum inputs and sum outputs are required to be equal. Therefore if your transaction spends two UTxO of 50 coins each and creates a single new UTxO of 90 coins - 10 coins are just no more )

1 Like

Ok, thx. I will have a look at that part of the code how it really works anyway.

1 Like