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

Respect trustline limit in to_classic conversions #516

Merged
merged 3 commits into from
Oct 5, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions soroban-env-host/src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1022,11 +1022,14 @@ impl Host {
let base_reserve = self.with_ledger_info(|li| Ok(li.base_reserve))? as i64;
let (min_balance, max_balance) = if let TrustLineEntryExt::V1(ext1) = &tl.ext {
let min_balance = ext1.liabilities.selling;
let max_balance = i64::MAX - ext1.liabilities.buying;
if tl.limit < ext1.liabilities.buying {
return Err(self.err_general("limit is lower than liabilities"));
}
let max_balance = tl.limit - ext1.liabilities.buying;
(min_balance, max_balance)
} else {
let min_balance = 0;
let max_balance = i64::MAX;
let max_balance = tl.limit;
(min_balance, max_balance)
};

Expand Down