From 6205097dd8e23a4241e0fc90951e18c6eec6ddb9 Mon Sep 17 00:00:00 2001 From: ai-bot Date: Mon, 16 Nov 2026 19:21:21 +0000 Subject: [PATCH] Let kroner move only through the bank --- validation.py | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/validation.py b/validation.py index d3f79cf..066ca45 100644 --- a/validation.py +++ b/validation.py @@ -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"]