Skip to content

feat: address filtering on the basis of active and inactive field#358

Merged
rmeena840 merged 1 commit intomasterfrom
346-worker-activeinactive-address-filtering
Feb 13, 2026
Merged

feat: address filtering on the basis of active and inactive field#358
rmeena840 merged 1 commit intomasterfrom
346-worker-activeinactive-address-filtering

Conversation

@rmeena840
Copy link
Contributor

@rmeena840 rmeena840 commented Feb 13, 2026

Description

Closes: #346


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • added appropriate labels to the PR
  • provided a link to the relevant issue or specification
  • added a changelog entry to CHANGELOG.md
  • included doc comments for public functions
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary

Summary by Sourcery

Filter nBTC deposits to ignore inactive deposit addresses and add coverage for this behavior.

New Features:

  • Support filtering out inactive nBTC deposit addresses when scanning transaction outputs.

Enhancements:

  • Log debug information when skipping inactive deposit addresses and remove obsolete TODO about active/inactive address support.

Tests:

  • Add a unit test verifying that inactive deposit addresses are skipped during nBTC deposit discovery.

Signed-off-by: Ravindra Meena <rmeena840@gmail.com>
@rmeena840 rmeena840 self-assigned this Feb 13, 2026
@rmeena840 rmeena840 requested a review from a team as a code owner February 13, 2026 11:36
@rmeena840 rmeena840 linked an issue Feb 13, 2026 that may be closed by this pull request
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Feb 13, 2026

Reviewer's Guide

Adds support for skipping inactive nBTC deposit addresses during deposit discovery, with corresponding tests and cleanup of outdated TODO comments.

Sequence diagram for skipping inactive nbtc deposit addresses

sequenceDiagram
    participant Caller
    participant Indexer
    participant Logger

    Caller->>Indexer: findNbtcDeposits(tx, network)
    activate Indexer
    loop for each vout in tx.vout
        Indexer->>Indexer: btcAddress = fromOutputScript(vout.script, network)
        Indexer->>Indexer: depositInfo = nbtcDepositAddrMap.get(btcAddress)
        alt no_deposit_info
            Indexer-->>Indexer: continue to next vout
        else deposit_info_found
            alt deposit_inactive
                Indexer->>Logger: debug(msg=Skipping inactive deposit address, txId, btcAddress)
                Indexer-->>Indexer: continue to next vout
            else deposit_active
                Indexer->>Indexer: config = getPackageConfig(depositInfo.setup_id)
                Indexer-->>Indexer: record matching nbtc deposit output
            end
        end
    end
    Indexer-->>Caller: deposits[]
    deactivate Indexer
Loading

Updated class diagram for Indexer nbtc deposit address filtering

classDiagram
    class Indexer {
        Map~string, DepositInfo~ nbtcDepositAddrMap
        findNbtcDeposits(tx, network) NbtcDeposit[]
        getPackageConfig(setupId) PackageConfig
    }

    class DepositInfo {
        number setup_id
        boolean is_active
    }

    class NbtcDeposit {
        string suiRecipient
        number amount
        string btcAddress
    }

    class PackageConfig {
        number setup_id
    }

    Indexer --> DepositInfo : uses
    Indexer --> NbtcDeposit : creates
    Indexer --> PackageConfig : fetches
    Indexer "1" o--> "*" nbtcDepositAddrMap : maintains
Loading

File-Level Changes

Change Details Files
Filter out inactive nBTC deposit addresses when scanning transaction outputs for deposits.
  • Replace direct setup_id lookup with retrieval of full depositInfo entry from nbtcDepositAddrMap.
  • Add conditional to continue when no deposit info exists for a BTC address.
  • Add guard to skip processing and log a debug message when a deposit address is marked inactive.
  • Use depositInfo.setup_id instead of the previous pkgId when fetching package configuration.
packages/btcindexer/src/btcindexer.ts
Add regression test ensuring inactive deposit addresses do not produce detected deposits.
  • Construct a block and target transaction from existing REGTEST_DATA fixtures for a specific index.
  • Temporarily override indexer.nbtcDepositAddrMap to contain a single inactive deposit address.
  • Call findNbtcDeposits and assert that no deposits are returned for the inactive address.
  • Restore the original nbtcDepositAddrMap after the test to avoid side effects.
packages/btcindexer/src/btcindexer.test.ts
Remove obsolete TODO about adding active/inactive support for nBTC addresses in the batch processor entry point.
  • Delete commented TODO that stated active/inactive address handling still needed to be implemented, since it is now supported by the indexer logic.
packages/btcindexer/src/index.ts

Assessment against linked issues

Issue Objective Addressed Explanation
#346 Implement filtering so that deposit addresses marked as inactive in the nbtc_deposit_addresses table are skipped during ingestion (in the btcindexer worker flow).
#346 Add unit test coverage to verify that inactive deposit addresses are not processed.

Possibly linked issues

  • #worker: Active/Inactive Address Filtering: PR implements is_active-based filtering in btcindexer, skips inactive deposit addresses, and adds corresponding unit test coverage.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • In the new should skip inactive deposit addresses test, consider restoring nbtcDepositAddrMap using a try/finally or afterEach hook instead of inline reassignment to avoid issues if an assertion throws and to make state cleanup more robust.
  • When logging skipped inactive deposit addresses, it might be useful to include the associated setup_id (if available) in the log payload to make debugging and operational tracing easier.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In the new `should skip inactive deposit addresses` test, consider restoring `nbtcDepositAddrMap` using a `try/finally` or `afterEach` hook instead of inline reassignment to avoid issues if an assertion throws and to make state cleanup more robust.
- When logging skipped inactive deposit addresses, it might be useful to include the associated `setup_id` (if available) in the log payload to make debugging and operational tracing easier.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@rmeena840 rmeena840 merged commit 148f882 into master Feb 13, 2026
13 checks passed
@rmeena840 rmeena840 deleted the 346-worker-activeinactive-address-filtering branch February 13, 2026 13:25
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.

worker: Active/Inactive Address Filtering

2 participants