diff --git a/src/records/balance_sheet/pathing.rs b/src/records/balance_sheet/pathing.rs index 902b033..0456add 100644 --- a/src/records/balance_sheet/pathing.rs +++ b/src/records/balance_sheet/pathing.rs @@ -35,11 +35,15 @@ pub fn balance_root_path() -> PathBuf { PathBuf::from(balance_path) } -pub fn canonical_balance_address(address: &str) -> Option { - // Balance storage is normalized to the deterministic short address, - // regardless of whether callers still pass a long or short address. - Wallet::normalize_to_short_address(address) -} +pub fn canonical_balance_address(address: &str) -> Option { + // Balance storage is normalized to the deterministic short address, + // regardless of whether callers still pass a long or short 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 { let canonical_address = canonical_balance_address(address)?; diff --git a/src/records/record_chain/pending_effects.rs b/src/records/record_chain/pending_effects.rs index 714f21d..2c08f30 100644 --- a/src/records/record_chain/pending_effects.rs +++ b/src/records/record_chain/pending_effects.rs @@ -249,7 +249,12 @@ fn apply_effect(db: &Db, effect: &PendingEffect) -> Result { 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 { address: address.clone(), amount: *amount,