mirror of
https://github.com/Routstr/routstr-core.git
synced 2026-10-05 12:28:22 +00:00
The auto top-up field has always been labelled "When credits are below (Sats)", but the backend compared it as `balance >= threshold * 1000` against a balance get_balance() had already converted to sats. Its sibling topup_amount_limit is plain sats - it goes straight to send_token(amount, "sat", ...). So one settings blob carried two units and the UI promised the one it did not use: an operator asking to top up below 1000 sats got one below 1,000,000. topup_threshold_sats says what it means and is compared as written. A legacy topup_threshold keeps the thousandfold it has always been compared with, since reinterpreting stored values as sats would drop the trigger point by a factor of 1000 on upgrade and leave a peer to run dry. A one-off warning per provider names the sats value to migrate to. The settings form now edits topup_threshold_sats, seeding it from the legacy value times 1000 so the number shown is the number in force. Editing therefore starts from the truth rather than silently moving the trigger on the next save, and saving drops the legacy key so the stored blob carries one unit. Validation accepts either key and rejects a blob carrying neither. The PPQ path keeps its own topup_threshold, which is USD and unaffected.