Skip to content

fix: clamp negative amounts to 0 in AmountWrapper deserializer#215

Merged
lcovar merged 1 commit intomasterfrom
BTC-3184-amount-wrapper-negative
Mar 18, 2026
Merged

fix: clamp negative amounts to 0 in AmountWrapper deserializer#215
lcovar merged 1 commit intomasterfrom
BTC-3184-amount-wrapper-negative

Conversation

@lcovar
Copy link
Contributor

@lcovar lcovar commented Mar 17, 2026

The staking service can send negative remainingStakingAmount (e.g. "-2282880") when the unstake amount exceeds the current balance. The u64 deserializer rejected these with "invalid digit found in string", preventing the intent from being processed at all.

The intent builder already guards with > 0 checks before using amount values (e.g. partial unstake in build.rs), so clamping negatives to 0 at deserialization is safe and lets the full unstake path proceed correctly.

Ticket: BTC-3184

The staking service can send negative remainingStakingAmount (e.g.
"-2282880") when the unstake amount exceeds the current balance.
The u64 deserializer rejected these with "invalid digit found in
string", preventing the intent from being processed at all.

The intent builder already guards with > 0 checks before using
amount values (e.g. partial unstake in build.rs), so clamping
negatives to 0 at deserialization is safe and lets the full unstake
path proceed correctly.

Ticket: BTC-3184
@lcovar lcovar requested a review from a team as a code owner March 17, 2026 23:56
@lcovar lcovar merged commit aaff21f into master Mar 18, 2026
13 checks passed
@lcovar lcovar deleted the BTC-3184-amount-wrapper-negative branch March 18, 2026 00:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants