cardano-client-lib
cardano-client-lib copied to clipboard
Check if minimum Ada is not met - issue
Hi,
In the UtxoTransactionBuilderImpl.buildOuputsForSenderFromUtxos you have this check
//Check if minimum Ada is not met. Topup //Transaction will fail if minimum ada not there. So try to get some additional utxos verifyMinAdaInOutputAndUpdateIfRequired(transactionInputs, changeOutput, detailsParams, utxoSet, protocolParams);
this is not quite correct as the rule is : transaction should be min 1 ada and not the resulting UTOX in the wallet.
For example if I have 1.5 ada in a wallet and I want to transfer it this should be fine (1.5 - fee). the node will validate it.
Thanks.
this is not quite correct as the rule is : transaction should be min 1 ada and not the resulting UTOX in the wallet.
As per my understanding, resulting UTXO should have some min ada. Without multi-asset it is 1 ada. Please check here https://docs.cardano.org/native-tokens/minimum-ada-value-requirement
For example if I have 1.5 ada in a wallet and I want to transfer it this should be fine (1.5 - fee). the node will validate it.
Yes node should validate that. In this case most probably there will be only 1 Utxo.
Just to clarify a bit, the issue I'm signaling here is that with this condition there you cannot send all the ada from a wallet, it throws the error.
If I comment out the verifyMinAdaInOutputAndUpdateIfRequired works just fine.
@sourcelib-stack Thanks for the clarification.
If sender balance = 1.5 Ada, fee = 0.169813 Ada then you need to send exactly 1.330187 ADA to receiver to send all ada from sender wallet.
This can be done in the application by getting sender's balance and calculating fee and set the transfer amount after subtracting the fee. So no change output.
But I just noticed that, in this case feeCalculation api is also throwing exception (not enough utxo) as it also tries to build the transaction. So if you are not able to calculate fee, you can't calculate final balance.
But I think the library should not throw this exception during fee calculation.
I think the following change in the last release introduced the error during feeCalculation. I need to see how to fix that as other part of the lib depends on this exception.
https://github.com/bloxbean/cardano-client-lib/commit/84b498fae272cc1c669bbf0bf07c65eb20f11866
Thanks for reporting this.
Closing this. @sourcelib-stack please re-open if you still see this issue.