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

[BUG] - cardano-cli cannot build auto-balanced transactions if --withdrawal option is specified #3096

Closed
yottalogical opened this issue Aug 19, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@yottalogical
Copy link

Internal/External
External

Area
Other

Summary
The cardano-cli transaction build command is unable to balance transactions correctly if the --withdrawal option is specified. It seemingly ignores the amount withdrawn when calculating how much is left to send to the change address. It also fails to calculate the correct fee.

Steps to reproduce
To see it incorrectly calculating change:
(Note: 0850cacebe8195d5afa769247a813d3c826ad08d514a9d0b69d69d9b44a012ce#1 contains 1000000 lovelace)

cardano-cli transaction build \
    --alonzo-era \
    --testnet-magic 8 \
    --tx-in 0850cacebe8195d5afa769247a813d3c826ad08d514a9d0b69d69d9b44a012ce#1 \
    --tx-out addr_test1qpj8z5xv8dhtvd9q7kf32xswrlt6n5e304tudyvmsf7z7ghyh6vfvdj4zfg2hd7j720l66xz0592xyzv6qrvnvas5tds9dhe74+2000000 \
    --change-address addr_test1qqve52e50yvh6q68c08ny2t5dwlk2pr22722p4auvj2gsc8yh6vfvdj4zfg2hd7j720l66xz0592xyzv6qrvnvas5tdsm063nu \
    --withdrawal stake_test1urjtaxykxe23y59tklf098ladrp86z4rzpxdqpkfkwc29kckecs6y+3000000 \
    --out-file tx.raw

You should get the following error:

Command failed: transaction build  Error: The transaction does not balance in its use of ada. The net balance of the transaction is negative: Lovelace (-1168185) lovelace. The usual solution is to provide more inputs, or inputs with more ada.

To see it incorrectly calculating fee:
(Note: 0850cacebe8195d5afa769247a813d3c826ad08d514a9d0b69d69d9b44a012ce#2 contains 5000000 lovelace)

cardano-cli transaction build \
    --alonzo-era \
    --testnet-magic 8 \
    --tx-in 0850cacebe8195d5afa769247a813d3c826ad08d514a9d0b69d69d9b44a012ce#2 \
    --tx-out addr_test1qpj8z5xv8dhtvd9q7kf32xswrlt6n5e304tudyvmsf7z7ghyh6vfvdj4zfg2hd7j720l66xz0592xyzv6qrvnvas5tds9dhe74+2000000 \
    --change-address addr_test1qqve52e50yvh6q68c08ny2t5dwlk2pr22722p4auvj2gsc8yh6vfvdj4zfg2hd7j720l66xz0592xyzv6qrvnvas5tdsm063nu \
    --withdrawal stake_test1urjtaxykxe23y59tklf098ladrp86z4rzpxdqpkfkwc29kckecs6y+3000000 \
    --out-file tx.raw

Sign tx.raw with the appropriate payment.skey and stake.skey:

cardano-cli transaction sign \
    --tx-body-file tx.raw \
    --signing-key-file payment.skey \
    --signing-key-file stake.skey \
    --out-file tx.signed

Finally submit the transaction:

cardano-cli transaction submit \
    --testnet-magic 8 \
    --tx-file tx.signed

You should get the following error:

Command failed: transaction submit  Error: Error while submitting tx: ShelleyTxValidationError ShelleyBasedEraAlonzo (ApplyTxError [UtxowFailure (WrappedShelleyEraFailure (UtxoFailure (FeeTooSmallUTxO (Coin 172453) (Coin 168185))))])

Expected behavior
When using the --withdrawal option, cardano-cli transaction build should include the withdrawn value in its balance calculations, as well as it should apply the correct fee. Once fixed, the above reproduction steps should be able to successfully build a valid withdraw transaction.

System info (please complete the following information):

  • OS Name: Ubuntu
  • OS Version: 20.04 LTS
  • Node version: cardano-node 1.28.0 - linux-x86_64 - ghc-8.10 git rev 281f9c8
  • CLI version: cardano-cli 1.28.0 - linux-x86_64 - ghc-8.10 git rev 281f9c8
@yottalogical yottalogical added the bug Something isn't working label Aug 19, 2021
@yottalogical
Copy link
Author

Although I searched for previous issues on this topic before submitting this, I must be totally blind, because the exact same thing was posted just 6 days ago. I need to look more carefully in the future.

This issue is a duplicate of #3074. Keep it open or close it as you see fit.

@dorin100
Copy link

closing this as duplicate

@catch-21
Copy link
Contributor

I don't think this is a duplicate of #3074, that one is to do with the withdrawal not succeeding after submit, this one it to do with not being able to balance the tx. No need to reopen as a new issue has now been created, see #3132.

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

No branches or pull requests

3 participants