Fixed an issue where cancelling NFT offer did not cancel other offers… #19129
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixing Chia-Network/chia-blockchain-gui#2563
I found that the primary issues of the above case are:
PENDING_CANCEL
status for trades which also offers the same NFT.trade_id
and not by coins being spent.CANCELLED
status to the trade records.Why cancelling multiple NFT offers doesn't work
When confirming the offer cancellation, which means the offering NFT coin was spent but requesting coins were not created,
trade_records
wallet db table in the issue's situation would be like:PENDING_ACCEPT
PENDING_ACCEPT
PENDING_CANCEL
(This inconsistent statuses is caused by issue
1.
above.)Then look at the code below. This code is executed when monitoring coin state has been changed.
For example, the offering coin is spent to cancel.
https://github.com/Chia-Network/chia-blockchain/blob/2.5.0/chia/wallet/trade_manager.py#L154
The target
trade
whose status is expected to be set toCANCELLED
is acquired byself.get_trade_by_coin(coin_state.coin)
.This is the problem.
When this is executed, it gets
offer1
in the above table.offer1
's status isPENDING_ACCEPT
.When offer is cancelled, its status must be
PENDING_CANCEL
according tohttps://github.com/Chia-Network/chia-blockchain/blob/2.5.0/chia/wallet/trade_manager.py#L204
So the current implementation misses to recognize offer cancellation for NFT.
This is the PR to fix this issue.