loan fixes

This commit is contained in:
viraladmin 2026-06-28 18:45:16 -06:00
parent f9ed67cbc4
commit 4fad309fc2
2 changed files with 15 additions and 6 deletions

View File

@ -35,11 +35,15 @@ pub fn balance_root_path() -> PathBuf {
PathBuf::from(balance_path) PathBuf::from(balance_path)
} }
pub fn canonical_balance_address(address: &str) -> Option<String> { pub fn canonical_balance_address(address: &str) -> Option<String> {
// Balance storage is normalized to the deterministic short address, // Balance storage is normalized to the deterministic short address,
// regardless of whether callers still pass a long or short address. // regardless of whether callers still pass a long or short address.
Wallet::normalize_to_short_address(address) Wallet::normalize_to_short_address(address).or_else(|| {
} let txid = address.strip_prefix("collateral_")?;
(txid.len() == 64 && txid.chars().all(|c| c.is_ascii_hexdigit()))
.then(|| address.to_ascii_lowercase())
})
}
pub fn address_root_path(address: &str) -> Option<PathBuf> { pub fn address_root_path(address: &str) -> Option<PathBuf> {
let canonical_address = canonical_balance_address(address)?; let canonical_address = canonical_balance_address(address)?;

View File

@ -249,7 +249,12 @@ fn apply_effect(db: &Db, effect: &PendingEffect) -> Result<AppliedEffect, String
operand, operand,
} => { } => {
balance_sheet_operation_with_db(db, address, *amount, coin, operand.as_str()) balance_sheet_operation_with_db(db, address, *amount, coin, operand.as_str())
.map_err(|err| format!("Failed to apply balance effect: {err}"))?; .map_err(|err| {
format!(
"Failed to apply balance effect: {err} address={address} coin={coin:?} amount={amount} operand={}",
operand.as_str()
)
})?;
Ok(AppliedEffect::Balance { Ok(AppliedEffect::Balance {
address: address.clone(), address: address.clone(),
amount: *amount, amount: *amount,