Skip to content

Commit f8daca6

Browse files
committed
Fix min lovelace when the input is Value type
1 parent 2b55909 commit f8daca6

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

pycardano/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def min_lovelace(
103103
Returns:
104104
int: Minimum required lovelace amount for this transaction output.
105105
"""
106-
if isinstance(amount, int):
106+
if isinstance(amount, int) or not amount.multi_asset:
107107
return context.protocol_param.min_utxo
108108

109109
b_size = bundle_size(amount.multi_asset)

test/pycardano/test_util.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ def test_min_lovelace_ada_only(chain_context):
1010
assert min_lovelace(2000000, chain_context) == chain_context.protocol_param.min_utxo
1111

1212

13+
def test_min_lovelace_ada_only_2(chain_context):
14+
assert min_lovelace(Value(2000000), chain_context) == chain_context.protocol_param.min_utxo
15+
16+
1317
class TestMinLoveLaceMultiAsset:
1418

1519
# Tests copied from: https://github.com/input-output-hk/cardano-ledger/blob/master/doc/explanations/min-utxo-alonzo.rst#example-min-ada-value-calculations-and-current-constants

0 commit comments

Comments
 (0)