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: Small input UTxO for sample-dApps/mint_nft breaks CML Change Balancing #73

Open
MitchTurner opened this issue Dec 23, 2022 · 3 comments

Comments

@MitchTurner
Copy link
Collaborator

"I'm using CML to build a TX for minting a one-shot token. Meaning I need to manually specify an input UTxO for the Policy to pass.

I've gotten it to work once, but I think I've encountered a subtle bug on my second run. The input it is specifying has the minimum Coin value, so it shouldn't be enough for an output after fees, but for some reason the let input_total = builder.get_total_input()?; in the method add_change_if_needed(), doesn't add any extra inputs to make up for the difference :(. i.e. add_change_if_needed() fails with the error
"Not enough ADA leftover to include non-ADA assets in a change address"

In playing around with the code, I removed the input UTxO from the transaction builder, just to see what inputs it gave me. And in that case it goes ahead and adds a big juicy UTxO to cover the fees + change (but of course the Policy fails on execution).
Is this a bug? Or could I be doing something different in the tx builder to help it add extra inputs?"

@MitchTurner
Copy link
Collaborator Author

Either it's a bug in CML or add_input changes the behavior of the input selection in a way that prevents the desired behavior.

Either way, I've reached out to the dcSpark peeps and hopefully I can get a response from them.

@MitchTurner
Copy link
Collaborator Author

My current solution is just requiring the "arbitrary" input UTxO to be large enough in the mint_nft dapp. This is still leaving a pitfall for the next person who tries this and hasn't seen my example. Admittedly it is kinda a niche case, there aren't many reasons to mint an NFT and send it directly to your wallet without any other specified outputs, but it definitely could happen.

I'll leave a note, but it all feels like leaking CML.

@MitchTurner
Copy link
Collaborator Author

One possible solution, without trying to get a PR through CML, would be to just check the unbuilt tx in our CML Client, and adding extra inputs if needed. I'd actually prefer that to going through the trouble of debugging the CML code and getting a PR through :P

@MitchTurner MitchTurner mentioned this issue Dec 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

1 participant