Let kroner move only through the bank

This commit is contained in:
ai-bot committed 2026-11-16 19:21:21 +00:00
1 parent 629d8069f7
commit 6205097dd8
1 file changed
+17 -13
+17 -13
View File
@@ -292,19 +292,23 @@ def validate_transaction(payload, markets):
errors[name] = "Feltet høyrer ikkje til denne typen."
if tx_type == "transfer_out":
_check_transfer_out(legs, errors)
# An empty destination is a withdrawal, and only kroner can be
# withdrawn (docs/spec.md section 3.11).
if _blank(data.get("to_market_id")):
if legs["leg_out_ore"] is None:
errors["to_market_id"] = "Ei overføring i sats må ha ein mottakar."
else:
to_market_id, error = validate_market_id(
data.get("to_market_id"), markets, "to_market_id"
)
if error:
errors["to_market_id"] = error
elif to_market_id == market_id:
errors["to_market_id"] = "Overføringa må gå til ein annan konto."
to_market_id, error = validate_market_id(
data.get("to_market_id"), markets, "to_market_id"
)
if error:
errors["to_market_id"] = error
elif to_market_id == market_id:
errors["to_market_id"] = "Overføringa må gå til ein annan konto."
elif bank_id is not None:
# Kroner go in and out through the bank and never between two real
# accounts; the bank holds no sats (docs/spec.md section 3.11).
if legs["leg_out_ore"] is not None:
if (market_id == bank_id) == (to_market_id == bank_id):
errors["to_market_id"] = (
"Kroner kan berre flyttast til eller frå banken."
)
elif market_id == bank_id or to_market_id == bank_id:
errors["market_id"] = "Banken held ikkje sats."
_check_fee(legs, tx_type, errors)
transaction["leg_in_sats"] = legs["leg_in_sats"]