Skip to content

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

@cedcardano

Description

@cedcardano

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions