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

Remove pre-1.0 code #523

Merged

Conversation

thunderbiscuit
Copy link
Member

@thunderbiscuit thunderbiscuit commented Apr 30, 2024

Instead of closing an issue, this PR opens one: #522.

I just thought I'd be cleaner to keep track of what we want to bring back in an issue (or maybe multiple issues?) rather than just old commented out code that's getting very stale at this point. The basic idea is that every codeblock that is removed here gets an associated todo item in #522.

Let me know what you think.

Summary by CodeRabbit

  • Refactor
    • Streamlined wallet functionalities by removing unused methods related to address and transaction handling.
    • Enhanced transaction builder by modifying the finish method and removing redundant data addition capabilities.
    • Removed outdated comments and unused code across various modules to improve code clarity and maintenance.

Copy link

coderabbitai bot commented Apr 30, 2024

Walkthrough

The recent updates to the bdk-ffi library focus on simplifying and streamlining the API by removing several methods across multiple structures such as Address, Transaction, and Psbt. Additionally, unused code and comments related to various functionalities like fee estimation and transaction building have been cleaned up. These changes indicate a shift towards a more concise and potentially more efficient interface.

Changes

File Path Change Summary
.../bitcoin.rs Removed methods from Address, Transaction, and Psbt.
.../esplora.rs Removed unused estimate_fee function.
.../lib.rs Removed a TODO comment regarding TxIn and Payload.
.../wallet.rs Major clean-up in Wallet struct methods and modifications to TxBuilder.

Recent Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 431ab90 and 5e8271e.
Files selected for processing (4)
  • bdk-ffi/src/bitcoin.rs (3 hunks)
  • bdk-ffi/src/esplora.rs (1 hunks)
  • bdk-ffi/src/lib.rs (1 hunks)
  • bdk-ffi/src/wallet.rs (3 hunks)
Files skipped from review due to trivial changes (2)
  • bdk-ffi/src/esplora.rs
  • bdk-ffi/src/lib.rs
Additional comments not posted (2)
bdk-ffi/src/bitcoin.rs (1)

Line range hint 89-89: Confirm removal of Transaction::lock_time(), Transaction::input(), and Transaction::output().

Ensure that no residual references to these methods exist elsewhere in the codebase.

Verification successful

The analysis of the context in which the terms 'lock_time', 'input', and 'output' appear in the files wallet.rs, error.rs, and bitcoin.rs reveals the following:

  1. wallet.rs: The terms 'input' and 'output' appear in commented-out code and in a method named list_output. These do not seem to be direct references to the removed methods from the Transaction class.

  2. error.rs: The term 'output' appears in an error message related to missing transaction outputs, and 'input' appears in an error message about missing input value information. These are contextually different from the removed methods.

  3. bitcoin.rs: The term 'lock_time' appears in a method is_lock_time_enabled, which is different from the removed lock_time() method. It seems to be a property check rather than a method that was directly removed.

Based on this detailed context analysis, it appears that the references to 'lock_time', 'input', and 'output' in these files are unrelated to the methods removed from the Transaction class. They are either used in different contexts or are part of different functionalities.

Conclusion:
The references to 'lock_time', 'input', and 'output' found in the codebase are not residual references to the removed methods from the Transaction class. They are used in different contexts or functionalities within the codebase.

  • bdk-ffi/src/wallet.rs: Uses 'input' and 'output' in commented code and a different method.
  • bdk-ffi/src/error.rs: Uses 'output' and 'input' in error messages unrelated to the removed methods.
  • bdk-ffi/src/bitcoin.rs: Uses 'lock_time' in a method checking a property, not in the removed method context.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Ensure no residual references to removed methods exist in the codebase.

# Search for 'lock_time', 'input', and 'output' in the entire codebase. Expect: No matches.
rg --files-with-matches --type rust 'lock_time|input|output'

Length of output: 128



Script:

