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

Avoid using immature coinbase inputs #614

Conversation

danielabrozzoni
Copy link
Member

@danielabrozzoni danielabrozzoni commented May 25, 2022

Description

With this PR we start considering how many confirmations a coinbase has. If it's not mature yet, we don't use it for building transactions.
Fixes #413

Notes to the reviewers

This PR is based on #611, review that one before reviewing this 😄

007c5a7 adds a coinbase parameter to populate_test_db, to specify if you want the db to be populated with immature coins. This is useful for test_spend_coinbase, but that's probably going to be the only use case.
I don't think it's a big deal to have a test function take an almost_always_useless parameter - it's not an exposed API, anyways. But, if you can come up with a different way of implementing test_spend_coinbase that doesn't require 007c5a7, even better! I looked for it for a while, but other than duplicating the whole populate_test_db code, which made the test way harder to comprehend, I didn't find any other way.

Checklists

All Submissions:

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

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

@danielabrozzoni danielabrozzoni force-pushed the 20220317_ignore_immature_coins_in_cs branch from 8520e53 to 36922b2 Compare May 26, 2022 17:20
@danielabrozzoni danielabrozzoni force-pushed the 20220317_ignore_immature_coins_in_cs branch from 36922b2 to 68f7c81 Compare May 26, 2022 21:32
@danielabrozzoni danielabrozzoni force-pushed the 20220317_ignore_immature_coins_in_cs branch from 68f7c81 to 59b0c52 Compare June 3, 2022 15:18
Copy link
Contributor

@rajarshimaitra rajarshimaitra left a comment

Choose a reason for hiding this comment

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

Concept ACK..

I have a comment on the selection logic..

src/wallet/mod.rs Outdated Show resolved Hide resolved
src/database/memory.rs Show resolved Hide resolved
Copy link
Contributor

@vladimirfomene vladimirfomene left a comment

Choose a reason for hiding this comment

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

Pulled changes, tested and reviewed code. I found it hard to review the macro part because I'm not very comfortable with macros. Tested ACK

src/wallet/mod.rs Outdated Show resolved Hide resolved
@danielabrozzoni danielabrozzoni force-pushed the 20220317_ignore_immature_coins_in_cs branch from 59b0c52 to 93ca3b9 Compare June 13, 2022 09:23
@danielabrozzoni
Copy link
Member Author

Rebased, and also updated set_current_height documentation

Copy link
Contributor

@wszdexdrf wszdexdrf left a comment

Choose a reason for hiding this comment

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

Tested ACK 93ca3b9

Copy link
Contributor

@rajarshimaitra rajarshimaitra left a comment

Choose a reason for hiding this comment

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

tACK 93ca3b9

src/wallet/mod.rs Outdated Show resolved Hide resolved
src/wallet/mod.rs Show resolved Hide resolved
src/wallet/mod.rs Outdated Show resolved Hide resolved
@danielabrozzoni danielabrozzoni force-pushed the 20220317_ignore_immature_coins_in_cs branch 2 times, most recently from 1cc696e to ab2397a Compare June 28, 2022 09:07
Allows user to ask for a test db populated with clean coins
from coinbases. This is useful for testing the wallet behaviour
when some inputs are coinbases.
@danielabrozzoni danielabrozzoni force-pushed the 20220317_ignore_immature_coins_in_cs branch from ab2397a to 3406908 Compare June 30, 2022 09:50
src/wallet/mod.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@rajarshimaitra rajarshimaitra left a comment

Choose a reason for hiding this comment

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

ReACK 3406908

One non blocking note..

src/database/memory.rs Show resolved Hide resolved
Copy link
Member

@afilini afilini left a comment

Choose a reason for hiding this comment

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

ACK e85aa24

@afilini afilini merged commit ec22fa2 into bitcoindevkit:master Jul 5, 2022
afilini added a commit that referenced this pull request Aug 4, 2022
0f03831 Change get_balance to return in categories. (wszdexdrf)

Pull request description:

  ### Description
  This changes `get_balance()` function so that it returns balance separated in 4 categories:
  - available
  - trusted-pending
  - untrusted-pending
  - immature

  Fixes #238

  ### Notes to the reviewers
  Based on #614

  ### Checklists

  #### All Submissions:

  * [x] I've signed all my commits
  * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)
  * [x] I ran `cargo fmt` and `cargo clippy` before committing

  #### New Features:

  * [x] I've updated tests for the new feature
  * [x] I've added docs for the new feature
  * [x] I've updated `CHANGELOG.md`

ACKs for top commit:
  afilini:
    ACK 0f03831

Tree-SHA512: 39f02c22c61b6c73dd8e6d27b1775a72e64ab773ee67c0ad00e817e555c52cdf648f482ca8be5fcc2f3d62134c35b720b1e61b311cb6debb3ad651e79c829b93
@danielabrozzoni danielabrozzoni deleted the 20220317_ignore_immature_coins_in_cs branch August 16, 2022 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

BDK will select coinbase inputs that are not matured yet
7 participants