Skip to content

[MEDIUM] admin_cancel lacks the atomic CAS status guard that admin_settle has #810

Description

@grunch

Severity: MEDIUM

admin_cancel lacks the atomic compare-and-set status guard that admin_settle has.

Where

src/app/admin_cancel.rs vs src/app/admin_settle.rs.

Problem

admin_settle guards its transition with a conditional update (only acts if the order is still in the expected status), which makes concurrent invocations idempotent. admin_cancel does not have the equivalent guard, so two concurrent admin-cancel requests (or an admin-cancel racing another transition) can both proceed. Combined with the irreversible cancel_hold_invoice side effect (see the "refund before validation" issue), this is worth hardening.

Suggested fix

Mirror admin_settle's CAS pattern in admin_cancel: transition status atomically and only run the LN side effect when the CAS actually updated the row.

Found during the deep review accompanying #803.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions