bdk
bdk copied to clipboard
Add API to delete spent UTXOs from database
Description
We currently store spent UTXOs in the database with an is_spent
field and we don't provide users with a way to delete these UTXOs. The issue here is that these could easily bloat the database or memory. This PR provides methods that can allow users to delete spent UTXOs from the database following certain criteria like size of spent utxos and number of confirmations.
This PR fixes issue #573
Notes to the reviewers
I haven't added this change to the change log and written test for it. I'm thinking we can use this PR as a starting point to discuss how best we can solve this issue. I think having an API that users can call manually is a great start towards solving this issue but it might also be necessary to implement an automatic version of this.
Checklists
All Submissions:
- [x] I've signed all my commits
- [x] I followed the contribution guidelines
- [x] I ran
cargo fmt
andcargo clippy
before committing
New Features:
- [ ] I've added tests for the new feature
- [x] I've added docs for the new feature
- [ ] I've updated
CHANGELOG.md
Thanks @rajarshimaitra for the great feedback! I have pushed some changes with the following:
- [x] Made the code more ergonomic.
- [x] Implemented the functionality as defaults methods on the Database trait.
- [x] Use
del_spent_utxos
indelete_spent_utxos_by_criteria
.
What is left: I have not added test because I believe a lot will still change on the current implementation. I have also not amended the code so that the two criteria can work in conjunction.
@rajarshimaitra and @danielabrozzoni , I have amended the PR based on your recommendations. I have also added tests for the methods.
@vladimirfomene did you also fix https://github.com/bitcoindevkit/bdk/pull/725#discussion_r967649903 ? Looking at the code, it seems to me it hasn't been
Yes I did
I have removed the del_spent_utxos_by_criteria
method and its test. We decided to remove the del_spent_utxos_by_criteria
because we don't currently store data that tells us how many blocks ago a utxo was spent. We only store data that tells us how many blocks ago, a utxo was received. This makes it hard to calculate the number of blocks passed since a utxo was spent and therefore difficult to use that as a criteria for deletion.
Hey sorry but I need to take this out of the 0.23 release, and there's a chance that with the up-coming bdk_core
work we may not need it. But this PR is a still a good bit of work so let's leave it open until we have more info.
My 2 sats would be to get it into bdk anyway even if we might not need it after bdk_core integration.. A full featured bdk_core integration would take a bit of time, and this can be useful feature to add for wallet devs anyway who might wanna stay with the older versions of bdk..
In my opinion getting this in might cause more disrupt than help:
- It takes resources away from bdk-core (I can't work on bdk_core and review on bdk at the same time :))
- We don't have proof that people need this right now
I agree that it might be useful to get this one in for the ones that want to stay on bdk
0.something
instead of switching to1.0
, but IMHO we should wait for the bdk_core integration to be almost ready before deciding this
Hey, we are in the process of releasing BDK 1.0, which will under the hood work quite differently from the current BDK. For this reason, I'm closing all the PRs that don't really apply anymore. If you think this is a mistake, feel free to rebase on master and re-open!