#!/bin/bash
# Description: Inspect the context of 'lock_time', 'input', and 'output' in the mentioned files.

# Display the lines and some surrounding context where 'lock_time', 'input', and 'output' appear in wallet.rs
echo "Context in wallet.rs:"
rg --context 2 'lock_time|input|output' bdk-ffi/src/wallet.rs

# Display the lines and some surrounding context where 'lock_time', 'input', and 'output' appear in error.rs
echo "Context in error.rs:"
rg --context 2 'lock_time|input|output' bdk-ffi/src/error.rs

# Display the lines and some surrounding context where 'lock_time', 'input', and 'output' appear in bitcoin.rs
echo "Context in bitcoin.rs:"
rg --context 2 'lock_time|input|output' bdk-ffi/src/bitcoin.rs

Length of output: 2669

bdk-ffi/src/wallet.rs (1)

Line range hint 245-245: Confirm removal of TxBuilder::add_data() and modifications to finish().

Ensure that no residual references to add_data exist and verify the correct implementation of changes in finish().


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

Note: Auto-reply has been disabled for this repository by the repository owner. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Out of diff range and nitpick comments (3)
bdk-ffi/src/bitcoin.rs (2)

[!TIP]
Codebase Verification

The verification process has revealed that the removed method Address::from_script is still referenced in the codebase within a commented section in bdk-ffi/src/wallet.rs. Although this does not impact the functionality, it could potentially lead to confusion. It is advisable to either update or remove this commented code to maintain clarity.

  • File and location: bdk-ffi/src/wallet.rs (within commented code)
Analysis chain

Line range hint 38-38: Confirm removal of Address::from_script() and Address::payload().

Ensure that no residual references to these methods exist elsewhere in the codebase.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Ensure no residual references to removed methods exist in the codebase.

# Search for 'from_script' and 'payload' in the entire codebase. Expect: No matches.
rg --files-with-matches --type rust 'from_script|payload'

Length of output: 81



Script:

#!/bin/bash
# Description: Extract and display the lines from bdk-ffi/src/wallet.rs where 'from_script' and 'payload' are mentioned.

# Use ripgrep to find the lines containing 'from_script' or 'payload' and display 2 lines of context around each match.
rg --context 2 'from_script|payload' bdk-ffi/src/wallet.rs

Length of output: 300


[!TIP]
Codebase Verification

The output from the script reveals that the methods txid, combine, fee_amount, fee_rate, and json_serialize are still referenced in various files within the bdk-ffi directory. These references appear in active code segments, not just in comments or deprecated sections. This indicates that the removal of these methods from the Psbt class could potentially lead to issues in other parts of the codebase that rely on these methods.

Given the findings, it is clear that there are residual references to the removed methods, which could affect the functionality of the codebase. The developers need to address these references either by updating them to align with the new method implementations or by revising the parts of the code that depend on these removed methods.

Conclusion:

  • Several files in the codebase still use the old function signatures.
  • The following files contain references to the removed methods and need attention:
    • bdk-ffi/src/error.rs
    • bdk-ffi/src/keys.rs
    • bdk-ffi/src/descriptor.rs
    • bdk-ffi/src/types.rs
    • bdk-ffi/src/wallet.rs
    • bdk-ffi/src/bitcoin.rs
Analysis chain

Line range hint 156-156: Confirm removal of Psbt::txid(), Psbt::combine(), Psbt::fee_amount(), Psbt::fee_rate(), and Psbt::json_serialize().

Ensure that no residual references to these methods exist elsewhere in the codebase.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Ensure no residual references to removed methods exist in the codebase.

# Search for 'txid', 'combine', 'fee_amount', 'fee_rate', 'json_serialize' in the entire codebase. Expect: No matches.
rg --files-with-matches --type rust 'txid|combine|fee_amount|fee_rate|json_serialize'

Length of output: 220



Script:

