Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wallet: Add ConfirmationSpendPolicy to spend only [un]confirmed outputs #1855

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

stevenroose
Copy link
Contributor

@stevenroose stevenroose commented Feb 25, 2025

Description

Notes to the reviewers

Changelog notice

Checklists

All Submissions:

  • I've signed all my commits
  • I followed the contribution guidelines
  • I ran cargo fmt and cargo clippy before committing

New Features:

  • I've added tests for the new feature
  • I've added docs for the new feature

Bugfixes:

  • This pull request breaks the existing API
  • I've added tests to reproduce the issue which are now passing
  • I'm linking the issue being fixed by this PR

@stevenroose
Copy link
Contributor Author

How do I run cargo fmt? If I do simply that, it changes almost all files.

@ErikDeSmedt
Copy link

This should close #1741

@ValuedMammal
Copy link
Contributor

How do I run cargo fmt? If I do simply that, it changes almost all files.

We use the default rustfmt config (no toml file) using the stable toolchain set to the current rust_version, so cargo fmt should be enough..

@stevenroose
Copy link
Contributor Author

It seems like this codebase doesn't allow using .find().is_some()? The CI says "help: consider using ...", sounds like a friendly suggestion, but it still gives a big red cross 😅

@stevenroose
Copy link
Contributor Author

It's in a unit test even for crying out loud.

@stevenroose
Copy link
Contributor Author

stevenroose commented Feb 27, 2025

error: called `is_none()` after searching an `Iterator` with `find`
   --> crates/wallet/tests/wallet.rs:845:13
    |
845 |       assert!(ret
    |  _____________^
846 | |         .unsigned_tx
847 | |         .input
848 | |         .iter()
849 | |         .find(|i| i.previous_output.txid == confirmed_txid)
850 | |         .is_none());
    | |__________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#search_is_some
help: consider using
    |
845 ~     assert!(!ret
846 +         .unsigned_tx
847 +         .input
848 ~         .iter().any(|i| i.previous_output.txid == confirmed_txid));

sigh how is

assert!(!ret
    ... 5 lines later
    any());

More readable than using .iter().find(...).is_none()? That negation ! right after the macro ! is barely visible.

@stevenroose
Copy link
Contributor Author

Fwiw, I pushed a commit to comply with CI. Didn't put my name on it, though.

@stevenroose stevenroose force-pushed the confirmation-policy branch 2 times, most recently from 102c07b to ef018d9 Compare February 27, 2025 19:19
Copy link
Contributor

@ValuedMammal ValuedMammal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this @stevenroose

@stevenroose stevenroose force-pushed the confirmation-policy branch from ef018d9 to b0d2c72 Compare March 3, 2025 16:37
@stevenroose
Copy link
Contributor Author

The CI failures seem to be about stuff I didn't touch. Can they be restarted?

stevenroose added a commit to ark-bitcoin/bark that referenced this pull request Mar 6, 2025
This branch includes:
- bitcoindevkit/bdk#1855
- bitcoindevkit/bdk#1839
- the patch for esplora-client
@stevenroose stevenroose force-pushed the confirmation-policy branch from b0d2c72 to ce723f1 Compare March 6, 2025 17:42
@stevenroose
Copy link
Contributor Author

Rebased.

@stevenroose stevenroose force-pushed the confirmation-policy branch from ce723f1 to 1bdf729 Compare March 6, 2025 18:02
Copy link
Contributor

@oleonardolima oleonardolima left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cACK 1bdf729

Thanks for working on this one, it looks pretty straight-forward. I was wondering about the name, but couldn't get to anything better 🤔 (should we stick with ...Forbidden usage as in ChangePolicy?).

I'd squash it into a single commit, and add the feat(wallet): prefix for conventional commits though.

@stevenroose
Copy link
Contributor Author

Hmm, well, Change is more binary than Confirmed, I felt. You mean doing UnconfirmedAllowed, UnconfirmedForbidden, OnlyUnconfirmed but then the height one becomes awkward, ConfirmedAfterForbidden or something? Idk, I feel like the names with Only make more sense if you can say "confirmed" vs "unconfirmed". With change that's harder, you'd have to say OnlyNotChange or so 😅

Anyway, semantics, happy to bikeshed more :)

@stevenroose
Copy link
Contributor Author

When it comes to squashing, I prefer not to attach my name to code I would not have written.. Like this
image

If you insist, I can put a disclaimer in my commit message. Since open-source is largely based on voluntary contributions, we should at least be entitled to pride in our work :) I'll put the prefix in.

@stevenroose stevenroose force-pushed the confirmation-policy branch from 1bdf729 to 4309fb3 Compare March 9, 2025 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

4 participants