# Cancel

Source: https://docs.settlemint.com/docs/operators/user-guides/system-addons/xvp-settlement/actions/cancel
Stop an open XvP settlement and return locked assets to their original senders.
Learn when the cancel endpoint cancels immediately, when it records an HTLC
cancel vote, and when expired-withdrawal is the correct recovery path.




Cancel stops an open XvP exchange before it executes and returns locked assets to
senders. The settlement state determines whether DALP cancels immediately,
records an HTLC cancel vote, allows cancel-vote withdrawal, or requires expired
withdrawal instead.

## Cancellation model [#cancellation-model]

Cancel is final. After the settlement contract cancels the exchange, it cannot
execute. The contract releases the escrowed local assets back to the senders that
locked them.

The cancel endpoint always targets the settlement contract and calls
`proposeCancel`. The contract decides whether that call cancels immediately or
records a vote from the caller.

| State                    | Behavior                                                                                                   | Path                                                                                                                               |
| ------------------------ | ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| Pending local settlement | A local participant can cancel in one transaction.                                                         | Call the cancel endpoint once from a local participant wallet.                                                                     |
| Pending HTLC settlement  | A local participant can cancel in one transaction before all local senders have approved.                  | Call the cancel endpoint once from a local participant wallet.                                                                     |
| Armed HTLC settlement    | Each local participant casts a cancel vote. The last required vote cancels the exchange and refunds funds. | Coordinate one cancel call from every required local participant.                                                                  |
| Secret revealed          | The contract rejects cancel because the HTLC unlock condition has been met.                                | Continue the execution flow instead.                                                                                               |
| Executed                 | The contract rejects cancel because the exchange is complete.                                              | Treat the settlement as final.                                                                                                     |
| Expired                  | The contract rejects cancel after the cutoff.                                                              | Use [Withdraw expired](/docs/operators/user-guides/system-addons/xvp-settlement/actions/withdraw-expired) to release locked funds. |

## How the endpoint behaves [#how-the-endpoint-behaves]

You call the cancel endpoint with the settlement contract address and wallet
verification. The legacy `PUT /xvp/cancel` endpoint returns the transaction hash
for the submitted on-chain call.

```http
PUT /xvp/cancel
Content-Type: application/json

{
  "settlementAddress": "0x71C7656EC7ab88b098defB751B7401B5f6d8976F",
  "walletVerification": {
    "secretVerificationCode": "YOUR_PINCODE"
  }
}
```

```json
{
  "transactionHash": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
}
```

The `POST /api/v2/addons/xvp-cancellation-requests` route can complete
synchronously or return an asynchronous acceptance. Send `Prefer: respond-async`
when you want DALP to accept the request and return a polling URL instead of
waiting for the transaction result.

```http
POST /api/v2/addons/xvp-cancellation-requests
Content-Type: application/json
Prefer: respond-async

{
  "settlementAddress": "0x71C7656EC7ab88b098defB751B7401B5f6d8976F",
  "walletVerification": {
    "secretVerificationCode": "YOUR_PINCODE"
  }
}
```

```json
{
  "transactionId": "01934567-89ab-7def-8123-456789abcdef",
  "status": "QUEUED",
  "statusUrl": "/api/v2/transaction-requests/01934567-89ab-7def-8123-456789abcdef"
}
```

Poll the status URL until the queued transaction reaches a terminal state. The
completed transaction status contains the final transaction hash.

For local settlements and unarmed HTLC settlements, the transaction cancels the
exchange immediately. No second participant approval is part of that path.

For armed HTLC settlements, the same call records the caller's cancel vote. The
exchange stays open until all required local participants have voted. The final
vote completes the cancellation and returns the locked assets.

## Rules and limits [#rules-and-limits]

Check these conditions before you submit a cancel request:

* The caller must be a local participant in the settlement.
* The settlement must still be open. It cannot be executed, already cancelled, or
  past the cutoff.
* A revealed HTLC secret closes the cancel path. Continue execution instead.
* A participant that has voted to cancel an armed HTLC settlement can use the
  withdraw-cancel route only while the settlement is still open and the secret
  remains hidden.
* Expired settlements use expired withdrawal, not cancel, to release locked
  assets.

## Choose your next step [#choose-your-next-step]

Use this overview to decide which operational page fits the current settlement
state:

* To stop a local or same-chain settlement before execution, read
  [Cancel a local settlement](/docs/operators/user-guides/system-addons/xvp-settlement/actions/cancel/local-settlements).
* To coordinate cancel votes for an armed HTLC settlement, read
  [Cancel an HTLC settlement](/docs/operators/user-guides/system-addons/xvp-settlement/actions/cancel/htlc-settlements).
* To understand why a revealed secret changes the cancel path, read
  [HTLC explained](/docs/operators/user-guides/system-addons/xvp-settlement/htlc/htlc-explained).
* To recover funds after the cutoff, read
  [Withdraw expired](/docs/operators/user-guides/system-addons/xvp-settlement/actions/withdraw-expired).

<Card title="Cancel a local settlement" href="/docs/operators/user-guides/system-addons/xvp-settlement/actions/cancel/local-settlements">
  Stop a local settlement before execution and return locked assets.
</Card>

<Card title="Cancel an HTLC settlement" href="/docs/operators/user-guides/system-addons/xvp-settlement/actions/cancel/htlc-settlements">
  Cancel before all local senders approve, or coordinate unanimous cancel votes after approval.
</Card>