#!/bin/bash
# Description: Inspect the contents of the files where removed methods are referenced to understand the context.

# List occurrences of 'txid', 'combine', 'fee_amount', 'fee_rate', 'json_serialize' in the specified files.
rg 'txid|combine|fee_amount|fee_rate|json_serialize' bdk-ffi/src/error.rs bdk-ffi/src/keys.rs bdk-ffi/src/descriptor.rs bdk-ffi/src/types.rs bdk-ffi/src/wallet.rs bdk-ffi/src/bitcoin.rs

Length of output: 4477

bdk-ffi/src/wallet.rs (1)

[!TIP]
Codebase Verification

The extensive output from the script reveals that the methods new, is_mine, get_address, get_internal_address, get_balance, sign, list_transactions, and list_unspent are still referenced across multiple files in the codebase. This includes active code usage, not just comments or documentation. This indicates that the removal of these methods from the Wallet class might have been premature or incomplete, as they are still actively used or required by other parts of the codebase.

Here are the specific issues found:

  • Active method implementations and calls: The methods are not only declared but also implemented and called in various parts of the codebase. For example, Wallet::new, Wallet::get_address, and Wallet::sign are actively used in wallet.rs.
  • References in other files: Other files like esplora.rs, bitcoin.rs, types.rs, keys.rs, descriptor.rs, and error.rs also reference these methods either in their implementations or in related functionality.

Given these findings, it is clear that the removal of these methods has not been fully accounted for in the codebase. This could potentially lead to runtime errors if the code attempts to call these now-nonexistent methods.

Conclusion

Several files in the codebase still actively use the methods that were supposed to be removed. This could lead to significant functionality issues or crashes. It is recommended to either restore these methods in the Wallet class or refactor the other parts of the codebase to remove the dependencies on these methods.

  • Files and methods that need attention:
    • bdk-ffi/src/wallet.rs: References to all removed methods
    • bdk-ffi/src/esplora.rs: References to new
    • bdk-ffi/src/bitcoin.rs: References to new, get_address
    • bdk-ffi/src/types.rs: References to get_address
    • bdk-ffi/src/keys.rs: References to new
    • bdk-ffi/src/descriptor.rs: References to new
    • bdk-ffi/src/error.rs: References to new, sign
Analysis chain

Line range hint 11-11: Confirm removal of commented-out methods in Wallet class.

Ensure that no residual references to these methods exist elsewhere in the codebase.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Ensure no residual references to removed methods exist in the codebase.

# Search for 'new', 'is_mine', 'get_address', 'get_internal_address', 'get_balance', 'sign', 'list_transactions', 'list_unspent' in the entire codebase. Expect: No matches.
rg --files-with-matches --type rust 'new|is_mine|get_address|get_internal_address|get_balance|sign|list_transactions|list_unspent'

Length of output: 288



Script:

#!/bin/bash
# Description: Extract the lines of code from each file where the removed methods are referenced to understand the context.

# List of methods removed
methods='new|is_mine|get_address|get_internal_address|get_balance|sign|list_transactions|list_unspent'

# Files to check
files="bdk-ffi/src/wallet.rs bdk-ffi/src/esplora.rs bdk-ffi/src/bitcoin.rs bdk-ffi/src/types.rs bdk-ffi/src/keys.rs bdk-ffi/src/descriptor.rs bdk-ffi/src/error.rs"

# Extract relevant lines from each file
for file in $files; do
    echo "File: $file"
    rg --context 2 "$methods" $file
    echo "----------------------------------------"
done

Length of output: 31489

Copy link
Collaborator

@reez reez left a comment

Choose a reason for hiding this comment

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

ACK 5e8271e

Awesome

@thunderbiscuit thunderbiscuit merged commit 5e8271e into bitcoindevkit:master May 1, 2024
25 checks passed
@thunderbiscuit thunderbiscuit deleted the refactor/remove-old-code branch May 1, 2024 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants