<!-- XE-0067 · [Lease Accounting] LeaseCancel after LeaseRenew refunds only the base cost — renewal top-up funds vanish (supply conservation broken) · testnet -->
*Markdown view of <https://bounty.xe.network/XE-0067>. The page is the record; this is the same page for reading.*

XE-0067 · Bounty

# \[Lease Accounting\] LeaseCancel after LeaseRenew refunds only the base cost — renewal top-up funds vanish (supply conservation broken)

Accepted
claimed Medium
[xe#92](https://github.com/xeprotocol/xe/issues/92)
filed 2026-10-26 21:52 UTC
by xe:6cf52cc9

Verdict
:   published when the fix ships

Tier
:   published when the fix ships

Claimed
:   Medium

Area
:   Leasing / ledger

Duplicate of
:   —

Tracked
:   internally

Updated
:   2026-11-16 13:42 UTC

Told
:   2026-11-05 22:11 UTC

### Patches

- [xe#109](https://github.com/xeprotocol/xe/pull/109) open by arturbarszcz78
  fix(core,store): refund full pending escrow including renewals on lease\_cancel (#92)

### History

- [9675](https://bounty.xe.network/log/9675) 2026-11-05 22:11 UTC reply.mirrored
- [9674](https://bounty.xe.network/log/9674) 2026-11-05 22:11 UTC reply.sent
- [9673](https://bounty.xe.network/log/9673) 2026-11-05 22:11 UTC proposal.adopted
- [9670](https://bounty.xe.network/log/9670) 2026-11-05 22:11 UTC proposal.adopted
- [9669](https://bounty.xe.network/log/9669) 2026-11-05 22:11 UTC ticket.award
- [9665](https://bounty.xe.network/log/9665) 2026-11-05 22:11 UTC proposal.rejected
- [6897](https://bounty.xe.network/log/6897) 2026-11-05 13:45 UTC proposal.created
- [1823](https://bounty.xe.network/log/1823) 2026-11-02 19:16 UTC proposal.created
- [1822](https://bounty.xe.network/log/1822) 2026-11-02 19:16 UTC proposal.created
- [1476](https://bounty.xe.network/log/1476) 2026-11-02 10:11 UTC note.added
- [748](https://bounty.xe.network/log/748) 2026-10-29 14:22 UTC note.added
- [747](https://bounty.xe.network/log/747) 2026-10-29 14:22 UTC ticket.facts area

[Full history](https://bounty.xe.network/log?ref=XE-0067) · [JSON](https://bounty.xe.network/v1/tickets/XE-0067) · [markdown](https://bounty.xe.network/XE-0067.md)

### Report

Suggested severity: Medium (2,500 XE).

## Summary

After a `lease_renew`, the pending escrow grows by the renewal top-up (`core/lease_renew.go:137-138`, applied as `pending += topUp` in `store/mem_store.go:338-343`). But `validateAndAddLeaseCancel` computes the refund as `expectedBal := oldBal + leaseBlock.Amount` (core/ledger.go:1853), where `leaseBlock.Amount` is only the BASE segment cost, and then deletes the entire pending escrow (`DeletePendingID` \+ `CancelLeaseHash`, core/ledger.go:1858-1867). The difference — the total renewal cost — is neither refunded to the consumer nor paid to the provider: it vanishes from circulation (a supply-conservation break, deflationary).

## Impact

A consumer who renews and then cancels loses exactly the renewal amount. This is provably a bug, not design: `validateAndAddLeaseForceSettle` (core/ledger.go:1879) correctly refunds `pending.Amount` (base \+ renewals) and settle burns the full pending. Only cancel uses the base figure.

## Steps to Reproduce (local, no real funds)

1. Consumer creates a lease (base cost C) and the provider accepts it.
2. Consumer renews (top-up R); observe pending escrow becomes C \+ R.
3. Consumer cancels (via the cancel-wins path if the accept is not yet finalized).
4. Observed: consumer balance after cancel is initial \- R (refund is only C); the R top-up is gone; the pending escrow is deleted in full; the lease ends Cancelled. Measured locally: initial 500,000,000,000 -\> after renew 499,999,940,000 -\> after cancel 499,999,970,000 (base 30,000 refunded, renewal 30,000 lost).

## Recommendation

Compute the cancel refund from `pending.Amount` (base \+ all renewal top-ups), exactly as force-settle does, and clear stale `Renewals` in the cancel-wins rollback path.

Honest caveat: the victim here is the consumer cancelling their own lease (not theft by an attacker), which is why this is filed as Medium, not High/Critical. This is a different function and root cause from force-settle accounting: cancel refunds `leaseBlock.Amount` instead of `pending.Amount`.

Payout address: to be provided on request.

### Thread

**Joseph Denne**team2026-11-05 22:11 UTCgithub

Thanks for the reports. To pay out we need an XE payout address in the report itself: please edit the issue body to add a line "Payout address: xe\_..." and say here when it is done. The desk entry is https://bounty.xe.network/XE-0067.

**Ryanmahrez44**2026-11-05 23:56 UTCgithub

Done — I have added my payout address to the issue body: xe\_a52c0b32eeAAf26015Fb27e2AfFDddA41ff9CE4c

**Reyzz95**2026-11-10 10:29 UTCgithub

Still reproduces at HEAD `89a542e` (testnet-0005, 2026-11-10).

`validateAndAddLeaseCancel` (`core/ledger.go:1852-1867`) refunds only the base cost (`expectedBal := oldBal + leaseBlock.Amount`) while deleting the whole pending escrow.

PoC (local `go test`, `TestPOCAreaB_XE0067_CancelAfterRenew`): escrow 2,668 (base 1,334 \+ renewal 1,334); after cancel the consumer holds 9,998,666 vs 10,000,000 start — the 1,334 renewal top-up vanished.

Note force-settle (`ledger.go:1970`) and the staged validator (`ledger.go:2817`) both use the full pending amount, so the codebase disagrees with itself here.
