mobilecoinofficial / full-service

A MobileCoin service for wallet implementations.
Other
46 stars 21 forks source link

fix update_key_images to not mark spent txos as unspent #1007

Closed holtzman closed 1 week ago

holtzman commented 1 week ago

Motivation

Full-service is taking spent txos and sometimes clearing their spent_block_index in the wallet db, which makes them appear unspent. This causes double spend key_image errors when trying to spend funds, and can result in a complete inability for a client to spend any funds in an account.

In this PR

Fixes update_key_image function to treat a None value for the spent_block_index parameter is an indication that the function should not update the spent_block_index, rather than setting it to null in the database.

As the spent_block_index database column starts as null, and is only changed to a block_index when the key_image that corresponds to the txo appears in the ledger, there is no need or reason to set it to null in this function.

Test Plan

docs-page[bot] commented 1 week ago

To view this pull requests documentation preview, visit the following URL:

docs.page/mobilecoinofficial/full-service~1007

Documentation is deployed and generated using docs.page.

codecov-commenter commented 1 week ago

Codecov Report

Attention: Patch coverage is 33.33333% with 6 lines in your changes missing coverage. Please review.

Project coverage is 69.03%. Comparing base (ab2af32) to head (549ee86). Report is 208 commits behind head on main.

Files with missing lines Patch % Lines
full-service/src/db/txo.rs 33.33% 6 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1007 +/- ## ========================================== + Coverage 60.12% 69.03% +8.90% ========================================== Files 88 125 +37 Lines 12356 16629 +4273 Branches 2010 2793 +783 ========================================== + Hits 7429 11479 +4050 - Misses 3238 5150 +1912 + Partials 1689 0 -1689 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.