Validator enable/disable must follow state transitions #28

Closed
opened 2026-06-13 22:02:52 +00:00 by padreug · 0 comments
Owner

Migrated from aiolabs/lamassu-next#28 — opened by @padreug on 2026-02-23.\n\n## Problem

The bill validator runs continuously after initialization. In brain.js, the validator is carefully enabled only during acceptingBills states and disabled everywhere else. Without this, bills could be accepted during QR display, dispensing, errors, or idle — causing undefined behavior.

Current behavior

hal.ts:connectValidator() wires validator events to the state machine but never calls enableValidator()/disableValidator() based on state transitions. The validator accepts bills at all times after init.

Required behavior (from brain.js)

Enable validator when entering:

  • cashIn.insertingBills (after exchange rate fetched)

Disable validator when leaving:

  • cashIn.insertingBills → any other state (FINISH_INSERTING, CANCEL, TIMEOUT, error)
  • On any validator error/disconnect with bills inserted → disable + enter "send only" mode

Also needed:

  • validator.lightOn() when enabling, validator.lightOff() when disabling
  • On billsRead with null denomination → validator.reject() (already handled)
  • On standby event → re-enable if still in accepting state

Implementation

Add XState entry/exit actions on the insertingBills state that call halServices.enableValidator() and halServices.disableValidator(). The HAL services ref is already available in the ATM store.

Impact

Blocker for hardware testing. Without this, inserting a bill while the machine is displaying a QR code or dispensing cash would corrupt the state machine.

> _Migrated from [aiolabs/lamassu-next#28](https://git.atitlan.io/aiolabs/lamassu-next/issues/28) — opened by @padreug on 2026-02-23._\n\n## Problem The bill validator runs continuously after initialization. In brain.js, the validator is carefully enabled only during `acceptingBills` states and disabled everywhere else. Without this, bills could be accepted during QR display, dispensing, errors, or idle — causing undefined behavior. ## Current behavior `hal.ts:connectValidator()` wires validator events to the state machine but never calls `enableValidator()`/`disableValidator()` based on state transitions. The validator accepts bills at all times after init. ## Required behavior (from brain.js) **Enable validator** when entering: - `cashIn.insertingBills` (after exchange rate fetched) **Disable validator** when leaving: - `cashIn.insertingBills` → any other state (FINISH_INSERTING, CANCEL, TIMEOUT, error) - On any validator error/disconnect with bills inserted → disable + enter "send only" mode **Also needed:** - `validator.lightOn()` when enabling, `validator.lightOff()` when disabling - On `billsRead` with null denomination → `validator.reject()` (already handled) - On `standby` event → re-enable if still in accepting state ## Implementation Add XState `entry`/`exit` actions on the `insertingBills` state that call `halServices.enableValidator()` and `halServices.disableValidator()`. The HAL services ref is already available in the ATM store. ## Impact **Blocker for hardware testing.** Without this, inserting a bill while the machine is displaying a QR code or dispensing cash would corrupt the state machine.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
aiolabs/bitspire#28
No description provided.