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

KeyError raised for pending funds in wallets with single assets #14

Open
cedcardano opened this issue Dec 30, 2021 · 3 comments
Open

KeyError raised for pending funds in wallets with single assets #14

cedcardano opened this issue Dec 30, 2021 · 3 comments

Comments

@cedcardano
Copy link

There is a situation where KeyError is raised: if a wallet has a single (non-ADA) asset, then if all UTXOs containing that asset are consumed in a transaction, calling wallet.assets() while the transaction is pending (and change has not arrived yet) raises the following KeyError:

    aid: Balance(bal["total"], bal["available"], None)
KeyError: 'available'

To illustrate, there are two situations where the error can be replicated:

First:
Send 10 ADA and 1000 asset A to a fresh wallet X with address Y (so wallet X contains a single UTXO at address Y, and nothing else.)
Submit a transaction on wallet X sending 500 units of asset A to address Y (internal transaction).
Call walletX.assets() before the transaction is confirmed - the above KeyError should be raised.

Second:
Assume wallet X has two UTXOs, each having 5 ADA and 500 asset A.

If you submit a transaction on wallet X sending 500 units of asset A to address Y, there is no issue calling walletX.assets(), it will display 'available' asset A as 500 units as expected, as one of the UTXOs is not consumed. But any transaction that requires the consumption of all inputs of asset A (ie, sending self 600 ADA) will cause KeyError to be raised if walletX.assets() is called whilst pending confirmation.

@cedcardano
Copy link
Author

cedcardano commented Dec 30, 2021

I would guess that this is the case for any transaction made from a wallet that consumes all UTXOs for all the non-ada assets in the wallet. So I would assume even if there are two assets in the wallet, if a single transaction is called that consumes all the UTXOs containing both assets, you would get this issue.

What happens if all the UTXOs for one asset are consumed and pending, but the other asset still has UTXOs left? I'm not sure, I haven't tested it, worth taking a look.

@cedcardano
Copy link
Author

I've done some more testing - it turns out that even if there are many distinct AssetIDs held in a wallet, if any single one of them have all their UTXOs exhausted by pending transactions, then any call to wallet.assets() will result in a KeyError.

@emesik
Copy link
Owner

emesik commented Jan 27, 2022

Hi,
I was unable to reproduce the error but I guess I have found the place in the code where it crashes. Perhaps it was already fixed in the cardano-wallet backend.
Anyway, the release 0.8.2 should be free of that problem. Could you please make a test run to confirm?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants