Skip to content

Commit bd731b1

Browse files
committed
Fix duplicated collateral inputs
1 parent 80cbe98 commit bd731b1

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pycardano/txbuilder.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@ class TransactionBuilder:
129129

130130
required_signers: Optional[List[VerificationKeyHash]] = field(default=None)
131131

132-
collaterals: List[UTxO] = field(default_factory=lambda: [])
132+
collaterals: NonEmptyOrderedSet[UTxO] = field(
133+
default_factory=lambda: NonEmptyOrderedSet[UTxO]()
134+
)
133135

134136
certificates: Optional[List[Certificate]] = field(default=None)
135137

@@ -870,7 +872,7 @@ def _required_signer_vkey_hashes(self) -> Set[VerificationKeyHash]:
870872

871873
def _input_vkey_hashes(self) -> Set[VerificationKeyHash]:
872874
results = set()
873-
for i in self.inputs + self.collaterals:
875+
for i in self.inputs + list(self.collaterals):
874876
if isinstance(i.output.address.payment_part, VerificationKeyHash):
875877
results.add(i.output.address.payment_part)
876878
return results
@@ -1526,6 +1528,7 @@ def _add_collateral_input(cur_total, candidate_inputs):
15261528
"SCRIPT"
15271529
)
15281530
and candidate.output.amount.coin > 2000000
1531+
and candidate not in self.collaterals
15291532
):
15301533
self.collaterals.append(candidate)
15311534
cur_total += candidate.output.amount

0 commit comments

Comments
 (0)